baggio2008 Posted April 3, 2015 Report Share Posted April 3, 2015 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 Quote Link to comment
ensegre Posted April 5, 2015 Report Share Posted April 5, 2015 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. Quote Link to comment
baggio2008 Posted April 5, 2015 Author Report Share Posted April 5, 2015 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 Quote Link to comment
ensegre Posted April 5, 2015 Report Share Posted April 5, 2015 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. vormessung c.vi Quote Link to comment
baggio2008 Posted April 5, 2015 Author Report Share Posted April 5, 2015 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. Quote Link to comment
ensegre Posted April 5, 2015 Report Share Posted April 5, 2015 vormessung c.vi Does it also work with multiple channels?of course. Quote Link to comment
baggio2008 Posted April 5, 2015 Author Report Share Posted April 5, 2015 Hello ensegre,Thank you for the Advice. I will try to write the code using the way as its describe in the Vi uploaded. Quote Link to comment
baggio2008 Posted April 8, 2015 Author Report Share Posted April 8, 2015 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 Quote Link to comment
ensegre Posted April 8, 2015 Report Share Posted April 8, 2015 (edited) 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 April 8, 2015 by ensegre Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.