Hardware outputs (binary, DAC, PWM) manipulation thourgh Server API. (ru)
- 9 years ago.
Hardware outputs (binary, DAC, PWM) manipulation thourgh Server API.
There are 3 ways to manipulate myCNC control board Hardware outputs through Serve API:
- Direct manipulation through commands "SetHWBinaryOutput", "SetHWDAC", "SetHWPWM"
- Manipulation through running PLC procedure with Hardware Outputs manupulation.
- Manipulation thourgh running short G/M-codes program
Direct Manipulation.
Command | Description |
SetHWBinaryOutput |
SetHWBinaryOutput <Port number> <Port value> SetHWBinaryOutput 0 1 <Turn ON binary output #0> |
SetHWPWM |
SetHWPWM <PWM channel> <PWM value> SetHWPWM 0 0 <Set value "0" to PWM#0 (PWM1). Max PWM value is 4095> SetHWPWM 2 3500 <Set value "3500" to PWM#2 (PWM3). Max PWM value is 4095> SetHWPWM 1 4095 <Set value "4095" (Maximum) to PWM#1 (PWM2). Max PWM value is 4095> |
SetHWDAC |
SetHWDAC <DAC channel> <DAC value>
SetHWDAC 0 0 <Set value "0" to DAC#0 (DC1). Max DAC value is 4095> SetHWDAC 1 4095 <Set value "4095" (Maximum) to DAC#1 (DAC2). |
Manipulation through PLC procedure.
Server API command "RunPLC" loads and runs PLC procedure on myCNC controller end with given parameter. We can run PLC procedure that manipulates Hardware outputs to get similar result.
Normally every profile configuration contains PLC procedures for Hardware outputs manipulation :
PLC procedure | Syntax |
M62 |
M62 <Parameter> M62 1 <Turn ON binary output #1> |
M63 |
M63 <Parameter> M63 0 <Turn OFF binary output #0> M63 15 <Turn OFF binary output #15> |
DAC |
DAC <Parameter> Example: DAC 0 <Set value "0" to DAC#0 (DAC1). Max DAC value is 4095>DAC 0x0600 <Set value "0x600" (1536) to DAC#0 (DAC1). Max DAC value is 4095> DAC 0x1400 <Set value "0x400" (1024) to DAC#1 (DAC2). Max DAC value is 4095> DAC 0x1000 <Set value "0" to DAC#1 (DAC2). Max DAC value is 4095> |
PWM |
PWM <Parameter> Example: PWM 0 <Set value "0" to PWM#0 (PWM1). Max DAC value is 4095>PWM 0x0600 <Set value "0x600" (1536) to PWM#0 (PWM1). Max PWM value is 4095> PWM 0x1400 <Set value "0x400" (1024) to PWM#1 (PWM2). Max PWM value is 4095> PWM 0x2000 <Set value "0" to PWM#2 (PWM3). Max PWM value is 4095> |
Examples to run PLC procedures through Server API shown in a table below
Binary input manipulation |
RunPLC M62 1 <Turn ON output#1> |
PWM control |
RunPLC PWM 0x1350 <Write to PWM#1 (PWM2) value 0x350> |
SetHWDAC | RunPLC DAC 0x1570 <Write to DAC#1 (DAC2) value 0x570> RunPLC DAC 0x800 <Write to DAC#0 (DAC1) value 0x800> RunPLC DAC 0x0 <Write to DAC#0 (DAC1) value 0> RunPLC DAC 0x1000 <Write to DAC#1 (DAC2) value 0> |
{avsplayer videoid=4}
Manipulation through running G-codes.
Server API command "SinglePlay" run G-code line (or a number of G-code lines divided by symbol ";" ).
It's possible to control binary outputs by running M-functions "M62", "M63". P-parameter set binary output number to control.
M-code | Syntax |
M62 |
M62 P<number M62 P1 <Turn ON binary output #1> |
M63 |
M63 P<number> M63 P0 <Turn OFF binary output #0> M63 P15 <Turn OFF binary output #15> |
Any custom PLC function can be written and assigned to M-code, then loaded through CNC Server API.
{avsplayer videoid=5}