View unanswered posts | View active topics It is currently Wed Apr 23, 2014 10:51 am






Reply to topic  [ 8 posts ] 
Synching and Encoding Program 
Author Message
Rookie

Joined: Tue Jun 18, 2013 6:04 pm
Posts: 29
Post 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
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post 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?

_________________
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
Profile WWW
Rookie

Joined: Tue Jun 18, 2013 6:04 pm
Posts: 29
Post 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. :bigthumb:


Sat Sep 14, 2013 9:11 pm
Profile
Rookie

Joined: Tue Jun 18, 2013 6:04 pm
Posts: 29
Post 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
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post 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
Profile WWW
Rookie

Joined: Tue Jun 18, 2013 6:04 pm
Posts: 29
Post Re: Synching and Encoding Program
N-G, I took out all of the C commands and the program works perfectly. Thank you very much. :bigthumb:


Mon Sep 16, 2013 11:03 am
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post 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
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post 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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 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.