Intuitive Digital Control

Intuitive Digital Control

Intuitive Digital Control is the name I've given my methodology that combines my PEC (Progressive Electronic Clutch) and automatically provides regen when the throttle is shut. It worked surprisingly well on the first attempt! Both Cindy and I felt it was, in fact, intuitive – and much more like riding an ICE bike now. I think some refinements may be possible, but it's usable as-is. I think this may be a patentable concept, but I have no interest in patenting it. That's why I'm putting it into the public domain via this website.

For review, my first design used the clutch lever just to modulate the throttle (somewhat akin to slipping the clutch). This was a completely analog system. Although I could have implemented the next step of adding regeneration as an analog system, I knew it would be easier to implement as a digital system.

Unfortunately, all of the microcontrollers I had used in the past were either too primitive to work without additional circuitry, or too physically large/power-hungry. Further, I had not written any embedded code since 2007 and needed to research more modern microcontrollers. What I found is pictured below. It's a Microchip PIC16F1615 soldered to a small PCB.

PIC16F1615 Protoboard

PIC16F1615 Protoboard

Quite an amazing piece of hardware – especially considering what it cost. There was a guy selling these on eBay, five for six dollars! Several years before, he had commissioned them as development boards for his own use and apparently overestimated the need.

I'm really pleased with my implementation. I needed to upgrade a C compiler to handle the modern microcontroller.

(And I'm happy I can still write embedded code!)

Intuitive Digital Control Schematic

Regenerative Braking

Initially, I did not feel regenerative braking was all that important on a trials bike – thinking the only benefit was to somewhat replenish the battery. It turns out there is more to it than that.

The rear brake on the 5.7 is very weak (possibly just due to the pad compound as the other parts are fairly standard trials components). This may have been a conscious choice on the part of EM to encourage riders to push the regen button. But to me, it was unnatural. My goal has always been to make any EV operate in a manner consistent with ICE vehicle behavior.

At some point, I had a minor epiphany regarding regenerative braking. Regenerative braking equals engine braking. When you shut the throttle on an ICE vehicle with a mechanical clutch, there is engine braking (of course more so on a 4T than a 2T).

So, regen braking must be present whenever the throttle is completely shut, but it must cease when you pull the electronic clutch lever in fully. It should be proportional to lever position – lots of engine braking with the lever fully released ranging to coasting with the lever pulled to the bar.

Linear Potentiometer versus Rotary Hall Sensor

My original PEC implementation (clutch lever just modulating throttle position) used the linear potentiometer shown below. Its primary advantage was simplicity. But it was difficult to mount a linear pot, and it actually took up a lot of space. Since the shaft moved through the sensor, there needed to be room on the “backside” for the shaft to protrude as it was being pulled.

The other device in the photo is a part used on the Sur Ron LB-X and Segway X260 (small electric off-road motorcycles). They call it a “Speed Adjustment Controller” and it's meant to be operated by a standard motorcycle throttle cable.

It's available as a replacement part (P/N 23700-NM1A-0000) for $32 via Sur Ron USA. The part is marked Liguang Industry Co., Ltd. so I suppose it could be purchased directly should the need arise (although probably in fairly large quantities). It utilizes a Hall-effect sensor, so it's non-contact and has an internal return spring that offers a reasonable lever feel.

Below is a photo of the system being tested on the bench. I had to fabricate an appropriate cable.

Top: Linear potentiometer Bottom: rotary Hall sensor

Testing of bicycle lever and rotary Hall sensor & homemade cable

Contacting Kelly

As part of my endeavor to create the above-mentioned Intuitive Digital Control, I contacted Kelly in China. I am very impressed with their support, receiving answers to technical questions literally overnight.

The Kelly controller has a signal input for “analog braking” that EM did not implement. (They just used a simple on/off push button to initiate regen). With the analog braking input, you can make regeneration strength proportional to an analog voltage. I added the necessary wire to the connector/harness (J2 pin 6), made an appropriate change via Kelly's configuration software, and experimented. Unfortunately, I could not get anything to happen.

My initial contact with Kelly informed them I was working with their controller installed in an Electric Motion motorcycle. I wondered if EM had requested some custom firmware that prevented it from seeing an analog regen signal. (Nope. Turns out you have to apply both a digital and an analog signal to get it to work.)

As part of the exchange, Kelly informed me that my controller's serial number had not been sold to Electric Motion in France but to a company in Canada called Lang's Off-Road. They even forwarded the original invoice to me. Most of it was Chinese, but there was enough English that I could make out what was going on – including the original purchase price of $90!

Lang's Off-Road

A quick search revealed a company in Ontario with a name that matched the invoice. Mostly out of curiosity, I sent them an email asking if they knew anything about the origins of my controller. Never got a reply, so I followed up with a phone call a week later.

Bob Lang was happy to chat with me for 20 minutes. (He did not reply because he assumed I wanted technical support on the controller. I guess I was a bit unclear.) Anyway, Bob is a trials guy and electronics technician. Yes, he told me, Kelly had sold the controller directly to Lang's Off-Road. EM was such a small company in those days, they suggested the Canadians source some of the parts themselves. Weird. He said it was the same with the charger. Later, I wondered if this had to do with import taxes or an “Assembled in Canada” designation.

Test Results

In the 5.7's one-year update I wrote that Cindy gave me the highest possible praise by saying that I had “Made a motorcycle out of it!My Intuitive Digital Control was part of the overall solution.

Unfortunately, one issue remained that I was unable to address prior to the end of the riding season. It had to do with regeneration in one specific, repeatable, circumstance. That is, you can't coast prior to descending a moderate hill and have any regen braking (the controller just freewheels the motor). Yet, an abrupt on-gas to off-gas transition beforehand would always provide regen there. As a test, I modified several controller settings: ABS enabled/disabled, auto-start-regen percent, and maximum regen current. All had a noticeable effect but did not solve the problem.

Subsequently, I pored over my embedded code looking for a bug but found nothing. I think the Kelly motor controller itself has something to do with the problem.

The PIC16F1615 has a single D/A converter that I use for the throttle command voltage. For the regen command voltage, I use a 19 kHz pulse width modulator. Although the Kelly user manual does not say anything about the regen (they call it braking) command's input circuitry, I was told in an email that the PWM rate should be at least 1.5 kHz. I decided to install a single-pole low-pass filter at the output of the regen signal from the microcontroller. This cleaned up some glitches I noticed during rigorous oscilloscope observation.

Field testing will resume in the spring of 2023.