06-12-2013 01:31 PM
I am new to develope application by using architecture. i would like to make robust code for my program. i developed one application for my instrument which skeleton of the program is attached below.
My application requirements are following given below
1.whether Instrument is connected or not ? (I will put this subVI and license validity in the Intiliaze and license checking part )
2..Check the licence validity of the instrument once when start the program
3.Two stepper motor are here. so i gave the option such as forward and reverse for both the motor which can rotate depend upon the user input. i would like to make if user press motor1 Run button, the motor1 will rotate in clock wise direction , if user press motor1 reverse button, motor1 will rotate in anticlockwise direction and same logic for motor2 also.
At the same time I gave option if user want to run motor2 while motor1 is running so that why i prefer master and slave architecture (both motor can run at different rate at the same time).
4.If user press the quit button the program comes to end
I attached skeleton of the program only so i put boolean indicator which can enable depend upon user input
Please view my code and tell me the suggestion what i made it wrong in my program? and how to make this program into simple ?
06-12-2013 02:28 PM
Change the Obtain notifier datatype to the type-def and the code will look better.
Your solution will work, although if you plan on using DAQmx to control the motors you only need 1 slave loop.
Instead of using the Mouse down event, it's more common to use the Value change-event, you can then use the Switch when pressed mechanic on the buttons.
I usually place my controls in their event, but it shouldn't affect behaviour.
The wait in the main function has no purpose, remove it. 🙂
A good skeleton!
/Y
06-13-2013 12:34 AM
Thank you for your reply Mr.yamaeda
I am using Labjack U12 to control stepper motor not DAQmx. If i suppose to run a two stepper motor alone means one slave is enough. but my task is to run two stepper motor simultaenously(whenever user want to run one motor, while another motor is running condition)so that why i preferred two slaves.
i would like make boolean button retain into off state after press it so i am using switch untill relesed. if i am using value change event, two times event happen such as on state and off state that why i preferred mouse down event change.
is it correct to use event structure in master loop ? In general producer/consumer architecture only use event structure than other architecture
06-13-2013 03:58 AM
I've never used Labjack, so cant say much about it, but if it's similar to DAQmx you could start a task which starts the motor and you dont need to wait or monitor it, thus only 1 consumer would be needed. It might not apply here. 🙂
Yes, a Values change event fires on both activation and deactivation if you have Switch when pressed. It can easily be filtered by placing the command in a case structure.
The general producer/consumer uses an event structure as main as it's supposed to handle UI actions and similar events, just like yours. There's also an event driver producer/consumer template which sends event to the consumers. If your notifiers are problematic (they shouldn't be) it could be a solution.
/Y
06-13-2013 04:11 AM
Thank you yamaeda