View unanswered posts | View active topics It is currently Fri Aug 01, 2014 3:15 am






This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Released: RobotC Driver Suite RC5 
Author Message
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Released: RobotC Driver Suite RC5
Hey everyone,

Some minor changes in this version and some bug fixes.

Changelog:
HTDIR-test1.c (0.2)
  • Partial rewrite by Dick Swan, waits a little longer for sensor initialisation
  • Nicer intro screen
  • Less screen flickering, only updated if there's been a change in data.

common.h: (0.3.2)
  • makes use of the new alpha's built-in clearI2CBus(). It is still defined for the older firmwares

MSLL-driver.h: (0.5)
  • Bug in LLreadSteering() fixed

HTPB-driver.h: (0.7)
  • Fixed a couple of function calls that had not been renamed.

TODO:
  • Add UART (RCX) functionality to HiTechnic IR Link driver.

The drivers’ website is here: [LINK]. The documentation can be found here: [LINK]. You can download the software from the Source Forge page here: [LINK].

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


Tue Jun 23, 2009 2:24 pm
Profile WWW
Rookie
User avatar

Joined: Fri May 30, 2008 2:08 pm
Posts: 5
Post Re: Released: ROBOTC Driver Suite RC5
Hello Xander,

First, I would like give my compliments for your great work on these drivers! I've been playing a lot with your driver for the HT IR Link Sensor and I made some changes in the original driver to make it to support the other PF modes like the Single Output PWM Mode.

I was also trying to add support for the RC Trains, sets 7898 & 7897, but had no luck. The main problem is the lack of documentation for the RC Protocol. The only good source that I could find was this one from Ralph Hempel, the creator of pbForth & pbLua.

There he says that the RC protocol is:

Quote:
Controlling the RC Train Motor
As easy as it was to get the Power Factor motors running with pbLua, the RC Train is even easier. You still need the nxt.EncodeIR() function, except this time we're using Mode 1 instead of Mode 2.

The data parameter is still decoded in nibbles as follows:
RC Channel - ranges from 1 to 3
Command - StepFWD (0) StepREV(1) Stop(2)
Toggle - Alternate between 0 and any non-0 value


So, I created this piece of code based on protocol above (you might recognize most of this code ;) ):

Code:
// same as addI2CHead
inline void addI2CHeadRC(tByteArray &data) {
  data.arr[0] = 16;    // Total msg length
  data.arr[1] = 0x02;  // I2C device address
  data.arr[2] = 0x42;  // Internal register
}

// uses mode 0x01 instead of 0x02 (PF Mode)
inline void addI2CTailRC(tByteArray &data) {
  data.arr[BUF_HEADSIZE + BUF_DATASIZE] = 11;         // Total IR command length
  data.arr[BUF_HEADSIZE + BUF_DATASIZE + 1] = 0x01;   // IRLink mode 0x01 is RC Train
  data.arr[BUF_HEADSIZE + BUF_DATASIZE + 2] = 0x01;   // Start transmitting
}


void IRTrain(tSensors link, int &toggle, int channel, int output) {
  tByteArray _iBuffer;
  tByteArray _oBuffer;

  // Clear the input buffer before we start filling it
  memset(_iBuffer, 0, sizeof(tByteArray));
  memset(_oBuffer, 0, sizeof(tByteArray));

  // This is the unencoded command for the IR receiver
  _iBuffer.arr[0] = channel << 4 + output;
  _iBuffer.arr[1] = toggle << 4 +
                    (0xF ^ channel ^ output ^ toggle);

  // update the toggle bit
  toggle = (toggle) ? 0 : 1;

  // Setup the header of the I2C packet
  addI2CHeadRC(_oBuffer);

  // Generate the data payload
  encodeBuffer(_iBuffer, _oBuffer);                       // Encode PF command

  // Setup the tail end of the packet
  addI2CTailRC(_oBuffer);
  //_oBuffer[3] = 0x80;

  transmitIR(link, _oBuffer, channel, 4);
}


Do you have any info about the RC Protocol or can you see anything wrong in my code?

Regards,

Ildefonso.


Sat Jul 25, 2009 9:31 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: Released: ROBOTC Driver Suite RC5
Hiya Ildefonso,

I am glad you like the drivers and extending them with your own functionality. I am not familiar with the IR Train protocol but I do have a PDF that I picked up from a site that I've found invaluable: http://itlug.8421.info/itlug_docs/LEGO_ ... ons_RC.pdf . It only describes the PF stuff, not the IR train.

I can't see anything obviously wrong with your code but did you try running your input buffer through the debugIR function? It prints out a nice binary representation of your buffer. Maybe you are not getting the input buffer stuff right. Like I said, I don't have any experience with the IR train as I don't own one.

I didn't implement the other PF modes as I didn't see when I would use them over ComboPWM or ComboDirect. How were you planning to use these other modes?

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


Sat Jul 25, 2009 1:42 pm
Profile WWW
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 3 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.