The Otherpower discussion board

Microcontrollers => Microcontrollers/General => Topic started by: SparWeb on September 11, 2017, 11:27:57 PM

Title: Arduino Based Datalogger
Post by: SparWeb on September 11, 2017, 11:27:57 PM
My personal "Rock of Sysiphus".  I've built two dataloggers before, but neither worked very well.
There wasn't anything particularly wrong with the other datalogger recipe projects, they just weren't suitable for my equipment.
The first was the Backshed PIClog, however the tachometer data was useless coming from my motor-conversion projects and the current measurement was far too crude.
My second was an attempt to add many features to a 28-pin PICAxe chip, but I got drowned in all the little details of building the board for the thing, which comes as a single microchip and needs all the power supply, clock, memory, interfacing, and pin impedance protection details taken care of before every thinking of hooking up an analog input!  Furthermore I still didn't have a good tachometer strategy so I would have ended up with more dud RPM data.

I finally hit on the tachometer solution which I documented here:,149270.0.html
The key was realizing that no matter what warped and scrambled waveform comes out of my motor conversions, it comes to one phase, then the second, then the third, and then repeats - so instead of trying to measure peaks or times, all I really needed to do was cycle through series of triggers, one phase at a time, until it came back to the first.
Here's an example of the messy waveform I'm dealing with:


Yes this project was also an opportunity to invest in a classic Tek 422 oscilloscope.  Nothing newer than 1960's technology for me!


I got that tachometer working nicely back in July, and spend the next month figuring out if I wanted to make it a real data logger and pack more stuff into the box...  Yes I do!

Here are photos from July, after I "packaged" the tachometer with a pretty LCD display and everything.




I am finally able to see my way through a whole datalogger project that could actually monitor my complete system.  So far I've got 4 channels of current measurement, 4 channels of "misc" analog inputs, and a LCD display.  The analogs are all scaled 6:1 right now so that I can measure up to 30V anywhere in the system (eg. battery, solar, wind).  The Arduino runs at 5V so these analog inputs have a 5k+1k voltage divider to scale them.  At least one more (unscaled) analog input is needed so that I can measure temperature, allowing me to calibrate the current measurement somewhat.  The current sensors are boxed up separately so I'll show them later in a separate post. 

Since I'm using an Arduino MEGA 256, the board has lots of spare digital pins that I haven't used yet, but only a dozen or so analog inputs.  I have space set aside for 2 more analog inputs but there are still some more - for anything I've forgotten!  I'm running out of space anyway on the expansion board that's stacked on top.  It's getting a lot more crowded than it was in July when I took that last photo. 

I started this post before realizing that I haven't unloaded the most recent photos from my phone, which shows the current look of the datalogger.  Updates coming shortly then!
Title: Re: Arduino Based Datalogger
Post by: SparWeb on September 13, 2017, 11:43:07 PM
Here's the schematic I'm working on:


Part 2 of the schematic:

Title: Re: Arduino Based Datalogger
Post by: SparWeb on September 27, 2017, 10:41:49 PM
Quick update:
Lots of pieces have been added since the last posting.
I installed the kit in my system 2 weeks ago, and I'm pleased to see BELIEVABLE RPM numbers now!
I also hooked up the current sensing box, but now I have decided that running the current carrying wires to that box I should be running the sensors to the current-carrying wires.
This will force me to re-built the box a bit.  While the circuit board itself is fine, I need to run data connections out where there used to be a big-a$$ terminal block.

I have also added a bank of 6:1 scaled voltage dividers to I can connect any pin to any voltage up to 30V safely and get a proper voltage reading on the LCD.  I have only calibrated 1 channel (battery voltage) so far but the process for the rest will be just the same as for the first.

Below: the current sensor box with the sensors inside.  I'm not sticking with this arrangement but for the sake of displaying where I am right now...

Below: layout of equipment on the wall as it was last weekend.  At the very top: 12V fusebox.  Next row, from left to right:  Wind Charge controller (Morningstar TS60) - Datalogger - Solar charge controller (Xantrex C40) - current sensor box.  Photo was taken before much of the data stuff was hooked up, so the datalogger LCD still reads 0-0-0 for most things.  The wind AC comes in through the blue CAT-5 cable so that works at least.
Title: Re: Arduino Based Datalogger
Post by: SparWeb on October 04, 2017, 10:48:45 PM
Another test run, this time with RPM, voltage, current, and timestamps all coming in simultaneously.


The output graphs look like this:


Very happy!
This is just 10 minutes of data, and there is a long way to go yet, but so nice to see believable numbers coming out of the system.
Title: Re: Arduino Based Datalogger
Post by: SparWeb on October 04, 2017, 10:58:10 PM
Here's the schematic, in 2 parts:



Title: Re: Arduino Based Datalogger
Post by: Bruce S on October 05, 2017, 07:05:49 AM
It sure is nice to see the numbers in a visual format!

Are you using those numbers to switch between star and Jerry?

I've also found the twisted pairs of CAT5 to be a great way to move data along. Every time I think I need another run of it ,,, I pull 2 instead. I've learned the hard way I'll eventually need that 2nd on

Title: Re: Arduino Based Datalogger
Post by: SparWeb on October 06, 2017, 12:26:39 PM
Every time I look for a simple connector and cable for the data inputs, I look around and around, and find stuff that's hard to mount, hard to connect, hard to pay for...
Then there's CAT 5 (and its little brother CAT 3) and all my problems are solved.
I too, and very glad I took the time run a CAT 5 along with the power cables when I buried the lines to the tower!

Nothing so fancy as automatic switching on Star/Jerry or /Delta.  Up until a month ago, there was no way to know the turbine speed, so how would the speed switch work?
Now that I do have a known speed, all of these possibilities open up.

Did another run for data last night, just in Jerry.  Put the Oscope on it just for kicks, and at night the green flickering glow was kind of eerie!  :)
Plotted last night's data on the same graph, and the line runs STRAIGHT through the data from last weekend.  Wow.

Next thing will be to connect a temp sensor and put in temperature corrections.  It's already apparent that the current sensor offsets go off  (by about 2 amps) when the unit is taken out of the warm house and into the cold shed.  As you can see in the schematic, that's no surprise and been part of the plan all along.

Last night's test in very light winds showed that, in Star, a trickle of current does come in, but at that speed the threshold to activate the RPM isn't crossed.  I could only see RPM when switched to Jerry where the turbine turns much faster.  I think the voltage divider which steps the incoming AC down 1/6 is too steep and I should change it to a 1/4 voltage divider.  Unfortunately I would need to add some 5V zeners for protection and there's almost no room on the board any more!
Title: Re: Arduino Based Datalogger
Post by: SparWeb on October 10, 2017, 10:10:32 PM
Good clean data coming in.
Not finding any blips or wobbles.

I did manage to burn up a current sensor on the weekend.  Made a better cable for it, but had the contacts switched!
Thankfully Amploc still makes these.