the hal PMW sounds like a nice way to do it. So far I have 2 files (a hal file, and an ngc file) that I think will do it. I believe i'd also add a remap line to my ini file like below:
ini file addition:
Code:
[RS274NGC]
USER_M_PATH = /home/<username>/linuxcnc/configs/<config_name>/m_codes/
hal file:
Code:
#setup PWM generator
loadrt pwmgen ouput_type=0
addf pwmgen.update servo-thread
addf pwmgen.make-pulses servo-thread
### ---mist signals start---
#configure PWM signals
#set to a scale from 0 to 100, and over a 2 second period
setp pwmgen.0.enable 1
setp pwmgen.0.scale 100
setp pwmgen.0.pwm-freq .5
setp pwmgen.0.value 55
#mist coolant stuff
loadrt and2 count=2
addf or2.1 servo-thread
addf and2.0 servo-thread
#setup our three inputs (physical button, M7 command, and pwm signal)
net mistOnButton <= hm2_7i76e.0.7i76.0.0.input-31
net mistOnCmd <= iocontrol.0.coolant-mist
net mistOnPWM <= pwmgen.0.pwm
#make M7 command act on PWM signal
net mistOnCmd => and2.0.in0
net mistOnPWM => and2.0.in1
#make output signal based off PWM signal or button
net mistOnButton => or2.1.in0
net and2.0.out => or2.1.in1
net mistOutOn <= or2.1.out
net mistOutOn => hm2_7i76e.0.7i76.0.0.output-09
### ---mist signals end---
and then my remapped M code command in a file called "M100", and added to the "m_codes" folder that i made in my config folder:
Code:
#!/bin/bash
#Intended to be run as a remapped M100 command. Used to set the pmw value for the mist system
pwmValue=$1
halcmd setp pwmgen.0.value $pwmValue
exit 0
does that look like the right way to go about it? I'm not sure if i'm doing the custom M code correctly, or maybe getting that and the remap confused... anyways, that's my first stab at it. Let me know what you think. Thanks!