how to set the pwmgen frquency using a variable

More
26 Nov 2021 07:47 #227625 by ericg
I am using the 2 PWM generators on my 5i25 board, one to drive a router and one to drive a laser,
The router PWM is controlled via a gecko G540 and a SuperPID box, and thats fine, the laser is controlled via the second pwmgen, however both use the same base frequency of 50hz, and both work well except that the laser does work much better at a higher frequency.
I would like to change my line hm2_5i25.pwmgen.pwm_frequency 50 in my hal file to something like hm2_5i25.pwmgen.pwm_frequency [pwm_out] where pwm_out is the net output of a mux2 instance (in laser.hal) which selects one of 2 numbers dependent on a switch I have, unfortunately I haven't quite got the code right as when I start AXIS is spits the dummy and tells me that [pwm_out] variable is empty
any help appreciated.
Eric
Attachments:

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

More
26 Nov 2021 22:35 #227699 by PCW
I would use PDM for the G540 and PWM for the laser so you can set
separate frequencies for each.

G540 PDM should probably be set to 500Hz or so
Higher PDM frequencies will have more non-linearity
lower frequencies will have more ripple

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

More
26 Nov 2021 22:53 #227702 by ericg
Thanks for the reply PCW, I know nothing about PDM so will look into it, however just quickly, I cannot see how to use it for the G540 as that requires a frequency of 50Hz to use it's internal VFD, so 500Hz would not work (at least that's my understanding)
Eric

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

More
26 Nov 2021 23:00 #227705 by PCW
If the G540 uses an analog RC filter for digital to analog conversion
(which I expect it does) , PDM should work fine

You could also try PDM on the laser if it uses a RC filter
leaving 50 Hz PWM for the G540

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

More
26 Nov 2021 23:03 #227706 by ericg
Thanks, I'll give it a try when I get my replacement Mesa 5i25 board from JT (blew it up when fiddling with this issue)
Eric

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

Time to create page: 0.095 seconds
Powered by Kunena Forum