New Project – Electric Bikes, Arduino and Programming

Exciting times – a new project, bringing together Electric Bikes, Computers and Programming!

During my troubles with batteries (which are pretty much sorted now) I realised I needed a way of looking at the voltage of all the 12 cells, not only while charging, but also while traveling on the bike. I have some 6 cell voltmeters, which are pretty good, even if they are a tad inaccurate at times, but limited in their usage, showing each cell voltage in turn on a very small display. I started brainstorming what I needed, versus what I wanted, versus what I could dream of! I needed 12 voltage sensors, feeding into something that could create a display of all 12 voltages at the same time (i.e. a decent display unit), that could log them to an SD card or similar for later analysis, and could possible use Bluetooth or similar to send the display to an android mobile phone, to save on wiring the whole bike up. Then I realised if I was monitoring and logging 12 voltages, I may as well monitor speed using a speed sensor, pedal cadence using the PAS (pedal assist sensor), incline, GPS coordinates and speed, ambient temperature, brake usage, altitude and the state of the world economy! Maybe not the last one. Of course, if you are monitoring the voltages in each cell, you have the basics of a battery management system, something a lot better than what you can buy from the battery suppliers.

So I started looking initially at a way of showing all 12 cell voltages in real time, and possibly logging them too. This led into an investigation into various technologies available. Firstly, I looked at making use of the spare Raspberry Pi I have in the workshop, adding a couple of ACD/PI expansion boards (analogue to digital converters), and 12 voltage sensors, a decent display etc. From here I looked at Arduino, a prototyping system aimed at exactly this sort of thing, and realised that if I bought budget equipment from my usual Chinese suppliers, I could actually possibly afford to do this.

In order to detect 12 or 16 (should I decide to go up to 48v batteries) analogue voltages, I need a board with that many analogue inputs. The Arduino Mega 2560 board has 16 analogue inputs, each capable of reading voltages up to 5 volts, so this is a good starting point. However, I will be testing cells which are wired into a series of 12 cells, making a nominal 36volt LiFePO4 battery. My cell voltages will be measured from wires tapped into each positive end of a cell, and the negative end of the battery. This leaves us with a problem of having a common ground for all cells. There would be a lot of smoke and tears if I tried this. This is why I am going to try these voltage sensors. These can employ a common ground and 5v power supply from the Arduino board, and supply a signal wire to an analogue pin on the Arduino board. The input consists of a positive and negative screw terminals. Into these, if I was testing cell 6, would be the tap from +ve cell 6 and +ve cell5 (which is attached to -ve cell 6). If testing cell 7, the taps from cell 7 and cell 6 +ve terminals would be used. The voltage sensors in effect isolate the rather brutal 39v 15AH battery from the rather delicate Arduino board. The 16 analogue pins, and the 16 voltage sensors I have bought, will allow for a move up to 48 volt batteries if we so wish later on.

At this stage I am going to use a 3.2 inch colour display which is on an Arduino shield that attaches directly to the mega board, making initial progress a little easier I hope. Having downloaded the software and samples that come with this screen, I may be in for some challenges! This display comes with an SD card reader on the back of it, as well as built in SPI-Flash so I may have my data logging sorted too.

I also ordered this prototyping board and some breadboard jumper wires.

Obviously none of this will work without some code to read the sensors, generate the display screen and logs, and maybe generate some web pages later on. I have already downloaded the Arduino IDE, and checked out some of the examples of projects, and I am fairly confident I can master the programming. Unfortunately, the language is “C”, which I have tried to avoid for the last 20 years, but it looks like fairly simple usage of it. As a Pascal and Basic programmer for a few decades, I am sure I can get over my dislike of excessive punctuation, and use of bizarre combinations of characters instead of nice simple English words and mathematical symbols.

With this equipment I should be able to build a hand held voltmeter as an initial project, which can then evolve into a full e-bike management system to rival those that Bosch, Panasonic, Shimano etc are producing. As a bonus, or possibly the main reason for doing all this, I get some real knowledge of Arduino programming.

I am already designing in my head a start system for a slot car racing track, inspired by a customer who had me build something for him a few months ago. From just a a simple “lights out” start signal (as per Grand Prix etc) I can already see very easy false start detection and reaction time recording being included very easily!

The parts are on order, I have got every book on Arduino projects out of Porirua library (all 3 of them, two aimed at younger people!), and in 3 weeks or so I will get down to some serious building and software design and circuit construction. More soon.

Posted in Arduino, Computer Stuff, Electric Bikes, Programming

Leave a Reply

Your email address will not be published. Required fields are marked *

*