Hardware outputs (binary, DAC, PWM) manipulation thourgh Server API.

 

There are 3 ways to manipulate myCNC control board Hardware outputs through Serve API:

  1. Direct manipulation through commands "SetHWBinaryOutput", "SetHWDAC", "SetHWPWM"
  2. Manipulation through running PLC procedure with Hardware Outputs manupulation.
  3. Manipulation thourgh running short G/M-codes program

 

Direct Manipulation.

Command Description
SetHWBinaryOutput

SetHWBinaryOutput <Port number> <Port value>
Port Number is number binary port. Range is 0...159
Set Port value - "1" to turn ON binary output (relay, open collector), "0" to turn OFF binary output

Example:

SetHWBinaryOutput 0 1 <Turn ON binary output #0>
SetHWBinaryOutput 1 1 <Turn ON binary output #1>
SetHWBinaryOutput 23 1 <Turn ON binary output #23>
SetHWBinaryOutput 0 0 <Turn OFF binary output #0>
SetHWBinaryOutput 1 0 <Turn OFF binary output #1>
SetHWBinaryOutput 19 0 <Turn OFF binary output #19>

   
SetHWPWM

SetHWPWM <PWM channel> <PWM value>
PWM channel is number of PWM pin. Software range is 0...3, however rela number of PWM channels depends on myCNC Ethernet controller model. Controllers ET1, ET3, ET5 contain 3 PWM pins.
PWM value.

Example:

SetHWPWM 0 2000 <Set value "2000" to PWM#0 (PWM1). Max PWM value is 4095>
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>
DAC channel is number of DAC pin. Software range is 0...1, however real number of DAC channels depends on myCNC Ethernet controller model. Controllers ET1, ET3 contain 1 DAC pins, Controllers ET5 contains 6 DAC pins.


Example:

SetHWDAC 0 1000 <Set value "1000" to DAC#0 (DAC1). Max DAC value is 4095>
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>
Turn ON binary output pin with given number (Parameter=Port number)

Example:

M62   1 <Turn ON binary output #1>
M62   0 <Turn ON binary output #0>
M62   15 <Turn ON binary output #15>

   
M63

M63 <Parameter>
Turn OFF binary output pin with given number (Parameter=Port number)

Example:

M63   1 <Turn OFF binary output #1>
M63   0 <Turn OFF binary output #0>
M63   15 <Turn OFF binary output #15>
   
DAC

DAC <Parameter>
low 12 bits (11...0) contains value of DAC to be written, bits (14..12) contains DAC channel

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>
low 12 bits (11...0) contains value of PWM to be written, bits (14..12) contains PWM channel

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>
RunPLC   M62  0 <Turn ON output#0>
RunPLC   M63  3 <Turn OFF output#3>
RunPLC   M63  5 <Turn OFF output#5>

   
PWM control

RunPLC  PWM  0x1350  <Write to PWM#1 (PWM2) value 0x350>
RunPLC  PWM  0x250    <Write to PWM#0 (PWM1) value 0x250>
RunPLC  PWM  0x2800  <Write to PWM#2 (PWM3) value 0x800>
RunPLC  PWM  0x0       <Write to PWM#0 (PWM1) value 0>
RunPLC  PWM  0x1000  <Write to PWM#1 (PWM2) value 0>
RunPLC  PWM  0x2000  <Write to PWM#2 (PWM3) value 0>

   
 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
Turn ON binary output pin with given number

Example:

M62   P1   <Turn ON binary output #1>
M62   P0   <Turn ON binary output #0>
M62   P15 <Turn ON binary output #15>

   
M63

M63 P<number>
Turn OFF binary output pin with given number.

Example:

M63   P1   <Turn OFF binary output #1>
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}