CNC plugin for the plasma torch height controlling on the base of Arduino (ATmega328P MCU). Can be used to improve cutting quality of bent and distorted metal plates. Regulator intercepts Z-axis (vertical) movement of a torch. Bypass mode is provided for cases when control is unneeded. Main idea is to determine the current height by measuring a voltage of the plasma arc: the higher the voltage, the greater the distance.
To minimize effect of cross-talks and spikes there should be solid assembly and the plugin must not be located near any high-voltage or power circuits. Some installed shield (full case or just to wires) is also desirable. It's advised to galvanic isolate device as possible to protect low-current and logic circuits.
All digital inputs are pulled-up to the high-level voltage by default (so they are triggered by 0). ATmega328P and Arduino pins notations are specified in the brackets.
To actuating of Z-axis your driver should provide 5 functions:
motor_init()
;motor_up()
;motor_down()
;motor_stop()
;motor_move(int16_t steps)
where the sign of steps
indicates a direction of movement.Also, note that your custom pinout should not conflict with other signals. It's recommended to use PC2-5 (Arduino's A2-5) pins.
There already 2 libraries in the /lib
folder representing 2 different drivers for stepper motors' driven Z-axis.
Straightforward driver that uses Timer2 to manually switches corresponding phases of 4-wire bipolar stepper motors (wave (one-phase-on) mode). Plug in your motor to any switches (relays, discrete transistors, array of transistors, driver IC and so on). Correct order of phases' connection depends on your motor but generally is A-C-B-D, considering AB and CD as 2 coils. Other parameters that you should adjust are period and pulsewidth (we consider them as equal).
Library for usage with "smart" drivers that controlled by 2 signals: STEP and DIRECTION. It also uses Timer2 to form STEP pulses sequence. Other parameters that you should adjust to match your driver are period and pulsewidth.
THC uses Arduino's LiquidCrystal library to manage LCD (HD44780, its derivatives and other compatible ones). Timer1 is used for refreshing information on the screen when it's needed (e.g. in Working mode or in the settings menu). By default LCD is connected to PD1-7 pins with following pinout (Arduino notation in the brackets):
Before flashing the firmware you can check and set some related parameters. Most of them are located in TorchHeightControl.cpp/h
files:
It's recommended to use PlatformIO for building and flashing as all-in-one solution.
Change settings in platformio.ini
file if needed (for example, specify whether use programming unit or not). Then in the same directory run:
$ pio run # build
$ pio run -t program # flash using usbasp
or
$ pio run -t upload # flash using on-board programmer
$ pio run -t uploadeep # write EEPROM
File
-> Add Project Folder
;platformio.ini
file if needed (for example, specify whether use programming unit or not);PlatformIO
-> Build
;$ pio run -t program; pio run -t uploadeep
or for Arduino board:
$ pio run -t upload; pio run -t uploadeep
After reset, LCD displays Idle mode. It contains current settings of setpoint hysteresis, the cutting height lft
(in steps) and the pierce time dlay
. Cycle through the settings menu by pressing settings button till you get back to the Idle mode. Current value of each parameter is indicated in the brackets. Use your potentiometer to adjust values.
After Plasm ON signal, start...
string is appears. After touching the metal, pierce...
lasts entire pierce time. Then define sp...
is appeared on short time during which setpoint is defining. Finally, working mode follows and the first LCD line displays measured setpoint and the second displays current averaged arc voltage. If the define sp...
string lasts too long it means that whether the number of values for setpoint definition is too high or the offset for averaging is too small or an arc signal is just too noisy.
After cutting completes, Idle mode will also display last measured setpoint.
To enter (and to exit) Bypass mode press and hold Settings button for 8 seconds. LCD will display regulation off
string. THC then will respond only to Up/Down signals. Bypass mode state is saved after resets and power offs.
See states diagram (UML) in torch-height-control-uml.*
files (created with draw.io).
Behavior of THC when multiple signals are applied is undefined in general and depends on the order of corresponding handlers in the PCINT0_vect
ISR. Because of the if - else if
construction execution of multiple code blocks is impossible but such conditions are still not recommended. However, at normal operating, those cases are not met.