pyBoard compatible E-Bike Computer - The pyEC

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
metri
Posts: 13
Joined: Sat Aug 17, 2019 4:23 am

pyBoard compatible E-Bike Computer - The pyEC

Post by metri » Mon Feb 24, 2020 1:08 pm

The pyEC is a pyBoard compatible multipurpose board capable of talking with just about anything on your E-bike. In fact it's more a general purpose board capable of doing a whole host of digital electronic tasks.

The idea behind the pyEC is that there are a number of layers interconnected to provide just the functionality you need and none of what you don't. The main board, or "Layer" as I've taken to calling them, is the main pyBoard v1.1 compatible board. It has a ton packed into a 4cm*4cm package. 50 pin header for inter-layer communications, CAN, OP Amp, Buzzer, LEDs, SD Card socket, user & reset switches and of course USB for debugging and loading on new programs. Most connectivity has been moved to other "layers". The "Control Layer" is just that, it controls all the layers and has the MCU. Without any additional layers it can basically just blink and beep.

Control Layer - pyBoard v1.1 compatible board w/USB, SD Card, Buzzer, USR/RST Switches and an RGB LED

Serial Layer - Exposes 4  Serial ports complete with RX/TX LEDs for easy debugging and 3.3V/5V level shifters

Input Layer -  Gives 5 switch Inputs and 2 Analog inputs, all with optional voltage dividers to scale inputs

Power Layer - Power input (12V), 5V output, 2 High power & 3 Low power digitally controlled outputs

Kelly Layer - 24V Step-Up converter, DAC Outputs, digital Outputs & UART. Designed for Kelly KLS-S controllers

Battery Backup Layer - Provides LiPo charging and either 5V stable output from LiPo

IMU Layer - Provides a WIT Motion IMU through either I2C or serial. GPS input and direct IMU access ports are provided.

Test Layer - Exposes all pins from the Control Layer as well as buttons / LEDs on IO pins and Potentiometers for ADCs
Attachments
Test-v1.2.jpg
Test-v1.2.jpg (129.4 KiB) Viewed 2561 times
pyEC-v1.2.jpg
pyEC-v1.2.jpg (137.22 KiB) Viewed 2561 times
pyEC-Stack-1.jpg
pyEC-Stack-1.jpg (81.58 KiB) Viewed 2561 times
pyEC-Overview.jpg
pyEC-Overview.jpg (86.33 KiB) Viewed 2561 times

uCTRL
Posts: 42
Joined: Fri Oct 12, 2018 11:50 pm

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by uCTRL » Tue Feb 25, 2020 4:52 am

Link to more info.
I hope the OP doesn't mind.

http://makestuff4.fun/2020/02/09/pyec/

User avatar
pythoncoder
Posts: 4571
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by pythoncoder » Tue Feb 25, 2020 5:32 am

This looks very impressive for a non-commercial project. It must have taken a lot of work.
Peter Hinch

metri
Posts: 13
Joined: Sat Aug 17, 2019 4:23 am

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by metri » Tue Feb 25, 2020 12:50 pm

Thanks, it was a fair bit of work, however laying out circuit boards is also a lot of fun. It's also related to my E-Bike (electric motorcycle really) and that is also something I love working on. I'm hoping to find some other people that would also like to use it.

If anyone wants more info or design files, feel free to contact me here or on my website above.

stijn
Posts: 494
Joined: Thu Apr 24, 2014 9:13 am

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by stijn » Tue Feb 25, 2020 1:24 pm

Can you elaborate a bit on how this works together with an e-bike? Can you plug it into any bike etc?
laying out circuit boards is also a lot of fun
So much fun it doesn't feel like working :)

metri
Posts: 13
Joined: Sat Aug 17, 2019 4:23 am

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by metri » Wed Feb 26, 2020 1:57 pm

stijn wrote:
Tue Feb 25, 2020 1:24 pm
Can you elaborate a bit on how this works together with an e-bike? Can you plug it into any bike etc?
Sure, at it's core it's a general purpose development board with many optional expansion boards. I've put a lot of the details on my website, link above, but I'll summarize here.

Perhaps it's best to describe what problem I'm trying to solve. I want to control my bike, from turning on, to throttle response, to lights, horn etc. and I want to log all the data.

All my switches, key, horn etc. go to the pyEC. Then the pyEC controls all the devices on the hardware. Now my headlight switch can be a push button。 If I want, multiple pushes can control the brightness of the light or make it flash on/off like a safety light. I can have my display give me a password screen, so if I forget my key, I can still turn on the bike. I can use the IMU input to detect the front wheel lifting and cut the throttle, like a virtual wheelie bar. I can use the IMU to detect if someone moves my bike when it's locked and turn on the siren. You could turn on the front & rear cameras too and see who knocked into your bike. Perhaps I want to use my GPS speed instead of my controller outputted speed for my display, or have a compass on my display.

Basically is adds a logic layer between the inputs of you bike (switches, throttle etc.) and the outputs (controller, BMS, Lights). You could add an RFID reader instead of a key or log your tilt angle if that's what you want to see.

It's not really aimed at low power, off the shelf E-bikes. Generally they don't have controller with interfaces you can use, with the Kelly Controls controller I have I can get all system parameters through serial. Higher power bikes, you may want to see how things are performing or implement specific features.

I'm using a Nextion display for my bike display, so I control it through serial and output all the data I'm interested in.

If there is anything you want to know specifically, let me know. I intend this to be an open source project, and always hope to find other people interested to use it or otherwise contribute.

User avatar
pythoncoder
Posts: 4571
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by pythoncoder » Thu Feb 27, 2020 8:00 pm

I can use the IMU input to detect the front wheel lifting and cut the throttle
If the thing can control the throttle of a powerful bike I'd worry about safety. If the processor crashes, so might you.
Peter Hinch

metri
Posts: 13
Joined: Sat Aug 17, 2019 4:23 am

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by metri » Sat Feb 29, 2020 3:45 pm

pythoncoder wrote:
Thu Feb 27, 2020 8:00 pm
I can use the IMU input to detect the front wheel lifting and cut the throttle
If the thing can control the throttle of a powerful bike I'd worry about safety. If the processor crashes, so might you.
Very true, and for this reason I have yet to do it. At the very minimum you need a watchdog timer, but to my knowledge this would need to be ASM or C implementation as the micropython watchdog is relatively slow. You also should ideally ensure your brake can over power the motor at full torque. In a car I believe this to be a requirement of design. Brakes need to be able to hold back engine at full power, two independent systems capable of... I recall it's something to this affect. I think you can also detect MCU rebooted due to a watchdog timer and essentially ensure zero throttle until system is rebooted, as opposed to just continuing regular operation. From a hardware perspective it's possible and I think it can be made safe with proper software design, but should not be attempted without proper design.

User avatar
pythoncoder
Posts: 4571
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by pythoncoder » Sun Mar 01, 2020 11:34 am

metri wrote:
Sat Feb 29, 2020 3:45 pm
...Brakes need to be able to hold back engine at full power...
At risk of stating the obvious the engine powers the back wheel but the brake which does all the work is on the front. I don't know how powerful your machine is; FWIW I rode high mileages on ~100bhp bikes. Using the brakes to control the machine on a slippery road while the engine churns out full power is an unappealing prospect.

This is getting rather OT but do take care. I would not attempt DIY "fly by wire" on throttle or brakes. Safety critical systems should use triple redundancy with majority voting, with each of the redundant systems developed by independent teams.
Peter Hinch

metri
Posts: 13
Joined: Sat Aug 17, 2019 4:23 am

Re: pyBoard compatible E-Bike Computer - The pyEC

Post by metri » Sun Mar 01, 2020 1:43 pm

pythoncoder wrote:
Sun Mar 01, 2020 11:34 am
metri wrote:
Sat Feb 29, 2020 3:45 pm
...Brakes need to be able to hold back engine at full power...
At risk of stating the obvious the engine powers the back wheel but the brake which does all the work is on the front. I don't know how powerful your machine is; FWIW I rode high mileages on ~100bhp bikes. Using the brakes to control the machine on a slippery road while the engine churns out full power is an unappealing prospect.

This is getting rather OT but do take care. I would not attempt DIY "fly by wire" on throttle or brakes. Safety critical systems should use triple redundancy with majority voting, with each of the redundant systems developed by independent teams.
I shouldn't have said what car brakes need to do. I don't have references to point to and this discussion relates to bikes not cars anyway.

Is your concern in general about micro-controllers, or because this one is using microPython? I'm also curious about systems like self-balancing unicycles, how much redundancy do they have? I point out that one in particular as the high speed ones can go 50km/h and can't coast. Do you feel most electric motor controllers for E-bikes have this much redundancy built in? I genuinely want to only make safe systems, but a team made triple redundant system seems virtually impossible on a hobby scale.

I'll put all talk of throttle/regen mapping on hold, and stick to logging for now. I respect your opinion and will research how other electric motorcycles implement redundancy. I also acknowledge this is much more complicated when we involve 3rd parties, and what I would write / test on my bike by myself, is completely different from what should be given to the general public to use.

PS I do have really big rear brakes, but as you say controlling a moving bike with brakes and runaway motor is a nightmare I don't want to live.

Post Reply