View unanswered posts | View active topics It is currently Tue Oct 23, 2018 5:53 am






Reply to topic  [ 1 post ] 
POE Marble Sorter Code is not working 
Author Message
Rookie

Joined: Wed Feb 10, 2016 8:29 pm
Posts: 1
Post POE Marble Sorter Code is not working
Hey guys, I'm having a problem with my code for my POE marble sorter. It runs but after I press my bump switch the motor with an encoder on it only moves in one direction and the servo to feed the marbles into the cups goes back and forth.

When I hit the button, it runs, but it starts my hopper motor and only moves one direction, meanwhile the servo keeps moving to 0 and -63.

I noticed that the quadrature encoder I have on the hopper motor so I can figure out where it is, resets to 0 every time it turns and drops a marble. So it keeps going in one direction randomly.

Thanks for any kind of help. Much appreciated.

Also, every time I compile and download to robot, an error comes up
Code:
***Error: Exception in Message sent from PC by ROBOTC IDE***:
Exception Type: 'System parm read out of range(19)'
Source: opcode message <SystemFunction> (0x67)
Exception Details: averageBatteryLevel(36)


Code:
#pragma config(Sensor, in1,    lightSensor,    sensorReflection)
#pragma config(Sensor, dgtl1,  startButton,    sensorTouch)
#pragma config(Sensor, dgtl2,  hopperEncoder,  sensorQuadEncoder)
#pragma config(Motor,  port2,           flashLight,    tmotorVexFlashlight, openLoop, reversed)
#pragma config(Motor,  port3,           feedMotor,     tmotorVex269_MC29, openLoop)
#pragma config(Motor,  port4,           hopperMotor,   tmotorVex269_MC29, openLoop)
#pragma config(Motor,  port5,           servoMotor,    tmotorServoStandard, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
startMotor(flashLight, 127);
SensorValue(hopperEncoder) = 0;
setServo(servoMotor, -63);
untilTouch(startButton);

while(true)
   {
   startMotor(feedMotor, 30);
   if (SensorValue(lightSensor) <= 40 && SensorValue(lightSensor) => 30) //PLASTIC
      {
      wait1Msec(500);
      setServo(servoMotor, 0);
      wait1Msec(200);
      setServo(servoMotor, -63);
      }
   else
      {
      wait(2);
      if (SensorValue(lightSensor) <= 360 && SensorValue(lightSensor) => 340) //BLUE
         {
         startMotor(hopperMotor, 30);
         untilEncoderCounts(-86, hopperEncoder);
         stopMotor(hopperMotor);

         wait1Msec(500);
         setServo(servoMotor, 0[code][/code]);
         wait1Msec(200);
         setServo(servoMotor, -63);

         startMotor(hopperMotor, -30);
         untilEncoderCounts(0, hopperEncoder);
         stopMotor(hopperMotor);
         }
      else
         {
         if (SensorValue(lightSensor) <= 700 && SensorValue(lightSensor) => 650) //AL
         {
         startMotor(hopperMotor, 30);
         untilEncoderCounts(-271, hopperEncoder);
         stopMotor(hopperMotor);

         wait1Msec(500);
         setServo(servoMotor, 0);
         wait1Msec(200);
         setServo(servoMotor, -63);

         startMotor(hopperMotor, -30);
         untilEncoderCounts(0, hopperEncoder);
         stopMotor(hopperMotor);
         }
         else (SensorValue(lightSensor) <= 940 && SensorValue(lightSensor) => 920 ); //WOOD
            {
            startMotor(hopperMotor, 30);
            untilEncoderCounts(-175, hopperEncoder);
            stopMotor(hopperMotor);

            wait1Msec(500);
            setServo(servoMotor, 0);
            wait1Msec(200);
            setServo(servoMotor, -63);

            startMotor(hopperMotor, -30);
            untilEncoderCounts(0, hopperEncoder);
            stopMotor(hopperMotor);
            } //last else
         } // ends 2nd last else
      } // ends first else
   } //ends while loop
} // ends whole program


Wed Feb 10, 2016 8:37 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.