Hello Andy, I implemented your suggested code and I am getting correct values of Duty cycle on Halscope. However, I am NOT getting the correct values on CRO.On CRO, I get correct values for frequencies of 100 Hz and 150 Hz But, when I try 110 Hz , 120 Hz etc. it takes wrong period always as 10 ms (corresponding to 100 Hz only) and the T-on is also not 2 ms which I set in the scale.0.gain parameter (it's slightly more than 2 ms),
However, on Halscope these parameters are correct. Below is the code I did: loadrt pwmgen output_type=0 loadrt tristate_float setp pwmgen.0.enable TRUE addf hm2_5i25.0.write_gpio base-thread addf pwmgen.make-pulses base-thread addf pwmgen.update base-thread addf tristate-float.0 servo-thread net PWM-Freq tristate-float.0.in <= pyvcp.CO-frequency-value //frequency value from Axis Gui setp tristate-float.0.enable TRUE net PWM-OUT tristate-float.0.out => pwmgen.0.pwm-freq loadrt scale net PWM-Freq scale.0.in // from above setp scale.0.gain 0.002 net duty-cycle scale.0.out pwmgen.0.value // Setting the Duty cycle addf scale.0 base-thread //Added to base-thread setp hm2_5i25.0.gpio.023.is_output TRUE setp hm2_5i25.0.gpio.023.invert_output FALSE net pwm-generate <= pwmgen.0.pwm net pwm-generate => hm2_5i25.0.gpio.023.out BRAdit From: andy pugh <bodge...@gmail.com> To: adit bhargava <adit_bh...@yahoo.com> Cc: Enhanced Machine Controller (EMC) <emc-users@lists.sourceforge.net> Sent: Tuesday, May 3, 2016 7:00 PM Subject: Re: [Emc-users] How to assign values to pwmgen parameters(duty-cycle, frequency, etc, ) from GUI ? On 3 May 2016 at 16:12, adit bhargava <adit_bh...@yahoo.com> wrote: > Thank you very much Andy. I forgot to add tristate_float to thread. Now, I > addeed to my base-thread and the output comes now on CRO. You should add it to the servo-thread really, there is no need to update the value at base-thread speed. > Duty-Cycle = ( 2 ms / Period )( where Period = 1/ Signal freq) > > How should I implement this formula in .HAL file? That simplifies to DutyCycle = 2mS * frequency (which passes a units check, but doesn't seem right) You would use the HAL "scale" component: http://linuxcnc.org/docs/2.7/html/man/man9/scale.9.html (It is probably worth a skim through all the real-time components listed in the section near the bottom of http://linuxcnc.org/docs/2.7/html/ ) net PWM_freq scale.0.in setp scale.0.gain 0.002 net dc scale.0.out pwmgen.0.value Or similar. -- atp "A motorcycle is a bicycle with a pandemonium attachment and is designed for the especial use of mechanical geniuses, daredevils and lunatics." — George Fitch, Atlanta Constitution Newspaper, 1916 ------------------------------------------------------------------------------ Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched! https://ad.doubleclick.net/ddm/clk/304595813;131938128;j _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users