On 16 March 2011 08:38, Klemen Dovrtel <klemen_dovr...@yahoo.com> wrote:
> I would like to measure some analog signals using emc (for PID control). I > think the easiest way would be to measure the pwm signal. Measuring a PWM digitally is almost never the easiest way. > I was thinking i could use two oneshot functions, one to trigger on rising > edge and one to trigger on falling edge. What i need is a function to measure > the time between those two events - is there a hal function for that? I think you could use oneshot set to retriggerable and a sample-hold function looking at oneshot.0.time-left and triggered on the same pulse. Note that I said "could" and not "should". The main drawback is that the pwm duty cycle measurement will have a granularity related to your base-thread time. As Visteurs has been saying, voltage-to-frequency with an encoder module linked to the signal (in counter-mode) will give much better results, it is much less affected by the sample time granularity. You would use the encoder-velocity output as your analogue voltage value. Are you using a parallel port, or some other hardware? -- atp "Torque wrenches are for the obedience of fools and the guidance of wise men" ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users