From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-10-2014 04:58 AM
Hello everyone,
I am fairly new to labview and programming and came up some tricky things, atleast for me.
I searched for the answers and tried one or two solutions but nothing works, or atleast I cant get it to work. Any help would be higly appreciated!
I dont know how to attacht it properly, i got it on a project base. I hope the attachments are well placed.
Anyway, I really want to get into it more, I really appreciate your help!
My excuse if my english or expressions are mistaken or misplaced.
Thank you, Geert
09-10-2014 05:23 AM
Hi!
For yours first issue I recommend getting know to Producent-Consumer structures. It'll provide you with independecy of main loop from subVI.
Second issue: In order to have time stamp, better is to build waveform and then define Time axis.
09-10-2014 07:03 AM
1) Learn to use the Event Structure. You have several loops that are just polling as fast as possible, eating up lots of CPU resources to do practically nothing.
2) Learn data flow. A loop cannot iterate until EVERYTHING inside of it is done running. That means your subVI must be done running before you can go read from your microcontroller again.
3) Why are you using the Baud Rate to set how many bytes to read? That makes no sense. Since you are using a termination character, just set the number of bytes to read to a large number. Use a constant, it will be more efficient.
In this case, I would seperate the system into 3 loops. One loop to do nothing but read from the Arduino, the second to show one display, and a third to show the second display. Read about User Events. They will be your friend here as you can use them to send the data from the Arduino to the other two loops that should just be Event Structures inside of While loops anyways. You can then use a queue or notifier to send the stop command to the serial read loop.
09-20-2014 04:49 AM - edited 09-20-2014 04:56 AM
Dear AdamTrojak and crossrulz,
Thank you for your reply! I have looked into eventsstructures as you stated. But is the data aquisition from an pic (Arduino) possible trough events? I cant seem to find a solution for this. For the subvi popup I can imagine how it goes, although it doesnt popup now. I look into that.
I understand that a loop has to be finished. I will try to get this clear, can you state out where this goes wrong?
The baud rate is this high because I programmed the Arduino whit this rate. This is because the Arduino now sends the data more real-time. I know this PIC isnt used for the real-time data aquisition, but this is close enough for me.
So seperate the program in 3 loops, with eventstructures.
Well, at this point I made some mistakes. I can point some out myself but I don't know how to fix them. And ofcourse, if you see more (and you will 🙂 ) please point them out!
1) Data aquisition runs and reads from the Arduino. But the data isnt shown untill the first loop is finished, so the data will be displayed when the first loop is stopped.
2) The SubVI in the third loop is unresponsive. I cannot call it at this point. (I want to use this stop button, which you can see, as a popupbutton)
3) To end the program it needs to be pushed at all the stop buttons. (The one in the first and second are combined, but the third requires fore some reason the stop button in the Event structure.)
4) Did I make some progress?
Your help is highly appreciated!!
09-20-2014 05:39 AM
you will make some progress when you will start to learn dataflow.
If you are going to follow crossrulz advice , he was talking about 3 independent while loops( and you made them dependent because next loop is waiting for the eariler one to finish.
you need to go step by step.
1. remove all loops , trun the highlight execution on and run the vi . See how the data is passed to individual nodes.
2. Now put a single while loop, keep initialize visa before the loop and close visa after the loop and put some wait in the loop and see the flow.
3. Learn about event structure as it is clear from your diagram that you did not learn about it before using( you have put your subvi into timeout case with no timeout value so this case will never execute).
Producer consumer, queues and user events are far ahead for now go simple try to learn Dataflow.
09-20-2014 05:48 AM
Your main problem is that you created a data dependency between the loops. So one has to complete before the next loop which has to complete before the next loop. What we want here is parallelism, meaning all three loops can run at the same time as the others.
To pass data from one loop to another, use a queue. Learn the Producer/Consumer, as this will help you understand the idea of parallel processes.
09-22-2014 10:13 AM
I looked op the producer consumer technique and came up with this;
At this point the loops are seperated and thus I can make some parallel dashboards, right?
I did not process the data yet, but the indicators give me the right data.
todo list
Make SubVI popup (dasboard 2)
Make datalogger
Send start byte write to arduino
Send stop byte write to arduino
09-22-2014 10:24 AM
Be very careful here. Once an element is dequeued, it is gone from the queue. What I am getting at is that both loops will NOT see every sample. They won't even see the same samples. If you truely want both consumers to process everything, then you need to either use two queues or a User Event. I recommend going the second queue in this instance.
09-22-2014 11:16 AM - edited 09-22-2014 11:17 AM
So this would be better, and see the same samples at the same time.
So if I want to close or stop the program, what is to be done with the stop buttons? I cannot find a usefull solution to stop or close the program with one stopbutton.
09-22-2014 02:12 PM
gertjezzz wrote:
So if I want to close or stop the program, what is to be done with the stop buttons? I cannot find a usefull solution to stop or close the program with one stopbutton.
You should be sending a stop command of some sort in the queue to let the consumers know they are done. In your case, I would send something like the string value "Stop". So after the producer is complete, you just enqueue that message into both queues. The consumers then check to see if the string is that stop command and stop when they see it. Release your queues after their respective consumer loop.