yumin-chen/skittle-color-sorter

Top Servo Stuck Error

isomorphic85 opened this issue · 4 comments

Hello,

i'm getting a top servo stuck error in the serial monitor and showing on the lcd display. It just keeps rotating the top servo and then reversing ....

I can't seem to figure out how to prevent this from happening.

I've tried setting both #define F_CALIBRATING to true as well as #define F_CALI_EMPTY_HOLE to true.

However it just constantly runs and reverses while showing top servo stuck

Any thoughts?

thanks for your time it is greatly appreciated.

The top servo stuck detection can be disabled by changing the F_TOP_SERVO_TIMEOUT_ENABLED flag to false. Please see TopServo.cpp

This can be a workaround for the problem you're facing right now. You can enable this after you finish the calibration and see if the problem persists.

This problem is likely caused by the hardware differences. Because you might have a different color chamber on the top servo that transports the Skittles, it will likely to affect the results the color sensor reports.

You can see the default C_HOLE_CLEAR is configured as 300 here on the Color Sensor. And if your chamber (the hole that transports Skittles) is a different color this might need to get configured to a different value.

It is hard for this to work on every single hardware straight out of the box because they vary quite a lot, so I left a lot of the attributes configurable for you to make it work for your specific device.

Here's the line where the color sensor detects if there's anything passing by. You can try and print out the c value before this line and decide a best C_HOLE_CLEAR value for your own device.

Let me know if this helped!

Thank you again for your help on this.. I've disabled the servo timeout flag to be set as false. This did stop the stuck detection and reversing. I see in your code how the C_HOLE_CLEAR is set as 300. I'm not sure how to print out the c value before the line you have highlighted though in order to determine what my best C_HOLE_CLEAR value is ?

Also with the physical device I have built my color sensor is on the opposing side from the way you have your's setup... is there any easy way for me to change what is considered the forward and reverse direction of the top servo? Currently in the forward "normal "direction it's rotating the drum clockwise when looking it at which never passes the skittle in front of the color sensor.

(edit* I believe I changed this without affecting anything negatively...

i changed the following line to read true instead of false:

void TopServo::update()
{
boolean dirction = true; // Set direction to forwards

Thank you for your time it's appreciated!

You can change the c value by adding the following line before the if branch.

Serial.print("c value is: "); Serial.println(c);

This will print the value to the serial.

To change the direction, change the following line on TopServo.cpp

from

this->write(dirction ? 180 : 0);

to

this->write(dirction ? 0 : 180);

If you're using the same continuous rotation servo, 0 is full-speed in one direction, whereas 180 is full speed in the other, and a value near 90 being no movement.

If you have any further question, you're more than welcome to ask here but please open a new issue each time with a concise and distinct title so that other users encountering the same issue will be able to find the answers easily. Thanks :)