07-25-2013 11:35 AM
Hi,
i'm programing a PWM read from a DI in an FPGA (NI 9425), this card doesn't accept fpga methods, so i need to figure out a way to detect when does it rise/fall, so with a sequence structure i can check the tick in wich this rise/fall ocurred and calculate the length of the high and low from the PWM...
Any ideas? I've been thinking all day, out of ideas right now...
Thanks!
Joan
PD: attached is the structure i have, next to the DI i need to place the rise/fall detector
Solved! Go to Solution.
07-25-2013 01:39 PM - edited 07-25-2013 01:49 PM
Hey Joan,
Here's a quick example of an edge detector:
For a more complete example (does pretty much exactly what your app is doing), please check out the PWM Input example in the NI LabVIEW Example Finder. In case you're not familiar, the Example Finder can be found under Help->Find Examples. From there, navigate to Toolkits and Modules->FPGA->CompactRIO->FPGA Fundamentals->Counters->PWM Input
07-25-2013 03:50 PM
Hi TJ G,
nice! Thanks!
How could i do it, to stop the tick count just in the rise/fall? I mean, to make the sequence wait until the rise/fall, then advance (pick tick count value) and then wait till the next one... there is no "wait" function in FPGA, isn't it?
07-25-2013 03:59 PM
You can set a boolean flag whenever you get a rising or falling edge and use a case structure that will only run when the flag is set. After you run your code in the event sturcture, clear the flag and carry on waiting for the next edge. You do not want to stall your FPGA code, just keep checking the flag on each clock cycle.
07-25-2013 04:19 PM
It looks like you probably want code that functions more like the example I pointed out. It measures the amount of high time, and the amount of low time for a given period. Is this what you want to do?
07-25-2013 04:35 PM
Wow! That looks great! Thank you very much!