I'd Rather Be Building Robots

May 31, 2009

Released: RobotC Driver Suite RC3

Filed under: RobotC Drivers, Sensors — Xander @ 16:28

A new version of the RobotC Driver Suite has been released.  Two new drivers were added and some improvements were made in the I2C bus error handling.

Changelog:
  • NEW: Added driver for AT24C512 EEPROM chip.
  • NEW: Added Light Sensor driver with calibration!  You can use one of the test programs to calibrate for both white and black.  Calibration data is saved to a file which is read when the driver is first used. You can also use the API to write your own calibration program.
  • I2C bus error handling code added to common.h.  When an error occurs, the bus is now flooded with 5 dummy I2C packets.  This usually clears it up.  The original packet is then retransmitted. Note that this is done only once for each packet.
  • HTPB driver has error checking removed, this is now handled by common.h
  • The drivers will generate an error when compiled with a RobotC less than 1.46.
TODO:
  • Add Mindsensors Line Leader driver, waiting for firmware API to stabilise
  • 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].

May 21, 2009

Control the world with the HiTechnic IR Link

Filed under: Sensors, Tutorials — Xander @ 20:53

IRLink Sensor The HiTechnic IR Link is capable of many things including controlling your Power Function devices.  The one thing you couldn’t do was transmit regular data.  That is, until now. 

The IR Link has several transmission modes, 0×02 for example is used for the PF functionality.  There is another mode 0×00, UART-mode, which can be used to transmit 8 bytes at a time at 2400 baud using a 38KHz carrier frequency.  It is also the mode that can be used for communicating with the RCX.

There are two ways you can use the IR Link to transmit your data.  The first method which can be used to send the same 8 bytes over and over again works by preloading the transmit buffer at 0×45 with the 8 bytes you wish to send, followed by the total message length (0×08) and the transmission mode to be used (0×00).  You can then trigger the IR Link to start transmitting by setting register 0×4F to 1 with another I2C message.  Care must be taken not to trigger a retransmission before the previous one is done or you’ll garble the currently transmitting message as it will immediately start transmitting from the first byte again.

If you don’t want to send just 8 bytes over and over again, you can also load up the transmit register at 0×45, followed by the message length (0×08), transmission mode (0×00) and the trigger (0×01). 

Due to the nature of UART-mode, the bytes are transmitted UART-style with odd parity.  That means that when you tell the sensor to transmit 0xAB (b10101011), the following is transmitted via IR:

Start B0 B1 B2 B3 B4 B5 B6 B7 Par Stop
1 0 0 1 0 1 0 1 0 0 0

Each data byte is preceded by a start bit which is always set to 1, then follows bits 0 through 7 of your data (least significant bit first), inverted (0 becomes 1, 1 becomes 0), the odd parity value and then a stop bit which is always 0.  Sounds complicated?  I agree, it took several edits of this blog entry to get this right!

For each bit set to 1, the IR Link’s transmitter goes high for 1/2400th of a second or about 0.42ms, that means that 2 consecutive bits set to 1 will mean an IR burst of a little more than 0.83ms. 

There is a gotcha with the IR Link’s transmission buffer;  its start register is counted backwards from 0×4D. That means that if you have an 8 byte message to send, the first data byte starts at 0×4D-0×08 = 0×45. So if you want to transmit the above sequence, you’ll have setup the IR Link’s buffer such that it looks like this:

Reg 0×45 0×46 0×47 0×48 0×49 0×4A 0×4B 0×4C 0×4D 0×4E 0×4F
Data 0xCC 0×76 0×66 0xFF 0xCC 0×00 0xAB 0xAA 0×08 0×00 0×01

Where:
0×4D is the number of bytes to be transmitted
0×4E is the transmission mode
0X4F is the transmission trigger
You will nee to skip the transmission trigger (0×4F) if all you want to do is preload the transmission buffers. 

Please note that there is no way for the IR Link to know if transmission was successful.  An easy way to check if your IR Link is sending *any* IR signals is to point it at a digital camera and look through the viewfinder.  The IR light should appear as a dot the small screen on the front of the sensor.  Most digital cameras are extremely sensitive to IR light.  This is also a good way to check if your TV remote is still working!

I’ve included two NXC programs, one which transmits the same message over and over again as fast as possible, the other sends a single message every 50ms.

IR Beacon: [LINK] Generates 1200Hz IR signal, can be used with IR Seeker V2
IR Messenger: [LINK]

The functionality to send messages via IR will be included in the next release of the 3rd Party RobotC Driver Suite, so I didn’t include any here.

May 15, 2009

New revamped RobotC Drivers project page

Filed under: Ramblings, RobotC Drivers — Xander @ 12:55

After a couple of hours of fiddling with HTML in Notepad, I’m proud to present the new and improved project page for the 3rd Party RobotC Driver project.  I’ll add more to it as time goes by.  For your tree killing pleasure, I’ve also added a PDF version of the documentation so you can print it out more easily.

You can now also donate to this project by clicking on the link at the bottom of that page.  Proceeds will be used to buy an additional NXT set to help with driver development.

Enjoy!

May 14, 2009

RobotC Tutorial

Filed under: Tutorials — Xander @ 18:06

As great as RobotC is, the one thing that its users have consistently complained about is the lack of good tutorials that go beyond the simple “move motorA at 20% speed”.  Well, rather than waiting for the CMU Robotics Academy to come up with one, Albert Schueller, one of the professors from Whitman College, has written an excellent course called “Programming with Robots” based on RobotC.

It covers all the bases, variables, conditionals, loops and arrays, you name it.  Each new concept is accompanied by example code and every chapter ends with a series of exercises that you can use to test if you have grasped the new concepts covered thus far.

You can download this course as a PDF file here: [LINK].

May 8, 2009

Released: RobotC Driver Suite rc2

Filed under: RobotC Drivers, Sensors — Xander @ 18:18

A new release of the drivers has been uploaded.  No code changes but the minimum requirement has gone from RobotC 1.40 to 1.46 after problems were reported with some of the drivers.

RobotC 1.46 can be downloaded from the following location: [LINK].  There is also a 1.47B available, which can be downloaded here: [LINK].

The drivers’ Source Forge project page is here: [LINK]. The documentation can be found here: [LINK].

Xander.

May 5, 2009

Luau!

Filed under: Ramblings — Xander @ 21:15

This made me laugh out loud for real.  I think I’ve played about 10 times now and I am still not sick of it.  The Swedish one is the best.

Blog at WordPress.com.