G-code
Supported M-codes
M54, M55, M56, M57 (General purpose IO)
19 min
please note that mentioned commands may fail during loading and/or simulation to make your macro code avoid these errors please take a look at the manual section docid\ p2jh9ffrvp0wcb5jcd9px digital outputs set output m54 p the p word must be between 1 and 10 where 1 is aux1 and 10 is aux10 m54 p1 (set aux1 out to 1) if the connected controller only has one aux output, 2 is mapped to flood and 3 to mist m54 p2 (set aux2 out to 1 or flood to 1 if the controller has 1 aux) clear output m55 p clear output the p word must be between 1 and 10 where 1 is aux1 and 10 is aux10 m55 p1 (set aux1 out to 0) if the connected controller only has one aux output, 2 is mapped to flood and 3 to mist m55 p2 (set aux2 out to 0 or fload to 0 if the controller has 1 aux) read outputs m57 p read output x , store the result in variable #5399 m57 p true 330,331 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type digital inputs read input m56 p true 330,331 unhandled content type left unhandled content type unhandled content type left unhandled content type unhandled content type left unhandled content type unhandled content type left unhandled content type unhandled content type left unhandled content type unhandled content type left unhandled content type unhandled content type left unhandled content type unhandled content type left unhandled content type unhandled content type left unhandled content type unhandled content type left unhandled content type the result is stored in docid\ oqhjs3llcfqksac cemc2 #5399 example erad aux input 3 m56 p3 (read aux in 3) if \[#5399 == 1] msg "aux3=on" else msg "aux3=off" endif example read home input of x axis m56 p51 if \[#5399 == 1] msg "home x=on" else msg "home x=off" endif read input + wait m56 p l q read digital input p and specify wait mode, the result is stored in variable #5399 p the input number l 0 do not wait l 1 wait for high l 2 wait for low q timeout (seconds) m56 p3 l2 q30 (read aux in 3) if \[#5399 == 1] errmsg "timeout while waiting for aux3 becoming low" else msg "aux3 is off" endif note that we use wait (l2) here, in the event of a timeout, the value of #5399 is 1 in order to make this code simulation and rendering proof we need to extend it like this if \[\[#5380 == 0] and \[#5397 == 0]] ;;check only if running job m56 p3 l2 q30 (read aux in 3) if \[#5399 == 1] errmsg “timeout while waiting for aux3 becoming low” else msg “aux3 is off” endif endif analog inputs read analog input m56 e … read analog input e, result stored in #5399 m56 e3 msg "analog value is " #5399 pwm set pwm m54 e q set pwm output e to permille value q (0 <= y <= 1000) m54 e2 q500 (set pwm2 to 50% pwm) read pwm output m57 e read pwm output, result stored in #5399 m57 e3 if \[#5399 == 0] msg "pwm is off" else msg "pwm is on, value="#5399 endif optional iocard if a relay board is used such as https //edingcnc com/product/rly8 io/ , the io number p or e is specified like in the following examples value of 103 means card 1 port 3 value of 208 means card 2 port 8