07-10-2018 07:28 AM
Hey All,
I have a question pertaining to timing of my loop. As you can see in the attached vi I take a readings with an Arduino Uno using the LINX software and those readings are being taken for a period of time designated by the elapsed time functions, Now my question is, is there a way to add a 2-3 second delay after the elapsed time functions that will not delay my entire system but will just block the flow of data in the output Boolen wire coming out of the Elapsed time functions.
I need to this because my project involves relays and they kick on right away because they are getting an improper reading for the first few seconds but adding a delay/pause on those two pieces should fix it because the rest of the program needs to continue to run during that time I just can not have those two wires feeding data.
I am fairly new to labview so this may be a simple fix, but I am lost because I tried wait and time delay and they slow my whole loop so any help would be appreciated.
Thanks,
Zachary
07-10-2018 07:52 AM
You could move the hardware interaction to a separate loop, and use some messaging mechanism to command it write outputs only when the controller loop determines.
Also, you're doing the same calculation in 6 places in your loop - put that functionality in a subVI.
07-10-2018 07:59 AM - edited 07-10-2018 08:00 AM
Hi Zachary,
is there a way to add a 2-3 second delay after the elapsed time functions that will not delay my entire system but will just block the flow of data in the output Boolen wire coming out of the Elapsed time functions.
So you want to delay those boolean values?
Idea:
1. create an array to hold as much boolean values as you need to delay your signal. In your case that would be 3s/10ms (iteration time of your loop) = 300 elements.
2. Insert the current boolean value in the array and remove the oldest from the array.
3. After 300 iterations your "current" boolean is moved to the "oldest" position and gets removed from the array: use it to drive your relays…
You basically do the very same with those shift registers in your VI: you delete the oldest elements and insert a new one! (Here you should use ReplaceArraySubset with an incrementing index value, much less array shuffling.)
You could also use the PtByPt-Queue function…
Why do you have so much duplicated code in your VI?
07-10-2018 08:13 AM
Thank you both for your quick responses,
I have not made any sub vi's yet because like i said I am pretty new to this and want to see all the code because I have had to do a lot of tweaking.
I guess you can say I have a lot of duplicate code but I would be unsure how to remove any of it because so far all the code holds a function for me because the true driver of this code is a Gy-520 which is a gryo/acclerometer. Each line indicates what to do at certain measuring points, in fact I am editing two more parts currently to run for time like the top two in the vi, this may seem very repetitive to you guys but I am not sure I would be able to follow what I am doing if I didn't have all my Inflate and deflate bolster controls labeled and wired individually i would love input on how to simplify it if you see fit.
but I will try these Ideas right now the delete array idea is actually used previously in this vi, which makes me wonder why I did not think of something like that before but I will see what I can do.
But there is really no timing functions that would work for this type of process, just asking for reference?
07-10-2018 09:24 AM
GerdW,
I am not sure what I am doing wrong on these arrays but it does not like the fact that I am trying to use Boolean's and a set number of elements, i can not seem to get any combination of what I am doing to work I am sorry to ask this but could you possibly break down your instructions slightly further?
I would really appreciate it but thank you for your input so far.
07-10-2018 09:32 AM
07-10-2018 10:13 AM
Wow thank you so much for that! Am I correct for assuming the top half is one solution and the bottom is the second ?
I did encounter one issue however so I have tried this a couple of times and at first i tried to do it with out creating a second while loop and just running the shift registers off of the the while loop that encases the whole program, that sparked an error in my mind and in the program which was that how to run the initial value to the first shift register because it needs to be after the elapsed time and the program didn't accept me running that to the initial shift register.
I then tried it using a second while loop inside of the main while loop ( which from what I have learned from research can cause complications), which in this case it did because I got all the program wired up properly but it won't let me run the final value back down to my LINX digital write channel, which I need to do to get my data unless I am suppose to wire it else from the new code?
Thank you,
Zachary
07-10-2018 11:01 AM
This what i added to no a veal it did not block the information I needed it to but it seems like it might have slowed down my Y and Z readings on both the Acclerometer and on the Gryo and I am not sure what I wired wrong here I have been playing with it for a while and will continue to do so but I am just wondering if I missed something big.
Thanks,
Zachary
07-10-2018 11:10 AM
Okay it did not actually slow down the Y and Z value that was just a mistake I made but it still does not block/delay the needed information for 2-3 seconds
I am sorry and Thank you,
Zachary