|
Page 1 of 1
|
[ 8 posts ] |
|
| Author |
Message |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 HTIRL help
Hi there,
I just got my HTIRL delivered, and I've been looking through some of Xander's drivers/ programs, but I don't get it at all... Could someone post the commands to make different PF motors move (at varying speeds), and the PF lights go on/ off?
thx, DiMastero
_________________leonoverweel.com
|
| Mon Jul 19, 2010 6:01 am |
|
 |
|
Jampoz
Rookie
Joined: Sat Jan 09, 2010 12:25 pm Posts: 48 Location: Rome, Italy
|
 Re: HTIRL help
The file is HTIRL-test1.c  |  |  |  | Code: #pragma config(Sensor, S1, HTIRL, sensorLowSpeed)
#include "drivers/HTIRL-driver.h"
task main { int MotorA_cmd = 0; int MotorB_cmd = 0;
nxtDisplayCenteredTextLine(0, "HiTechnic"); nxtDisplayCenteredBigTextLine(1, "IRLink"); nxtDisplayCenteredTextLine(3, "Test 1"); nxtDisplayCenteredTextLine(5, "Connect sensor"); nxtDisplayCenteredTextLine(6, "to S1"); wait1Msec(2000); eraseDisplay(); // Test the motors and recievers. for (MotorA_cmd = 0; MotorA_cmd < 16; MotorA_cmd++) { MotorB_cmd = 15 - MotorA_cmd; // PFcomboPwmMode allows you to control the speed of the PF motors. // There are 7 forward speeds and 7 reverse speeds, brake and halt PFcomboPwmMode(HTIRL, 0, (eCPMMotorCommand)MotorB_cmd, (eCPMMotorCommand)MotorA_cmd); PFcomboPwmMode(HTIRL, 1, (eCPMMotorCommand)MotorB_cmd, (eCPMMotorCommand)MotorA_cmd); PFcomboPwmMode(HTIRL, 2, (eCPMMotorCommand)MotorB_cmd, (eCPMMotorCommand)MotorA_cmd); PFcomboPwmMode(HTIRL, 3, (eCPMMotorCommand)MotorB_cmd, (eCPMMotorCommand)MotorA_cmd); }
PlaySound(soundDownwardTones); while (bSoundActive) {}
for (MotorA_cmd = 0; MotorA_cmd < 4; MotorA_cmd++) { MotorB_cmd = 3 - MotorA_cmd; // PFcomboDirectMode does not allow speed control. The motor is either // going full speed forward or reverse. You can also brake and float the // motor. PFcomboDirectMode(HTIRL, 0, (eCDMMotorCommand)MotorB_cmd, (eCDMMotorCommand)MotorA_cmd); PFcomboDirectMode(HTIRL, 1, (eCDMMotorCommand)MotorB_cmd, (eCDMMotorCommand)MotorA_cmd); PFcomboDirectMode(HTIRL, 2, (eCDMMotorCommand)MotorB_cmd, (eCDMMotorCommand)MotorA_cmd); PFcomboDirectMode(HTIRL, 3, (eCDMMotorCommand)MotorB_cmd, (eCDMMotorCommand)MotorA_cmd); } }
|  |  |  |  |
|
| Mon Jul 19, 2010 6:52 am |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 Re: HTIRL help
thx, but I don't get which command does what, and when I copy/ paste individual commands, I get errors... Could you tell me which command does what, and which have to be combined in order to run?
thx, DiMastero
_________________leonoverweel.com
|
| Mon Jul 19, 2010 7:02 am |
|
 |
|
Jampoz
Rookie
Joined: Sat Jan 09, 2010 12:25 pm Posts: 48 Location: Rome, Italy
|
 Re: HTIRL help
Starting Pragma is the tipical RobotC sensor configuration, then there is the include of the needed drivers The commands can be found inside HTIRL-driver.h  |  |  |  | Code: CPM_MOTOR_FLOAT = 0, /*!< Float the motor */ CPM_MOTOR_FWD_PWM_1 = 1, /*!< Forward speed 1 */ CPM_MOTOR_FWD_PWM_2 = 2, /*!< Forward speed 2 */ CPM_MOTOR_FWD_PWM_3 = 3, /*!< Forward speed 3 */ CPM_MOTOR_FWD_PWM_4 = 4, /*!< Forward speed 4 */ CPM_MOTOR_FWD_PWM_5 = 5, /*!< Forward speed 5 */ CPM_MOTOR_FWD_PWM_6 = 6, /*!< Forward speed 6 */ CPM_MOTOR_FWD_PWM_7 = 7, /*!< Forward speed 7 */ CPM_MOTOR_BRAKE = 8, /*!< Brake the motor */ CPM_MOTOR_BAK_PWM_7 = 9, /*!< Reverse speed 7 */ CPM_MOTOR_BAK_PWM_6 = 10, /*!< Reverse speed 6 */ CPM_MOTOR_BAK_PWM_5 = 11, /*!< Reverse speed 5 */ CPM_MOTOR_BAK_PWM_4 = 12, /*!< Reverse speed 4 */ CPM_MOTOR_BAK_PWM_3 = 13, /*!< Reverse speed 3 */ CPM_MOTOR_BAK_PWM_2 = 14, /*!< Reverse speed 2 */ CPM_MOTOR_BAK_PWM_1 = 15 /*!< Reverse speed 1 */
|  |  |  |  |
So, for example PFcomboPwmMode(HTIRL, 2, (eCPMMotorCommand)MotorB_cmd, (eCPMMotorCommand)MotorA_cmd); This one method is telling the Ir receiver on channel 2 (means 3) to give both motors two different commands, stored one two variables, and they can include any number from the upper list But if you just plug the sensor and make some motors available, then the example will find 'em and move 'em as it scans for all channels and all commands
|
| Mon Jul 19, 2010 9:03 am |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 Re: HTIRL help
Thx... I tried it by writing this code: It didn't work, and I got error reports stating the following: **Error**:Undifined procedure 'PFcomboPwmMode'. **Error**:Undifined variable 'eCPMMotorCommand'.'short' assumed. **Error**:Unmatched left parentheses '(' **Error**:Expected-> ')'. Found 'MotorB_cmd' **Error**:Expected-> ')'. Found 'MotorB_cmd' **Error**:Expected-> ';'. Found ',' **Error**:Unexpected scanner token-> ',' **Error**:Unexpected scanner token-> '(' **Error**:Expecting ';' before ')' **Error**:Unexpected scanner token-> ')' *Warning*:Meaningless statement -- no code generated
_________________leonoverweel.com
|
| Mon Jul 19, 2010 9:22 am |
|
 |
|
Jampoz
Rookie
Joined: Sat Jan 09, 2010 12:25 pm Posts: 48 Location: Rome, Italy
|
 Re: HTIRL help
See? check the first error line, it can't find PFcomboPwmMode, that's because you didn't include the drivers, try including the needed .h file like the code above
|
| Mon Jul 19, 2010 9:24 am |
|
 |
|
Jampoz
Rookie
Joined: Sat Jan 09, 2010 12:25 pm Posts: 48 Location: Rome, Italy
|
 Re: HTIRL help
You need to follow these instructions when using Xander's drivers That's because including .h files is essential
|
| Mon Jul 19, 2010 9:26 am |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 Re: HTIRL help
What do you mean by including the drivers and .h files? And how should I do that? (I already installed the drivers on your link a few weeks ago)
thx, DiMastero
EDIT: NEVER MIND; I FOUND THE ANSWER BEING A PIECE OF CODE (HOW STUPID OF ME NOT TO NOTICE IT IN THE BEGINNING!!) THANK YOU
_________________leonoverweel.com
|
| Mon Jul 19, 2010 9:33 am |
|
|
|
Page 1 of 1
|
[ 8 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
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
|
|