View unanswered posts | View active topics It is currently Tue Sep 30, 2014 7:58 pm






Reply to topic  [ 2 posts ] 
Custom Lego Remote 
Author Message
Rookie

Joined: Wed Nov 21, 2012 11:17 am
Posts: 1
Post Custom Lego Remote
So I have been working on a remote control for my car that I built similar to this one that uses motor A for steering and motors B and C to move. I have a controller for it which features two motors to steer. One has a wheel like a steering wheel, the other is sideways like a throttle. I had originally been using the nxt buttons to steer and the program was working great, once I switched to a steering wheel, the program broke. The rover starts moving at the start of the program even though it should be stopped, half the time the throttle no longer works and I have yet to make the steering wheel actually work. Would someone mind looking at the code and telling me if they can find a problem or suggest how to get the steering wheel to work?
Thanks, Michael

Remote Control Code
Code:
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
int V;
int a;
int b;
task main()
{

nMotorEncoder[motorA]=0;
nMotorEncoder[motorB]=0;
while(true)

{

a = nMotorEncoder[motorA];
b = nMotorEncoder[motorB];
V = nNxtButtonPressed;


  sendMessageWithParm(V, a, b);
  wait1Msec(100);  // Don’t send messages too frequently.


}
}




Car Code
Code:
#pragma config(Sensor, S1,     ,               sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

int turn = 0;
int math1;

void stop()
{
   motor[motorB]=0;
   motor[motorC]=0;
}
void turnright()
{
while(nMotorEncoder[motorA] <15)
      {
            motor[motorA]=21;
   }
      motor[motorA]=0;


}
void turnstrait()
{
   if (nMotorEncoder[motorA]>-100 && nMotorEncoder[motorA] < 0 )
      {
               while(nMotorEncoder[motorA] != 0 )
      {
            motor[motorA]=21;
   }
      motor[motorA]=0;
   }
   if (nMotorEncoder[motorA]>0  )
      {
               while(nMotorEncoder[motorA] != 0 )
      {
            motor[motorA]=-21;
   }
      motor[motorA]=0;
   }
}
void turnleft()
{

   while(nMotorEncoder[motorA] > -15)
      {
            motor[motorA]=-21;
   }
      motor[motorA]=0;



}



task steer()
{
  while(true)
  {

   math1= 32-turn;
   //find the direction



   motor[motorB]=turn;
   motor[motorC]=turn;


}
}

task main{   nMotorEncoder[motorA]=0;

StartTask(steer);
motor[motorB]=0; motor[motorC]=0;

while (true)
{
  //
  // Skip to the last message received
  //
  while (bQueuedMsgAvailable())
  {
    word temp;
    ClearMessage();   // We’re ready to process the next message
    temp = message;   // Obtain the next message
  }
  if (message == 0)
  {
   // No message is available to process
    wait1Msec(5);
    continue;
  }
  // A message is ready to be processed
 int ident = message;
 if(ident== 1)
   {// the value of ‘S1’ from the remote NXT



   //throttle: line 1: dead zone or, set the motors to = the rotation
  if (messageParm[2] > -10 && messageParm[2] < 10)
     {motor[motorB]=0; motor[motorC]=0;}
 else{
  motor[motorB] = messageParm[1];
  motor[motorC] = messageParm[1];}
int a = messageParm[0];
int b = messageParm[1];
int c = messageParm[2];



  //steering
  turn = messageParm[1];
if (messageParm[0]!=-1){motor[motorA]=10;}

  }                             
}

}


Wed Nov 21, 2012 11:30 am
Profile
Expert
User avatar

Joined: Fri Nov 02, 2012 12:07 am
Posts: 164
Location: California, USA
Post Re: Custom Lego Remote
Could you explain this in more detail, so I could maybe help out?

:downloading: :downloading: :downloading: :downloading:
:eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek: :eek:

_________________
string Robored = "Awesome"
~~Neil Balch~~


Thu Nov 22, 2012 12:56 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.