LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

There must be a better way of doing this

Solved!
Go to solution

You are very welcome. You will learn here that fancy looking code usually ends up in the Rube area of the forum. Fancy is usually a long way of saying that it took too many steps to get where you were going.

 

I must say that I agree with IAN about the reliability of using a DAQ assistant for long term data collection. It is not the best or most reliable way to code this project.

 

Good luck with your project.

Tim
GHSP
0 Kudos
Message 11 of 46
(1,808 Views)

What would you suggest instead of the DAQ assistant? I have tried to use the individual DAQ VI's but with little success. Would it be easy to be able to read from every channel, and use the code you've shown me already with the VI's?

 

Chris

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 12 of 46
(1,804 Views)

OK I am going to throw you into the deep end a little here. I have made this about as simple as it gets. If you use the light bulb to view the vi you should be able to see what is going on. The state machine is a stryct type definition. To add more states all you have to do is right click on the constant and open the type def. Then you need to right click the control and edit items. I know it may sound complicated but you will realize fast that this was the best thing I ever taught you!!!

 

Take a look at the code and then we can talk some more. I think that we can simplify what you are trying to do here and get a more simple report.

Tim
GHSP
0 Kudos
Message 13 of 46
(1,790 Views)

Blimey, when i first opened this i was a bit worried, "how the hell am i going to be able to do something like this!" lol, But you were right, following with the lightbulb really helps.

 

I can see that the producer loop collects the data from the DAQ and then transfers it to the consumer loop via a local variable set to read. The data is then inputted into the "log data" case and executes as before, producing N number of reports. For future reference are consumer/producer loops a specific type of loop or does the use of local variables turn loops into one or the other?

 

I'm having a bit of trouble seeing how to control the rate and number of samples that are being read (on my screen number of samples = -1 !) and what is the significance of the event timeout in controlling the rate of data aquisition?

 

I also see that the task set up VI allows me to choose the number of channels that will be read from, will the DAQmx read.VI automatically record the data from all of the channels into the 2D array?

 

I was a bit confused as to what the state machine actually does, but i've done a bit of research and think i've got it. It's like a flow chart with each state corresponding to an action (or an algorithm in labview) with the states referencing each other and ending the program etc.

 

 

 

I've also been asked to read 24 digital inputs from the DAQ and use them to light 24 LEDs on the front panel (these are pass/fail conditions). These will have to be running on the front panel of this VI. I'm looking forward to having a go at this one, seeing if i can get it to work within the loops etc. I'll post my attempt soon!

 

Again, huge thanks for your time (and patience!) Aeastet

 

Chris    

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 14 of 46
(1,773 Views)

OMG.  Jimi Hendrix has risen from the dead.  Smiley Surprised  (referring to the subject bar)

- tbob

Inventor of the WORM Global
0 Kudos
Message 15 of 46
(1,761 Views)

I can see that the producer loop collects the data from the DAQ and then transfers it to the consumer loop via a local variable set to read. The data is then inputted into the "log data" case and executes as before, producing N number of reports. For future reference are consumer/producer loops a specific type of loop or does the use of local variables turn loops into one or the other?

 

No producer loops are the loop that provide the information that you need. This could be data, string path references. It could be anything that produces an output for a different loop to use (cunsume).

 

I'm having a bit of trouble seeing how to control the rate and number of samples that are being read (on my screen number of samples = -1 !) and what is the significance of the event timeout in controlling the rate of data aquisition?

 

This will be controled one of two way or a little of both depending on how you work with it. This was why I said that we need to revisit this after you get a better understanding of what I gave you. I would most likely set it for continuous data acquisition and just use what I need. We can get into that a little later.

 

I also see that the task set up VI allows me to choose the number of channels that will be read from, will the DAQmx read.VI automatically record the data from all of the channels into the 2D array?


If you look at the setup vi you will see that it give you an array of channels (i.e. DEV1/AI0, DEV1/AI1 etc...) and array of channel names (Voltage_0, Voltage_1, Voltage_2 etc...) you will have to edit these and all of the fields that are arrays to make each channel work for this method. There are easier ways to do this and we can exploer that later.

 

I was a bit confused as to what the state machine actually does, but i've done a bit of research and think i've got it. It's like a flow chart with each state corresponding to an action (or an algorithm in labview) with the states referencing each other and ending the program etc.

 

A few things here if you update the strict type def for the machine states then when you save and apply changes it will appy it to all of the other constants. You will see this is a great!!!! feature and why I and many other use them. You can also right click on the case structure and have it add a case for every value and just add the code.

Tim
GHSP
0 Kudos
Message 16 of 46
(1,748 Views)

Right, I'm back after the weekend (unfortunately!), hope you guys had a good one too. Here's my attempt at using digital inputs (25) to control LEDs on the front panel. I'm not sure about its placement in the loops.

 

However i've just been asked (read told!) to alter what i'm measuring! I now need to produce two seperate graphs, but using data taken from the same channel. The first graph needs to display the voltage of the battery as it charges and then stop recording when the charge cycle is over.

 

The second graph then needs to use data from the same analog channel to show the voltage as the battery is discharging. Therefore i guess i need to use some variety of trigger(s) to sort out the data i need, but i'm really not sure how to implement them whilst using the producer/consumer loops.

 

Chris

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 17 of 46
(1,719 Views)

Update - I would actually like to trigger the data recorded from one analog input (AI1) by using another analog input (call it test_number):

 

Succeeded:

 

if (test_number = 2V)

       send data from AI1 to graph 1

 

if (test_number = 3V)

       send data from AI1 to graph 2

 

else

       take no action - ie do not record data

 

 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 18 of 46
(1,704 Views)

Oops - spellchecker turned psuedocode in succeeded

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 19 of 46
(1,702 Views)

Looking at what you have I would suggest that you put the digital into it's own loop too. I try to seperate AI, AO, DI and DO into their own loops. This gives me the flexability to do what ever I need to do when ever I need to do it. I would copy what I did for the analog loop with the event structure and a while loop around the whole thing.

 

As far as the graphs go do you still need to generate 25 reports to go with these graphs? What are you going to graph? You were sending three values to each report do you what to graph the middle one depending on the voltage value?

 

In the code under the log data case you will need to replace the min max function with on the array pallet.

 

18211iB9310BA6091DC480

Tim
GHSP
0 Kudos
Message 20 of 46
(1,662 Views)