07-19-2024 08:24 AM
Hello i'm pretty new to Labview and i'm trying making a block scheme that makes speed profile by using 2 arrays.
So i made this project and i'm having problems with for loops (probably is trivial :D).
Basically when i start the code the first 2 couples of values of speed-time are bypassed and the codes procedes calculating the ramp of the speed with the third couple of values, then the fourth couple of values is bypassed to.
Where am i doing wrong?
07-19-2024 08:36 AM
First, I'd recommend saving your attached VI in a previous version of LabVIEW so that more people will be able to view it. LV 2024 is not something that many will have at this point. That, or, save your code as a .png snippet and post.
If I had to guess as to why your first set of values are being skipped: if you are multiplying your values by one of the for loop iteration terminals, it may be returning 0 as a result since the increment starts at 0 and not 1.
07-19-2024 09:12 AM - edited 07-19-2024 09:19 AM
Waiting for a new VI with all controls having values, a description of how you run it, and what you expect to happen.
07-22-2024 08:38 AM
Wellll ok but this doesn't solve my problem... I know that my code is not perfect and can be improved but at the moment I only care that it works, then I will think about how to optimize it.
With 'bypassed' I mean that the first two pairs of speed and time values are skipped without ramping inside the small for loops.
Essentially the code performs the speed ramp by reading the initial speed at t = 0 and the third pair of values.
If you run the code you can see it.
07-22-2024 08:57 AM
Hi zeta,
@zeta1928 wrote:
If you run the code you can see it.
Well, if you would downconvert your code then more people would actually be able to run it!
General suggestion: Downconvert using File->Save for previous to LV2021 or older, I prefer LV2019…
07-22-2024 09:00 AM
Hi sorry i forgot to do this
Here you have 🙂
07-22-2024 09:55 AM - edited 07-22-2024 09:59 AM
Hi zeta,
you should not autoindex the "desired speed" and "time" arrays at your FOR loop!
Instead you should use ArrayIndex inside the loop and only index a new element when you want to start a new ramp…
(Due to autoindexing the first 3 speed/time values will be already "used" for the first 3 states of "start", "comparison", and "salita"/"discesa"!)
Additionally that FOR should be a while loop…
Btw. you also forgot to set some reasonable default values in those controls as requested by Altenbach!
07-22-2024 10:08 AM
Sorry but I didn't quite understand.
How can I use an indexArray inside the loop? Once inside the loop I will already have a single value so I cannot use indexArray right?
Sorry so this is probably a trivial problem but I just started using labview 🙂
07-22-2024 10:13 AM
Right click the tunnel and disable autoindexing. Then you get the whole array inside the loop.
07-23-2024 09:06 AM
@zeta1928 wrote:
Hi sorry i forgot to do this
Here you have 🙂
You would not have a problem with "double for loop" (sic) if you would implement a proper state machine and use the outer while loop for all the spinning. That's all you need! You don't even need to distinguish between ramp up or down of you would use the same loop but a single increment (positive or negative, depending on end points)