View unanswered posts | View active topics It is currently Tue Feb 19, 2019 4:17 am

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
Synching and Encoding Program
Author Message
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:

{

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
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.

 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
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
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
Exception Type 'cannot update Slave Sync(60)'

When I eliminate the synching lines, the program runs fine, but the bot goes on an angle.

{

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
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
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
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).

Mon Sep 16, 2013 6:37 pm
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 8 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning