View unanswered posts | View active topics It is currently Thu Sep 18, 2014 9:57 pm






Reply to topic  [ 9 posts ] 
Cannot Update Slave Sync (69) error when running program 
Author Message
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post Cannot Update Slave Sync (69) error when running program
Hey there,

When I run my program, I get the following error:

Code:
Byte Code Interpreter Exception:
  Program Slot: 0, Task ID: main[0]
  Error at PC: Sub autoCalibrate+0x000B
  Task PC: PC: Sub autoCalibrate+0x000B,
  TaskState: 'Exception'
  Exception Type: 'Cannot Update Slave Sync(69)'


The source code can be downloaded here: LINK

The sub in question I'll paste:
Code:
/*
  Due to varying lighting conditions, the light reflected by the edge
  of the line may vary.  This sub will attempt to find the min and max
  values of the sensor as it rotates back and forth over the line.
 */
void autoCalibrate () {
   int _currValue = 0;

  nMotorEncoder[motorB] = 0;
  nMotorEncoder[motorC] = 0;

  _currValue = 50;
  sensorMax = _currValue;
  sensorMin = _currValue;
  pivotLeft();
  while (nMotorEncoder[motorB] > -100) {
     _currValue = centerValue;
     if (_currValue > sensorMax)
       sensorMax = _currValue;
     if (_currValue < sensorMin)
       sensorMin = _currValue;
  }
  stopRobot();
  threshold = (sensorMax + sensorMin) / 2;
}


Anyone know what this error means? I am stumped :)

I am using RobotC v1.30B4.

Regards,
Xander


Fri May 30, 2008 2:09 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post 
I've done some more testing and it seems that if you've got
Code:
  nSyncedMotors = synchBC;  // Motor ‘C’ is slaved to motor ‘B’

in your program, you cannot simple do a
Code:
  nMotorEncoder[motorB] = 0;
  nMotorEncoder[motorC] = 0;

without first calling
Code:
nSyncedMotors = synchNone;


So my code now looks like this:
Code:
/*
  Due to varying lighting conditions, the light reflected by the edge
  of the line may vary.  This sub will attempt to find the min and max
  values of the sensor as it rotates back and forth over the line.
 */
void autoCalibrate () {
   int _currValue = 0;
  nSyncedMotors = synchNone;
  nMotorEncoder[motorB] = 0;
  nMotorEncoder[motorC] = 0;
  nSyncedMotors = synchBC;

  _currValue = centerValue;
  sensorMax = _currValue;
  sensorMin = _currValue;
  pivotLeft();
  while (nMotorEncoder[motorB] > -100) {
     _currValue = centerValue;
     if (_currValue > sensorMax)
       sensorMax = _currValue;
     if (_currValue < sensorMin)
       sensorMin = _currValue;
  }
  stopRobot();
  threshold = (sensorMax + sensorMin) / 2;
}


Question is, why am I not allowed to reset the slave's encoder? How should I reset the counters without "unslaving" the other motor?

Regards,
Xander


Fri May 30, 2008 3:27 pm
Profile WWW
Novice

Joined: Sun Feb 04, 2007 12:48 am
Posts: 69
Location: Australia
Post 
My understanding, in simple terms, is that when you synch two motors, one is the master and the other is the slave. Hence you can only give instructions to the 'master' motor as the slave will simply move based on the movements performed by the 'master' motor.

So in your code, you only need to reset motorB.
Secondly, as you are aware you're not allowed to send any commands to motorC (whilst in Synch mode).

Hence:
nMotorEncoder[motorC] = 0;

throws the error. From what I can see you don't need to reset the encoder on motorC.

Cheers
James


Fri May 30, 2008 9:13 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post 
The thing is, I did some testing and when they motors are bonded together like that, sending a nMotorEncoder[masterMotor] = 0; does NOT reset the encoder for the slave. That seems like very odd behaviour.

I guess my question is what is the recommended way to reset both encoders? I am using the encoder values for dead reckoning purposes, so I need to be able to reset them when it suits me.

Regards,
Xander


Sat May 31, 2008 2:07 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
hi,
so I'd propose (suggest? I'll never get the difference...) that you better wrote your own synch routine, where you'll have full control on all encoder values - I did the same for some of my purposes before (where I had to synch 3 motors over all).

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat May 31, 2008 4:08 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post 
Hey Ford,

Suggest or propose, both are fine in this case :) You can even propose to suggest or suggest to propose, but the latter has a slightly different meaning, haha.

Do you think you could send me your synching (not sinking) code? I'll even throw in a virtual blanket for on your travels and a meal voucher for the restaurant at the end of the Universe. (yeah, I'm a big fan of those books, too).

Regards,
Xander Beeblebrox


Sat May 31, 2008 4:41 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
mightor wrote:
You can even propose to suggest or suggest to propose, but the latter has a slightly different meaning, haha.

what difference? (or is this actually just for adults? :? )

mightor wrote:
Do you think you could send me your synching (not sinking) code?

To be honest, this was a java (lejos) application for RCX.
But the code is very very simple:

Code:
//motors 0 and 1 to be synchronized!
//ensure that motor=0 is "floating", not "stop"
#define enc nMotorEncoder;
enc(0)=0;
enc(1)=0;
do {
  if (enc(0)>enc(1)) {motor(0)=0; motor(1)=100;}
  else
  if  (enc(0)<enc(1)) {motor(1)=0; motor(0)=100;}
   else
  if  (enc(0)==enc(1)) {motor(0)=100; motor(1)=100;}
} while (// ??//);


mightor wrote:
I'll even throw in a virtual blanket for on your travels and a meal voucher for the restaurant at the end of the Universe. (yeah, I'm a big fan of those books, too).


I'll be glad to gad one! nice to willhavehadwant seawn you there! (ok, I know, never try to make jokes in a foreign language... :oops: )

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Last edited by Ford Prefect on Sun Jun 01, 2008 9:34 am, edited 1 time in total.



Sat May 31, 2008 5:59 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post 
Ford Prefect wrote:
mightor wrote:
You can even propose to suggest or suggest to propose, but the latter has a slightly different meaning, haha.

what difference? (or is this actually just for adults? :? )

Nah, to propose to suggest would mean something like "making the suggestion to suggest something". To propose can have two meanings, it can mean to suggest OR to ask someone to marry you, that's the meaning of the second one, ie make the suggestion to ask someone to marry you. It's a little play on words, nothing bad.

I used to go to a German school in Ireland and we used to play on German words a lot. One of the words we invented was "gereift". We derived it from Reifen, which is a tyre. Tired, is sort of like past tense of Tyre, hence Gereift, past tense of Reifen :) It confused the heck out of our German teachers, haha.

Ford Prefect wrote:
mightor wrote:
Do you think you could send me your synching (not sinking) code?

To be honest, this was a java (lejos) application for RCX.
But the code is very very simple (pseudo code):

That seems simple enough, thanks!


Fored Prefect wrote:
I'll be glad to gad one! nice to willhavehadwant seawn you there! (ok, I know, never try to make jokes in a foreign language... :oops: )

Haha, nah, I get it. I've read those books (I have all the books in one big book) about 9-10 times now. I love it!

Regards,
Xander


Sat May 31, 2008 7:01 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
mightor wrote:
One of the words we invented was "gereift". We derived it from Reifen, which is a tyre. Tired, is sort of like past tense of Tyre, hence Gereift, past tense of Reifen :)

Weird. Sort of Irish humor, eh? :lol:
you DO know the original meaning of "gereift", don't you?
It's derived from "reif" = mature.
tired=tyred=ge-Reift=gereift=reif=mature.
tired=mature.
**LOL**

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat May 31, 2008 12:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: Mr.Petes 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.