LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure Based on Changing Input Controls

Hello. I am trying to create a control VI for a quad-copter. Right now I've managed to build a basic program that gets input from some sliders and transforms and sends it to the quad-copter motors through I2C and virtual serial port.

 

The problem that I'm having is that I want to be able to control the engines either individually or in pairs, so I can achieve motion in all directions. But since I can't have multiple inputs at the same time for each engine, I think I might need a case structure. What I would like to do is have a scenario where depending on whether an input changes and how (either for an individual motor or a group), the case structure switches to that case and takes the inputs specified for that particular case. What I'm thinking is having 10 or so sliders, 1 for each engine, and then 1 each for groups like 1 & 2, 3 & 4 and 1 for all, and depending on whether they change and how, switch to the case where only those particular engines change speed.

 

Can you please help me out with that? Thank you. 

0 Kudos
Message 1 of 14
(3,614 Views)

Hi CN,

 

see attachment for a simple case structure approach using 4 slides and 4 outputs...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 14
(3,594 Views)

Hi GerdW,

 

Thanks for the reply. Your solution is good, but I want it to have a slider for each individual motor and also for each group of motors, and when one of them changes, for the case structure to be selected appropriately so it sends the same output to only one motor or more. 

 

Basically, what I want to do as a final step is to integrate the Kinect Development Kit into the program and control the quad-copter using a manipulation of the coordinates of a selected joint or skeleton point. This bit with the sliders is sort-of an intermediate point for me to see if I can reliably do this motor grouping control.

 

Constantin

0 Kudos
Message 3 of 14
(3,575 Views)

I want it to determine on its own which case it is, 'cause me having to select it is not good. I was thinking about using some shift registers in a loop to determine whether there's a change from one iteriation to the other in each slider and if there is, then switch to the case that involves that one. How does that sound?

0 Kudos
Message 4 of 14
(3,571 Views)

Hi CN,

 

it sounds good. All you have to do is to define the logic needed and then program it 🙂

 

You're on the right track when you mention shift registers!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 14
(3,564 Views)

Cool. I'll have a go and see what happens. Thanks a lot again. 

0 Kudos
Message 6 of 14
(3,561 Views)

If you are just looking for when the values change you can use the event structure with a value change event for each control.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 14
(3,555 Views)

I've managed to do it, just the way I want. What do you guys think. Is there a more elegant way of achieving this?

 

@Mark: I'm not too familiar with the event structure. 

0 Kudos
Message 8 of 14
(3,542 Views)

That is one way to accomplish it. I would probably use the event structure. It is not that difficult to use. It is very similar to the case structure.

 

I would also caution you on comparing two floating point numbers. Due to rounding it is possible that you will subtract two values which are essentially equal but return a non-zero result. You should use the "In Range" VI and set some tolerance value which indicates the numbers are equal.

 

One last item, do you want your shift registers to be unitialized? If they are unitialized they will retain the values from the last execution of this VI. You may not want that since I assume you would want your motors to be off in the initial state.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 14
(3,539 Views)

Alright, so this is the final version that I'm going to test tomorrow in the lab, see if it actually works. I know it's not too elegant, but for now it does the job, I think. 

0 Kudos
Message 10 of 14
(3,528 Views)