LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shiftregister

I am on a project reading a spectrometer and driving simultaneously a stepper motor.
I like to divide the program into the steps "Init Spec", "Read Spec", "Move Motor", "End".
The first part is called only once, the end part also.
From "Move Motor" the program should go back to "Read Spec" till the last position has
been reached.
For this i initialized a shiftregister of a while loop with an enum control element containing
the fields "Init Spec" .... "End" as above, but set on "Init Spec".
Inside the while loop i have a case structure which executes the program part related to
the selection of the enum field passed by the shift register.
Inside the different program parts i can switch the shift register, which represents the enum
to another value, so that i can for example go from "Move Motor" back to "Read Spec".
This works perfectly until i want to insert a new field into the enum. Than all enum constants
in the while loop contain only the old enum fields and the case identifiers of the case structure
don't display the enum constants anymore but only the numbers. This means, that i don't know
which case belongs to which enum field anymore.
 
 
Here is the description how to build up the vi:
 
1.) Setting up enum input element with fields "Init", "Read", "Move", "End"
2.) Select "Init" with the hand tool
2.5) Create While loop, create shift register
3.) Connect enum with outer side of shift register of the while loop
     (Means that the integer corresponding to "Init" is passed into the while loop)
4.) Insert Case structure into while loop
5.) Connect the inner side of the shift register with the selector of the case structure (The identifiers of all avaiable cases of
     the case structure should change to the names of the enum fields.
6.) Create block diagram for all fields of the enum and so for all cases of the case structure so that each case sets
     the shift register to the index of the next case via an enum constant.
 
For an example what i mean above, that the identifiers get lost:
Add a new field to the enum. You see, that none of the constants inside the while loop will change also.
This is a pity, because they belong to the initializing enum and should all contain the same fields!
After that, the block diagram wil be messed up, because the routing via the enum constants does not work anymore.
 
Sneff
 


Message Edited by Sneff on 07-29-2008 09:41 AM
0 Kudos
Message 1 of 2
(2,439 Views)
You need to set the control as a type definition. This way, all instances of the object will have matching datatypes.

If you right click one of the enums, goto advanced -> customise, then at the top change control to type def and save teh new control. Now replace each copied instance with a copy of the new typedef.

Now when you add a new item to the enum, goto its type definition and do it there as you normally would. Another nifty use of typedef enums, is if you right click on the case structure, you can now select "add case for every value" which does what it says on the tin 😛

p.s. You can attach labview files to posts along with various other file types that most other forums disallow


Message Edited by yenknip on 07-29-2008 04:07 PM
_____________________________
- Cheers, Ed
0 Kudos
Message 2 of 2
(2,422 Views)