ROBOTC.net forums
http://www.robotc.net/forums/

Problem with remote control transmitter operating motors
http://www.robotc.net/forums/viewtopic.php?f=11&t=708
Page 1 of 1

Author:  stemke [ Sat Aug 30, 2008 11:47 pm ]
Post subject:  Problem with remote control transmitter operating motors

Help me, I do not know what I am doing wrong.
I can get a remote control to operate 2 motors with Easy C.
WHen I change over the firmware and run the sample program called Single Joystick Control.c, I cannot get the motors to turn.
I have left the physical setup the same as when it worked with Easy C.
I have tried every Ch1..8 and every motor port. Nothing moves.
I have tried the tether connection, also, but do not need to since the transmit/receive frequency works with Easy C.
I can single step in the debugger and it executes the line of code.
If I just set the motor on with (motor[port1] = 50), the motor turns.
The sample program turns off the autonomous flag.
All batteries are fresh.
THe sample program appears as follows:
task main()
{
bMotorFlippedMode[port2] = 1; //Port 2 Motor Direction Flipped
bVexAutonomousMode = false; //Activates Remote Control Mode

while (true) //Creates an infinite loop
{
motor[port2] = vexRT[Ch3]/2 - vexRT[Ch4]/2; //y-axis value: forward/backward motion
motor[port3] = vexRT[Ch3]/2 + vexRT[Ch4]/2; //x-axis value: left/right steering
//divided by 2 to prevent values over 127
}
}

Author:  fryfrog [ Sun Aug 31, 2008 12:45 am ]
Post subject:  Re: Problem with remote control transmitter operating motors

I had some trouble with that one too, so I switched it up a little and came up with this:

Of note is that I have motors in port 1 and 7 and 2 and 8 paired up. You would of course need to customize things to your needs.

Code:
#pragma config(Motor,    port1,                  leftMotor1,                  tmotorNormal)
#pragma config(Motor,    port2,                  rightMotor1,               tmotorNormal)
#pragma config(Motor,    port7,                  leftMotor2,                  tmotorNormal)
#pragma config(Motor,    port8,                  rightMotor2,               tmotorNormal)
//*!!Code automatically generated by 'ROBOTC' configuration wizard                      !!*//

void MotorsOff();

task main()
{
  bMotorFlippedMode[rightMotor1] = 1;
  bMotorFlippedMode[rightMotor2] = 1;
  bVexAutonomousMode = false;

  while (true)
  {
     // Only do stuff if the transmitter is on (safety first!)
    if (nVexRCReceiveState == 1)
    {
      motor[leftMotor1] = vexRT[Ch3] - vexRT[Ch4];
      motor[leftMotor2] = vexRT[Ch3] - vexRT[Ch4];

      motor[rightMotor1] = vexRT[Ch3] + vexRT[Ch4];
      motor[rightMotor2] = vexRT[Ch3] + vexRT[Ch4];
    } else {
      MotorsOff();
    }
  }
}

void MotorsOff()
{
  motor[port1] = 0;
  motor[port2] = 0;
  motor[port3] = 0;
  motor[port4] = 0;
  motor[port5] = 0;
  motor[port6] = 0;
  motor[port7] = 0;
  motor[port8] = 0;
}

Author:  fryfrog [ Sun Aug 31, 2008 12:46 am ]
Post subject:  Re: Problem with remote control transmitter operating motors

I also strongly suggest putting code into [code] put all your code here; [/code] blocks so that it is readable.

Author:  stemke [ Sun Aug 31, 2008 3:10 pm ]
Post subject:  Re: Problem with remote control transmitter operating motors

What I failed to mention in my initial message is that I can only get 0 or maybe 1 out of the VexRT[]
command no matter what I do to the joysticks.
If the code says: motor[port1] = 127; the motor turns.
but I cannot get anything but 0 or 1 out of the vexRT[Ch1] command.

Author:  fryfrog [ Sun Aug 31, 2008 7:06 pm ]
Post subject:  Re: Problem with remote control transmitter operating motors

Are you moving the right sticks around? The *left* side appears to be ch3/ch4 and the *right* side appears to be ch1/ch2. I thought this was a little weird. Are you sure you transmitter and receiver are okay? What happens if you use the real vex firmware, do the channels work right?

Author:  stemke [ Sun Aug 31, 2008 8:05 pm ]
Post subject:  Re: Problem with remote control transmitter operating motors

I tried all joysticks and buttons, none registered on the debug display or made any of the motors move.
I had switched to the EASYC and run a simple program with the remote control proving that it was communicating to the micro-controller and joysticks working. I reloaded the ROBOTC firmware afterwards before loading the ROBOTC sample program.
That is all I did to change from EASYC to ROBOTC (select download firmware from the robot menu of ROBOTC).
Is that all I am supposed to do?

What is the "real vex firmware" that you mentioned?

Author:  stemke [ Sun Aug 31, 2008 8:33 pm ]
Post subject:  Re: Problem with remote control transmitter operating motors

OK, I got it. There is a motors and sensors setup. Once I setup the 2 motors I was using, the program worked as expected.
THanks for responding to my plight.

Author:  fryfrog [ Sun Aug 31, 2008 9:37 pm ]
Post subject:  Re: Problem with remote control transmitter operating motors

The "real" vex firmware is (in my opinion) the one that it comes with, the one that I guess is made to be used with EasyC. By default it lets you RC the robot w/o any work.

But you figured it out and that is all that matters :)

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/