02-08-2012 01:18 PM
I recommend you check your math. When I put 50% duty cycle at 1hz into your VI, I get wait times of 0.5ms. Perhaps you meant to have your wait times in seconds?
02-08-2012 01:26 PM
inputs :
duty cycle=50%
frequency=500Hz
outputs:
ms high=0,001seg
ms low=0,001 seg
inputs:
duty cycle=50%
frequency=1Hz
outputs:
ms high=0,5seg
ms low=0,5 seg
it is ok,isn´t it? i just want to generate the pwm signal, the normal frequency for me will be 100-500Hz
sorry,i don´t understand which is the problem
02-08-2012 01:29 PM - edited 02-08-2012 01:32 PM
ok ok,so my frequency is s^-1,then the mshigh and mslow which i am generating are in sec,aren´t them?
and i have my counter in ms, so i should change the values of mshigh and mslow to ms,after calculate it,yes?
02-08-2012 01:32 PM - edited 02-08-2012 01:40 PM
Yes.
02-08-2012 01:54 PM
yes,it works thank you so much 🙂 i was thinking about this almost 2 weeks and i couldn´t see the problem!!
i have the problem that i just can see the signal when the frequency is around 50hz, is there a way to get it with more frequency,about 100 or 500 Hz?
02-08-2012 02:01 PM
Again, think about the math. The input of the Wait function is an integer. At 500hz, what duty cycle values will give you an integer number of milliseconds to wait? (Hint: not very many)
You might need to change the Wait function to use a smaller unit of time. I'm not sure what the accuracy of the clock is on a cRIO.
02-08-2012 03:01 PM
the counter can has ms or microms,but for example for a duty cucle of 50%:
frequency=50Hz i have mshigh and ms low=10ms(integer number)
and frequency=500hz i have mshigh and mslow=1ms(integer number)
so it should work to frequency <500hz, but i just can have <=50Hz, "the wait function has an integer number in its input",shouldn´t it?
and when i did it with the another code which i saw you before,i was able to generate a pwm signal with frequency=500Hz
02-08-2012 03:25 PM
You will never match the performance of the built-in solution, where you write the duty cycle directly. It's not worth trying.
Time the while loop and see how fast it's running (you can use the output from the Wait function, and a shift register, to do this). That will give you the maximum frequency at which you can generate a pulse. You might be able to improve performance slightly by using a timed loop.
02-09-2012 02:45 AM
sorry,but i don´t understand how to do that
02-09-2012 10:56 AM
could i use a timed loop?isn´t the wait function which determines the period of execution?