Parallel Port - how to invert PWM value
- rodw
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 11997
- Thank you received: 4084
19 Jul 2026 09:15 #347838
by rodw
I decided to build a parallel port LinuxCNC config cos I'd never done one before. All went very easily after firing up stepconf which got motors moving straight out of the box.
But now I got problems with the PWM to control the spindle because the volts were running the wrong way eg 24000 rpm = 0 volts and 0 rpm = 10 volts. I thought it would be easy to invert the signal but to no avail.
I tried to adjust with a sum2 component so -24000 + Commanded RPM = - desired RPM. This turned out to be a dry gully too.
I figured if I had to convert it to an absolute number I could do that but halshow promptly showed me that -24000 + 12000 = 0
I got rid of the negative and used a gain of -1 and I still got the same wrong answer...
So what is the trick to invert the PWM value?
Parallel Port - how to invert PWM value was created by rodw
I decided to build a parallel port LinuxCNC config cos I'd never done one before. All went very easily after firing up stepconf which got motors moving straight out of the box.
But now I got problems with the PWM to control the spindle because the volts were running the wrong way eg 24000 rpm = 0 volts and 0 rpm = 10 volts. I thought it would be easy to invert the signal but to no avail.
I tried to adjust with a sum2 component so -24000 + Commanded RPM = - desired RPM. This turned out to be a dry gully too.
I figured if I had to convert it to an absolute number I could do that but halshow promptly showed me that -24000 + 12000 = 0
I got rid of the negative and used a gain of -1 and I still got the same wrong answer...
So what is the trick to invert the PWM value?
Please Log in or Create an account to join the conversation.
- rodw
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 11997
- Thank you received: 4084
19 Jul 2026 09:56 #347839
by rodw
Replied by rodw on topic Parallel Port - how to invert PWM value
Hmm, this might work
parport.<p>.pin-<n>-out-invert
parport.<p>.pin-<n>-out-invert
Please Log in or Create an account to join the conversation.
- tommylight
-
- Offline
- Moderator
-
Less
More
- Posts: 21705
- Thank you received: 7417
19 Jul 2026 18:16 #347844
by tommylight
Replied by tommylight on topic Parallel Port - how to invert PWM value
Some examples of PWM stuff:Probably more there, but usually all you need is frequency and scale, sometimes also offset.
loadrt pwmgen output_type=1
addf pwmgen.make-pulses base-thread
addf pwmgen.update servo-thread
net dout-00 <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 1000.0
setp pwmgen.0.scale 6.0
setp pwmgen.0.offset 0.2
setp pwmgen.0.dither-pwm true
net dout-00 => parport.0.pin-02-outPlease Log in or Create an account to join the conversation.
Time to create page: 0.466 seconds