Author |
Message |
chris garrett
Rookie
Joined: Tue Jun 18, 2013 6:04 pm Posts: 30
|
 Synching and Encoding Program
We are trying to target a distance of about 24' using our encoders and a little math. We are trying to hit the target with precision by using degrees of rotation of the wheel. At that distance, the robots are going off on an angle, none of them with go straight so we are trying to synchronize the motors as part of the program. The program has flaws and won't download. None of the error codes are giving us clues as to what is wrong. I know we are using the encoders properly, because the math and the program work. But when we insert the synch program it fails to download. Here is the code:
task main ( )
{
nSyncedMotors = synch BC; nSyncedTurnRatio = 100; //synch motor C to 100% of motor B
nMotorEncoder[motorB] = 0 //clear encoder B nMotorEncoder[motorC] = 0 //clear encoder C
nmotorEncoderTarget[motorB] = 17584 //distance in degrees motor B nMotorEncoderTarget[motorC] = 17584 //distance in degrees motor C
motor[motorB] = 50; //motor B @ 50% power motor[motorC] = 50; //motor C @ 50% power wait1Msec(10000); //sufficient time to reach target
}
|
Sat Sep 14, 2013 5:18 pm |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Synching and Encoding Program
It looks like you're missing a few semicolons and have the wrong command on the sync motors. How's that work?
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
Sat Sep 14, 2013 5:28 pm |
|
 |
chris garrett
Rookie
Joined: Tue Jun 18, 2013 6:04 pm Posts: 30
|
 Re: Synching and Encoding Program
I think our original program had the semi-colons. I typed the one here from memory. But the sync programming was surely wrong. I will try your fix tomorrow. Thanks for your help. I'll let you know how it works. 
|
Sat Sep 14, 2013 9:11 pm |
|
 |
chris garrett
Rookie
Joined: Tue Jun 18, 2013 6:04 pm Posts: 30
|
 Re: Synching and Encoding Program
Below is the corrected code that I am able to download to the bot, but when I try to run it I get a weird double beep sound and a message that says:
ByteCode Interpreter Exception Program Slot0, TaskID: main[0] Exception Type 'cannot update Slave Sync(60)'
When I eliminate the synching lines, the program runs fine, but the bot goes on an angle.
task main() {
nSyncedMotors = synchBC; nSyncedTurnRatio = 100; //synch motor C to 100% of motor B
nMotorEncoder[motorB] = 0; //clear encoder B nMotorEncoder[motorC] = 0; //clear encoder C
nMotorEncoderTarget[motorB] = 17584; //distance in degrees motor B nMotorEncoderTarget[motorC] = 17584; //distance in degrees motor C motor[motorB] = 50; //motor B @ 50% power motor[motorC] = 50; //motor C @ 50% power wait1Msec(10000); //sufficient time to reach target }
|
Mon Sep 16, 2013 8:40 am |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Synching and Encoding Program
Ah, I suspect the problem is you're giving commands to motor 'C'. Try removing all of those, so you're just reading and controlling motor 'B'.
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
Mon Sep 16, 2013 10:13 am |
|
 |
chris garrett
Rookie
Joined: Tue Jun 18, 2013 6:04 pm Posts: 30
|
 Re: Synching and Encoding Program
N-G, I took out all of the C commands and the program works perfectly. Thank you very much. 
|
Mon Sep 16, 2013 11:03 am |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: Synching and Encoding Program
Btw, I just wanted to confirm that "bytecode exception" is a general error that could mean anything. Because I've seen it several times, and they were all different problems. What does it mean? That the stack overflowed? Or something? Accessing invalid memory addresses?
_________________FTC Team 6424, the 'Oly Cow - Chief programmer. FRC Team 4450, Olympia Robotics Federation (ORF). and also quadrotors. Quadrotors!
|
Mon Sep 16, 2013 6:37 pm |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Synching and Encoding Program
I think that's the case Ernest. bytecode exception is an error in the running program, Program slot is which program slot (Prolly a remnant from the RCX, as the NXT doesn't have slots), which task the error is in, and the actual error.
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
Mon Sep 16, 2013 9:08 pm |
|
|