10-04-2017 09:01 AM - edited 10-04-2017 09:02 AM
Hi guys,
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)
Thanks
10-04-2017 03:06 PM
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.
10-05-2017 09:20 AM
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.
Anyone help?
10-05-2017 12:53 PM - edited 10-05-2017 12:55 PM
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.
10-06-2017 12:47 AM
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?
10-06-2017 02:13 AM
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):
10-06-2017 04:35 AM - edited 10-06-2017 04:35 AM
Something like this should/could work; PWM frequency is fixed to 8 kHz:
Dutycyle 0<x<100:
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.
Regards, Jens
10-06-2017 04:42 AM
thanks jg69, but I need variable pwm frequency fron 600Hz, up to 8kHz.
I'm thinking hard about it!
10-06-2017 05:56 AM
10-06-2017 12:12 PM
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.