arduino nano ebike controller board (TSDZ2+VESC)

beemac

10 kW
Joined
Dec 5, 2020
Messages
538
Location
Bristol, UK
Whilst this is slightly TSDZ2 specific as-is - it would be easy to remove (or not use) the TSDZ2 specific torque sensor circuit and use this for almost any ebike....

This project builds on previous work in the 'TSDZ2 wireless project' - adds the torque sensor circuitry I've been working on - and brings it together into a small, self-contained ebike controller.

The 'design specs'

Input voltage 20-80v
Pin compatible with Nano/Nano BLE 33 (BLE 33 allows the use of ANT+ LEV - can reuse the code from the TSDZ2 wireless project).
12v/5v/3.3v regulators (3.3v provided by regulator on the Nano)
UARTs for VESC and Display (or two VESCs)
Support for headless (direct connection of keypad to controller)
Dual brake sensors
Dual throttle inputs (could also be used as PWM throttle outputs)
Dual speedsensor inputs
Dual PAS inputs.
Two extra GPIO/ADC pins on Aux connector.
Switched VBATT available on Display connector
board dimensions 33x63mm (1.3"x2.5") - and about 10mm (0.4") high - tbc

The nano BLE 33 also has a 9 axis Inertial Measurement Unit (IMU) which might be interesting to play with. Crash detection perhaps?

1716561631979.png

1716561480948.png

So far the board is untested - so don't get too excited - this is in the early stages...

Software wise, obviously this would be compatible with the Arduino IDE and/or CircuitPython however I've also mashed together the TSDZ2 wireless code, plus the ebike controller part from casainho's OSF and tested with the Android App. So far I've not actually got the ebike part operational as I've not had much time - but I do have all sensors working, the android app connects over bluetooth, you can select assist levels, see the sensor readings in the app etc.

To flash custom bootloaders, you need to have SWDIO/SWCLK soldered on the nano. I've left pads on the board for wire links between the SWDIO/SWCLK pads on the underside of the nano - as otherwise it would be impossible to reach once the nano is soldered into the pin headers. I solder wires to the pads on the underside of the nano, secure with a blob of 2-part epoxy and then you've got a nice secure connection to SWCLK/SWDIO. Once that's done flashing can be done via the SWD connector available on the board. If you only plan to use the Arduino IDE - all that isn't necessary and you can use the USB port on the nano for flashing - but tbh I'd do it anyway just in case as once you've soldered in the nano, you're not getting at the underside!

Next steps:

Take feedback about the circuitry/pcb design - electronics and PCB design are not my forte - to try and eliminate any obvious bugs.
Get a couple of sample boards made to test.
Likely repeat the first steps to get a working board! :)
Finish off the ebike app part
Stuff the board and a VESC inside a spare TSDZ2 case and see what happens!

I'm using EasyEDA Pro at the moment - I know it's not as good as KiCAD or others - but it makes life a lot easier with the parts and PCB fabrication integration.

Constructive criticism welcome! :)
 
Last edited:
After having a go routing the above board, I decided to simplify.

This board provides equivalent functionality to a native TSDZ2 controller but without the 6v headlight output - when coupled with an appropriate VESC controller.

I'm planning to use the Makerbase MKSESC 75100 with this board to replace all the internals of a TSDZ2...

Estimate the board will cost about $30 to get made up as it stands, plus the VESC and a nano/nano ble 33.

Board measures 25x60x13mm (W x L x H)
Eliminated the 5V regulator - uses the 5V feed from the VESC
Reduced number of connectors.

INTERNAL:

1. ADC Motor temperature
2. PAS1
3. PAS2
4. 5V DC (this is an input from the VESC but also needs to be connected to the PAS and Temp Sensor)
5. Torque sensor excite
6. VESC RX
7. VESC TX
8. Ground

EXTERNAL:

1. Speedsensor
2. Button Up
3. Button Down
4. Button Ok
5. Button Power
6. ADC Throttle
7. Brake Sensor
8. 5V DC (for Speedsensor/Throttle)
9. Ground

DISPLAY (Optional):

1. Brake Sensor
2. Switched VBATT
3. Display RX
4. Display TX
5. Ground

RGB LED: (For feedback in headless/no-display mode) - i'm not sure about this, especially if the cables to the LED are long- might need too much current from the GPIO pins, might be better to use an APA102 or similar powered from the 5V supply.)

1. LED Red
2. LED Green
3. LED Blue
4. Ground

VBATT:

1. Battery voltage input (20-80V)
2. Ground

Board is 2 layers, fully manually routed and passes all DRC checks, but I've had enough of EasyEDA for today, will take another look tomorrow with fresh eyes and maybe order a few samples to test!



1716755174616.png

1716755195026.png
1716756125151.png
 
Last edited:
I had a similar board to the above made - it worked ok-ish on the bench but was very noisy and impossible to debug properly because i'd put the arduino above most of the circuitry and so couldn't probe - rookie mistake! I'm waiting for rev.2 to be delivered that has some changes to the power stages and filter output from the torque sensor and also moves almost all circuitry from under the nano so it can be probed. I will report back on progress and hopefully publish some schematics.
 
Good to see someone still at it.
Twelve years ago I built an Arduino Nano based BMS.
Note I didn't want to deal with surface mount for a hobby project, so through hole.
Ran it for 9 years trouble free:

 
Good to see someone still at it.

Note I didn't want to deal with surface mount for a hobby project, so through hole.
cheers, yea It's a good way to learn more about electronics for sure but no way i'm doing smd soldering on even this relatively small scale. I'm getting the boards made by jlcpcb, still amazes me (and slightly worries me!) that I can get custom pcbs made, populated, tested and delivered from china to the UK in a week.
 
still amazes me (and slightly worries me!) that I can get custom pcbs made, populated, tested and delivered from china to the UK in a week.
Downside is your design will almost certainly be reviewed and parts or all copied if it has commercial potential.
40 years ago a company I worked for considered the same deal with the devil.
 
Downside is your design will almost certainly be reviewed and parts or all copied if it has commercial potential.
40 years ago a company I worked for considered the same deal with the devil.
Ah I'm not looking to keep anything a secret, will all be open source and published on github. I'm building on top of the work of others - esp from a software point of view.
 
Hey, Ive been following these threads ever since my tsdz2 with the old controller and OSF got stolen. Looking to use this to convert my replacement bike with tsdz2 to open source.
@beemac , any progress since July on this project? Stuff to share and/or possibilities to contribute?
 
Back
Top