View unanswered posts | View active topics It is currently Thu Oct 23, 2014 2:46 am






Reply to topic  [ 2 posts ] 
LEGO mindstroms ploter x,y,z, help with code please 
Author Message
Rookie

Joined: Sat Jan 26, 2013 8:13 pm
Posts: 1
Post LEGO mindstroms ploter x,y,z, help with code please
Hello,

Hi, i have been build a ploter x,y,z, and i want to make him move, for now i have the reseting positions and movement to brick but i can't write right function so i ask can somebody help me with that please.

this is what i want to do: ( or something similiar not so complicated like this)
http://www.youtube.com/watch?v=pX1cO2XhMrg

and i made this and wrote some code using Robotc
Image
Image

Code:
#pragma config(Sensor, S1,     xhome,          sensorTouch)
#pragma config(Sensor, S2,     yHome,          sensorSONAR)
#pragma config(Sensor, S3,     zhome,          sensorTouch)
#pragma config(Motor,  motorA,          xMotor,        tmotorNXT, PIDControl, reversed, encoder)
#pragma config(Motor,  motorB,          yMotor,        tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorC,          zMotor,        tmotorNXT, PIDControl, reversed, encoder)


void zresetowaniePozycjiX();
void zresetowaniePozycjiY();
void zresetowaniePozycjiZ();

void przesunX(int docelowaX);
void przesunY(int docelowaY);
void przesunZ(int docelowaZ);

void wiercenie(int tablicax ,int tablicay, int tablicawiercenie);

int tablicax[5]={-51,-52,-53,-54,-55,};
int tablicay[5]={50,51,53,54,55,};
int tablicawiercenie[5]={55,56,57,58,59,};


task main()
{
      zresetowaniePozycjiX();         
      wait1Msec(1);
      zresetowaniePozycjiY();
      wait1Msec(1);
      zresetowaniePozycjiZ();
      wait1Msec(1);                        //reseting positions
   
      wait1Msec(1);                     
      przesunX(-50);
      wait1Msec(1000);
      przesunY(-50);
      wait1Msec(1000);
      przesunZ(50);
      wait1Msec(4000);                  //movement to brick
      
      nMotorEncoder[motorA] = 0;   nxtDisplayTextLine(1,"%d", nMotorEncoder[motorA]);
      nMotorEncoder[motorB] = 0;   nxtDisplayTextLine(2,"%d", nMotorEncoder[motorB]);
      nMotorEncoder[motorC] = 0;   nxtDisplayTextLine(3,"%d", nMotorEncoder[motorC]); 
                                          
                                                //reset motor encoder & show
      void wiercenie;
      wait10Msec(1000);

}




void wiercenie(int tablicax, int tablicay, int tablicawiercenie)
{
 nxtDisplayTextLine(0,"Test %d %d %d",tablicax,tablicay,tablicawiercenie); 
}




void zresetowaniePozycjiX()
{

   while(SensorValue[S1]==0)
   {
      nxtDisplayTextLine(1,"%d", nMotorEncoder[motorA]);
      nxtDisplayTextLine(2,"%d", SensorValue[S1]);
      motor[motorA] = 10;
   }
      motor[motorA] = 0;
      nMotorEncoder[motorA] = 0;
}

void zresetowaniePozycjiY()
{

   while(SensorValue[S2]>5)
   {
      nxtDisplayTextLine(1,"%d", nMotorEncoder[motorB]);
      nxtDisplayTextLine(2,"%d", SensorValue[S2]);
      motor[motorB] =10;
   }
      motor[motorB] =0;
      nMotorEncoder[motorB] = 0;
}
void zresetowaniePozycjiX()
{

   while(SensorValue[S1]==0)
   {
      nxtDisplayTextLine(1,"%d", nMotorEncoder[motorA]);
      nxtDisplayTextLine(2,"%d", SensorValue[S1]);
      motor[motorA] = 10;
   }
      motor[motorA] = 0;
      nMotorEncoder[motorA] = 0;
}
void zresetowaniePozycjiZ()
{

   while(SensorValue[S3]==0)
   {
      nxtDisplayTextLine(1,"%d", nMotorEncoder[motorC]);
      nxtDisplayTextLine(2,"%d", SensorValue[S3]);
      motor[motorC] = -10;
   }
      motor[motorC] = 0;
      nMotorEncoder[motorC] = 0;
}

void przesunX(int docelowaX)
{
      int aktualna1=nMotorEncoder[motorA];
      int roznica1=aktualna1-docelowaX;

      while(aktualna1 != docelowaX)
      {
      aktualna1 = nMotorEncoder[motorA];
      roznica1 = aktualna1 - docelowaX;
     motor[motorA] =-10;
      wait1Msec(-roznica1);
   {
      nxtDisplayTextLine(1,"%d", aktualna1);
      nxtDisplayTextLine(2,"%d", docelowaX);
      nxtDisplayTextLine(3,"%d", roznica1);
     }
   }
   motor[motorA] = 0;
}

void przesunY(int docelowaY)
{
      int aktualna = nMotorEncoder[motorB];
      int roznica = aktualna - docelowaY;

      while (aktualna != docelowaY)
      {
      aktualna = nMotorEncoder[motorB];
      roznica = aktualna - docelowaY;
     motor[motorB]=-10;
      wait1Msec(docelowaY);

      nxtDisplayTextLine(1,"%d", aktualna);
      nxtDisplayTextLine(2,"%d", docelowaY);
      nxtDisplayTextLine(3,"%d", roznica);
   }
   motor[motorB] = 0;
}

void przesunZ(int docelowaZ)
{
      int aktualna2=nMotorEncoder[motorC];
      int roznica2=aktualna2-docelowaZ;

      while(aktualna2 != docelowaZ)
      {
      aktualna2 = nMotorEncoder[motorC];
      roznica2 = aktualna2 - docelowaZ;
     motor[motorC] =10;
      wait1Msec(--roznica2);
   {
      nxtDisplayTextLine(1,"%d", aktualna2);
      nxtDisplayTextLine(2,"%d", docelowaZ);
      nxtDisplayTextLine(3,"%d", roznica2);
     }
   }
   motor[motorC] = 0;
}


Sat Jan 26, 2013 8:42 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3225
Location: Rotterdam, The Netherlands
Post Re: LEGO mindstroms ploter x,y,z, help with code please
Hi there,

If I could give you some advice on sharing code with people, it's that you should look into using English names for your functions and variables. It is pretty difficult to guess what everything should do or what you think they should do. Running this stuff through Google Translate is not really an option, since Google does not speak Polish ROBOTC :)

What is that you need help with? What do you mean by "right function"?

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jan 27, 2013 2:18 am
Profile WWW
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.