-
Notifications
You must be signed in to change notification settings - Fork 0
Getting started
Start by opening the Fritzing file and connect the 5 Arduino pins according to the comments. If you're using an actual Leonardo then you should use other pins than 0 and 1 for the analog stuff, but if you're using the A-Star 32u4 board like me then unfortunately pins 0 and 1 are probably the most reliable analog pins. Your mileage may vary.
The negative ADC is used mostly for diagnostics, make sure you connect it right next to the resistor legs or the software might behave strangely.
When you're done connecting everything, take out your trusty multimeter and measure the resistance over the resistor(s). Write this value down for later. Now connect your Arduino power source and measure the voltage across the 5V and GND pin on the Arduino board, make sure you write this down too.
Open the Arduino sketch and configure the pins. The intelligent stuff happens at the Octave end anyway, so there really isn't that much to see here.
This is where the fun stuff happens. First, you'll need to set up the environment. I'd strongly recommend using Linux for this.
Start out by installing the "octave" package. It should bring in a lot of dependencies, most notably "gnuplot". Once that's done, run "sudo pkg install instrument-control" and Octave will pull in the library required for serial communication. That's it for the dependencies!
Now we must configure the Octave script. To do this, open the file "AStar_32u4_battery_discharger.m" with your favorite text editor. Remember the values you wrote down earlier? Now replace the values "v_cc" and "resistance" with your actual values. You may also want to change the "v_cutoff" value, however the default is pretty safe for LiPo batteries.
Now you're done with configuring the software!
Now that everything is set up properly, we're just almost ready to run the Octave code. All that's left is to connect the Arduino USB cable and find the serial port of your Arduino. You should find this in your Arduino IDE, but note that this is not a constant value and may change when you reset your Arduino.
So, you've got your serial port, the battery is charged and the bag of popcorn is nice and warm. What now?
Don't connect your battery just yet, we want to make sure the battery error detection works before we risk any damage.
First of all, open up a terminal and cd to the directory of the project files, then start the Octave interpreter by simply running "octave". Now run "AStar_32u4_battery_discharger " (for example "AStar_32u4_battery_discharger /dev/ttyACM0"). You should see an error message about it not finding a battery. This is a very good thing; both the serial communication and the error detection is fully functional. Make sure to read the configuration message and verify that this looks correct.
If it displays the parameters that you want then you can connect the battery (mind the polarity) and then press any key to retry detecting the battery. If this works you'll then reach the regular message prompting you to start the test by pressing any key.
Now that the test is running, there are a few things to note:
- There's a bug in the serial library that makes it difficult to abort a running test by pressing Ctrl-C. Instead, please disconnect the battery to abort the test.
- The capacity displayed while running the test is an approximation and does not account for Arduino clock drift.
- A plot of voltage over time will be presented to you when the test is over and will usually open on top of any open window. This window doesn't accept any keyboard input except for the arrow keys and there are no single click actions, so it's pretty safe to just leave the test running in the background and do something else while you wait for the test to finish.
- Make sure you read the entire summary, if you aren't pleased with the reliability then you may want to investigate both the "serial error" and "ADC warning" counts.
- Do not leave the computer unattended while running the first test, if the resistors or MOSFET get dangerously hot, or the software fails to disconnect the battery automatically after the test is complete, you have to disconnect the battery manually to avoid damaging the battery and/or the circuit.