07-15-2021 04:01 PM
Hi,
I am trying to make a function that counts up to a specific number and then counts down and does that over and over again. I wrote the logic in C++ but I am having such a hard time converting this into LabView logic. Attached is my code I want it to do in C and then also the VI that I am trying to make work, I also threw in a screen shot of it just for quick reference. Hopefully my code is easy enough to follow. Basically end game I want to feed the rpm output to a frequency port on an fpga sinewave generator. I just want the rpm to wave around the chosen rpm based on how much percentage it should hunt. Right now all it does is stay at whatever the first rpm it saw was. Also I don't have a way to really test what if the C++ code works, but it's fairly simple I think it should work.
Thanks,
Solved! Go to Solution.
07-15-2021 04:13 PM - edited 07-15-2021 04:25 PM
Something like this?
It gets tricky if you need to use floating point numbers as 10.000000001 <> 10
Also if you can't open the snippet the True Case just passes Y straight through.
07-15-2021 04:21 PM - edited 07-15-2021 04:22 PM
07-15-2021 05:10 PM
I did a lot of labview training while it was free last year, just haven't kept refreshed with it lately. You guys replied really quickly, so thank you. Kinda felt like it was quite a simple issue. I am quite more familiar with C, less with visual coding forms like labview.
Thanks!
07-15-2021 06:01 PM
Hmmm, I was almost sure that would work, but I had to make a few adjustments to the code to make it do as I wished but I still now only outputs a value of 1 continuously. I thought maybe the comparison signs were flipped around but that is not it either. Even tried changing the loop to continue if true. Briefly got it it work and output 1800, but then it failed again without me doing much I don't think
07-16-2021 12:50 AM - edited 07-16-2021 12:51 AM
Hi MGardner,
please do the LabVIEW basics (again): learn about THINK DATAFLOW!
It does not make any sense to place that "Hunting" button outside the inner while loop!
It also does not make any sense to place that outer while loop, which only iterates once! (That's just Rube-Goldberg!)
See this (again):
07-16-2021 11:46 AM
Ahhhh I see what the issue was, I had my output connected to the rpm output shift register rather than just a node though the while loop. Then I kept overthinking the issue thinking the logic was wrong. Thanks, I am good to go now.👍
08-06-2021 11:35 AM
I got some time to sit down and work out the bugs I've been seeing. This is now my accepted version. This now does exactly what I've been wanting it to do. FYI I am running continuously on the project I am going to incorporate this into so that's why I went this route.
08-06-2021 03:26 PM
Do you mean you are using the "Run Continuously" button to execute your VI? If so, don't. This is basically the same as starting the VI an infinite number of times. Essentially it runs the VI and when it finishes it starts it over again. You have no control over the sate of things. If you need your program to run continuously, write the code to do that. I have been programming in LabVIEW for over 25 years and The last time I used "Run Continuously" was probably 25 years ago.
08-06-2021 03:44 PM - edited 08-06-2021 04:13 PM
How is that any different than putting everything inside an infinite while loop? My main program is an exe program that logs into a cRIO. The program is active whenever it's connected. I am not sure if that is continuous or not.