LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fpga analog input convert to voltage

I've been trying to use the cRIO fpga to convert the analog input values to a voltage. Also, I'm trying to run those value through a PI controller and then to a PWM digital output. Is it possible to do this efficiently in the FPGA?
I've already set this up using the RT target and FPGA but would like to use the FPGA alone because I need it to go fast...1 kHz minimum.
Any help or suggestions are appreciated!
Thanks,
Pete
0 Kudos
Message 1 of 7
(4,684 Views)
Actually, I've changed my approach and am trying to process the AI binary variables directly into a PI controller. Then the output goes to a PWM DO. Its not working though. THe FPGA won't run continuously. It runs one iteration and stops at best.
0 Kudos
Message 2 of 7
(4,665 Views)
Hi, Pete,

Is that the VI that you are actually using? I noticed that both of your While loops have a True constant connected to the condition terminal, and that they are set to Continue if True. This means that once you start the first While loop, it will never exit and continue executing. It might be the case that your VI actually never iterates and gives you the impression that it runs just once. Do you also have the Host VI? Feel free to include it, so we can take a look at it. I also noticed that you have at the end the Interrupt VI. Since it will wait to be cleared, make sure that you acknowledge the interrupt on your host VI.

Best regards,

GValdes
0 Kudos
Message 3 of 7
(4,646 Views)
Thanks very much for your help.

Do you know how I could incorporate a PI controller and PWM output together? Would I need to put them inside the same while loop or use a autoindexing for loop or...?

Attached is the host VI.

Thanks, Pete
0 Kudos
Message 4 of 7
(4,642 Views)
Hi, Pete,

Unfortunately, I don't have a piece of code that does Analog Input and PWM output, however, the best way will be to have both operations within the same while loop. You could have something as AI -> PI -> PWM (first read the input, then process, then adjust the PWM). Or another method could be to implement pipelining, so multiple operations happen at the same time.

I hope this helps,

GValdes
0 Kudos
Message 5 of 7
(4,624 Views)
That was my original plan... AI -> PI -> PWM, but like you said, the code is never exiting the first while loop. I wonder if this is unique to the fpga, because in the host VI, data seems to flow easily from one while loop to the next. Could it be something as simple as controlling the loop time? Or maybe even changing the fpga architecture to not use the interrupts and run parallel loops? hmm.
THanks,
Pete
0 Kudos
Message 6 of 7
(4,615 Views)
Okay, I got it working. I put everything inside a single loop and changed the fpga architecture (without interrupts). It seems to be running very fast and now need to figure out how to determine the actual loop time, need at least 1khz.
0 Kudos
Message 7 of 7
(4,606 Views)