Home Page
  Home  |  Contents  |  Forum
Print



Piclog - PicAxe Logger Controller. Page 1 | 2 | 3 | 4 | 5

I needed a logger. Some way to record windmill data during the day while I was at work. And as I'm a big fan of the PicAxe chips, a 08M chip had to be the brains. This logger controller, along with the PC software, records battery volts, current drain, windmill watts and windmill RPM. The controller can also operate on its own as a simple shunt regulator. The PicAxe based controller is a simple circuit, and sends raw data to a PC via the serial port. All the calculations and calibration is performed by the PC software.

I call it PicLog.

Latest version 2.0, Page 4

Please note, if you want to build this project, you will need some experience with electronics, including making your own circuit boards, and programming in Visual Basic and PicAxe basic. As this is an ongoing project, I will occasionally release updated versions.

There are two halves to this project, the PicAxe circuit board, and the PC software. The PicAxe is used to make simple measurements, and send the data to a PC via a 3 wire serial cable. The software on the PC converts this raw data into real values we can understand and record.

There are two different configurations. The PicAxe used, a 08M, has only 4 usable pins, so this limits our options. I could have used a 18X chip to give us several more pins, but I wanted to keep this project simple, and I had a few 08M chips in stock. But the software could easily be used on a 18X chip.

1. Logger - Regulator. Measures Volts, Amps and Windmill RPM or Wind Speed. The last PicAxe pin is used to switch the dump load.

2. Logger Only. Measures Volts, Amps, Windmill RPM and Wind Speed.

PicLog. Ver 1.1

Click to enlarge

 

I'm using two of the ADC inputs of the 08M chips to measure battery voltage (pin 3) and shunt voltage (pin 6). The PC software calculates battery current by comparing the difference in battery and shunt voltage, ie if the battery is 12 volts, and the shunt measures 12.2 volts with respect to the battery -ve, and the shunt is 0.1 ohms, we can work out amps using 12.2v - 12v = 0.2v, so 0.2v / 0.1ohm = 2amps. The PC software actually uses a different method to work out amps, but you can get the idea. The 0.01uF caps filter out any spikes. Originally the circuit also included a 4.7v zener to protect against excess voltage, but this was found to be affecting the accuracy of the readings, so was removed.
Windmill RPM is measured by sniffing the AC directly from the windmill, before it passes through the bridge rectifier. The PicAxe can count pulses per second, so we use this to work out RPM. There is a opto coupler there to isolate the AC from the battery side of the bridge rectifier, and provide some protection for the 08M input (pin 4).
You could also use an opto-vane sensor or reed switch to measure windmill rpm. Your windmill may have a DC output, so you cant use the AC circuit above. If this is the case, you can replace the AC measurement circuit above with this one.
This will take a pulsed signal (9 to 30 volts ) from a speed sender and feeds the PicAxe input. Again there is an opto coupler there to protect the PicAxe from spikes on long wire runs. Below are the circuits for reed switches or opto - vane senders. You can find opto - vane senders in old printers or photo copiers, even some old floppy disk drives. If you use a reed switch, I suggest you add a 22nF capacitor across the contacts to filter out spikes
We can also use this input circuit for wind speed measurement, using a home made anemometer, the one shown uses 1 magnet and a reed switch. The PicAxe measures RPM or Wind Speed by counting the number of pulses in a 1 or 2 second interval, and this can be a problem if you want to measure low wind speed. The anemometer shown has one magnet, so the reed switch only pulses once per revolution. At low wind speed, it may only spin 1 or 2 times per second, so this will give inconsistent wind speed measurement. It really needs 4 or more magnets to operate reliably at low wind speed, but once the wind has picked up the reading will be more accurate even with only one magnet. Another "fix" is to increase the duration the PicAxe uses to count pulses. To make my anemometer work correctly, I added a extra magnet, and increased the count period to 2 seconds.

Dump Load. If the battery voltage is too high, a mosfet ( from pin 5 ) drives a automotive relay to switch a dummy load ( couple of 12v spotlights would do ) across the battery to drain off the excess power.

The circuit can run on either 12v or 24v, but there are a couple of resistors that need to be changed. If you wanted to quickly change from 12 or 24 volt, a double pole switch could be used to change the resistor values. To keep it simple, I'll use 12v for the rest of the controller description.

I machined my circuit board on my cnc router, but its a fairly simple circuit and you could use veroboard. If you have a cnc router drop me a email and I'll send back the dxf file.

PicAxe software.

Pretty simple this one. The 08M measures the battery voltage, shunt voltage, RPM and or Wind Speed, then sends this info out the serial connection at 4800 baud. The two inputs are measured as 10bit, or 0 to 1023, where 500 is equal to 12 / 24 volts. This is converted to a real value in the PC software. If the battery voltage rises above 14v ( =580 in the PicAxe , 1 volt = 40 ), it switches on the mosfet. If the voltage drops below 13 ( =520 ), it switches off the mosfet. These switching points can be changed to suit your own preferences, but this means you need to reprogram the picaxe, easy enough to do.

Version 1. Logger Regulator

Start:
SYMBOL RPM = W2
SYMBOL Amp = W1
SYMBOL Volt = W0
SYMBOL Mode = b8
Mode=0

Main:
readadc10 4,Volt  
readadc10 1, Amp  
Count 3,1000,RPM  
sertxd("[<V>", #volt, "</V><I>", #Amp, "</I><R>", #RPM, "</R><M>", #Mode, "</M>]")
if Volt>580 then SwitchToLoad 
if Volt<540 then SwitchToCharging
goto main

' ########## Switch on dummy load

SwitchToLoad:
High 2
Mode=1
goto Main

' ########## Switch off dummy load  

SwitchToCharging:
low 2
Mode=0
goto Main

Version 2. Logger Only.

Start:
SYMBOL WSpeed = W3
SYMBOL RPM = W2
SYMBOL Amp = W1
SYMBOL Volt = W0

Main:
readadc10 4,Volt  
readadc10 1, Amp  
Count 3,1000,RPM
Count 2, 1000, WSpeed
sertxd("[<V>", #volt, "</V><I>", #Amp, "</I><R>", #RPM, "</R><S>", #WSpeed, "</S>]")
goto main


PC Software.

Just a note about the PicLogs software. As well as a useful data logger, the Piclog is here as a teaching tool in electronics and software. The software developed for the Piclog is open source, meaning everyone can see the code in its raw format, learn how it works and use parts of it for their own projects. You may use parts of the PicLog software for your own projects and distribute them as your own creations, providing you dont call it a PicLog or similar ( PicLog2 for example ). If you have a "improved" or "modified" version of the PicLog, you should include the source code with your new program. Remember the PicLog is here as a teaching tool, so any version of the PicLog must include full source code so others can continue to learn from the PicLog.

Written in vb6, the windows application does all the number crunching and logging. There are 4 screens, Main display, Setup, Calibration, and Logs.

The main display shows the current Battery voltage, Current, Watts, RPM and/or Wind Speed. This is updated on every heart beat from the PicAxe, every 2 to 3 seconds. Typically the data from the PicAxe would look like...

[<V>520</V><I>540</I><R>12</R><S>23</S><M>0<M>]

V is Battery Volts, A is Shunt Volts, R is pulses per second, S is Wind Speed pulses per second, M is mode ( dummy load on or off )

The program breaks this info up into its individual values, then uses its calibration settings to get our true battery voltage, Battery current, Watts, RPM, WindSpeed and Mode. This info is displayed on the screen.

If you click the Start button in the logging section, the program will start recording the values into a text file. A new text file is started for every day. The interval is set to 60 seconds be default, but this can be changed from 10 seconds to 600 seconds ( 10 minutes ).

The Program Setup screen is used to set some general program settings, and saves the information to a text file called prog.cfg.

  • Com Port: Set to the com port on your PC that the PicAxe serial cable is plugged into.
  • Save HTML Page: Updates a web page every few seconds with the loggger data, more on this later.
  • Save Excel File: Creates an Excel file, one for every day, with the log history.
  • Default Logging Interval: Pretty obvious.
  • Start Logger Automatically: Logging starts on program start.
  • Display RPM: Turn on RPM display.
  • Display Wind Speed: Turn on Wind Speed display.
  • Wind Speed Units: What measurement base for wind speed ( ms, knots, etc )

The Calibration screen is used to set up the software. Just follow the steps. Its saves the configuration as a text file called settings.cfg. Dont be tempted to edit this file, if there is a problem with it the program will crash.

The Show Logs screen displays logs, and includes graphs. Just enter in a date and hit Display. You can then narrow down the time spread using the From and To time values. The graphs are scaled to the max and min values. If you move your mouse over the graphs, it will display the value and time, depending on where your mouse pointer is. You can also turn off and on individual traces.

HTML Page. You need to have a web server installed on the PC and a basic understanding of IIS administration if you want to use this function. If the Save HTML pages it turned on, on every heart beat the program will open a file in the HTML directory called "template.asp". It searches for tags in the HTML code, and replaces these with the actual data.

<VV> = Volts, <AA> = Current, <WW> = Watts, <RR> = RPM, <SS> = Wind Speed, <TT> = current time.

The web page is then saved as Logs.asp. You can map the HTML directory as a virtual directory in your web server. If you would prefer the page saved in another format ( html, php, jsp) please let me know.

This is a sample page, I was displaying live data here, but there were too many visitors and my poor old satelite connection was crying for help.

Batt Volts 12.45 volts
Current 1.05 amps
Watts 13.0 watts
RPM 92 rpm
Wind Speed 21 kmh
Date Stamp 8 Oct 2006 13:30

 

Next page, an updated version.