Parallel Port - how to invert PWM value

More
3 months 1 week ago #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?

Please Log in to join the conversation.

More
3 months 1 week ago #347839 by rodw
Hmm, this might work
parport.<p>.pin-<n>-out-invert 

Please Log in to join the conversation.

More
3 months 1 week ago #347844 by tommylight
Some examples of PWM stuff:
Code:
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-out
Probably more there, but usually all you need is frequency and scale, sometimes also offset.

Please Log in to join the conversation.

More
3 months 1 week ago #347850 by rodw
I answered my own question by reading the docs!
setp parport.0.pin-01-out-invert 1
Is exactly what I needed, I went looking for -not pins with no joy and never thought to look at parameters

Please Log in to join the conversation.

More
3 months 1 week ago #347852 by tommylight

Hmm, this might work
parport.<p>.pin-<n>-out-invert 
That is why i did not mention it, as that is exactly what you needed.
-
Welcome to the parport club, i bought 3 old PC's with parallel ports (a Pentium 4 and two of Core 2) for 40 euro about 5 days back, and no matter how much fanfare goes on here from time to time about it being obsolete, i still love it as it works perfectly...for nearly 20 years without a single hiccup ever.
And also keep a stock of 2-4 at all times in the shop, so now should be 6...as one went off yesterday to it's new work place.

Please Log in to join the conversation.

More
3 months 1 week ago #347877 by PCW
"-not" works for inputs, but not outputs
(without some fairly micky-mouse logic)

Please Log in to join the conversation.

More
3 months 1 week ago #347887 by Todd Zuercher
Wouldn't the proper way to invert a PWM be to use a negative value for the PWM scale? (setp pwmgen.N.scale = negative value)

Please Log in to join the conversation.

More
3 months 1 week ago #347891 by PCW
If you had signed PWM hardware and you got minus full scale
instead of full scale with a full scale positive PWM value, then  yes,
inverting the PWM scale would fix the problem.

For unsigned PWM when 0% duty cycle PWM gives you full scale output
and 100% duty cycle gives you 0% output, you would need to digitally invert
the PWM pin (and this is the situation here AFAICT)
 

Please Log in to join the conversation.

More
3 months 1 week ago #347907 by rodw

Wouldn't the proper way to invert a PWM be to use a negative value for the PWM scale? (setp pwmgen.N.scale = negative value)

I thought this too. But I was wrong!

For unsigned PWM when 0% duty cycle PWM gives you full scale output
and 100% duty cycle gives you 0% output, you would need to digitally invert
the PWM pin (and this is the situation here AFAICT)

Peter has it right. You need to use the parameter for the pin to invert it

setp parport.0.pin-01-out-invert 1

Please Log in to join the conversation.

Time to create page: 0.385 seconds
Powered by Kunena Forum