View unanswered posts | View active topics It is currently Sun May 27, 2018 1:39 am

 Page 1 of 1 [ 9 posts ]
 Print view Previous topic | Next topic
Turn specified degrees?
Author Message
Rookie

Joined: Sun Mar 02, 2008 9:41 am
Posts: 25
Turn specified degrees?
Hi,

Does anyone knows a way to tell nxt to turn a specified number of degrees?

90 or 180 for example?

Any help appreciated.

Regards,
giannis

Sun Mar 02, 2008 12:46 pm
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

ja, hier ist mein Vorschlag / my suggestion ? proposal ?:
du brauchst den Raddurchmesser /
you need the wheel diameter(DiameterWheel)
und den Abstand der beiden Antriebsräder /
distance of both wheels (WheelDistance):

 Code:int round(float f){  if(f>0) return (int)(f + 0.5);  else    return (int)(f - 0.5);}void turn_degr(float angle){float DiameterWheel;   // cm , e.g. 8.2    float WheelDistance;   //  cm , e.g. 12.0int Ticks, speed;float AnglePerTick;AnglePerTick=DiameterWheel/WheelDistance;   nMotorEncoder[1]=0;nSyncedTurnRatio=-100;  // motors 1 + 2 to be synchronized!Ticks=round(angle/AnglePerTick);while(nMotorEncoder[1]!=Ticks){if (abs(nMotorEncoder[1]-Ticks)>20){speed=30;}      else speed=12;                                       if (nMotorEncoder[1]Ticks)     {       motor[1]=-speed;     }   }motor[1]=0;}void move_cm(float s)   // analog: to go straight{int Ticks, speed;float DiameterWheel;   // cm       float cmPerTick;   cmPerTick=(PI*DiameterWheel)/360;   nSyncedTurnRatio=100;  // motors 1 + 2 to be synchronized!nMotorEncoder[1]=0;  Ticks=round(s/cmPerTick);while (Ticks!=nMotorEncoder[1])  {    if (abs(nMotorEncoder[1]-Ticks)>20) {speed=40;}      else speed=15;                      if (Ticks > nMotorEncoder[1]) {motor[1]=speed; }    else    if (Ticks < nMotorEncoder[1]) {motor[1]=-speed; }  }motor[1]=0;}

if you're interested in a complete navigator program, please refer to
http://www.mindstormsforum.de/viewtopic.php?t=2875

HTH!

_________________
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 Mar 02, 2008 7:22 pm, edited 5 times in total.

Sun Mar 02, 2008 2:44 pm
Rookie

Joined: Sun Mar 02, 2008 9:41 am
Posts: 25
hi
Hi,

Could you please explain to me what you mean by "distance of both wheels (WheelDistance): "

I havent tested this but if this works, you have safed me a lot of time for my project

Thanks a lot for your help though.

Regards,
Giannis

Sun Mar 02, 2008 5:07 pm
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

Distance of the wheels - well , sorry for my poor English;
how else should I say?
the length of the axis?

 Code:#                     ##                     ##                     ##  MM             MM  ##- - - - -   - - - - -##  MM             MM  ##                     ##                     ##                     #^ left wheel          ^ right wheel  with motor            with motor ^- - - - - - - - - - -^    distance between    left and right wheel

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

Sun Mar 02, 2008 6:12 pm
Rookie

Joined: Sun Mar 02, 2008 9:41 am
Posts: 25
Hi
Hi again,

Oh no worries mine are not better ...

I did try this but the robot keeps going around forever.

Do i need to the parameters below as well:
float DiameterWheel; // cm , e.g. 8.2
float WheelDistance; // cm , e.g. 12.0
int Ticks, speed;
float AnglePerTick;

I called the function like this: turn_degr(90); with the WheelDistance set to 15 and the DiameterWheel set to 56 (which i dont think is in cm, it is written on the tire though. And it still keeps going around forever.

Would you know why please?

Regards,
Giannis

Sun Mar 02, 2008 6:27 pm
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

try it with a ruler...

?
float DiameterWheel= 5.6 ;
float WheelDistance=15.0 ;

notice:
// motorA =0
// motorB =1
// motorC =2
// to sync motors 1+2: nSyncedMotors = synchBC;

and then try this:

 Code:int round(float f){  if(f>0) return (int)(f + 0.5);  else    return (int)(f - 0.5);}float DiameterWheel=5.6  ;float WheelDistance= 15.0 ;float AnglePerTick;void turn_degr(float angle){int Ticks, speed;nMotorEncoder[1]=0;nSyncedTurnRatio=-100;  // motors 1 + 2 to be synchronized!Ticks=round(angle/AnglePerTick);while(nMotorEncoder[1]!=Ticks){if (abs(nMotorEncoder[1]-Ticks)>20){speed=30;}else speed=12;if (nMotorEncoder[1]Ticks)     {       motor[1]=-speed;     }   }motor[1]=0;}task main(){  AnglePerTick=DiameterWheel/WheelDistance;  nSyncedMotors = synchBC;  turn_degr(90);}

_________________
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 Mar 02, 2008 7:17 pm, edited 4 times in total.

Sun Mar 02, 2008 7:02 pm
Rookie

Joined: Sun Mar 02, 2008 9:41 am
Posts: 25

Hi,

I did try with a ruler but it stills keeps going around for ever.

I think the problem is because the variable AnglePerTick is 0.

Could you explain me what is this variable or what should i set it to please?

Kind Regards,
Ioannis

Sun Mar 02, 2008 7:06 pm
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

see above!

you have to take the ABSOLUTE CORRECT measures!

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

Sun Mar 02, 2008 7:11 pm
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030

have you got it?

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

Tue Mar 11, 2008 6:54 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 9 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

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.