Sunday 6 April 2014

Adventures in Arduino

Around 9 months ago I bought both a Raspberry Pi and An Arduino Micro-Controller. The Pi is a proper computer whereas the Arduino is much more simplistic, I was looking for a programming project and it would take an off-the-cuff comment after a Laser-Tag LRP event to provide inspiration. The latest sensors we use for Laser-Tag have the ability to programmed with different configurations as per each games requirements. The only way to do this in the fielt was to pre-program set configurations that could be transmitted using a device in the field, but if you wanted a different configuration to one that you had with you then you would need a PC to reprogram them, the idea was floated of a device that could do on-the-fly configurations in the field without needing a PC.

First test with LCD menu

The Arduino seemed a perfect fit for this as the Pi would seem like overkill. Initial research seemed to indicate that the Arduino would work so picking up a couple of other bits (such as an LCD screen) I set about prototyping my project on breadboard.

The hardware came together relatively quickly, the first part of the programming was implementing a menu system, I had a couple of examples of the type of thing I wanted to achieve and moslty they worked. The majority of the logic used in the code hasn't really changed since I was coding back in College (more years ago then I care to think) but there were other issues (like switch debouncing) that I hadn't anticipated but the Arduino user forums were both helpful and unhelpful in equal measure, as with most times when searching the Internet, it's not the answer that matters but how you ask the question.

Finished Prototype

Once the menu system was done my next problem was to how to transmit my parameters to the sensor, the methodology was simple, Infra-Red, but the I didn't understand the format of the data, and the fact the data also relied on a Cyclic Redundancy Check (CRC) to confirm the data just added to the problem. In the beginning I hadn't been keen on involving the designer of the system as I knew he had a lot on so I tried to only ask questions when I had to, after one such conversation, he sent me some code and he had converted his code from Assembler into C (what the Arduino uses). A few tweaks were still needed but mostly it was there, once we had the basis of transmssion we could then add in multiple parameters. Hopefully the code I'd written was scaleable and able to be expanded with future developments.

Constructing an actual prototype was relatively quick, requiring only one afternoon and a bit of a morning once I'd got my Dremel back from my dad. It's not the finished design as I'd like to mount the front switches better than I have and the circuit needs mounting better to keep it from moving where the programming socket it on the side.

 

 

No comments:

Post a Comment