07-24-2015 09:02 AM - edited 07-24-2015 09:24 AM
Hey everyone,
I am stuck on getting an iteration that I want. So I upload the test text file onto labVIEW. And it will turn the pins on or off based on the text file (Status boolean array). Next, I get rid of that column.
After this, I am lost on how to accomplish the iteration I want.
The iteration I want, specific to the text test file, starts at column 2, row 1.
I want to add code to the program, meaning I want this to occur after what my current code does. So the new code addition will:
1) wait 2 ms then turn status (index 0) off.
2) wait 3 ms then turn status (index 1) off.
3) wait 2 ms then turn status (index 2) on.
4) wait 4 ms then turn status (index 3) on.
Next, move on to column 4 (The next set of status - wait in the text file)
5) wait 4ms then turn status (index 0 on).
6) wait 3ms then turn status (index 1 on).
7) wait 2ms then turn status (index 3 off).
😎 wait 2ms then turn status (index 2 off).
And repeat if there are more sets of status-wait columns in the text file (In this case their aren't).
I am at lost on how to accomplish this, hopefully I have been clear
07-24-2015 09:27 AM - edited 07-24-2015 09:27 AM
This could be done nicely with a state machine in LabVIEW. You read the text file in, and insert the required steps into a queue. So I imagine you could use here a Queued state machine. Of course properly set-up, so you can pause/abort any time if necessary.
But! Before you would start to work on the above programming task, you should explain what is your goal with this? The problem here is that, you cannot accurately time your software running on Windows, you can expect up to several millisecond fluctuations.
You wrote about you want to do waits like 2 msec, 3 msec, etc... You cannot do this with pure software timing in Windows. However, you can use a proper hardware with built in clock to achieve what you need.
So what do you want to do with these msec waits?
07-24-2015 09:29 AM
So I didn't read your instructions well, but it wasn't clear at first. So this isn't a perfect solution. Instead this will go through one row at a time turning on and off the pin in that row. I should have probably used a state machine but it was simple enough not to. Oh and I changed the time to seconds so it could be easier to see. Is this intended on running on a Windows machine? You will have way too much jitter to actually turn on and off hardware with software timing, at the timing requirements you have.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-24-2015 09:33 AM - edited 07-24-2015 09:36 AM
Thank you for the tip on the state machine, and thank you for the example code I will take a look at it soon.
But yea, I wrote ms, but my intention was to multiply it by 1000 and do it in seconds instead. My goal is to upload a text file with information like I posted before, and it will then turn on/off some daq hardware that sends signals. I am using an array so I control different lines on the DAQ hardware, and I thought it would be the best way.
I want the wait time (In seconds) just so I can watch the daq hardware turn on/off at certain times. And it is intended for a regular computer machine.
07-24-2015 09:38 AM
Yes, then this will work. But use a proper state machine, otherwise you have no option to stop/abort/pause an ongoing operation in a sane way ("sane way" means you handle properly for example an abort procedure: you set your HW outputs to a initial state if necessary, etc...).
07-24-2015 09:42 AM - edited 07-24-2015 09:42 AM
Can someone give a good example of a state machine....I have never used one before.
07-24-2015 09:46 AM
hmm, the best thing if you start some LabVIEW course. You need to learn quite a few aspects to be able to make a proper state machine, so I would recommend you to start with some learning, depending on your available access for resources:
Learn NI Training Resource Videos
6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
And here are some actual state machine examples:
http://www.ni.com/tutorial/7595/en/
But if you google for it, and search the forum, you find vast amount of info regarding to state machines...
07-24-2015 09:47 AM
07-24-2015 12:08 PM - edited 07-24-2015 12:16 PM
Is there any other way to do this then a state machine.....possibly an easier way?
I've been looking at state machines and cannot seem to figure out how to program it in this scenario
07-24-2015 12:42 PM - edited 07-24-2015 12:44 PM
State machine is easy. The simplest, scaleable architecture. I've seen really crappy developers go amazing places with a simple state machine.
Follow the links you were given above which are from the Rules and Guidelines page.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'