Can't get PWM gen to work

More
19 Feb 2020 17:44 #157878 by oddwick
I have been fighting this for a week and i know that i must be missing something obvious.

i finally decided to switch my vfd control from manual to linuxcnc. i have been paranoid about doing this because it is so easy to overlook something stupid (thus the post!) and bits and material are expensive. but for consistency's sake, i decided to give it a go.

the problem is that no matter what i do, i can't seem to get a pwm signal. the best i have gotten is when i invert the pin, i get 0.0v and without inverting the pin, i get 4.29v. period. no matter what i do, i cant change it. and when i look in the hal config at pwmgen, all of the values i get are huge negatives. is that what they are supposed to be?

anyway, i am running two parallel breakouts, with a 10v pwm converter. i know its not a hardware issue, because all of it has been tested and works fine. and parallel cards are just fine (after a week of trying to get a second parallel port working, i now own more parallel cards than most people own underwear). and no matter what pin i use, i always get the same result. all or nothing.

so i have it wired into parport.0 pin 17 for pwm and parport.0 pin 9 for the enable. i also have parport.0 pin 4 available, and several open on parport.1, but i would like to keep all of my spindle and axis controls on the same breakout if possible. for my hal configuration, this is what i am using or at least the relevant parts:

chibi_usaga.hal
#-------- PARPORT -------------------------
#loadrt hal_parport cfg="1 out 0 out"
loadrt hal_parport cfg="0xd030 out 0xd070 out"

setp parport.0.reset-time 5000
loadrt stepgen step_type=0,0,0,0
loadrt pwmgen output_type=0

addf stepgen.make-pulses base-thread

addf parport.0.read base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread

addf parport.1.read base-thread
addf parport.1.write base-thread
addf parport.1.reset base-thread

addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf pwmgen.update servo-thread
custom.hal
#-------- SPINDLE -------------------------
# spindle speed

net spindle-cmd-rpm => pwmgen.0.value
net spindle-on <= spindle.0.on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 100.0
setp pwmgen.0.scale 100.0
setp pwmgen.0.offset 0.0
setp pwmgen.0.dither-pwm true
net spindle-cmd-rpm     <= spindle.0.speed-out
net spindle-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-cmd-rps     <= spindle.0.speed-out-rps
net spindle-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-at-speed    => spindle.0.at-speed

net spindle-on      => parport.0.pin-09-out
net spindle-pwm     => parport.0.pin-17-out

i get no errors, everything works just fine. except, no pwm. i have tried just about every solution from the documentation, forums, and even used steperconf to generate a test config all to no avail. my guess is that it is something so stupid that i feel a facepalm coming on!

Please Log in or Create an account to join the conversation.

More
19 Feb 2020 18:05 #157880 by PCW
Replied by PCW on topic Can't get PWM gen to work
You are missing the

addf pwmgen.make-pulses base-thread

statement

Please Log in or Create an account to join the conversation.

More
19 Feb 2020 18:30 - 19 Feb 2020 18:31 #157883 by oddwick
Replied by oddwick on topic Can't get PWM gen to work
i added that in after stepgen.make-pulses and it made no difference. i was hoping that it was that simple, but no
Last edit: 19 Feb 2020 18:31 by oddwick.

Please Log in or Create an account to join the conversation.

More
19 Feb 2020 18:50 - 20 Feb 2020 01:37 #157887 by PCW
Replied by PCW on topic Can't get PWM gen to work
Right

addf pwmgen.make-pulses base-thread

is necessary but the hal file likely has additional issues

(note that a scale of 100 is pretty odd unless 100 RPM is the maximum spindle speed)
Last edit: 20 Feb 2020 01:37 by PCW.

Please Log in or Create an account to join the conversation.

More
19 Feb 2020 19:25 #157890 by oddwick
Replied by oddwick on topic Can't get PWM gen to work
sorry, should have mentioned that those were dummy values for the rpm. i was trying different values to see if i could get different values for my voltage. right now my vfd is not connected to the controller because my procedure is add-test add-test and now after adding the adc is when i found out that i have no pwm. theoretically my spindle is 24k rpm, but it is relatively new and i haven't tached yet to confirm that. once i get it working, then i will calibrate it.

as soon as i get off work, i will post my entire configuration to make sure the errors are not in there deeper

Please Log in or Create an account to join the conversation.

More
20 Feb 2020 03:54 #157924 by oddwick
Replied by oddwick on topic Can't get PWM gen to work
Ok so here are my full configuration files as well as my ini for good measure...

File Attachment:

File Name: chibi_usag...2-19.hal
File Size:1 KB

File Attachment:

File Name: custom.hal
File Size:5 KB

File Attachment:

File Name: chibi_usag...2-19.ini
File Size:4 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
20 Feb 2020 04:31 #157930 by PCW
Replied by PCW on topic Can't get PWM gen to work
I don't see anything obvious although the thread order seems wrong to me.
I would expect the hardware (parallel port in this case) reads to be the first addfs
and the hardware writes/resets to be the last addfs in the hal file

You should be able to trace the PWM signal from pwmgen.0.pwm to
the signal to the output pin state all in hal (either with halmeter or halscope)
and also check the value and enable pin states.

If you set the PWM value to 1/2 of the PWM scale, and PWM is enabled,
and set a low frequency (say 1 hz) so halmeter can see the signal it should be
pretty easy to trace where the signal is lost

Please Log in or Create an account to join the conversation.

More
20 Feb 2020 04:59 - 20 Feb 2020 05:00 #157932 by oddwick
Replied by oddwick on topic Can't get PWM gen to work

I don't see anything obvious although the thread order seems wrong to me.


i was wondering if it might be an ordering issue. when you say the order is wrong, you are referring to the main hal file, not the custom hal, right? how would you suggest ordering them?

as for the signal, as soon as i get my ducks out of my bathtub, i will go poke around with it and see what i can find. and which signal am i exactly looking at? is it pwmgen.0.value or pwmgen.0.pwm? when i scoped it before i was coming out with huge negative values. dunno why.
Last edit: 20 Feb 2020 05:00 by oddwick.

Please Log in or Create an account to join the conversation.

More
20 Feb 2020 15:57 #158017 by oddwick
Replied by oddwick on topic Can't get PWM gen to work
ok so last night i messed around with it, but to no avail. when i looked at the signals on the halscope, i got squat even with the frequency set to 1hz. the only thing i can see is when spindle.on goes high. but i know that is working because it is hooked to a relay and i can hear it turn on and off and when i adjust the spindle override to 0, then it kicks off as well.

when i looked at the pwmgen.0.value on the halmeter, i keep getting negative values for it. is this correct? i set the scale to 1000 for easy math, and when spindle is off, the value is 0, and when it is on and spindle override set to say 25%, the value is -0.025, while the voltage at pin 17 still stays at a steady 4.29v regardless of what i have it set to except for a small dip 0.02v when the relay kicks off and on.

is there a way i can test each line of the hal individually so i can see where it is going wrong? my spindle is an open loop system, so do i really need the spindle.at-speed and rpm-abs? is there a step by step procedure for enabling each component one by one to test it?

Please Log in or Create an account to join the conversation.

More
20 Feb 2020 16:16 - 20 Feb 2020 16:16 #158022 by PCW
Replied by PCW on topic Can't get PWM gen to work
You have set PWM mode 0. The pwmgen manual (man pwmgen) says that if you set negative PWM
values you will get a 0 PWM output, so that part is behaving as expected, the question now is
how are you setting the spindle speed?

When you resolve the spindle speed issue you may want to connect the PWM value to

spindle-cmd-rpm-abs

rather than

spindle-cmd-rpm
Last edit: 20 Feb 2020 16:16 by PCW.
The following user(s) said Thank You: oddwick

Please Log in or Create an account to join the conversation.

Time to create page: 0.194 seconds
Powered by Kunena Forum