11-15-2013 05:35 PM
Hello!
I have a problem with my program.
I made the block diagram below. I pretend to control a bipolar stepper motor with the daq and a l293d, so i made the sequence
that the coils requires with the flat sequence, and the extern case structure just reverses the sequences . It works as I tought, but,
when I connect the daq 6008 it just doesn't seem to recieve any data. I think its the flat sequence, because I tested the daq with
other program with just a while loop and it works the right way.
Please someone explain me this... Thanks!!
and yes, I'm new here
Solved! Go to Solution.
11-15-2013 05:47 PM
No shame in being new, we all were at one point.
It would help if you posted the VI and not a picture. If your VI is exactly like your picture I can tell you you have race conditions, and your program will not loop but only write to the DAQ output once. What the values will be on that output cannot be determined.
You are also using software timing, meaning you ask Windows to wait a while and then change the output, if you ask to change too quickly Windows will not be able to keep up. This is not a microcontroller running one task, your PC is running hundreds of things at once and they get in the way. An anti-virus program may run and cause a delay, and now your timing is screwed up. To fix this you can rely on the hardware to keep the timing. You will need to read the data sheet for your hardware to determine if it is capabile of hardware timed output. Looking at the 6008 I don't think it supports feature.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
11-15-2013 05:49 PM
This is simple data flow! In LabVIEW any node or block of code can run when all its inputs are available.
So your DAQ Assistant runs almost immediately when the VI starts. The sequence structure amy start at about the same time but will not complete until all the Waits have completed. So the changing data will not get to the DAQ Assistant because it will already be finished.
All the code needs to be inside a loop.
Try to rewrite your VI so that no sequence structure and no local variables are used. Hint: Look at State Machines.
Lynn
11-15-2013 06:05 PM
First of all thanks for your comment.
What do you mean with race conditions?
So you are telling me that i will not be able to run the program correctly with that logic?
What would be an optimal way to make a binary sequence with adjustable timing, i mean, if it's possible.
Thanks buddy
11-15-2013 06:10 PM
Oooh i get it, so when the program starts not only the binary sequence starts, the daq assistant also starts reading, thats why it cannot be determinate what it'll read, thanks man, I'll start reading about state machines here in NI.
11-15-2013 06:24 PM
A race condition is a situation where two or more parts of the program can run independently from each other and nothing in the program controls or forces the order of execution. In the code image you posted the local variables in the first frame of the sequence structure may run before or after the ones connected to the DAQ Assistant. Of course the sequence structure assures that the locals in the 2nd, 3rd, and 4th frames will run later than the first frame. It will not actually happen but in principle the entire case + sequence structure coule run before the locals connected to the DAQ Assistant were read. Then you would get onley the last value.
To fix it, learn to take advantage of dataflow. Create a 2D array of the booleans. Using Autoindexing on a for loop, read one row at a time and wire it to the DAQ Assistant (also inside the loop). Look at the attached VI.
Lynn
11-15-2013 06:35 PM
Woah, thank you very much guys, as I said I am new here, and now im looking forward to keep learning.
One more thing to ask please... would you mind to tell me where can i find a basic tutorial of labview?
the thing is that im studying electronic engineer but the labview class sucks (the way its been taught),
i guess that a full labview tutorial must be here in the NI website but i cant find it.
And again, thanks a lot
11-15-2013 07:38 PM
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
11-18-2013 04:20 PM
thanks dude!
02-20-2015 09:52 AM
Thank you very much ... this was very helpful for me as well!!