yumin-chen/skittle-color-sorter

Proble during calibration

wanaideed opened this issue · 9 comments

Always display - 'Top servo is stuck; Direction reversed' during calibration.
Please help me.

Hi,

The top servo would automatically reverse direction when enough time has passed and no objects are ever detected by the color sensor.

Please check this line:
https://github.com/CharmySoft/skittle-color-sorter/blob/master/TopServo.cpp#L15

You can disable this feature by either changing the F_TOP_SERVO_TIMEOUT_ENABLED flag to false, or increasing C_TOP_SERVO_TIMEOUT to a larger number if your top servo is too slow.

But another very probable cause to this issue is either your color sensor is not functioning correctly, or there is nothing on your top wheel to be detected. Please note in my prototype a chamber is carved out on the top wheel to transit Skittles, and the chamber would have a distinctly lower clear value when measured by the color sensor.

You should have a chamber (a hole) carved out on the top wheel. If you watch the demo video, you'll notice the sensor is on the right side of the top white spinning wheel. And inside the white wheel, a chamber is carved out so each time one skittle can get in there. Try changing this value if you do have a chamber carved out but still unable to be detected.
https://github.com/CharmySoft/skittle-color-sorter/blob/master/ColorSensor.cpp#L19

Hi Mr.Chen,
I've tried your instructions and advice from above and the code would not get pass "top servo stuck" my color sensor is working fine

Have you tried set the TOP_SERVO_TIMEOUT flag to false? You shouldn't be getting that "top servo stuck" once you disable that top servo timeout flag.

Yes I disabled that and the top servo did not move, Is there a way to increase the distance it senses in the hole? apparently we do not get any reading from serial monitor until we take the sensor out and put the skittles closer to it.

I'm afraid you'd have to think of a way to physically move your color sensor closer to the chamber. There's no way you can programmatically increase the distance your color sensor can pick up.

You have a macro named C_HOLE_CLEAR in ColorSesnor.cpp what does this set? I am having trouble calibrating the colors

The C_HOLE_CLEAR defines the threshold value of the clear channel to determine whether the chamber is empty. When your color sensor measures the color, if the clear value of the result is above the C_HOLE_CLEAR, it'll think this is not a skittle, and keep moving on. When it's below the C_HOLE_CLEAR, it'll think it's a skittle and start measuring its details.

Hi Chen I've been doing the calibration and after the calibration line you have " /* Don't forget to exclude these invalid colors in the HAS_COLOR macro function */. I have checked all the files and I have no find the HAS_COLOR macro. what does it do also?

I originally named that macro "HAS_COLOR" but then changed it to "HAS_RESULT". It is a macro function to check if the result is a valid color. The colors we defined include positive ones that are Skittle's colors, and also negative ones that are from the empty chamber. So when the empty chamber crosses the color sensor. It should go lower the C_HOLE_CLEAR and get detected, but it shouldn't be seen as a valid result since it's not a Skittle.