
|
|
This is the driver board for the Cylon Eye project, which includes an accelerometer for leveling purposes. Originally I started this project as something silly with no pratical purpose, but it has morphed into a fairly useful project. There are three functions of the Cylon Eye when using this board:
That's right. The silly zombie/Cylon/Rainbow lighting effects that originally drove this project has now become a clearance light for your pin-box so that you don't run into it at night. I came up with the idea of calling the Cylon effect a clearance light after seeing another camper put a green light into a 5 gallon bucket hanging on their pin box... I immediately came to the conclusion "of course", it's a clearance light so you don't run into it at night. So this project is now 100% legitimate, even though the clearance light pattern might be overdoing it a bit.
The driver board includes a 5V power supply, an Atmel ATTiny85 microcontroller that controls the LED strip, a rotary switch that provides mode selection, and an accelerometer module. The power supply itself is capable of around 1A, which is sufficient to power the 9 LEDs of the Cylon Eye LED strip. Even then, you should try to limit the distance between the Cylon Eye and driver board to 9ft or less.
The on-board rotary switch programs a voltage that is read by the ATTiny85 via one of it's analog ports, which is analyzed by an analog-to-digital converter to determine the mode. The programmed modes will provide the following functions:
While only one axis is used, the accelerometer is 3 axis for a couple of reasons. First, the cost of a 1 axis vs 3 axis accelerometer these days is nil, and in fact, it is almost impossible to find the 1 axis version. Second, the 3 axis capability allows you to mount the circuit board in the RV virtually anywhere, simply chosing the appropriate axis.
Once the mounting configuration is known, a shorting block needs to be placed over the appropriate X, Y, or Z Axis (note: Only one Axis will be shorted at a time). This provides the proper output from the accelerometer to the ATTiny85 microcontroller. The Accelerometer should have the X, Y, and Z axis mapped out on the circuit board, so use that drawing to determine which axis must be made active. In addition, there is a Tilt function that needs to be determined. The Tilt direction is determined by a second shorting block. Note that there will always be one shorting block on one of the axis pins, but the Tilt function may or may not have a shorting block.
The Tilt mode determines which direction the LEDs move when the RV is not at the level and center point. When the Tilt pins are shorted with a shorting block, the mode will be in one configuration, and when the pins are un-shorted (shorting block removed), the mode will be in the second configuration. So which configuration is which - it is impossible to determine until you install everything. The tilt direction is primarily dependant on two things:
For example, if you mount the accelerometer circuit board upright or upside down, the tilt direction will be the opposite. Similarly, if you mount the Cylon Eye so that LED1 is to the left, the tilt direction will be opposite of mounting the Eye so that LED1 is to the right.
Also, depending on if you want the Cylon Eye to act like a spirit level or a 5th wheel hitch ball level, the tilt mode will again be the opposite. So instead of trying to figure things out, simply determine if you need to short the Tilt mode after everything is working (note, changing the tilt mode orientation will typically require re-calibrating the accelerometer).
Several accelerometers were tested during the design phase of the Circuit Board. I purchased three different versions:
After extensive testing, all three accelerometers performed adequately, however the sensitivity was just a bit different between the three. However, since they are all based on the Analog Devices 335/337 accelerometer, I have to think this was due to mfg tolerances.
Perhaps the most significant difference between the three devices is the layout of the board. The Adafruit accelerometer has a different pin-out than the other two. However, I did put both pin-outs on the Circuit board so you can build the project using any of the three accelerometers. Sensitivity: Generally the maximum sensitivity is shown in the chart above, however, you can increase the sensitivity a bit by using the "MAP" command in the software (this will be discussed during the programming phase). You can also detune the sensitivity if you wish - again discussed in the programming phase).
The output of the Accelerometer, whether it be connected to the X, Y, or Z axis is an analog voltage from approx 0~3.3VDC. The center point (0 G) will be approx half voltage, or around 1.65VDC. As the accelerometer detects -3 G, the voltage will be around 0, and at +3 G, the 3.3V max is detected. Now it is a bit counter-intuitive since we you might think the reading will only be during acceleration or decelleration, but honest - the reading also measures a difference in G force during a tilt. I don't pretend to know precisely how this works, but you can read the Data Sheet for the ADXL335 HERE Fortunately, you don't have to understand how it does this bit of magic to make it work for our purposes. The Accelerometer output is fed into an Analog-to-Digital converter in the ATTiny85, which produces a number corresponding to the voltage. Typically the AD converter returns a 0 when the input is 0, and 1024 when the input is at max (5VDC). This equates to about 0.005V per digit. However, since the Accelerometer is powered at 3.3VDC, the analog output will be 0-3.3V, which corresponds to a Digital range of 0-the true Digital range is closer to 0-660 rather than 0-1024 (the previously mentioned MAP function can re-map the output to 0-1024 for additional resoluiton). When the Accelerometer is at the 0 G point - more or less what would be level in a spirit level, the output voltage as stated is about 1.65V, which will be resolved by the A-D converter to approx 330. A second A-D converter is connected to a resistor bridge, consisting of R9, R10, and R11. When the Corse (R11) and Fine (R9) potentiometers are adjusted so it too outputs 1.65V, then both A-D converters will result in a reading of 330. The values are subtracted from each other, so the result is 0. Then an Offset (+4) is added to the result, which turns on LED#4 in the Cylon Eye. This Offset ensures the center LED will be on when the difference of the two A-D converters is 0. This normalizes the range of the A-D converter differences to center on the Cylon Eye. However, when the Accelerometer is tilted, it's voltage will change, but the voltage from the resistor bridge will not. For example, if the voltage output of the Accelerometer becomes 1.655V, the A-D conversion will output the value of 331. When the resistor-bridge A-D having a value of 330 is subtracted from 331 (result = 1) and the same +4 offset is added, then LED#5 on the cylon Eye is now lit. It is just happenstance that each 0.005V change in the Accelerometer cooresponds to a 0.75deg change in tilt angle, so it is simple math to compare the readings and display the difference. The Tilt shorting pin, when enabled the inverse of the difference is used. For example, in normal mode, if one A-D comparitor is 330 and the other comparitor is 331, the difference is 1, unless the Tilt pin is enabled, in which case the difference is the inverse, or -1. This causes the Cylon Eye to display in either a Left-Right or a Right-Left direction.
|