
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:
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.