When I wrote that last piece about the iButtons, yes, I’d got the iButton to display its unique serial number on the PC screen. I did this using an RS232 link to my PC using a free program called PuTTY which emulates the old ‘Hyperterminal’, not found on Windows 7.  This was no mean feat -I’d never programmed a PIC for RS232, so it was new territory all round.

Yes, the PC would display the list of numbers, but the problem was, it would only do it occasionally!Before...

By its very nature, 1-wire communications with the iButton is shaky, even at the best of times, so getting the thing to display the proper numbers consistently was something of a challenge.

In the end, I had to read seemingly thousands of pages of dry-as-a-bone documentation, both from Microchip (the makers of the PIC processor) and from Dallas Semiconductors (the makers of the iButton).

A very long and very boring story later, and very late last night, I finally cracked it.

Initially, the PC would read the correct number maybe only once in thirty button touches.  Now, it’ll do it between eight and nine times out of ten.  Okay, still not ‘production’ quality, and I’m sure I can improve it further, but you’ll agree, it’s a Big Lot better.

Up to the right here is my board.  You’ll remember the ‘flying board’ of the I2C real time clock sat there on its piece of card, attached with gaffer tape. The iButton is the red thing at the side, while the iButton reader is to the left of that, joined by its two wires....and after.

To the left here is the same board, but this is after I’d gently touched the iButton to the reader, and you can see the white LED towards the back of the board, lit to show that the button has been recognised.

I’ve also programmed it such that different iButtons will light different LED’s, while tapping an ‘unknown’ iButton illicts no response whatsoever.

So, we can safely say that this is now a ‘Job Done’.  iButtons are now recognised, and more importantly, different iButtons produce different responses, while ‘new’ iButtons, until programmed in, aren’t recognised at all.The result!

To the right here is a pretty poor picture of what the screen says when a valid iButton is touched to the reader.  Pretty neat, eh?  And yes, the black ear behind the box on the screen is that of my cat, Alfie.

And the next job, Wardo?


That’ll be the I2C non-volatile RAM I mentioned seemingly weeks ago.

With this in circuit, I’ll be able to record, using the RTCC clock for reference, just when an iButton was touched to the system, and it won’t ‘forget’ once the power is turned off.

And after that?

Ah, Dear Reader, therein lies the ‘challenge’.  After that, I plan to design and build a monitoring circuit that will measure -and record- battery usage as the unit is working.  This board will be a ‘hybrid’ board, combining both digital circuits with an analogue ‘front-end’ that will monitor the currents going both into and out of the battery, but it will also ‘time-slice’ this data into usable ‘chunks’ with an integrator.  It is this integrator that has proved most troublesome, but thanks to the excellent ‘Khan Academy‘, a free Internet maths revision site, I think I’ve got it cracked.

Tie this to iButton usage, and I’ll have a permanent record of just who was using the bike, when they were on it, and most importantly, how much juice they put into the battery.

This data could then be used as the basis for the strict rationing of the ever-popular LEAF chocolate biscuits!

No, seriously, this could have a profound effect on how we might approach possible funders, and on what basis we apply for the ever-shrinking pot of public monies.

But to be honest, I’m not thinking quite that far ahead just yet.

One problem at a time, and the current problem is the non-volatile (NV) RAM.

Then I’ll look at the challenge of power monitoring.

All clean, healthy fun.

Print Friendly