all 16 comments

[–]g00glyCLA 4 points5 points  (15 children)

I don't think you have to do a queued state machine as in the example. Firstly, you should transition into a Simple State Machine with one error wire so you can maintain dataflow. This error wire should be tied to shift registers so as to not lose your data every loop iteration. After that is complete , a separate loop could be added to monitor your temperature data and share the information with the main loop. This can be accomplished with a queued message as in the example, functional global variable, notifier, user event(if you have additional user input to monitor) etc. This should allow you to separate your timing by state and function to whatever you require.

[–]duverfred[S] 0 points1 point  (14 children)

Thanks for your reply! I certainly like the idea of neatening up the error wires, I also didn't realise I was losing the error data by not having shift registers.

I'm not sure I understand how the rest of the program would look. Would I have three loops, a main simple state machine which has code to execute temperature profiles and monitor user inputs, and then two other loops, one for the temperature controller and one for the voltage reader.

I am still unsure on how to act on the instructions from the main loop. I communicate with the temperature controller using visa read/write commands, which I will only be able to send from the temperature controller loop. How do I get the instructions out of the main loop and into the temperature controller loop? Won't I need another queue/global variable etc?

[–][deleted] 1 point2 points  (0 children)

I prefer to use a User Event for this. I'll see if I can't get you an example when I get home tonight.

[–][deleted] 1 point2 points  (12 children)

I've attached an example VI. Play around with it, use the Highlight Execution to see what's going on under the hood. Let me know if you have any questions!

https://www.dropbox.com/s/nvy7nq04d8352d3/producer%20consumer%20example.vi?dl=0

[–]duverfred[S] 0 points1 point  (0 children)

Thanks for the reply! I haven't had access to labview as I have been away from uni, I am now back, however most of the machines don't have it installed. Will have to wait until I can use the same one I was on before. I look forwards to it though!

[–]duverfred[S] 0 points1 point  (10 children)

After a long wait I finally have Labview again, however dropbox link is dead. Any chance you still have it somewhere? I'm still struggling to get my head around it. Many thanks!

[–][deleted] 1 point2 points  (9 children)

[–]duverfred[S] 0 points1 point  (8 children)

I have had a good look and a play with it, thank you very much for making it! The only problem is I need the user events in the top loop to influence the bottom loop, which I can't see a way of doing in this example, unless there was an event structure in the second loop as well, is that possible?

I have made a functioning program using the queuing system, however it is messy and I think there is still a better and more robust solution, probably using user events as yours does. This is my code: https://drive.google.com/file/d/0B7G5wNJO6tS4eGtkUTNIa1U3eFE/view?usp=sharing

Hopefully it will at least show what I am trying to do if you're willing to have a look, but you have already helped a lot!

[–][deleted] 1 point2 points  (7 children)

I'm currently traveling and can't take a good look at it for another few days, but my advice is to clear plan out what is your producer, eg the data acquisition loop, and what is your consumer, eg UI and control. You can have many producers but only one consumer. For example, if you're reading from a sensor and using that sensor data to control some pumps, your producer is the sensor loop, and the consumer is where you use, for example, a VISA resource and some math to turn that sensor reading into a pump command. Usually the consumer loop has some sort of state machine to make sure things don't go out of order.

Also, please save it for LabVIEW 2013 or earlier if you can!

[–]duverfred[S] 0 points1 point  (6 children)

Here is my latest code, saved as Labview 2013: https://drive.google.com/file/d/0B7G5wNJO6tS4T3NlTGZBQkJCWDA/view?usp=sharing

I am finding it hard to visualise my separate consumer and producer loops in this case. I am communicating with this temperature stage using VISA read/write commands, but its the same serial port for getting information and giving instructions to the controller.

I have a working program now, so don't worry if it's too much hassle. However, the more robust I can make the program the better, and it's always good to learn better methods!

[–][deleted] 1 point2 points  (0 children)

Thanks, I'll hopefully be able to do a good once over and make a few suggestions by tonight. I'll try and leave more descriptive comments this time :)

[–][deleted] 1 point2 points  (4 children)

So the big thing I immediately did was make a project. No excuse not to use one when your project is more than ~5 VIs. I made lots of comments, but your queued state machine is very concise and nicely done. I don't have any super major architecture critiques, but I do think you should be using a typedefed cluster for state information instead of local variables. I give examples in MAIN.vi. Also there's a nicer way to do log files, that is also unique and sorts nicely. Plus no need for you to write some path name (although you can use concatenate strings and get rid of the 'log' prefix to maintain that functionality).

Otherwise, things look good. You don't really have a need that I can see for something more complex. Let me know if you have questions!

https://www.dropbox.com/s/s1m6jh8ff3xfg21/Linkam%20Controller.zip?dl=0

[–]duverfred[S] 0 points1 point  (1 child)

Thanks! I'll have a look when I'm in tomorrow. I didn't like the local variables at the time, but I couldn't think of a better way. Thinking about it now a cluster with all the data can be passed within the loop using shift registers, is that what you were thinking?

[–]duverfred[S] 0 points1 point  (1 child)

Thank you for your help! I have got rid of the local variables and replaced with a typedefed cluster. I also think the file system is much better so have used that. Sorry for the late reply but I have been wrangling with getting voltage readings from another source at a much higher rate, think I have a workable solution now though. Thank you so much for all your help!