Andrew Que Sites list Photos
Projects Contact
Main

April 25, 2015

Replacement I/O Shield

   The replacement I/O shield for the Sun Dragon arrived today.  I quickly got it programmed and it is now monitoring voltage from both the battery and solar panel.  Not sure how useful this is as I think all the positives are tied together in the charge controller.  Nonetheless, the setup is functional, calibrated, and logging data.
   The I/O shield basically consists of an Arduino connected to the Odroid by a serial bus.  So I can do development on an Arduino without out worries about hurting the hardware on the I/O shield.  In theory this is what I am suppose to do, but the other day I did development directly on the I/O shield and destroyed it.  Nonetheless I could develop the software side using the Arduino.
   The system right does the averaging and conversions on the Arduino.  All analog inputs are read every 2 ms, and a total of 16,384 samples are averaged together.  This comes out to an average period of about 32.8 seconds, which is all the faster I want data to be logged.  After each averaging period, the results are converted using calibration points and printed on a serial bus.  This allows software on the Odroid to read the data.  Calibration involves hooking a variable power supply to the voltage dividers, along with a multimeter.  Software on the I/O shield prints the raw ADC values.  Two points are selected.  One at a low voltage, and one near the highest voltage.  The two points correlate an ADC value with to a voltage.  So after the 30 second averaging period, the ADC values are translated into voltages and those values are passed on.
   Software on the Odroid simply opens the serial port to the I/O shield, reads the voltage and current data, and logs this to a SQLite database.  This script runs continuously, but spends most of it's time waiting for data from the I/O shield.  Data older than 24-hours is dropped from the database.  In this way, charts can be drawn of the various data points on record.
   Right now the current traces are always zero.  I destroyed the current measuring op amps the other day, and am waiting for replacement parts.  Once the new parts arrive, I should be able to start logging this data as well.  One step at a time.
 

April 24, 2015

Buck-Boost Converter Experiments

   Spent much of the day reading about buck, boost and buck-boost voltage converters.  I started this research because I am unhappy with the charge controller on the Sun Dragon.  I read an article about how someone built an Arduino based solar battery charger.  This included making a buck converter using a PWM channel from the Arduino.  After I started looking into the technique, I wondered if I couldn't do one better. 
   First, buck/boost/buck-boost converters in a nutshell.  A buck converter transforms DC voltage from some higher input voltage down to a lower output voltage.  A boost converter transforms a lower DC voltage to a higher DC voltage.  And a buck-boost combines the two techniques to transform either a higher or lower voltage.  The technique involves using properties of an inductor being switched on and off quickly, and pretty much all modern DC power supplies use this technique.
   The article I read used a buck converter to collect energy from the solar panel at the maximum power using Maximum Power Point Tracking.  This is a very good way to get the most power out of a solar panel, but the setup assumes the solar panel will always have a voltage higher than the battery being charged.  If a buck-boost converter is used, the solar panel can still contribute energy to the system even if the voltage is lower than the battery because the circuit will operate in boost mode.
   After a good deal of reading, I started playing around with a Arduino controlled buck converter.  What I found is that with my small inductor I don't get a great setup.  The Arduino typically operates it's PWM at 1,000 Hz.  Most buck converters I've read about operate between 100 kHz and 1,000 kHz.  At best the Arduino can operate a PWM at just over 60 kHz.  I think this is making my setup less than ideal.  I have some larger inductors on the way so I can continue my testing.  I'm really bad at getting hardware to do what I want, but I might be able to get something working.

April 23, 2015

Better current measurement

Tooling around on the Internet looking for an alternative to my current sense circuit, I came across a module from China based on the TI ADS1115 16-bit analog to digital converter. I had already considered getting a high resolution external A/D because the Arduino only has a 10-bit A/D. When I started reading about the ADS1115, I found I also shouldn't need an op-amp. I should be able to wire the current sense resister directly to the A/D because it has a programmable gain of up to 16x. I ran some calculations and this is looking pretty good.

I would like to be able to monitor current to/from the battery at -1 to +20 amps, with -1 being 12 watts of draw, and +20 being 20 amps of charging at whatever voltage. The A/D has a built-in 4.096 reference voltage, and the programmable gain divides this voltage by powers of 2. So a gain of 1 means the input measure -4.096 volts to +4.096 volts. At 16-bits this means -4.096 volts is -32768, and +4.096 is +32768. A gain of 16 means ±4.096 / 16 = ±0.256 volt range.

What this allows me to do is change the gain as needed. The solar panel output won't jump around too quickly, and even if it does I over sample fast enough I can take care of any saturation by ignoring it until the correct gain is setup. With that in mind, I can use a 0.1 ohm shunt resister and measure the voltage directly across that. With a gain of 16, I can measure up to 2.56 amps, and theoretically down to 78 μA. With a gain of 1, I can measure up to 40.96 amps, and down to 1.25 mA. In reality the bottom end is going to have noise of probably 2 bits. So those low ends are closer to 312.5 μA with a gain of 16, and 5 mA with a gain of 1. That is plenty of resolution.

April 22, 2015

More broken hardware

   Today I got new shunt resisters which were to increase the range of my current measurements.  However, after I wired the first one in, I seemed to inadvertently destroyed every single current sense op amp in the setup.  They are disgustingly sensitive devices and I now hate them.  I've killed two already, and this makes a total of 5.  The thing about them I hate the most is they are surface mount parts on an through-hole adapter board.  Surface mount sucks for bread boarding.  The adapters are expensive and the pads fall off if you try and switch parts.  I'm not happy about this at all.  Clearly, I am not a good electrical engineer.

April 21, 2015

A look at initial chage/discharge data


   The past couple of days have been cloudy, but I have been able to get voltage and current readings for the Sun Dragon.  The data is currently being monitored with an Arduino and logged with the Blue Dragon.  The graph shows several interesting things.  The battery voltage is suppose to hold around 14.5 volts when the sun is up.  This is the charging voltage of the battery.  When the sun sets the voltage drops to just above 13 volts, and then slowly drops over the evening.  The lowest point is right before the sun comes back where the battery voltage is around 12.8 volts.  That's the good news.
   The bad news is that the voltage sometime spikes up well over 15 volts, which is the maximum the sensor can measure.  This shouldn't happen.  It appears the charge controller simply turns off and connects the battery directly to the solar panel.  It also turns off the Sun Dragon.  This seems to happen when there is a great deal of sunlight.  Either something I've wired is upsetting the charge controller, or the charge controller is a piece of junk.  At this point I wouldn't be surprised by either.

April 20, 2015

Happy TCD!

   Show today at Elmwood Park.  We had three bands that put preformed in the garage and had a decent turnout for the event.  Concerned about how loud the bands would be I walked around the outside of the house several times throughout the night.  While I could hear the music, it wasn't loud.  No one complained, and I don't think anyone will.  So hopefully this is a first of many.
Ottoman Empire soldger from the Great War

Ottoman Empire soldger from the Great War

The Sun-Dragon has two flash devices for file storage. The operating system is located on an 8 GB eMMC and the data for the website held on a 256 GB micro SD card. The 256 GB drive is mounted to /mnt/sd and contains two directories: lost+found and webpages. The lost+found directory is standard for ext* file systems. I had created a symbolic link in the root directory of the file system called webpages that linked to to the SD card directory. This works fine when all operations are done on the local machine. However, when viewed from a remote system the link wasn't showing up. Presumably the symbolic link was attempting to resolve a path on the non-local system—a path that did not exist.

The solution was to make a special mount point, a bind mount point. I first created an empty directory in the roof file system called webpages, and then mounted it with the bind option:

mount --bind /mnt/sd/webpages /webpages

That did exactly what I desired, allowing remote computers to access to the webpages directory. To get this mount point on system start I added the following line to /etc/fstabs:

/mnt/sd/webpages /webpages none bind

April 18, 2015

Step forward, step backward

   I got the Sun Dragon running the code on the I/O shield for monitoring currents and voltages.  I just had battery current and voltage to start with, but that was a good start.  To get this information to the Odroid, I wrote a simple PHP script.  The I/O shield's Atmel chip is setup for serial communications at /dev/ttyACM99.  The Atmel software writes data out once a second, so simply opening this port as a file and reading a line will result in getting the latest data from the device.  Since that worked, I modified some scripts I wrote for logging system statistics for the Blue Dragon.  They use a sqlite database to store data points about the Blue Dragon's CPU load, temperatures, fan speeds, ext.  With just a little tweaking I reused the same system for logging statistics from the Atmel chip.  A shell script calls my PHP script in a continuous loop.  Each time the PHP script runs it reads one sample from the Atmel chip and logs the data to the sqlite database.  On the Sun Dragon page I added graphs for the information I have available to log.
   With that all working perfectly I decided to work on the rest of the circuit.  I blew up two current sense op amps during this project.  Either I killed them during wiring, or static discharge.  (I'm a bad electrical engineer.)  However, I had been smart and ordered backup chips.  So using my microscope and hot air rework station I replaced the dead chips with new ones.  That did the trick and I started wiring the new setup.  Like an idiot, I left this setup plugged into the I/O shield during wiring.  I shorted 12 VDC from the battery to the ground for the I/O shield and promptly blew up the Atmel chip I had already replaced once for doing something similarly stupid.  My working setup is now dead, and I will have to replace the Atmel chip yet again.
   Lesson learned: do the development work on the development board.  When it functions, move it to the production hardware.
   Pictured is the Sun Dragon with the battery current sense and voltage monitoring functioning.
   I've been working on the software for the Atmel ATmega328 chip on the I/O shield of the Odroid—parts of the Sun Dragon.  I've decided the Atmel will do all the power control and simply make that information available to the main processor.  The first step is acquiring the data and filtering it.  In full daylight with the battery charger, the a PWM controls current into the battery.  The current sense op amp is fast enough to see the turn on/off of this switching.  Rather than try and filter this out with hardware, I filter this with software.  One thing about the Atmel compiler I've found is that it doesn't complain when you run out of memory.  My average buffers had grown too large for the device, but rather than print a link error, the software compiled, loaded into the device, and then did nothing.  That surprised me.
   The code I developed is given a couple of calibration points to in order to determine voltage or current.  I use fixed-point math for everything, so the average always collects samples in powers of two.  Taking 1024 (210) samples at one a millisecond results in roughly a 1 second average.  This gives a pretty good indication of what the current or voltage was for that period.  I let this run for the night on the Arduino.  Tomorrow I'll put the code into the Atmel chip on the I/O shield of the Sun Dragon.
   A shot I did of Raven the other day.  She is posing with Matt's harp and I set the shot up rather quickly as I was taking other pictures.  I did a diamond shot and managed to get some nice motion from the bottom left moving up and to the right, and then back to the left again.  For not spending much time with it, I don't think the composition is not too bad.