View unanswered posts | View active topics It is currently Sun Sep 21, 2014 2:13 pm






Reply to topic  [ 6 posts ] 
Hitechnic IR link questions 
Author Message
Rookie

Joined: Mon Jun 11, 2012 9:28 pm
Posts: 37
Post Hitechnic IR link questions
Hello again,
I have some questions about using the hitechnic IR link with the driver suite.
I have looked at the sample program and it is very helpful, however...
1. I am not sure how to choose which channel of the PF system I will be controlling.
2. There appear to be a few different modes I can use... Which one is the best/simplest?
3. Slightly unrelated... what is the best way to ensure the servo motor always runs at a specific speed, e.g. 1 rotation every 2 seconds? Is there a nice function for it or shall I make my own proportional algorithm?

Many thanks,
sqiddster


Tue Jun 12, 2012 5:27 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Hitechnic IR link questions
sqiddster wrote:
Hello again,
I have some questions about using the hitechnic IR link with the driver suite.
I have looked at the sample program and it is very helpful, however...
1. I am not sure how to choose which channel of the PF system I will be controlling.
2. There appear to be a few different modes I can use... Which one is the best/simplest?
3. Slightly unrelated... what is the best way to ensure the servo motor always runs at a specific speed, e.g. 1 rotation every 2 seconds?

Many thanks,
sqiddster


1. That varies depending on which mode your using.
2. There is no "best" per se, but the simplest is probably the "PFMotor" command, used in my Bucket 'o' Bricks LEGO brick sorter.

Here's a rundown of the commands:
Code:
PFcomboDirectMode(tSensors link, int channel, eCDMMotorCommand _motorB, eCDMMotorCommand _motorA);//This is used to run both motors in a
//bang-bang configuration when they're
//within the line-of-site of the IRLink.  tSensors link is the port of the IRLink (S1-S4), channel is one of the four IR channels (0-3),
//and the eCDMMotorCommands are these:
//CDM_MOTOR_FLOAT = 0,      /*!< Float the motor */
//CDM_MOTOR_FWD = 1,        /*!< Forward */
//CDM_MOTOR_BAK = 2,        /*!< Reverse */
//CDM_MOTOR_BRAKE = 3       /*!< Brake the motor */
PFcomboPwmMode(tSensors link, int channel, ePWMMotorCommand _motorB, ePWMMotorCommand _motorA);//This is the same as the one above, except the
//motors continues running without having to receive messages, and it allows speed control.  The speed commands are:
//MOTOR_FLOAT = 0,      /*!< Float the motor */
//MOTOR_FWD_PWM_1 = 1,  /*!< Forward speed 1 */
//MOTOR_FWD_PWM_2 = 2,  /*!< Forward speed 2 */
//MOTOR_FWD_PWM_3 = 3,  /*!< Forward speed 3 */
//MOTOR_FWD_PWM_4 = 4,  /*!< Forward speed 4 */
//MOTOR_FWD_PWM_5 = 5,  /*!< Forward speed 5 */
//MOTOR_FWD_PWM_6 = 6,  /*!< Forward speed 6 */
//MOTOR_FWD_PWM_7 = 7,  /*!< Forward speed 7 */
//MOTOR_BRAKE = 8,      /*!< Brake the motor */
//MOTOR_REV_PWM_7 = 9,  /*!< Reverse speed 7 */
//MOTOR_REV_PWM_6 = 10, /*!< Reverse speed 6 */
//MOTOR_REV_PWM_5 = 11, /*!< Reverse speed 5 */
//MOTOR_REV_PWM_4 = 12, /*!< Reverse speed 4 */
//MOTOR_REV_PWM_3 = 13, /*!< Reverse speed 3 */
//MOTOR_REV_PWM_2 = 14, /*!< Reverse speed 2 */
//MOTOR_REV_PWM_1 = 15  /*!< Reverse speed 1 */
PFMotor(tPFmotor pfmotor, ePWMMotorCommand _motorCmd);//The last (and simplest, IMHO) command.  Simply identify the motor using one of these:
//pfmotor_S1_C1_A = 0,  /*!< Motor A, Channel 1, IR Link connected to S1 */
//pfmotor_S1_C1_B,      /*!< Motor B, Channel 1, IR Link connected to S1 */
//pfmotor_S1_C2_A,      /*!< Motor A, Channel 2, IR Link connected to S1 */
//pfmotor_S1_C2_B,      /*!< Motor B, Channel 2, IR Link connected to S1 */
//pfmotor_S1_C3_A,      /*!< Motor A, Channel 3, IR Link connected to S1 */
//pfmotor_S1_C3_B,      /*!< Motor B, Channel 3, IR Link connected to S1 */
//pfmotor_S1_C4_A,      /*!< Motor A, Channel 4, IR Link connected to S1 */
//pfmotor_S1_C4_B,      /*!< Motor B, Channel 4, IR Link connected to S1 */
//pfmotor_S2_C1_A,      /*!< Motor A, Channel 1, IR Link connected to S2 */
//pfmotor_S2_C1_B,      /*!< Motor B, Channel 1, IR Link connected to S2 */
//pfmotor_S2_C2_A,      /*!< Motor A, Channel 2, IR Link connected to S2 */
//pfmotor_S2_C2_B,      /*!< Motor B, Channel 2, IR Link connected to S2 */
//pfmotor_S2_C3_A,      /*!< Motor A, Channel 3, IR Link connected to S2 */
//pfmotor_S2_C3_B,      /*!< Motor B, Channel 3, IR Link connected to S2 */
//pfmotor_S2_C4_A,      /*!< Motor A, Channel 4, IR Link connected to S2 */
//pfmotor_S2_C4_B,      /*!< Motor B, Channel 4, IR Link connected to S2 */
//pfmotor_S3_C1_A,      /*!< Motor A, Channel 1, IR Link connected to S3 */
//pfmotor_S3_C1_B,      /*!< Motor B, Channel 1, IR Link connected to S3 */
//pfmotor_S3_C2_A,      /*!< Motor A, Channel 2, IR Link connected to S3 */
//pfmotor_S3_C2_B,      /*!< Motor B, Channel 2, IR Link connected to S3 */
//pfmotor_S3_C3_A,      /*!< Motor A, Channel 3, IR Link connected to S3 */
//pfmotor_S3_C3_B,      /*!< Motor B, Channel 3, IR Link connected to S3 */
//pfmotor_S3_C4_A,      /*!< Motor A, Channel 4, IR Link connected to S3 */
//pfmotor_S3_C4_B,      /*!< Motor B, Channel 4, IR Link connected to S3 */
//pfmotor_S4_C1_A,      /*!< Motor A, Channel 1, IR Link connected to S4 */
//pfmotor_S4_C1_B,      /*!< Motor B, Channel 1, IR Link connected to S4 */
//pfmotor_S4_C2_A,      /*!< Motor A, Channel 2, IR Link connected to S4 */
//pfmotor_S4_C2_B,      /*!< Motor B, Channel 2, IR Link connected to S4 */
//pfmotor_S4_C3_A,      /*!< Motor A, Channel 3, IR Link connected to S4 */
//pfmotor_S4_C3_B,      /*!< Motor B, Channel 3, IR Link connected to S4 */
//pfmotor_S4_C4_A,      /*!< Motor A, Channel 4, IR Link connected to S4 */
//pfmotor_S4_C4_B,      /*!< Motor B, Channel 4, IR Link connected to S4 *///And then use the above PWM commands to control the speed.  It also
//continues moving without continuos IR messages.  It only controls one motor at a time.

Whew! That was a lot of typing! (kidding. That was a lot of copying/pasting).

3. If by "servo motor" you mean the PF motors (they're just plain old motors, not servo motors), there isn't really a way to do that with the IRLink. You can get it close, but not always at the same speed. That requires a computer reading a encoder attached to the motor, and depending on that feedback it can adjust the speed to cope with any forces applied to the motor. That's the system that RobotC uses for the NXT motors.

P.S. (for anyone who likes weird facts) My post count is now at exactly 8-bits if you start counting at 1! :mrgreen:

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Tue Jun 12, 2012 6:01 pm
Profile WWW
Rookie

Joined: Mon Jun 11, 2012 9:28 pm
Posts: 37
Post Re: Hitechnic IR link questions
NeXT-Generation wrote:


snip



Thanks! That's quite the list of commands, I'll look into that!

When I said 'servo motor', I was indeed referring to an NXT servo motor. The question wasn't really related to my previous ones, I should have made that more clear, sorry.

Also, I am OK with 'roughly' one every two seconds. No need for atomic precision ;)

Great community here!

EDIT: I had a look at your color sorter program (very cool bot BTW) and I tried to recreate some code for my own means. However I get an assortment of errors when I try this:

Code:

#pragma config(Sensor, S1,     HTIRL,          sensorI2CCustom)

//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

tPFmotor claw1 = pfmotor_S1_C1_A;

ePWMMotorCommand claw1grab = MOTOR_FWD_PWM_4;
ePWMMotorCommand claw1release = MOTOR_REV_PWM_4;

// some code here, task main blah blah

PFMotor(claw1, claw1grab);


Tue Jun 12, 2012 6:22 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Hitechnic IR link questions
Did you include the driver? Xander's 3rd party RobotC driver is what those commands are from. I've attached the appropriate header file. Place it in RobotC's "includes" folder, and put this line of code after your #pragmas.
Code:
#include "HTIRL-driver.h";


Attachments:
HTIRL-driver.h [16.09 KiB]
Downloaded 139 times

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.
Tue Jun 12, 2012 9:53 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3223
Location: Rotterdam, The Netherlands
Post Re: Hitechnic IR link questions
I'd rather you didn't post loose files from my suite, they'll end up being out of date and also missing some prerequisites (like common.h). It is better to post the link to where you can download them. (see my signature).

The PFMotor() API was made so you wouldn't have to worry about modes and things. It operates pretty much the same way as the normal way you control an NXT motor.

The different modes exist to allow you either:
  1. Continuously (every second or so) tell the motor to keep moving at speed X
  2. Tell the motor once to move at speed X and it will run until the batteries are dead or until you tell it to stop

Obviously the first one is great because if your robot should stop transmitting, the motors will stop after a second or so. The second one is great if you don't want to continuously send updates.

There are other modes too but I didn't think they were all that useful, so I didn't implement them. If you're feeling so inclined, you can check out the PDF with technical details here: [LINK].

- 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]


Wed Jun 13, 2012 1:26 am
Profile WWW
Rookie

Joined: Mon Jun 11, 2012 9:28 pm
Posts: 37
Post Re: Hitechnic IR link questions
I forgot to #include... Wow... noobish mistake!
Thanks Xander, that makes it a bit easier to understand.

I'll give it another try this afternoon!

EDIT: still not sure if there is a function to make an NXT motor go at a constant rate in terms of revolutions per second. I have a fair idea of how to do this manually however I want to make sure I'm not missing a simple way to do it.


Wed Jun 13, 2012 6:25 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.