Marble Sorter help

Hi,
We are sophomores and we are working on our marble sorter project. Our group has very little knowledge on robotc and programming in general and we would like some help. Our sorter has 2 servo 393 motors, a light sensor, a custom 3d printed object, string etc. We are trying to make the light sensor detect the type of marble(glass, wood, and metal) so they can be sorted. We would like the lever to go down to that certain metal piece(3 bars) to make the marble roll down into a certain cup(haven’t really decided)How do we achieve this? Thanks again.

Here are some pictures:
image1.JPG
image2.JPG
image3.JPG

The big challenges of the marble sorter are:

  1. Detecting the kind of marble. You can do this independently by the light sensor and seeing what the values are for each kind of marble. Do you have other sensors too like the line follower to use as a second type? (You may want your sensor closer tot he marble so background light is not interfering) Get a good handle on what ranges each marble type gives you. Then turn your apparatus so the background light changes and see if it still holds true. Use the debugger for this to see the values real time.

  2. Processing one marble at a time. Making sure you only do one marble at a time is key as you don’t want the same decision applied to many marbles of different types. I’ve seen the black intake rollers used with success here. Not sure what is on your white disk to do one marble only.

http://www.vexrobotics.com/media/catalog/product/cache/11/image/296x/5e06319eda06f020e43594a9c230972d/i/n/intake-roller_1.jpg

  1. Sending them the right way once you know what marble it is. Looks like you have the structure. But you need some measurement device to know which section the feeder is pointing to. Make sure you give enough time for the motor to move the arm before releasing the marble too. Is your rubric more on speed or accuracy?

Use a potentiometer or an IME for determining arm position. The pot has many more advantages over the IME.
Pot:
http://www.vexrobotics.com/media/catalog/product/cache/11/small_image/135x135/5e06319eda06f020e43594a9c230972d/p/o/potentiometer-a_2.jpg

IME:
http://www.vexrobotics.com/media/catalog/product/cache/11/image/296x/5e06319eda06f020e43594a9c230972d/2/7/276-1321-motor-393-encoder-module-a_1.jpg

Thank you very much for the response. We will try out the potentiometers. The white disc has small hole in which the marble will be dropped into and it will rotate. The hard part for us is the actual coding

The potentiometer only goes 270 degrees so don’t rotate it all the way around or it will break. Put it on the back side of the arm joint but you need some space to attach it. Some metal or 1/2" standoffs to stabilize the pot to the axle and the base. The shaft moves, the pot stays grounded to the frame. Otherwise it does not change values.

To program the potentiometer, look for ranges of acceptable values to be in for the arm position, then drop the marble on to the track once you know the arm is in the right place. Knowing which way to send the arm is an error calculation of “how far am I away from where I want to be” of
SensorValue[my_potentiometer] - target_location_value

Then apply power based upon the distance away (and multiply by a limiting factor like 0.10 to slow the motor down a ton, you have about 7.6 pot values per degree of movement)

Thanks anymore tips I can get for the programming?

Get it started first and the community can always help…

Look in the sample robot C programs to look for how to use the potentiometer and other sensors.

https://vexforum.com/t/my-overengineered-marble-sorter/29647/1

If you want something more accurate than a rubber roller so you can more accurately release one ball, you could make a mechanism like the one I drew in this crappy paint diagram.
crappy paint diagram.png

We added a shaft encoder instead of the potentiometer because our teacher said it would work well. We’re having a lot of trouble with the coding. A lot of the coding has come from other classmates but we think it isn’t helping at all.

startMotor(port1,127);
SensorValue[dgtl1] = 0; //resets encoder count
setServo(port1, 10);
setServo(port1, 20);
untilTouch(dgtl3); //waits to start until button is pressed

while (1==1) //loop program infinitely
{
wait1Msec(500);
setServo(port7, 5); //gate 1 opens to allow a marble to enter the sensor chamber
wait1Msec(200);
setServo(port7, 20); //close gate 1
wait1Msec(1000);

if(SensorValue(in1)>350) //if the marble is
{
setServo(port6, 30); //open gate 2
wait1Msec(200);
setServo(port6, 10); //close gate 2
} //end color one sort

else
{
if(SensorValue(in1)>88)	//if the marble is <wood>
{
    startMotor(port1, 30);	//rotate the bins
    untilEncoderCounts(85, dgtl1);	//until position 2
    stopMotor(port1);	//stop motor
    startMotor(port1, -30);
    wait1Msec(80);
    stopMotor(port1);
    wait1Msec(500);

setServo(port6, 30); //open gate 2
wait1Msec(200);
setServo(port6, 10); //close gate 2
wait1Msec(200);
startMotor(port1, -30); //rotate the bins
untilEncoderCounts(-85, dgtl1); //until position 2
stopMotor(port1); //stop motor
startMotor(port1, 30);
wait1Msec(80);
stopMotor(port1);
} //end color two sort

else //if the marble is
{
startMotor(port1, 30); //rotate the bins
untilEncoderCounts(175, dgtl1); //until position 3
stopMotor(port1); //stop motor
startMotor(port1, -30);
wait1Msec(80);
stopMotor(port1);
wait1Msec(500);
setServo(port6, 30); //open gate 2
wait1Msec(200);
setServo(port6, 10); //close gate 2
wait1Msec(200);
startMotor(port1, -30); //rotate the bins
untilEncoderCounts(-175, dgtl1); //until position 2
stopMotor(port1); //stop motor
startMotor(port1, 30);
wait1Msec(80);
stopMotor(port1);
} //end color 3 sort
}
}

Any help we can get?

Is this the infamous POE Marble Sorter project? :stuck_out_tongue:

Focusing on the actual problem, it’s a little hard to read the code given that it’s in natural language PLTW and not written using the “code” tags that format it correctly.

As a basic programming technique, I would recommend creating separate functions for the repeated blocks of your code, since this will make it both easier to read and easier to edit if you need to add more functionality. As for specific problems:

  • I noticed that in the first few lines, you seem to be using the motor on Port1 as both a normal 393 and as a servo. If Port1 is the 393 with IME, then the lines using setServo() won’t work; if it’s actually a servo, then the lines using startMotor() won’t work.
  • Second problem (which I think is probably the cause of the bug), you are attempting to set a negative encoder target. While it seems to make sense to do “untilEncoderCounts(-175, dgtl1)” to move backwards, for some reason, the Natural Language doesn’t like that and only returns positive values. My guess is that because of this, the motor keeps spinning forever/not at all, which is why you’re experiencing problems

Try those fixes and see what happens, then let us know if there might be some other problems in the code.

One idea that I’ve seen a number of people use is sorting certain marbles based on weight. It’s pretty easy to create a mechanism that sorts out the metal marbles from the rest so you only have to use sensors for the other two. I personally don’t think that this is the most efficient method in terms of time but if your having trouble coding it might be worth looking into. I even saw a group that sorted all the marbles without using any senors.

Absolutely, as long as you have an indexing mechanism, you can physically separate by:

  • size: two rails spaced out so smaller marbles fall through while larger ones roll along
  • weight: lever that will tip down if the marble is heavy enough, rolling it the opposite direction
  • magnetivity (might be the wrong word :P): vertical drop with lots of magnets on one side, metal balls get deflected and won’t go down straight
  • bounce (this one’s a little iffy): Vertical drop followed by incline with 2 “channels” stacked on top, little/no bounce balls will roll through the bottom channel after the drop, but bouncy balls will roll along the top channel

There’s probably more methods of sorting too, but yeah if you can sort physically, then often you can eliminate complexity in the programming, especially if that’s a weak point for your team.

That being said, don’t try to build a super huge machine that uses only physical methods unless you’re sure it’s the best way, because I think the optimal design is a mix of both physical and sensor-based sorting.