ROBOTC.net forumshttp://robotc.net/forums/ Synching and Encoding Programhttp://robotc.net/forums/viewtopic.php?f=1&t=6823 Page 1 of 1

 Author: chris garrett [ Sat Sep 14, 2013 5:18 pm ] Post subject: 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}

Author:  NeXT-Generation [ Sat Sep 14, 2013 5:28 pm ]
Post subject:  Re: Synching and Encoding Program

It looks like you're missing a few semicolons and have the wrong command on the sync motors.

 Code:task main (){  nSyncedMotors = syncBC;  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}

How's that work?

 Author: chris garrett [ Sat Sep 14, 2013 9:11 pm ] Post subject: 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.

 Author: chris garrett [ Mon Sep 16, 2013 8:40 am ] Post subject: 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}

 Author: NeXT-Generation [ Mon Sep 16, 2013 10:13 am ] Post subject: 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'.

 Author: chris garrett [ Mon Sep 16, 2013 11:03 am ] Post subject: Re: Synching and Encoding Program N-G, I took out all of the C commands and the program works perfectly. Thank you very much.

 Author: Ernest3.14 [ Mon Sep 16, 2013 6:37 pm ] Post subject: 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?

 Author: NeXT-Generation [ Mon Sep 16, 2013 9:08 pm ] Post subject: 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.

 Page 1 of 1 All times are UTC - 5 hours [ DST ] Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/