|
Page 1 of 1
|
[ 15 posts ] |
|
HiTechnic IR Link Sensor and RobotC
| Author |
Message |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2861 Location: Rotterdam, The Netherlands
|
 HiTechnic IR Link Sensor and RobotC
Hey there,
Has anyone played with the HiTechnic IR Link Sensor? Does anyone have any documentation on how to make this thing work in RobotC?
Thanks,
Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Wed Jul 23, 2008 12:03 pm |
|
 |
|
Abbeyjean
Rookie
Joined: Thu Jun 26, 2008 11:27 am Posts: 21 Location: Johannesburg, South Africa
|
Hi
Here is a link ( http://www.robotc.net/forums/viewtopic.php?t=379) to a previous post with some info on the HiTechnic Link Sensor.
According to this 'JustAnotherNXTHacker' got it to work but never posted the final working version. Perhaps he could be persuaded to do so.
I am also interested in this as I have this very day ordered said sensor.
|
| Fri Jul 25, 2008 3:40 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2861 Location: Rotterdam, The Netherlands
|
I am currently working on writing a driver for the IR Link. I was provided with some of the details on the bit encoding scheme used to generate that massive byte array in the code of that post you linked. With that information I will start working on an easy to use interface. Once it's completed I will work on the other modes that the PF motors can be controlled (there are 4 modes in all). The driver will be released for sure, so keep an eye on this post! I will be releasing the driver in chunks as each mode is completed, so you won't have to wait until it is all done.
Regards,
Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Fri Jul 25, 2008 3:50 am |
|
 |
|
nxt
Rookie
Joined: Sat Apr 12, 2008 11:09 am Posts: 44 Location: holland
|
Helo,
I have the basic commands working on channel 1 and 2, but i can not find any logic in it.
Hi-technics told me there is not a simple way to program using the PF-data sheet.
I will post my program later
|
| Mon Aug 04, 2008 5:05 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2861 Location: Rotterdam, The Netherlands
|
Hiya NXT,
Yeah, I have the comboDirectMode working nicely. I am now working on comboPwmMode but I still have a few bugs to iron out. Will keep you posted with my progress.
Regards,
Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Mon Aug 04, 2008 11:02 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2861 Location: Rotterdam, The Netherlands
|
 Re: HiTechnic IR Link Sensor and RobotC
I have a working version of the driver posted on my blog, you can read the article here: LINK. The link to the code is at the bottom of the page. Enjoy. Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Thu Aug 14, 2008 2:21 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: HiTechnic IR Link Sensor and RobotC
hi, great if you'll manage to write a convenient driver for the IR-link sensor. To this I have some suggestions: for 1 nxt motor you use with other C libraries you maybe will use for the same purpose if you got 4 RCX's (0,1,2,3) and a motor at RCX[3] -Port 0 (A) via IR-Link , there could be a motor command (RCXmotor) like: at RCX(1), but Port 2 (C), and backwards:: 3 motors (0,1,2) with built-in IR-receivers (power motors), could work this way: and with 5 train motors this way: If you'll manage this, that would be one giant leap for mankind... 
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
Last edited by Ford Prefect on Thu Aug 14, 2008 5:34 pm, edited 1 time in total.
|
| Thu Aug 14, 2008 2:54 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2861 Location: Rotterdam, The Netherlands
|
 Re: HiTechnic IR Link Sensor and RobotC
Ford, Those are some nice suggestions. I will definately look into them! They'll be added as wrappers around my base functions. There would have to be some kind of task that monitors these variables. As for speeds, there are only 7 steps, excluding brake and coast. It is not a 0-100 variable like with the normal motors. I'll have to figure something out for that  Regards, Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Thu Aug 14, 2008 3:39 pm |
|
 |
|
Parax
Rookie
Joined: Sun Dec 02, 2007 5:29 pm Posts: 1
|
 Re: HiTechnic IR Link Sensor and RobotC
And just to expand on the knowledge, My cobbled together ComboPWM Driver is here: http://www.brickshelf.com/gallery/Parax/NXTSample/RobotC/pwm_0-1-6.c (with comments!) But if your good at reading code or like a challenge try this More to come. maybe. Parax.
|
| Thu Aug 14, 2008 4:18 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: HiTechnic IR Link Sensor and RobotC
hello, I didn't know that - but I think 7 steps should be enough! but BTW, there could be another sophisticated thing be done: simultaneously reading of the values of a rcx rotation sensor attached to the related motor (RCX-motorA /RCX-sensor1 ....) 
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Thu Aug 14, 2008 5:28 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2861 Location: Rotterdam, The Netherlands
|
 Re: HiTechnic IR Link Sensor and RobotC
Ford,
No RobotC driver for RCX has been made yet. I will need one to test with first.
Regards, Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Fri Aug 15, 2008 1:04 am |
|
 |
|
nxt
Rookie
Joined: Sat Apr 12, 2008 11:09 am Posts: 44 Location: holland
|
 Re: HiTechnic IR Link Sensor and RobotC
Hello, I copied some code of Parax and made an include file of it, so you can easy use PFcomboPWM within the program by calling one procedure. here is some sample code of how to do that Call the PFComboPWM procedure each time when you want to change a speed and for all four channels. speed value 1 to 7 for forward, speed value -1 to -7 far reverse, speed value 0= float speed values outside -7 to +7 = brake. here is the include file  |  |  |  | Code: /* include program for RobotC-HTLink-Power Function PWM Mode Version: 1.0 Date: 26/08/08 Author: Gerrit Boomsma Contact: Usage: give easy use for PFmotors in RobotC userprograms ******************************************************************************************* COPYED code from Mike Hatton and added code to it to easy use it in user programs. /* RobotC-HTLink-Power Function PWM Mode Version: 0.1.6 Date: 14/08/08 Author: Mike Hatton Contact: Parax77ATgooglemailDOTCom Usage: *********************************************************************/
int i; int sensorport=0; int index1=0,index2=0; int array[4][2]; #pragma autoStartTasks
byte PFB[17];
int speedvalue(byte speed)//convert selected speed to speed for PFmotor { if (speed==0)//if selected speed is 0, motor will float { return 0; } else if (speed>0&&speed<8)//motor runs forward at selected speed 1 to 7 { return speed; } else if (speed<0&&speed>-8)//motor runs reverse at selected speed -1 to -7 { return speed+16; } return 8; //if speed selected other than -7 to +7, motor will brake. }
// put selected speeds in an array. void PFComboPWM(const tSensors sensorport,byte Channel, byte OutX, byte OutY) { array[Channel-1][0]=OutX; array[Channel-1][1]=OutY; }
// send data to PF receiver. Most code copyed from Mike Hattom void sendIR(const tSensors sensorport,byte chan, byte OutX, byte OutY) { nI2CBytesReady[sensorport] = 0; byte PFBi = 0; //PFByte Counter byte PFBBi = 0; //PFByte Bit Counter byte N[4]; //Nibble Array byte Ni = 0; //Nibble Counter byte NBi = 0; //Nibble Bit Counter //Clear PFB[] Array for (PFBi = 0; PFBi < 17; PFBi++) { PFB[PFBi] = 0x00; } PFBi = 0; //Populate Nibbles N[0] = 0x4+chan; //PWM Mode + (0-3) N[1] = speedvalue(OutX); //(0-15) N[2] = speedvalue(OutY); //(0-15) N[3] = 0xF; //XOR CRC N[3] = N[3]^N[0]^N[1]^N[2];//XOR CRC //Write PFB[0-3] (Fixed) PFB[0] = 16; //PFByte Length PFB[1] = 0x02; //Sensor Address PFB[2] = 0x42; //Write to Address PFB[3] = 0x80; //Start Bit //Write PFB[4-13] From Nibbles for (Ni = 0 ; Ni < 4 ; Ni++)//For Nibble 1 to 4 { for (NBi = 0 ; NBi < 4 ; NBi++)//For Nibble Bit = 1 to 4 { PFB[4+(PFBBi/8)] = PFB[4+(PFBBi/8)]|(0x80>>(PFBBi%8)); if (N[Ni]&(0x8>>NBi)) { PFBBi = PFBBi + 5; // add High = 5 } else { PFBBi = PFBBi + 3; //add Low = 3 } //Next NibBit } //Next Nibble } PFB[4+(PFBBi/8)] = PFB[4+(PFBBi/8)]|(0x80>>(PFBBi%8)); PFB[14] = 0x11; //Length PFB[15] = 0x02; //PF Mode PFB[16] = 0x01; //Xmit for (i=0; i<4; i++) { while (nI2CStatus[sensorport] == STAT_COMM_PENDING) {} sendI2CMsg(sensorport, PFB[0], 0); // Send PFBytes } } task xmit() { // initialising SensorType[S1] = sensorI2CCustom9V; nI2CBytesReady[S1] = 0; // clearing the array for (index1=0; index1<5;index1++) { for (index2=0; index2<3;index2++) array[index1][index2] = 0; } int xmitchannel=0,xmitblue=0,xmitred=0; while(1) { xmitblue=array[xmitchannel][0]; //load blue motor speed xmitred= array[xmitchannel][1]; //load red motor speed sendIR(sensorport,xmitchannel,xmitblue,xmitred);//send param to conversion code
xmitchannel++; //swapp channels 1-4 if(xmitchannel>3) xmitchannel=0; wait1Msec(20); } }
|  |  |  |  |
Anyone who can improve this code or who can make some kind of driver from it?
|
| Wed Aug 27, 2008 11:14 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2861 Location: Rotterdam, The Netherlands
|
 Re: HiTechnic IR Link Sensor and RobotC
Version 1.1 of my driver is out now. The only thing that has changed is that the code no longer has a main task without being explicitly enabled with a define at the top of the file. This stops it from causing issues when used as an include  Edit: you can download it here. Regards, Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Wed Aug 27, 2008 11:17 am |
|
 |
|
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 298 Location: San Diego, California. USA
|
 Re: HiTechnic IR Link Sensor and RobotC
Great Work  You may also want to post your code under the projects section, so others could find it in the future. Scott B-)
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
| Wed Aug 27, 2008 4:26 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
 Re: HiTechnic IR Link Sensor and RobotC
whow, man, this is really sophisticated: 
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Wed Aug 27, 2008 4:45 pm |
|
|
|
Page 1 of 1
|
[ 15 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 5 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
|
|