01-26-2021 10:23 PM
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
The program for my color detection are as such:
Front panel:
Solved! Go to Solution.
01-26-2021 10:32 PM
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!)
01-27-2021 12:10 AM - edited 01-27-2021 12:12 AM
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.
01-27-2021 07:50 AM
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.
01-27-2021 09:40 AM
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.
01-27-2021 09:58 AM
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