GSM middrive, with VESC and Teensy "ForumsController" conversion

daenny

Pedelecer
Jun 10, 2015
34
18
37
So, my latest build is finally mostly complete:

I used for the build a GSM middrive (without internal controller) from Woosh, a VESC open source controller and a Teensy as "CycleAnalyst/ForumsController".
I have built a display based on a 2.2 inch LCD and also module with 5 way joystick for the controls and push throttle-button.
For power I use 12s LiPo (MultiStar 8000mAh 6s x 2 from HobbyKing in a saddle bag). I am an RC enthusiast, so I already had proper balancing chargers and know about the pros and cons of LiPos.
I ran the wires through the frame for a nice a clean build.

The front light is powered via a step-down module and the power can be switched on via the handlebar controls. This is the final bike:

2016-10-10 12.33.04.jpg

In more detail:

I used the VESC (http://vedder.se/2015/01/vesc-open-source-esc/) as controller as it gives complete control over the settings. Via Serial communication I can get the battery current and voltage, board and Mosfet temperature, motor current and RPM.
However, as it is based for electrical skateboards, there is no input for throttles, ebrakes, PAS and displays. It has two available analog/digital pins but also a Serial port.
So I first thought I will add a CycleAnalyst for this and use one of the A2D pins as throttle input. However, then I came across the ForumsController (some info in German: http://www.pedelecforum.de/wiki/doku.php?id=elektrotechnik:forumscontroller) and thought, I can build this myself, and since I need much less functionality, i.e. I can get a lot of data already from the VESC, I basically only need the microcontroller to handle all the e-bike accessories.
The ForumsController code is nice since it already took care of a lot of things, i.e. Voltage cutoff, PID control for the output, PAS, velocity limits, range calculation, different profiles, etc.

I bought a Teensy (a 96mhz "Arduino compatible") board and adapted the ForumsController code to run on it.
I build a simple PCB to which I attached the ebrake, display, throttle and the Serial communication from the VESC. The VESC also provides one 5V 1A output which powers the Teensy and all accessories.
Below an intermediate PCB version and the VESC in a 3D printed case:
2016-07-29 20.36.50.jpg 2016-07-29 20.37.05.jpg
In the final version I changed the JST connectors for USB-C type connectors and wired it up using USB-C cables. I put the VESC and the teensy together in a 3D printed box on the down tube.
2016-10-10 12.33.22.jpg

As a display I did not like the standard display, which is usually used, namely a Nokia 5510 display. There was already a mockup for a colour LCD, so I used the existing code and made it work with the Teensy.
2016-07-29 20.36.11.jpg 2016-07-29 20.38.13.jpg

Some more info on the Display (in German):
http://www.pedelecforum.de/forum/index.php?threads/forumscontroller-eine-display-diskussion.16947/page-8#post-701276
Video from the display:
https://www.dropbox.com/s/o81ibg4oab30zgj/2016-07-29 19.21.39.mov?dl=0

As final step I changed the throttle for a 5 way joystick and a push button throttle. I used various resistors to hook all 6 buttons up via a single Analog input. I kept the e-brake on a separate wire, just to have more reliability and I had the spare wire anyway ;) .
2016-10-09 18.29.59.jpg 2016-10-09 18.29.52.jpg

I used a USB 3.0 cable which I wired through the frame. It has 8 wires in total. The display used 6 of the wires, so I had exactly one left for the analog input for the 6 buttons and one for the e-brake. The ground is combined in the display case. I recycled the connectors of these Julet wire harnesses so I have the USB cable go inside the display case and two Julet connectors for the e-brake and the button panel, for which I 3D printed a case. See the button panel below:

2016-10-10 12.34.27.jpg 2016-10-10 12.31.00.jpg

With the 5 way joystick I can increase and decrease the support in 50W steps (up/down) and change the views of the disply (left/right). A center push enters the menu, which then temporarily overwrites up/down and center for selection. The push button on the left is a push throttle, which directly sets the target support for 500W.

I also build a speed sensor. It is simply a Hall switch and a spoke magnet from an old bike computer.
The light can be controlled via the menu, there is a step-down module hidden underneath the front fork. The module has a shutoff input, so the Teensy can switch it on and off (see the display video 2:40)
The module is like this one:
http://www.ebay.co.uk/itm/LM2596HV-DC-DC-Buck-Converter-5V-60V-to-1-25V-26V-Power-Module-48V-to-3V-5V-12V-/321512279591?hash=item4adba00e27:g:fr4AAOSwQItUCR6F

The code can be found on github, it is mostly in English, maybe here and there a German comment/text ;)
https://github.com/daenny/Arduino-Pedelec-Controller

If you have any questions or want some more details (e.g. your German is not sufficient) let me know!
 

parasole

Finding my (electric) wheels
Oct 31, 2016
11
1
62
Sweden
Hi Daenny,

Nice I found your post, I was planning similar setup, have already GSM middrive, next looking forward for VESC... in my understanding you use curently available version 4, have you done any changes/adaptations on controller side?
And why 32 bit Teensy instead of Atmega?
 
Last edited:
  • Like
Reactions: LeighPing

daenny

Pedelecer
Jun 10, 2015
34
18
37
Hi,
I use the VESC 4.12 with the latest BLDC firmware.
I did a quite somechanges to get the ForumsController code running on the Teensy, they are all on my github link in my initial post.

I used a Teensy because:
- Multiple UART RX/TX (so you do not need to unplug the VESC while programming the Teensy), and more flexible other pins (all are Analog and Digital)
- More space, the Nano is on its limit with the ForumsController code.
- I wanted the colour LCD display. It's now connected directly to the Teensy, I do not know if the atmega's are fast enough and have enough space for it.
- Faster, 96MHz vs 16 or 32MHz on the atmega's. I could run the PID control loop at 1Khz, if I would want to (which does not make sense, but it's fast enough for it ;) ).

I have biked now around 800km with this setup, and all is still working fine :)
 
  • Informative
Reactions: LeighPing

parasole

Finding my (electric) wheels
Oct 31, 2016
11
1
62
Sweden
Thanks for your reply Daenny, clear enough, will try to move forward by using your setup...
 

parasole

Finding my (electric) wheels
Oct 31, 2016
11
1
62
Sweden
Hi Daenny,
looking down to your display code, is it on porpose or pinout mistake?

#define TFT_CS 10
#define TFT_RST 10
 

daenny

Pedelecer
Jun 10, 2015
34
18
37
No that's actually on purpose. It saves a pin and therefore a cable that runs through the frame. You need to give the LCD library all pins, so that is why I defined them. but one of them does not need to be connected, I think it's CS which I pulled to ground if I remember correctly. This of course only works when you only have one SPI connection
 

parasole

Finding my (electric) wheels
Oct 31, 2016
11
1
62
Sweden
Thanks, clear, assume CS is used for selecting between display or SD card reader, which is not required... One more question, looks like you are not using analog throttle, instead one button for power boost when required?
Otherwise PAS sensor is the main input for the bike to ride?
 

daenny

Pedelecer
Jun 10, 2015
34
18
37
Yes indeed. CS is for selecting between different SPI devices, and since I only have one it's always the LCD. I ditched the throttle eventually, the PAS with the option to quickly change in 50W steps is usually more than enough. And in the rare case that you want to quickly overtake someone or make the traffic light, the boost button is nice.
 
  • Agree
Reactions: parasole

parasole

Finding my (electric) wheels
Oct 31, 2016
11
1
62
Sweden
Hi Johan,

there is no real diagram to share about, I gathered every thing from Daniel explanation over here and on pedelecforum.de forum (home for FC)...
In my case it is almost the same as Daniel describe except that I am not using Teensy, instead I did a small PCB and attached to it the controller soldered to an adapter PCB. I am using same controller as in Teensy so fully used Daniel code, the difference is in programming the controller which I did by using Jlink... Then FC takes all the signals like brake, control switches, speed and PAS sensors and communicate with VESC over serial as well it takes the power supply from there... If you are around Stockholm then you are free to come over and see my setup...
 
Last edited:

thomasrtg

Just Joined
Sep 22, 2020
1
0
Hi there,

I know it's an old thread but I love the idea of this project. I have bought a vesc and manufacture a custom made ebike kit. My issue is that I would like to implement this on my VESC so I can get a PAS sensor, however I am a big noob at programming or understanding codes. Is there a step by step tutorial (for noobies :D) that I could understand ?
If not, would one of you accept to assist me ?

thanks in advance guys !


P.S. : here is a picture of the bike

38429