I'm developing a PWN on my crio-9066 fpga with ni-9403 module.
This is my code:
but I can't get a pwn signal all high with 100% duty, and all low with 0% duty.
How to improve this? I have to use the single cycle timed loop? How? (I can't use the FPGA I/O node in a SCTL)
Something like this?
You can set duty to 0 and then it will always output false and if you make duty bigger than period it will always output true.
For future reference, if you needed to transfer information between loops (not needed in this case) you can use a local as shown in the bottom loop.
Uhm. Are you sure? In the shift register what kind of integer do you have? It's doesnt the ticks count of the main clock. I get a delay of 50 us each semi period.
All integers in that block diagram are U16. The size isn't too important and you could change them all to U8 or U32 depending on what your max period is.
Is 50 us increments of period unacceptable? The maximum write rate is dictated by the card and it should be 7 us.
Ok but what kind of unit is the integer? The processor ticks? I think no.....
I can't speed up than 4kHz. I need 8kHz PWM. Is it possible?
The module have 7us of commutation time, so I can have up to 70kHz PWM, right?
This is the max frequency that i can get out (4,59kHz / 50% duty):
This is the pwm with 0% duty (I have 50us high per period):
This is the pwm with 100% duty (I have approximately 50us low per period):
Something like this should/could work; PWM frequency is fixed to 8 kHz:
Dutycylce = 0:
and another case for Dutycylce = 100 where the output is always TRUE.
Of course you can transfer just the high-time instead of the dutycyle and change the conditions for the case structure.
The top loop should run at approximately 7us per cycle. So if you put a 0 in for the period the shift register should just toggle between 1 and 0 giving you a period of ~14us for a ~71kHz frequency. If you put in a duty of 0 you should get 100% low, if you put in 1 you should get 50% duty, and if you put in 2 you should get 100% high.
What values are you using for period and duty in my example to get what you see on the scope. Please delete the bottom loop for your test. It was just to demonstrate how you might use a local.