|
Page 1 of 1
|
[ 4 posts ] |
|
Slight Problem with compiling
| Author |
Message |
|
Sellers3143
Rookie
Joined: Tue Dec 02, 2008 12:40 pm Posts: 9
|
 Slight Problem with compiling
I seem to be getting an error when i try to compile that I cannot grasp the problem. What I have done is I have a custom setup with the motor controllers and I have two extras that I use but they wont compile  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none) #pragma config(Motor, motorD, , tmotorNormal, openLoop, ) #pragma config(Motor, motorE, , tmotorNormal, openLoop, ) #pragma config(Motor, mtr_S1_C2_1, left_arm, tmotorNormal, openLoop, ) #pragma config(Motor, mtr_S1_C2_2, right_arm, tmotorNormal, openLoop, )
#include "JoystickDriver.c"
task main() { while (true) { getJoystickSettings(joystick); // This is controller 1 telling the drive motors to go forward or backward motor[motorD] = joystick.joy1_y1; motor[motorE] = joystick.joy1_y2;
getJoystickSettings(joystick); // This is controller 2 telling the arm motors to go forward or backward also max speed of 50 motor[left_arm] = joystick.joy2_y1*0.4; motor[right_arm] = joystick.joy2_y1*0.4;
|  |  |  |  |
Here are my errors
|
| Thu Dec 04, 2008 6:07 pm |
|
 |
|
grajalese
Rookie
Joined: Thu Jul 10, 2008 12:30 pm Posts: 14
|
 Re: Slight Problem with compiling
If you double click on the #pragma lines at the top of your code you will go to the Motor and Sensor setup screen. Make sure that your motors are named and not blank, do not use the names like "motorD" or "motorE", use something more descriptive like "left12vmotor".
_________________ Eric Grajales
|
| Thu Dec 04, 2008 6:30 pm |
|
 |
|
Sellers3143
Rookie
Joined: Tue Dec 02, 2008 12:40 pm Posts: 9
|
 Re: Slight Problem with compiling
Same problem just with the motors names.
|
| Thu Dec 04, 2008 6:35 pm |
|
 |
|
grajalese
Rookie
Joined: Thu Jul 10, 2008 12:30 pm Posts: 14
|
 Re: Slight Problem with compiling
In your configuration you have 2 HiTech motor controller, and 1 HiTech servo controller. Here is the code that should work...  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none) #pragma config(Motor, mtr_S1_C1_1, left12vmotor, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, right12vmotor, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_1, left_arm, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_2, right_arm, tmotorNormal, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
const int joystick_deadband = 5; const float joystick_scale_factor = 25.0 / 32.0;
int scale_joystick(int joystick_value) { int result;
// The joysticks return values between -127 and 127 // however the motor controllers for both the Hi-Tech // and Lego only accept values between -100 and +100 // This functions scales the joystick values by // multiplying the joystick output by 100/128. // result = (int) ((float) joystick_value * joystick_scale_factor);
// If the joystick value is within the deadband constant, // set the result to zero. if ((result < joystick_deadband) && (result > -joystick_deadband)) { result = 0; }
return(result); }
task main() { while (true) { getJoystickSettings(joystick); // Gets all joystick information
// Controller 1 - Tank style drive motor[left12vmotor] = scale_joystick(joystick.joy1_y1); motor[right12vmotor] = scale_joystick(joystick.joy1_y2);
// This is controller 2 telling the arm motors to go forward or backward also max speed of 50 motor[left_arm] = scale_joystick(joystick.joy2_y1)*0.5; motor[right_arm] = scale_joystick(joystick.joy2_y1)*0.5;
wait1Msec(5); } }
|  |  |  |  |
I included my scale_joystick function, remember if you use servos, they take values from 0 to 255, you can scale the joystick to use in servos by adding 128 to the joystick value. Hope this helps...
_________________ Eric Grajales
|
| Thu Dec 04, 2008 9:54 pm |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 0 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
|
|