So I've been trying to change the duty cycle of a PWM signal that I setup from a custom M code... but something's not working right. This is my first time messing with custom M codes, so i'm sure there's something small that i'm missing, I'm just not sure what that is. Here's my current setup.
In my main INI file i have this to set the location of my custom M code files:
Code:
[RS274NGC]
USER_M_PATH = /home/gerrg/linuxcnc/configs/PrintNC/m_codes/
Then I setup my PWM in a hal file. The file is being pointed to in the INI file by the way
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 finally, I have my M100 file (no file type, the entire file name is "M100"), and it's in the "m_codes" folder specified above
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
I've tried looking at the hal meter to make sure the pwm value changes or not, and it's not changing. I can change the default value in the hal file, and restart linuxCNC and then value changes then... but so far it's not changing with the M code. Any thoughts of where i'm messing up? Thanks a bunch!