Friday, October 28, 2011

An LED clock and using GitHub

Fresh from Ponoko, it all fits!
I have completed an LED clock and have a repository for it at GitHub. As I learn more about git the more I love it. My repository at GitHub has code, notes, svg files for the laser cut parts and even a blender file for the 3D layout. Open Source rules...

I wanted to make something practical, colourful and easily shown off to anyone coming through my door and portable enough to take places. I settled on using 12 RGB LEDs to tell the time with colour and brightness.

Getting good pixs of LEDs is hard
How does my clock tell time? The current hour is Magenta. All other hours are a background Green, except those that tell current Minutes and Seconds. Minutes move through green-yellow-RED-yellow-green. The bright RED occurs at each exact 5 minute interval. Seconds move from green -> cyan -> BLUE -> cyan ->green. The bright BLUE occurs at each 5 second interval. Fairly easy to get the hang of it. Not so easy to describe. Here is an example showing the time as 9:05:24.

Blender render of the partial clock assembly.

I learned to use Blender to create 3D renders of my clock assembly. I imported the same Inkscape .svg files that I created for the laser cut parts and modified them for 3D. A bit of a learning curve but possible for guy who turns 70 next week.

I also have a repository for my updated Solar Monitor Project which is being done in collaboration with Anthony.

The current version of the Solar Monitor uses an 1.8" 18-bit color TFT LCD display with microSD card breakout and a DS1307 Real Time Clock breakout board kit, both sourced from Adafruit.

1.8' TFT  display

The TFT LCD, a sample screenshot shown here, displays (top to bottom):
  • (text): battery voltage and current
  • (graph): battery current for the last 100 seconds (positive and negative)
  • (graph): integrated current for the last few hours (positive and negative)
  • (text): date and time
  • (bar graph): battery "percent charged" for the last few days

The monitor also logs the battery current and voltage, integrated for one second, on a micro SD card. Over time a power profile will develop which can used to determine patterns of appliance usage and specific appliance power consumption.  All this from one current sensor with a timestamp I hope. A Bayes network looms.

Tuesday, June 21, 2011

Finally the schematic I promised and some notes

Here is the schematic of how the Current Sensor interfaces to my Solar Batteries and the Arduino monitor. It is very simple, just an 8 volt DC supply for the Current Sensor and a limiting resistor in series with the output to the Arduino inputs.

The current sensor is a hall effect device with an output of about 32 mv per Amp. As both positive and negative current is sensed the output sensor voltage is about in the middle of the current sensor supply voltage with zero amps.   I will use an Op amp in the future to optimize the output range and sensitivity. Zero amps to/from the battery is about 4volts. As my solar panels will only output about 30 amps to the batteries on a sunny day (32 x .03~ 1volt) the Arduino analog input will be right at FS or 5volts. The battery discharge is max at about -60amps. Arduino input about 2volts. The Current Sensor saturates at +- 72 amps.

I have now added a SDdata logger shield to the Arduino solar monitor  and will soon add a second current sensor for the 240 inverter power usage. This will enable me to track/log all power for the whole system. Solar power in, the battery stored energy and all power out (household and other DC).  I can log most household items electrical usage just by inspecting the current monitors and their derivatives. more on this later.

Friday, December 3, 2010

My Laptop died!

My Dell XPS 1710 died with a fried or unsoldered display driver chip from what I can gleam from Google. I was never happy with it so I'm shopping for a new cheap laptop.  I'll get back to my projects when I get all this sorted and extract my data from the Dell.

Saturday, November 20, 2010

Xbee and newsoftserial

Receiver Xbee/Arduino
very simple newsoftserial
Overview My Solar Battery Monitor will move into the house via a wireless Xbee link. I have been testing how Xbee's work as a stand alone sensor input.  I just transmit the A/D conversions to my Arduino Xbee in the house every few seconds or so. I looked at what others have done and the Xbee libraries available and decided to use only newsoftserial for the Xbee/Arduino link and sort out the A/D data in the Xbee RF packet with the Arduino. What follows is how I did this, it is simple and should work for any simple use of one or more Xbee's transmitting data to a Xbee receiver connected to an Arduino via newsoftserial. This makes it easy to update the Arduino while listening to what your sensors are sending. Once you decide how to configure the transmitter Xbee's ( # of channels to A/D, which ones, etc) the data packets can be grabbed just by counting the input bytes. My test set up follows closely the Tweet-a-Watt setup at Adafruit.  Get the Xbee Manual .

Sensor Xbee test board. Three inputs
for the A/D's selectable.
Detailed example follows:
I used X-CTU to configure all Xbee's .

The receiver Xbee is default (transparent mode)  with a PAN ID that agrees with all of your transmitter Xbee's. Set all the baud rates the same. This is so you only receive data from YOUR transmitters!

I used one Xbee for transmission, it has three AD inputs A0,A1,A3 active. Configured as follows:
MY (16bit source) = 1 the first and only unit transmitting at this PAN ID
SLEEP MODE = 4  cyclic  wakeup every 2 seconds transmit data go to sleep
ST =3  Time after last sample to go back to sleep. (ms)
SP = C8  sleep period  2 seconds (Hex in 10ms steps)
D0, D1, D3 = 2   This enables A/D on these inputs
IT = 4  sample each input 4 times
IR =1  time (ms) between samples
Thats all; just supply this Xbee with power and hook up the three inputs. You will see the power lite blink every 2 seconds and if you look closely the red data lite blinks also for the one RF packet that is sent.

Set up newsoftserial between the receiver Xbee and the Arduino like the Adafruit example

In my example the sampled RF packet bytes = 35 as follows:
7E, 0, 20, 83, 0, 1, 4F, 0, 4, 16, 0, 1, C1, 0, 9C, 3, 64, 1, C1, 0, 9C, 3, 64, 1, C2, 0, 9C, 3, 64, 1, C1, 0, 9C, 3, 64, FD, 
My code to test xbeePacketsize
Quick view of my Headers:
8 bytes of RF header; 3 bytes of Data header; Data values, checksum.

  1. 7E Packet start delimiter
  2. 00 MSB length
  3. 20 LSB length  Length is 32 + 3 bytes already; end is at byte 35
  4. 83 ATI identifer..receive 16 address packet data, the only mode I use.
  5. 00 MSB 16 bit source address
  6. 01 LSB  16 bit source address in my case 1
  7. 4F RSS RF signal strength -75dBm.  I'll plot this vs distance soon. This is typical for wireless.
  8. 00 reserved Options 
  9. 04 Total number of data samples (a/d conversions) 4 in  my case
  10. 16 bitwise indication of channels enabled A/D see manual. This is how you setup the transmitting Xbee. 
  11. 00 bitwise indication of digital enabled pins on the transmitting Xbee. None in my case.
  12. 01 MSB A/D first conversion for pin A0 in my case.  1*256 + LSB
  13.  AB LSB A/D first conversion for pin A0. Value is  MSB + 160 + 11 or 427 (0-1023 possible)
.... to byte 35.
Remember I count from 1's but arrays are indexed from 0. I sometimes mix them up, be careful! Count!
My data starts at byte[11] and ends at byte[34] and  byte[35] is the checksum. My case 3channels*4samples*2bytes/value = 24 more bytes. 11 + 24 inclusive is 34. 34 is the last data byte.

All data in this xbee mode will start at byte[11] and be (num sampled channels) * (num A/D conversions) * 2 bytes of data long.
It is simple to now fill a dataArray[3][4] with the outputs of the xbee A/D values for each conversion
My code xbeeDataArray

Hope this helps.

Saturday, November 6, 2010

Arduino Solar Battery Monitor

The primary battery in my Solar Powered Home is a series of 4, 6 volt 395 Amp-hrs deep-cycle lead acid batteries. The capacity of this 24 volt battery system is about 9.5 kwHr. This Arduino project measures the power into and out of the battery and the battery voltage and displays on a 2x16 LCD display the current charge state of the battery along with other useful information.

Setup of the sensors
The cables connected to this battery are large and the currents high (~60 amps max). As a current sensor I used a hall effect CSLA2CD made by Honeywell Control. I had to splice in a smaller Battery cable to go thru the sensor. The sensor output saturates at about +/- 70 amps and the output is about +/- 33mv/amp with zero amps being the mid point of the sensor power supply, in my setup 8 volts.

A small protoboard has all the sensor electronics and is located near the batteries and draws power from them.  The 24 volts is regulated down to 8 volts for the hall effect current sensor and the 24 volt input is divided by ~ 1/6 to be suited for an Arduino A/D input. The two sensor outputs and a ground are wired back the the Arduino board which is located in a more convenient place several metres distant.

----------Schematic-coming soon----------

Breadboard version
Arduino and LCD display
Without the Breadboard
The Arduino and LCD display are wired up the same as the Adafruit project here with the two sensor inputs on A/D 0 and 1. A0 for the current to and from the battery and A1 the battery voltage.  I have used two of the Arduino's PWM outputs for the LCD back light and contrast.

The LCD displays two pages of information alternating 3 seconds each.
Page 1: battery voltage, battery current, state of charge %, fully charged = 100%, battery mode: charging, discharging, absorb and equalize.
Page 2: Today's stats in minutes reset at dawn
 charge time, discharge time, absorb time, equalize time.

The current weather including solar irradiation on the solar panels and the panel temperature (Extra sensors) are here.

Arduino Software
All my code is messy. May contain commented out debug stuff. You can rewrite it much better!
View code 
download code

Friday, November 5, 2010

First Post

 I got my first Arduino about 6 months ago and think they are wonderful. I have lived in a solar powered home in Tropical Far North Rural Queensland Australia for the last 20 or so years. My Arduino's are being used in sensor interfaces and data collection for many of my solar and water projects.  As I'm learning I hope to keep a record here of what I've done and why. I'll try to post about projects, talk about sensors and what I use them for and will post all code somewhere. I'll figure it out as I go along.