LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Servo motor signal debouncing?

Solved!
Go to solution

I'm a student doing a project for my studies, I'm trying to control a servo motor to sort items based on their colors. I've written a program so that if the toggle switch is on (the colored LEDs) and the desired color is detected the servo swings and stays until the color is no longer detected on the camera. I tried using select and switch case. both yield the same error.

 

when I hover color over the camera, the color indicator(small green LEDs) stays lit however the servo motor flickers back and forth. I did testing on the part for the servo motor itself by giving a straight boolean signal from a toggle switch, I was able to fully control the servo motor.

 

I suspect that the flickering of the servo motor would be due to an inconsistent signal from the color detection part of the program. Any help would be greatly appreciated!

Thanks

Derrick2407_0-1611720980000.png

The program for my color detection are as such:

Derrick2407_1-1611721092972.png

Front panel:

Derrick2407_2-1611721171370.png

 

0 Kudos
Message 1 of 6
(560 Views)

Can you attach your VI?

 

Can you do a block diagram cleanup before taking a picture of it?  That 2nd image has more backwards running wires than forwards.  It is hard to know what connects to what.

 

You have 3 Express VI's marked red, green, blue for duty cycle.  What do each of those do?  (If we had a VI, we could open up those Express VI's and look at their settings!)

0 Kudos
Message 2 of 6
(557 Views)

Derrick2407_1-1611727437094.png

the program is in the color detection servo control vi. thank you!

the 3 express vi are for the PWM frequency is set at 50Hz and the duty cycle is selected through the select function.

0 Kudos
Message 3 of 6
(531 Views)

Thank you for attaching your code.

 

Unfortunately I see it is based on the MyRIO which I don't have as an installed module or drivers.  So I can't see what is going on with those Express VI's.

 

Can you answer the question I asked about them?  What does each of them do?  You have 3 of them labelled Red, Blue, Green taking either a .06 or .025 value.  My understanding is they control a servo motor.  Are they all controlling the same servo motor? 

 

If so, I think you'd have a conflict when one blue box gets one value, and the other two blue boxes get the other value.  If they all go to the same output, the program is going to bounce that servo motor rapidly between the different values.

0 Kudos
Message 4 of 6
(500 Views)

It is to set the state of the servo motor extended out and not. and they control the same servo motor and ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh i think I get what you mean. since my other signals are giving 0 while one of it is giving it 1 that's why its flickering between on and off is that why? if so that's a very rookie mistake I'm sorry for wasitng your time XD.

 

but is there any way for me to prioritize the 1 signals?

 

Thanks.

0 Kudos
Message 5 of 6
(494 Views)
Solution
Accepted by topic author Derrick2407

Yes.  That is what I was thinking.

 

Get yourself down to a single PWM Express VI.  Use logic before that to determine whether you should send a .06 or .025.

I don't know what is the signficance of red vs. green vs. blue in your case.  Should you send a .06 if ANY of the those values are true?  If so use an OR function on booleans.

 

If there is an order that matters (right now they all put out .06 if true), you could nest case structure so if behaves like an If, elseif, else, endif   if this was a text based language

Message 6 of 6
(491 Views)