01-28-2016 11:05 AM
On a PC, the code behaves as expected after removing the IO nodes. Bob is referencing that your defualt value is 1, not 1500, as your front panel indicator shows for a range. So, if you do not set this value before you start the FPGA VI, you should be running a loop every 1ms ideally. You should set this to be the ideal default value, say 1500.
01-28-2016 11:25 AM
Dawud,
Yes, that's what I'm saying. I also agree with Matthew, that's also what I said.
BS
01-28-2016 11:40 AM
What frequency are seeing at the two extremes?
01-28-2016 11:44 AM
One other thing, you should set your datatypes to match. You have the timer configured to use a 32-bit counter, but your front panel control is 16-bit. Change the control representation or the counter size so there's no coercion necessary.
02-02-2016 09:31 AM
So I saw you were still having trouble in the other thread - from looking at your code, I really can't see why you would be having any issues with outputting a PWM signal by toggling the output on one of the 9474 outputs.
However did you know that, when in Scan Engine mode, you can right click on the C Series module in your project, and there is a tab called 'specialty digital configuration' and it actually allows you to configure the outputs as a PWM signal directly? You specify the frequency, and can then vary the duty cycle:
For PWM on FPGA, I usually do something similar to this:
Note that the floating point operations at the end are fairly resource intensive / slow (i.e. multiple clock cycles) - it's only really there to help you see the values. This method allows you to specify both the period and duty cycle (whereas your original code only allows you to set the frequency with a 50% duty period). I don't claim for it to be the most efficient/fastest way to implement PWM either - but it should be no problem for 2kHz PWM.
e.g. specifying an on time of 10uSec and an off time of 90uSec gives you a duty cycle of 10% and a frequency of 10kHz (1/100uS)
02-02-2016 11:34 AM
Thanks Sam. Does that facility allow you to control the frequency in code?
I am controlling a motor so frequency controls speed and I need variable speed.
02-03-2016 03:44 AM