I'd Rather Be Building Robots

August 20, 2008

HiTechnic Prototype Board Driver

Filed under: Experiments, Sensors — Xander @ 20:57

Here’s the first release of the HiTechnic Prototype Board driver for RobotC.  It has all the basic functionality you’ll need to use it.

byte HTPBReadIO(tSensors _link, byte _mask)
Returns values of inputs specified by mask
void HTPBWriteIO(tSensors _link, byte _mask)
Writes values to outputs specified by mask
void HTPBSetupIO(tSensors _link, byte _mask)
Configure the ports for input or output according to the mask, 0 = input, 1 = output
int HTPBReadADC(tSensors _link, byte _channel, byte _width)
Read the value of the analogue channel specified. For more or less accuracy you can specify either 10 or 8 bits as the width.

You can pick up the code for version 0.2 here: LINK (Version, 0.3 available here).  This code has only been tested with RobotC 1.40 Public RC2.  The next version of the HTPB driver will allow you to change the update interval for the input values.

Protoboard and Bread Board Circuit Diagram

The demo code in it works with the breadboard setup above.  Note that it is exactly the same as on the HiTechnic Prototype Board page, apart from the LED colours. R1-R6 are 470 Ohm resistors and R7 is a 1K Ohm pot meter.  D1-D6 are standard LEDs.

How does it work?  As you turn the knob on the pot meter, you change the voltage on the analogue input.  The small IC on the proto board changes this into a digital value that is sent to the NXT.  The NXT switches the LEDs on or off, depending on the value of the analogue input.  This is all done through the same proto board.

August 19, 2008

Thanks HiTechnic!

Filed under: Experiments, Sensors — Xander @ 16:33

HiTechnic Prototype BoardThis morning the postman delivered a small package from HiTechnic, the Lego NXT Sensor folks.  Steve, one of the engineers, asked me if I would be interested in writing a RobotC driver for their Prototype Board.  I said I was, so he told me he’d send one and here it is.  I guess now I have to fulfill my end of the bargain and start producing some code!

The first thing I noticed about this board is the compactness of it.  It has 6 digital IOs and no less than 5 analogue inputs.  The board is also able to provide 3.3V, 4.3V, 5V and 9V to your project via various pins.  I was given the breadboard version (NPT1055), but there is also a version with a small solderable area (NXT1050 on which you can add your projects directly.  The breadboard version measures 25×56mm and has a 16 pin male header on its underside.  It takes a little force to push onto your breadboard. However the little leaflet that comes with it has instructions on how to do this properly so you don’t snap or bend it.  Taking it off your board requires the same kind of care. 

I am sure I am going to have a lot of fun with this board and I will keep you updated as I progress.

August 13, 2008

In (Remote) Control with the HiTechnic IR Link Sensor

Filed under: Experiments, Sensors — Xander @ 22:04

IRLink Sensor [Taken from HiTechnic.com] The HiTechnic IR Link Sensor allows you to use IR signals to communicate with the Power Functions IR receivers, the remote controllable Lego trains and the venerable RCX.

I bought myself one a few weeks ago and have been busy tinkering with it ever since.  I contacted the HiTechnic company to ask for some documentation on how this sensor worked but for various business reasons (NDAs, etc) they were unable to give me *all* the details. However, one of their engineers, Steve, was very helpful explaining how the Power Functions part worked.  The sensor has a few modes, one for each device you can control with it (NXC, PF or Train).  The idea is that the sensor’s functionality is kept as generic as possible, putting all the intelligence in the software controlling it, RobotC in my case.  Using the Lego Power Functions RC document and the detailed description of the encoding mechanism given to me by HiTechnic, I was able to cobble together a nice implementation of the Combo PWM Mode.  Once I had that completed, I also implemented the Combo Direct Mode based loosely on the NXC example code Steve had provided.  For details on the encoding scheme, I suggest you read through the code attached to the end of this post.  I have added plenty of comments throughout the code.

Power Functions Test Bed @ HiTechnic

That is a picture of what Steve used to test my driver.  That’s a pretty sweet setup if you ask me.  How it must suck to make a living working with Lego and sensors all day!  My test setup is a little less impressive looking.  I only have the PF stuff that came with the Bulldozer.  With this RobotC driver, I can control not only the direction of the motors but also the speed at which they rotate.  This is not possible with the standard PF remote which implements only the Combo Direct Mode.  Using the Combo PWM Mode I have a lot more control over the motors.  The driver can handle all 4 channels, allowing you to control up to 8 motors simultaneously.

Without further ado, here is the driver: LINK.  Future additions might include routines to control the RCX and those remote controlled trains. I will keep you posted.

Edit: Version 1.1 is out and available here.  The main task is no longer enabled by default.

Blog at WordPress.com.