Archive for September, 2007

Arduino Joy

9 September, 2007

Now that I’ve got my Arduino module working well again I decided to get started on an old project of mine.

Ages ago I requested some samples of a 3 axis accelerometer chip from ST Microelectronics. The chip was a LIS2L02AS4, and I got sent 3 of them. I was quite awed at the fact that they managed to get a 3 axis accelerometer in such a neat package. However I received a SOP24 package, now as SMDs come, it is quite a large device with a large pin spacing.

In order to fit it into the Arduino I’d need to at least build a breakout board so I could put it into a breadboard and then use jumpers to connect this to the Arduino pins. And as the device runs from a 3V3 source it would make the most sense to include that on the breakout board. I figured that would be too complicated as the board grew to be rather large. One of the key features of the Arduino is the sockets arranged around the outside edge of the board. These allow PCBs called Shields to be inserted onto of the Arduino board and then function like a whole product. So it was set, I would make it into a board. I borrowed the Arduino NG (that’s my version) PCB Shield layout in Eagle format from here. However I made a few changes, I wasn’t using the IO8-IO13, GND and AREF pins so I made the board as small as I could so as to save PCB.

This is what I ended up with this:

Accelerometer shield for an Arduino NG

So far I’ve gone through testing the sub assemblies. The 3V3 regulator outputs around 4V, which is not ideal, but the LIS2L02AS4 hasn’t released the magic smoke yet, and doesn’t seem like it will. The RGB LED is connected up to 3 of the Arduino’s (with an ATMega 168) PWM pins. This allows me to create all colours of the rainbow. I’ve JUST finished writing the code that fades it through all colours of the rainbow. However I want to streamline it some more before I post it up onto the internet.

One common problem that kept cropping up was that as the colour got very bright, it would flash. I finally figured this has happening because the PWM values were going above 255, which causes then to just turn off. So the RGB would get very bright with one colour, then that colour would just turn off, and then it would come back as being very bright and then it would finally fade away. I solved this problem by constraining the colour variables to 250.

Another problem lay with the switch I included. I simply wanted a normally high switch that would go low when pressed. Now I figured the ATMega168’s own internal pull-up resistors were being used so I wouldn’t need to include my own. I was not correct. Which meant that when the switch was pressed the output would just float. This meant the Arduino could not see it. I solved this by simply adding a 4k7 resistor in between the IO2 and 3V3+, however I’m yet to test this.

One of the first things I tested however was the accelerometer outputs as this was the most important part of the project and I was wary of my SMD soldering. I wrote enough code to simply read the analog inputs, dump the values into variables, and then print the variables as serial data which I could pick up on a serial terminal, like the one build into the Arduino IDE. This was fairly easy and I managed to get the values back, these were “x:453 y:450 z:395.” Unfortunately I don’t quite know how these values relate to each other, and how they are scaled, however they do change as I move the board around. This suggests that the accelerometer does indeed work. I also have the “FS” pin on the LIS2L02AS4 connected to I4 I can set whether the LIS2L02AS4 will read values up to 6g or just 2g, but again, I’ve not tested this yet.

The remaining tasks seem to be essentially figure out how the raw values can be converted to quantities of g and testing the PTM switches inputs.

Aside from the accelerometer shield I’ve also found an interesting article on the Arduino: Blog, there seems to be a way to make the Arduino NG board reset automatically when you upload a program to it here. It involves soldering a o.1uF capacitor between the bottom 2 solder points near diode and the ATMega168, I’m intending on trying this out, the moment I actually have some 0.1uF capacitors.

Finally, I recived 2 packages through the post recently. One contained “The Art of Electronics – 2nd Revision” by Horowitz and Hill from Amazon. The other was a sample pack from Microchip, it contained 3 ENC28J60s. This is an Ethernet to SPI chip, I’m looking forward to experimenting with it.