11-16-2011 02:15 PM - edited 11-16-2011 02:16 PM
Hello all,
Here I'm working on a program that is supposed to take the voltage read off a load cell, compare it to a desired value, and activate a stepper motor based on the comparison. It is a tension load cell, so if the voltage is lower than the desired value, it is supposed to turn on the motor, and pull the material until the voltage is comparable. I want the initial stretch of the material to be done at a set initial value. Once the material reaches the desired voltage for the first time, I want it to readjust itself like I described above.
I have attached what's been written so far. The program is capable of doing that initial stretch, but then I am almost completely lost as to where to proceed from here. I've looked into the shift registers to get the actual voltage numbers out of the while loop to compare it to the desired voltage, but I'm not sure if that is what I need here. Should I even be using while loops in this scenario?
Please let me know if there is any further information you guys need. If I need to do a complete program overhaul, please at least set me in the right direction. Thanks everyone! You guys have been tremendous help so far.
11-16-2011 02:36 PM
So, you've got the first state of your state machine coded up! Great. Now look at the shipping examples for "State machine" and we'll get it put together with some polish!
11-17-2011 04:51 PM - edited 11-17-2011 04:56 PM
Hi jpturne,
From what I can see, it looks like you have no problem coding specific tasks for your application, but it looks like you have some questions about how to structure your overall program. As Jeff has suggested, it will be well worth your time to investigate the state machine architecture for your program.
As a supplement to Jeff's suggestion of looking at the LabVIEW shipping examples, I would also suggest going through this Developer Zone article: Application Design Patterns: State Machines which explains the concept and benefits of state machines while providing some practical examples to solidify your understanding.
One last thing to keep in mind when developing a feedback controller on a computer is that there may be time delays in the system due to the OS running other applications in the background. I am not sure what the requirements are for your setup, but it is always good to keep this in mind. If timing is critical, one thing I can suggest from examining your VI is that you do not use Express VIs (e.g. the Build XY Graph and Load Cell VIs). While Express VIs are convenient, they often sacrifice computational efficiency for user-friendliness. Thus, it may be beneficial for you to code these functions yourself with lower-level functions.
I hope you find this helps you! Please do not hesitate to post any further questions. Have a nice day!
11-17-2011 05:12 PM - edited 11-17-2011 05:20 PM
You have badly used the data type terminals. I just had a look into your program and everything is with red dots. By the way, If you want to know much about state machines and passing values and states between them. See following link, you have some good video's there which may probably helps you.
http://blog.shienandy.com/2008/12/labview-state-machine-basic-example.html
Also, Try to see labVIEW beginners video's here at http://zone.ni.com/devzone/cda/tut/p/id/7466
Today's post about using Shift registers http://forums.ni.com/t5/LabVIEW/shift-register/m-p/1778734#M616871
11-18-2011 03:55 PM
Thank you everyone for the suggestions about the State Machine. I didn't want to give everyone the impression that I stopped working on the program, but here is what I have so far. I have transitioned all the old functions into this new state machine architecture. I still have not yet determined how I'm going to implement the desired voltage step yet, but I'm guessing that in the "Loading" state, I will need a comparison to determine whether or not it is time to transition into the "Static" state.
Right now, my main concerns are these:
1) I want to get rid of the clunky distance formulas that use the start time and current time and set frequency to determine the distance from origin. I am aware that it's not currently functioning in the current attachment, but it did function in my original attachment. I want to know if there is a way to determine how many times a pulse was actually sent, so I could use that to determine what the position of the motor should be.
2) One of you mentioned to get rid of the Express VI's for creating an XY graph. What should I be using instead?
Thanks for all the help
James
11-22-2011 11:54 AM - edited 11-22-2011 11:59 AM
Hi James,
To answer your first question, a sure way of knowing how many pulses you have actually sent out is to wire the counter output to another input and counting the pulses. In fact, for many DAQ devices (M and X series i.e. 62xx and 63xx) you can internally route the output signal of one counter to the source or gate of another counter on the same card without having to physically wire one channel to another. This KB describes the process: http://digital.ni.com/public.nsf/allkb/8A85E97855EDADC98625730C00065F58.
With regards to your second question, my comment was intended as a general rule of thumb in the sense that you want to have as little extraneous code running in the feedback control loop as possible. Concerning the Express VI for the XY graph, I looked through the actual code in the VI (you can access it by copying the VI to a blank VI, right clicking and selecting "show front panel") and it looks fairly streamlined and efficient. My main concern was with the DAQmx express VIs, but it may very well be that you will not need to worry about them, depending on your latency requirements.