View unanswered posts | View active topics It is currently Sat Aug 23, 2014 3:31 am






Reply to topic  [ 2 posts ] 
motor[motorB]= abs(speed); 
Author Message
Rookie

Joined: Sat Apr 12, 2008 10:43 am
Posts: 2
Post motor[motorB]= abs(speed);
I wrote a program for moving robot. i wrote functions for moving forward, backward, turnig, etc.
everything was working great. but then i added the code for accelerating.
at frist try the robot was accelerating well, but at second try it didn't start moving at all. i removed the code and it still didn't move. it freezd. i had to remove the battery from the brick to turn it back on.
this is the code for moving forward

nSyncedMotors = synchBC;
nSyncedTurnRatio = 100;

motor[motorB] = abs(speed);
while ( (SensorValue(stikalol)!=1 & SensorValue(stikalod)!=1) & (abs(dolzinapoti)<dolzina) )
{
dolzinapoti = nMotorEncoder[motorB] * STRAITRATIO / 360;
nxtDisplayTextLine(3,"dolzina %3.0f",dolzinapoti);
}

i found out that if i remove the abs function in
motor[motorB] = abs(speed);
the robot is moving...

i have no idea what is wrong because the first code with abs was working in the beginning. probably is something with robotc.


Thu Apr 17, 2008 6:41 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
hmmh...
- have you initialized speed before the first call?
- what happens if you wrote
int dummy;
dummy=abs(speed);
motor[motorB] = dummy;

:?:

_________________
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)}


Fri Apr 18, 2008 9:40 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.