04-01-2013 11:45 AM
Hello all,
I am trying to create presets for my VI and I would like some input from others who've created methods for presets. I saw this post and saw that it was possible to create a pre defined preset fairly easily. That's good an all, but I need to update my presets on the fly. Basically, I want to move four servos to a certain position via pulsewidth. However, there will be many different positions (~20) I need them to be at, and trying to stop the code and put in constants seems like it will be extremely time consuming for each preset. I would like to create a preset method which would take the servo location and store it somewhere so I can load it again later.
One idea I had was to create a txt file and store the pulsewidth of each servo. This way I could overwrite the file and read the file at any time.
I have been looking into event structures, but that seems like it will go with the idea of making pre made presets.
Any help would be gladly appreciated.
Thanks,
Matt
Solved! Go to Solution.
04-01-2013 11:54 AM
If you merely have 20 positions, which will never change, you can use an Enum control wired to a case structure (all of this in a while loop). If the Enum control value changes, select the case structure which contains the correct pulswidth values.
If your positions could change overtime, an external file would be a good way to go. Look at Configuration Files. You can write one section for each position. In each section, you will store the 4 pulsewidth values you need.
04-01-2013 01:08 PM
once you have all your preset defined on the front panel goto>edit>make current values default>Cntrl S(save) or on the BD you could use control pallette's vi server reference connected to involk node, default values, reinitialize all default
04-01-2013 02:17 PM
Im going with PJR1121's comment on Configuration files. Main reason (which I now realize I forgot to mention in the OP >.<) is that I'm not going to be the end user. I want others to be able to modify the presets in a way which won't break my code.
Thanks for your replies!
Matt