intro
The data logger is designed for the
Pepito WindMill project to gather data about the windmill's performance. Althougth I have abandoned this project in favor of
WindLcdMeter but I was quite pleased with the code I wrote for this project for a number or reasons. This was the 1st time is wrote to and read from EEPROM with an AVR (it's pretty trivial honestly but still) as well as the serial shell was pretty neat and it allowed the user to write ADC samples to EEPROM and later download the sample data. In addition the system offered 2 distinct execution paths. If a key is pressed within 2-3s of powering up the system then the user is taken into an interactive shell, otherwise the system goes into a deep sleep state and periodically wakes up to take a sample from the ADC and write it to EEPROM.
spec
ATmega32 RISC uC
-
- too much processing power (using it anyway)
- free via sample
- built-in USART (rs232)
- built-in 8 channel 10 bit ADC
- built-in 1024 bytes EEPROM
Serial Shell
- The command shell is entered by rebooting the datalogger and pressing 's' within 5 seconds.
- If this does not happen the datalogger will return to logging mode and start recording a new record.
- Once done downloading/erasing or other simply disconnect the power, there is no need for a shutdown procedure
Shell Options
- d - download flash
- download all records over the serial port
- e - erase flash
- clear all records in the logger to make room for more
- c - configuration options
- this feature has yet to be implemented. not sure what options even need to be set short of the sample rate which will be set through an external RC circuit.
- Secret Option
- E - test eeprom writing and reading (used in development of application)
- a - test analog sampling. An analog sample is taken and echoed to the terminal
Logging Mode
this mode almost entirely consists of sleeping to conserve power (we work hard to generate it so no point in wasting it). When a sample is to be taken the processor is woken up, the system time is incremented and then the sample is read and written to eeprom before the processor returns to sleep.
- wakeup
- increment system time
- take sample
- store sample in flash
- return to sleep
File System
each data point consists of a 10bit analog reading and an 8 bit 'timestamp'. ideally this means that only 18 bits are needed per sample. for ease 3 bytes will be used in rev1, 1 byte for the timestamp, and one word for the sample. this eliminates the need to develop a packing algorithm but wastes EEPROM as well.
- 1 byte - timestamp (abandoned, only data sample is recorded)
- 1 word - data sample
System Time
at power up the system time is set to 0. each time the processor wakes up to take a sample the clock is incremented. therefore the datalogger reports a relative time that could be seconds, minutes, or hours.
raw logs
the documentation will be partially formed from this:
mike:
It seems to put out about 18volts doing a high wind, which I think is good
for charging 12volt batteries, and makes me worry less about high-voltage
issues that I thought I might face. As long as she doesn't throw a blade or
over-charge my little battery (I don't have a charge controller or a
dump-load yet) it should be good. Unfortunately it's right next to the road
so if it did throw a blade it could be ugly (luckily not much traffic out
here).
chris:
to simplify things i will just use a more powerful uC with all the
hardware that i need onboard (i was going to go from a smaller uC and
external EEPROM but would rather deliver something sooner than never).
the data will be stored in onboard EEPROM and downloaded thru the
serial port on your computer. the chip i'm using (free sample, hand
built board - staying within the budget of the project) has 1024 bytes
of EEPROM and i need 18 bits for each data sample (assuming 1 10bit
voltage and a 'timestamp') so that means that:
(1024 bytes * 8 bits/byte) / (18 bits per sample * X samples/day) =
Days of operation before download is needed
| X | Days | Sample Frequency |
| 24 | 18 | hourly |
| 12 | 37 | every 2 hrs |
| 8 | 56 | every 3 hrs |
| 4 | 113 | every 6 hrs |
the samples/hour should be able to be modified 'in the field' either
thru the serial port or via an external switch. the device will be
low power and probably be parasitic (powered by the windmill) so as to
not need an external battery. it is expected to be placed on the
battery terminals, not on the windmill tower (easier to get to. as
valuable?) - the timer will start each time it is powered up and take
samples every X hours.
would it be more effective to measure the voltage output by the
windmill itself (above the blocking diode)?
chris:
i'm making good progress on it but i'm starting to get into the things
i've never done before (writing to EEPROM for one - that seems easy
enough though). batterys do tend to leak badly when they are
overcharged (at least caps do) so anything much over 13V will probably
be lost. that being said the mill producing 14V means the battery
will charge faster (and probably damaging it to boot).
measuring at the battery terminals would tell you how quickly the
battery is charging/discharging (i.e. if the mill produces 14V for 5
min you may only see 5V on the battery). This is best measured slowly
to give an overall trend (i.e. 1 sample every 2 hrs would allow for 1+
mo of data before it needed to be downloaded). measuring at the mill
motor outputs would give you an instantaneous measurement of the
voltage produced but totally depends on the wind at that moment (best
to sample this in bursts - like every 5 sec for 40 minutes (gathering
more data would will require more flash than what's in the uC i'm
using).
it would be good to take current measurements too but will double the
amount of data (thus half the samples can be collected). usually
current is measured thru a very small resistor (like a 5W 1ohm - then
V = I). it will be easiest to start off with just voltage sampling
using internal EEPROM. if it proves useful it is easy enough (but not
as easy) to interface to a seperate EEPROM and take a lot more data
samples including current.
rev 1: 1 voltage data sample with pseudo timestamp
rev 2: 2-3 voltage samples with real timestamp (1 at the motor, 1 at
the battery, 1 for the calculated current. the 'real timestamp' would
come from a real time clock if you want to gather that sort of data,
otherwise it'll be the same relative timestamp)
it's a fun project. glad to be on it.
--
ChristopherPepe - 11 Apr 2006