View unanswered posts | View active topics It is currently Fri May 24, 2019 3:41 pm






Reply to topic  [ 9 posts ] 
Encoders not clearing in Curriculum Companion and OR 
Author Message
Rookie

Joined: Thu Sep 11, 2014 4:47 pm
Posts: 9
Post Encoders not clearing in Curriculum Companion and OR
We are having issues getting the encoders to clear in both the curriculum companion and Operation Reset. We figured out how to get them to work by checking our motors and sensor setup. Opened up the Back Road Insertion Point code, downloaded, the robot will travel forward until the encoders get to the 2520. We can see this in the sensors window so we know the encoders work. However, at that point, nothing happens. It is supposed to turn left until the rightEncoder is no longer < 60. When I change the 60 to a number higher than 2520, the code will run letting me know that the SensorValue[rightEncoder] = 0; is not working. Suggestions?


Thu Sep 11, 2014 5:08 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Jun 11, 2014 9:59 am
Posts: 115
Post Re: Encoders not clearing in Curriculum Companion and OR
lordvader5,

I am sorry that you are having this issue.
One thing to try is using this command below to get the encoder value.
Code:
nMotorEncoder[leftMotor]  nMotorEncoder[rightMotor]


If this does not work, make sure that your robot configuration is exactly the same as the configuration on the Robot preview screen in the virtual world that you are trying to use.

If these are not the correct solutions, I will need a little more information about the problem. Can you please let me know what the version of ROBOTC and Operation Reset you are using, as well as the robot and platform type? Also, If you are using any other code than Back Road Insertion Point, please copy and paste it in the forum (please include the pragmas).

Thanks, Lee


Fri Sep 12, 2014 9:35 am
Profile
Rookie

Joined: Thu Sep 11, 2014 4:47 pm
Posts: 9
Post Re: Encoders not clearing in Curriculum Companion and OR
Here is the code we are trying. You will see the second while statement with 3000 instead of 60 for the encoder. We found that since the encoders won't clear we can get the robot to keep going with a value higher than 2520. This is the code straight from the sample programs other than the 3000 change. I've also changed the right and left encoders in the motors and sensors setup along with the motor to the 269 motor. We are using 4.10 because 4.25 and 4.26 are both crashing on us. So I uninstalled those and put 4.10 back in. I just downloaded the latest version of Operation Reset yesterday hoping that was the problem. Still a no go.

On the plus side, my students are loving the challenge and some of them are in a race to figure out the problem first.

#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1, lineFollower, sensorLineFollower)
#pragma config(Sensor, dgtl5, compassSensor, sensorVirtualCompass)
#pragma config(Sensor, dgtl6, touchSensor, sensorTouch)
#pragma config(Sensor, dgtl8, sonarSensor, sensorSONAR_cm)
#pragma config(Sensor, I2C_1, rightEncoder, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_2, leftEncoder, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port1, gripperMotor, tmotorVex269_HBridge, openLoop)
#pragma config(Motor, port2, rightMotor, tmotorVex269_MC29, openLoop)
#pragma config(Motor, port3, leftMotor, tmotorVex269_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++++
Sector 3 - Back Road Insertion Point (Standard ROBOTC)
- This program will cause the robot to drive forward from Sector 1 into Sector 3, and turn toward
the Charge Cube in that area.
- It will be up to you to add the ROBOTC code that causes the robot to pick up the Charge Cube
and take it to the Communication Tower pad.
- Remember that you can press the "Reset" button in the lower-left corner of the Operation Reset
window to return to the Insertion Point every time you modify your ROBOTC code.
* Please note that the values in this program were written for Mammalbot using a high-end computer.
You may need to adjust the values in this program for your computer.

Robot Model: Mammalbot

[I/O Port] [Name] [Type] [Description]
Motor Port 2 rightMotor Motor Right side motor
Motor Port 3 leftMotor Motor Left side motor
Digital Port 1 rightEncoder Encoder Right side motor
Digital Port 3 leftEncoder Encoder Left side motor
----------------------------------------------------------------------------------------------------*/

//Every program has a task main(). All commands that the robot follows go between the curly braces.
task main()
{ //The program begins.
wait1Msec(2000); //The robot will wait for 2 seconds before executing commands.

//Reset the encoders to 0.
//SensorValue[rightEncoder] = 0;
//SensorValue[leftEncoder] = 0;

while(SensorValue[rightEncoder] < 2520) //while less than 2520 counts of the right encoder have passed...
{
//...move forward.
motor[rightMotor] = 63;
motor[leftMotor] = 63;
}

//Stop
//motor[rightMotor] = 0;
//motor[leftMotor] = 0;



SensorValue[rightEncoder] = 0;
SensorValue[leftEncoder] = 0;

while(SensorValue[rightEncoder] < 3000) //while less than 60 counts of the right encoder have passed...
{
//...turn left.
motor[rightMotor] = 63;
motor[leftMotor] = -63;
}

//Stop
motor[rightMotor] = 0;
motor[leftMotor] = 0;


//Enter the code for the robot to drive forward to the charge cube here:


//Enter the code for the robot to turn right toward the Communication Tower here:


//Enter the code for the robot to drive forward to the Communication Tower pad here:


} //The program ends.


Fri Sep 12, 2014 10:42 am
Profile
Rookie

Joined: Thu Sep 11, 2014 4:47 pm
Posts: 9
Post Re: Encoders not clearing in Curriculum Companion and OR
One thing I have not tried is making sure EVERY SINGLE sensor is matching in RVW. But I would think that would not matter. Does it?


Fri Sep 12, 2014 10:43 am
Profile
Rookie

Joined: Thu Sep 11, 2014 4:47 pm
Posts: 9
Post Re: Encoders not clearing in Curriculum Companion and OR
Oh, we are also using the MammalBot.


Fri Sep 12, 2014 10:53 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Jun 11, 2014 9:59 am
Posts: 115
Post Re: Encoders not clearing in Curriculum Companion and OR
Lord,

In your motors and sensors setup please configure the encoder ports to I2C_1 for the right motor and I2C_2 for the left motor, and select PID Control.

Image

This will set up your encoder ports. As far as your code goes, you will need to replace SensorValue[rightEncoder] with nMotorEncoder[rightMotor]. Also be on the look out for if the encoder increments or decrements. For the Mammal bot, the right encoder decrements.

So say for example you wanted to do something for one rotation, your condition would be:

Code:
nMotorEncoder[rightMotor] = 0;
while(nMotorEncoder[rightMotor] >= -240.448)  //240.448 = 1 revolution for vex 269 Integrated Encoders
{
//do something
}


Please let me know if this solves your problem

Thanks, Lee


Fri Sep 12, 2014 12:43 pm
Profile
Rookie

Joined: Thu Sep 11, 2014 4:47 pm
Posts: 9
Post Re: Encoders not clearing in Curriculum Companion and OR
Ok. So one of my students made it work! But we are confused. In the debuggers window the encoder count for both motors in counting up from 0 to 2000. But here is the code that works. Why does it stop when it gets to 2000? We are under the assumption that since the encoder count is starting at 0, then the while statement is TRUE that the encodercount is >= -2000. Therefore, the code should not run.

//Reset the encoders to 0.
nMotorEncoder[rightMotor] = 0;
nMotorEncoder[leftMotor] = 0;

while(nMotorEncoder[leftMotor] >= -2000) //while less than 2520 counts of the right encoder have passed...
{
//...move forward.
motor[rightMotor] = 63;
motor[leftMotor] = 63;
}

//Stop
motor[rightMotor] = 0;
motor[leftMotor] = 0;

//Reset the encoders to 0.
nMotorEncoder[rightMotor] = 0;
nMotorEncoder[leftMotor] = 0;

while(nMotorEncoder[rightMotor] >= -60) //while less than 60 counts of the right encoder have passed...
{
//...turn left.
motor[rightMotor] = 63;
motor[leftMotor] = -63;
}

//Stop
motor[rightMotor] = 0;
motor[leftMotor] = 0;


Fri Sep 12, 2014 1:57 pm
Profile
Rookie

Joined: Thu Sep 11, 2014 4:47 pm
Posts: 9
Post Re: Encoders not clearing in Curriculum Companion and OR
So I played around more with the code and am finding this....

1. The encoders are still not resetting to ZERO. They work and the Mammalbot will move based on my calculations. However, when you open the debuggers window and watch the encoder count, the numbers never reset until the entire program is done.

2. Both encoders in the debuggers window count up from zero, but in the code we are having to use >= a negative number. Do the 269 Motor Encoders always count down?

Here is the code I am playing around with. In some places I have the encoders clearing and in other places I don't to see if there is any change.

#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1, lineFollower, sensorLineFollower)
#pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, leftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl5, compassSensor, sensorVirtualCompass)
#pragma config(Sensor, dgtl6, touchSensor, sensorTouch)
#pragma config(Sensor, dgtl8, sonarSensor, sensorSONAR_cm)
#pragma config(Sensor, I2C_1, rightEncoder, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_2, leftEncoder, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port1, gripperMotor, tmotorVex269_HBridge, openLoop)
#pragma config(Motor, port2, rightMotor, tmotorVex269_MC29, PIDControl, encoderPort, I2C_1)
#pragma config(Motor, port3, leftMotor, tmotorVex269_MC29, PIDControl, encoderPort, I2C_2)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++++
Sector 3 - Back Road Insertion Point (Standard ROBOTC)
- This program will cause the robot to drive forward from Sector 1 into Sector 3, and turn toward
the Charge Cube in that area.
- It will be up to you to add the ROBOTC code that causes the robot to pick up the Charge Cube
and take it to the Communication Tower pad.
- Remember that you can press the "Reset" button in the lower-left corner of the Operation Reset
window to return to the Insertion Point every time you modify your ROBOTC code.
* Please note that the values in this program were written for Mammalbot using a high-end computer.
You may need to adjust the values in this program for your computer.

Robot Model: Mammalbot

[I/O Port] [Name] [Type] [Description]
Motor Port 2 rightMotor Motor Right side motor
Motor Port 3 leftMotor Motor Left side motor
Digital Port 1 rightEncoder Encoder Right side motor
Digital Port 3 leftEncoder Encoder Left side motor
----------------------------------------------------------------------------------------------------*/

//Every program has a task main(). All commands that the robot follows go between the curly braces.
task main()
{ //The program begins.
wait1Msec(2000); //The robot will wait for 2 seconds before executing commands.

//Reset the encoders to 0.
nMotorEncoder[rightMotor] = 0;
nMotorEncoder[leftMotor] = 0;

while(nMotorEncoder[leftMotor] >= -2000) //while less than 2520 counts of the right encoder have passed...
{
//...move forward.
motor[rightMotor] = 63;
motor[leftMotor] = 63;
}

//Stop
motor[rightMotor] = 0;
motor[leftMotor] = 0;

//Reset the encoders to 0.
nMotorEncoder[rightMotor] = 0;
nMotorEncoder[leftMotor] = 0;

while(nMotorEncoder[rightMotor] >= -60) //while less than 60 counts of the right encoder have passed...
{
//...turn left.
motor[rightMotor] = 63;
motor[leftMotor] = -63;
}

//Stop
motor[rightMotor] = 0;
motor[leftMotor] = 0;


//Enter the code for the robot to drive forward to the charge cube here:
while(nMotorEncoder[leftMotor] >= -1500) //while less than 2520 counts of the right encoder have passed...
{
//...move forward.
motor[rightMotor] = 63;
motor[leftMotor] = 63;
}

//Stop
motor[rightMotor] = 0;
motor[leftMotor] = 0;

//Reset the encoders to 0.
nMotorEncoder[rightMotor] = 0;
nMotorEncoder[leftMotor] = 0;

//Enter the code for the robot to turn right toward the Communication Tower here:
while(nMotorEncoder[leftMotor] >= -110)
{
motor[rightMotor] = -63;
motor[leftMotor] = 63;
}
//Reset the encoders to 0.
nMotorEncoder[rightMotor] = 0;
nMotorEncoder[leftMotor] = 0;

//Enter the code for the robot to drive forward to the Communication Tower pad here:


} //The program ends.


Mon Sep 15, 2014 12:15 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Jun 11, 2014 9:59 am
Posts: 115
Post Re: Encoders not clearing in Curriculum Companion and OR
Lordvader,

Unfortunately there are some problems that you will run into with the earlier versions of ROBOTC. There have been fixes made to the encoders since ROBOTC 4.10, so I believe that you may be experiencing an issue that has been fixed. I advise an upgrade to ROBOTC 4.26. If you are having trouble with installation, licences activation, or crashing please contact us at support@robotc.net and we will be happy to assist you with the installation. If there are any more questions please feel free ask.


Thanks, Lee


Tue Sep 16, 2014 9:17 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.