Jump to content

Data acquision


Recommended Posts

Hello,

I'm new in LV- Programming and have a Project in Data acquision field. Data must be acquire from 15 channels, FFT and PSD- Graph must be view in Live during acquisition and then the Data must be saved over 2 min as Array for Postworking. During The acqusition the user will be able to start, reset,restart and stop the acquisition. Im now looking for how to structure the program to have a modulare and simple Program without spaghetti-code. 

question:

1-How can i really strukture this?

2- It seems like even structur is one of the way but i don't really know how use it.

For more comprehension i attach  basic-structures how the programm will work.

Thank you 

post-53358-0-04414400-1428097466_thumb.p

post-53358-0-00551000-1428097480_thumb.p

post-53358-0-44814400-1428097497_thumb.p

Link to comment

If you have already an idea of the state machine, you're already well set for a start, you have just to see one by one the programming details of the subtasks you need to implement.

In general I could suggest:

-look up examples and get accustomed to the basic operations (e.g. create DAQ task/acquire continuously/graph data/save data), even in a run-once example.

-spot out if there are tasks which need to run concurrently in your construction, like e.g. processing or graphing data while more is being acquired, react to GUI events while processing still goes on, etc: these need separate while loops, and a way to communicate data between them (as simplest, local variables; more structured data queues, producer-consumer model,... different solutions with different merits)

-learn and define which tasks need a setup which is carried on to every other state of the machine, e.g. definition of the DAQ tasks, and how to carry the information from one state to the other via shift registers. Similarly for properly closing resources on stop/change of configuration, etc.

Event structures are not difficult - you just drop the frame inside the while loop and decide whether you need a timeout action or not. The easier events to be grasped are those generated by a GUI action, e.g. the user presses the save button, a Save button Value Change is generated, and the relevant code in the frame is executed for that iteration of the while loop.

Link to comment
Hi ensegre,

thank you for the reply. I have tried now to emplement with one chanel as testprogram. The Acquisition is suppose to stop automatically after 2 min. the data will be also save. Now i want to seperate each task. I want to seperate for example save button, save only by press button, i also want that after complete the acquisition the program return to start until Stop is pressed.  As summary how can i seperate acquire, stop, save  and reset and restart.

 

The VI for the one channel testprogramm is attached below.

Thanks

vormessung b.vi

Link to comment

This could be, schematically, one way to do that. To you to write proper code for each action, of course. I'd recommend to use true DAQmx VIs rather than these Express thingies and separate Create Task, Start Task, Read channels, Stop, etc. That way you can keep the DAQ task open across states, and repeat only the read on demand.

post-28229-0-25407900-1428251978_thumb.p

vormessung c.vi

Link to comment
Hello ensegre,

I thank you for the Quite reply,

i'm not able to open you VI. Please can you upload it  so that It can be opened with LV 2011 or LV2013?

Another Question you mention that i used DAQmx  for the the Projet i am supposed to work with 15 channel. Does it also work with multiple channels?.

 

Thank you. 

Link to comment

hello I tried to do astep with my project. I'm now able to recieve Signal. but in Aquiring state the acquisition must run 2 min before leave the look inside. Another problem that i have is why  by droping of a step o another  the graph other step don`'t run?.

Please check the attached Vi

 

Thank you for your help

Testprog.vi

State.ctl

Link to comment

hello I tried to do astep with my project. I'm now able to recieve Signal. but in Aquiring state the acquisition must run 2 min before leave the look inside.

For that, divide the continuous acquisition in chunks, say of ~100ms worth of data, and care for accumulating the data in some buffer or array as time goes on. That way an user event can be processed at the first available slot, before the acquisition completes. The completion of the 2min worth can be tracked with a counter of chunks. As said this is something you control very well if you use the elementary DAQmx blocks, I'm not really familiar with these Express VI signal thingies and I generally avoid them.

 

Another problem that i have is why  by droping of a step o another  the graph other step don`'t run?.

Please check the attached Vi

I don't really understand what you mean, and I can't get into every detail of your coding. At first sight, though, perhaps you should think more in dataflow terms. For instance, your code seems to acquire only once before the event structure; the signal on the output wire is not going to change before the next iteration of the outer while loop (2min?). I don't understand therefore what should happen in the inner while loop in the Acquiring case within the Timeout event. Why do you need an inner while? And why at all a case structure in the timeout event, which redoes and interferes with the way state changes are dealt in other events? I didn't look too carefully at your code, though, nor attempted to run it.

Edited by ensegre
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.