12-13-2012 03:23 AM
Hi all,
I have an application in which I have to communicate with two serial port to control two different microcontroller. One of the microcontroller is used to to move a stepper motor while the other one reads a parameter.
Please see the attachment showing front panel of application. Here multiple buttons are given for user for the application. I will just explain main features of the program.
1- When the user presses Auto Scan button Motor goes to start point and moves in defined steps towards end point, at each step a parameter is read from other controller and is stored in an array. Once motor reaches end position the GUI plots the result doing Gaussian fitting on it.
2- If any of the limit switch is pressed accidentally or manually the motor has to stop immediately.
3-If user presses Motor Stop button motor has to stop immediately and scanning has to be stopped.
In the attached program I have more or less achieved the desired results but I still feel that there are much scope for improvement.
Suggestions are welcome.
12-13-2012 03:28 AM
I only looked at the screenshot:
Lose the outrageous colors and arrange the buttons and controls so the sequence the user goes through is intuitive, even if that means numbering the controls.
12-13-2012 09:00 AM - edited 12-13-2012 09:00 AM
Don't worry about the colors yet, work on the block diagram. Look up "state machine". Both the front panel and the block diagram should fit on one screen (or you should only have to scroll in one direction.)
Your diagram is way too big, it has too many sequence structures, too many globals and is very difficult to read.
Take a step back and think about the architecture and program flow.
12-13-2012 09:56 PM
hi vt92,
I got your point and will try to implement these things in next version.
My main concern was that I have to stop any running loop or subvis whenever user presses Motor Stop button. To achieve this I am reading this button in polled fashion, in a parallel loop and putting the value in a global variable. Now in every Subvi I have a parallel loop which is reading that global variable again in polled fashion and cuasing termination of running loops.
Is there any better way to this.
12-13-2012 10:01 PM
Use an event structure in a while loop and create a "value change" event for the stop button. The event handler for the Stop button value change would then communicate to all your loops to "stop". There are several methods of inter process communication at your disposal. Since you are "notifying" all your loops to stop, a "Notifier" should work fine. Take a look at the examples using a notifier. It's fairly easy to implement.