For the past four years one of my great joys has been cycling. Although of a certain age, and with not a few health issues, the advent of the e-bike has allowed me to return to one of the pleasures of my youth, as I’ve been known to blog about elsewhere.
But we’re not here to talk about cycling – we’re here to talk about not cycling.
You see, my bike died.
The electrical/electronic setup is pretty simple. Snuggled under the rear rack is a huge battery – 36V 14.5Ah 522Wh. If I had to guess, I’d say there’s probably 50 18650 Li-ion cells in the battery pack. This is based on an assumption that 10 cells in series (at a nominal 3.6V a piece) would give the 36V output, more or less. Then five of these 10-cell packs in parallel would provide the stated power output if each cell was a 2900mAh unit. Now that’s somewhat towards the top end for 18650s, but I’m also allowing for the stated power rating to be … um, how shall I put this politely … optimistic.
Also, I weighed 12 18650 cells, stored in three plastic cases, and they averaged out at 62g per cell. The bike battery weighs 3,190g which, divided by 62g, gives 51.45 – which is close enough to 50 for my money.
On the handlebars is a controller – to turn the bike on and off, select level of assist, turns lights on and off and a few other things.
There are also three sensors – one detects the speed of rotation of the rear wheel, another the speed of rotation of the pedals and a third detects the use of the front brake – the motor is set into the front wheel so you don’t want them fighting each other.
There’s a cable running to the front light (the rear one is built into the battery) and, of course, the motor. The controller also has a USB port that you can use for charging your phone. Yes, my bicycle has a USB port. Whoever thought that that would become a sentence?
My problem was the sensor that reads the rotation of the chainring – the big sprocket driven by the pedals that moves the chain – had breathed its last electron. This sensor lets the e-bike’s computer know when you’re pedalling, and how fast. Affixed to the chainring is a smaller ring into which a dozen magnets are embedded. The sensor is fixed to the frame and registers the passing of the magnets as the chainring rotates.
The reason for this is that the bike’s 250W motor drives the wheel only when you’re pedalling. You can’t just cruise along doing nothing and have the motor do all the work. This is what defines the bike, under French regulations, as a vélo assistance éléctrique (VAE) and allows you to ride it in places where normally only bikes are allowed but motor vehicles are banned, such as on greenways (voies vertes).
Hall effect sensor
Even without research, it was obvious that the device that detects the turning pedals is a Hall effect sensor, which responds to nearby magnetic fields. It had stopped working because I destroyed it. Eventually.
In fact, I damaged the plastic casing of the sensor about three years ago. It continued to work fine and then, a few weeks ago, it finally gave up. Powering on the bike resulted in an obscure error code.
The bike’s manufacturer, Gitane, has proven itself worthless when it comes to after-sales service. It has failed to answer, or even acknowledge, several queries by me via its website and Facebook page. The firm appears to have no Twitter account. (Seriously?) The owner of a local bike repair shop phoned them direct and they simply shrugged and said they couldn’t understand what was wrong with the bike. Clearly, they couldn’t care less. I was obviously going to have to fix this myself.
When I tried dismounting the sensor, the remains of the plastic casing crumbled away, like stale cake, exposing bare circuit board. The Hall effect sensor isn’t in there by itself – there are some supporting components – 330Ω and 10kΩ resistors, a capacitor (probably decoupling), a diode and the inevitable unmarked, eight-pin IC, which I presume is a microcontroller of sorts. There’s also a red 3mm LED that flashes when a magnet is detected.
The cables from the sensors, brakes, power supply etc are all routed through the inside of the main tube of the bike’s frame. It’s a Dutch-style (step-through) bike, so this tube has a reasonably large diameter. Even so, the cables had been stuffed inside in such an ad hoc way that they were firmly jammed. Very little thought seems to have been given to maintainability. It would take me some time to untangle them and see what, if any, connectors were on the cables.
In the meantime, I bought a sensor and ring kit on Amazon. The chances of getting the right one were pretty low – and so it proved. But no matter – I just wanted something for my experiments.
When I finally disentangled the cables from the bike frame I found that the wire running from the sensor was only about 20cm long. It terminated in a circular three-pin female socket. The corresponding three-pin plug is on the end of the cable that runs through the frame to the e-bike’s controller.
Given that the sensor was well-buggered, I cut it off in order to re-use the connector. I stripped and tinned the three conductors in the cable, which were colour-coded red, black and white.
Using my multimeter in continuity mode, I buzzed out the wires to determine which colour connects to which position in the socket.
With the cable reconnected to the bike and the latter switched on, I measured voltages across the three conductors. There was a 2.4V potential between red and black and about the same between white and black. I surmised that red is the VCC supply to the sensor, black is ground (GND) and white is the sensor signal wire, pulled up to VCC – a not uncommon way of wiring Hall effect sensors.
Later, when I scraped more of the plastic from the dead sensor’s PCB, I could see that the white cable was connected directly to the anode of the LED, confirming that this is the signal wire.
Square plug for a round hole
The next step was to try out the sensor I’d just bought. This came with a square male plug. Not much use to me. I cut it off and stripped and tinned the three conductors which were, annoyingly, red, blue and yellow.
Life is full of rules – except where they would be useful.
Oh well, time to experiment.
I fired up the bench supply and, via the three-pin connector, applied +2.5V to the red cable of the wire I’d taken from the bike and attached GND to the black cable.
Where the wires of this cable meet the wires of the new sensor, I had to apply guesswork. I connected red to red – that seemed a given. I figured the blue wire would probably be GND and the yellow one the signal. This was based on an intuition guided by decades of study and experience. And, of course, I was wrong.
I started getting sensible results when I swapped so that the black wire of the original cable connected to yellow on the new sensor, and white to blue.
I measured the voltage on the sensor (white/blue) line, with reference to ground (black/yellow) as I moved the magnets embedded in the ring past the sensor. The value alternated between around 0.7V and 0V, which didn’t seem right. It wasn’t.
I’d forgotten that, when I measured the voltages coming from the bike, there should have been 2.4V on the white line.
I pulled up the white/blue line by attaching a 10K resistor between the sensor line and the VCC line at the plug. Once that was done, checking with the magnets showed the sensor line alternating between 2.5V and 0V – exactly the effect I was looking for.
The connections between the new sensor’s cable and the old sensor’s cable (with plug) were a bit dodgy, so I re-stripped the wires and soldered permanent connections, with heat-shrink insulation for good measure. I went to this trouble because I was starting to get a bit cocky. That’s always a mistake.
Time to test
It was time to put this solution to the test. It seemed likely that the error message was appearing on the controller because it couldn’t detect the presence of the pedal sensor – it being dead’n’all. Even if the new sensor wasn’t quite right (for one thing, it’s bigger than the old one), having a sensor attached should at least make the controller happy.
I plugged in the new sensor to the cable on the bike and power up…
…and got the same error message.
Oh well, back to the drawing board.
To be continued…