You are here

Switch two Motor Profiles/Modes (UART)

8 posts / 0 new
Last post
anli
Offline
Last seen: 5 years 6 months ago
Joined: 2017-09-29 20:17
Posts: 5
Switch two Motor Profiles/Modes (UART)

Hi guys,

I've built an e-kick-scooter and it works very well, except the German laws ;)

Driving electronic vehicles in the street without number plates, insurance, helmet, etc is illegal. But, there are "pedelecs", which are the smallest models of the e-bike section. Those are (nearly) handled as regular bikes, having the following limitations:

P_max = 250 W (on the wheel)

v_max = 25 km/h

- only Assist Mode: fire at 250 watts while pedaling (no throttle)

- "drive up assist/push bike assist" (throttle) up to 6 km/h with unlimited power

Now there is the first kick scooter available on the market which is legal to drive in pedelec mode (Metz Moover) and I want to add this feature to my scooter. To achieve this, I have connected an esp8266 to my VESC, which recognizes a acceleration "kick" and sets "max power" to the motor for a few seconds. "Max power" is limited via VESC-Tool, as well the max speed. This is working  quite well so far, all i have to do is optimizing my "kick detection" code to make it deal better with hill-down driving, braking etc.

 

But, ...

... when I want to drive off-road or in the woods, I want to switch to my normal setup which means i want to use the throttle for speeding up and unlock the erpm limit and power limit in the VESC. For doing this I do not want to always carry my notebook wit me.. ;)

So I run through the VESC source code, but as I understand, there is no way to read/write the motor/app config from/to the VESC using UART (without writing code and compiling firmware). Is it possible to use the USB-Port for this, as the VESC-Tool is doing?

 

The other option I thought about is reading the actual rpm and power values, and setting up a control loop inside the esp8266, to cut the power at 25 km/h and to drive at a maximum power of 250 watts. But this will not be an easy job to me...

There is another thread (regarding a German e-bike using a VESC) out there in the www where someone is telling that it is nonsense to limit the power of a vehicle, simply because there are no measuring devices for traffic control, measuring the power of a pedal-assisted vehicles. So maybe the second idea is not that difficult. Mayby 5 speed stages where the esp sets different max currents, to get an output at around 250 W.

 

So if anybody has an idea how to switch the motor config or how to control the power to achieve the presented goal, please let me know...

 

Thanks,

anli

 

frank
Offline
Last seen: 1 week 5 days ago
VESC BronzeVESC FreeVESC GoldVESC OriginalVESC PlatinumVESC Silver
Joined: 2016-12-27 20:19
Posts: 847

Get yourself a NRF module and use your Smartphone. Benjamin is working on  profiles that can be written onto the vesc with a single click. 

App download works via purchased files top right of this page.

https://www.trampaboards.com/nrf-dongle-p-25516.html

basti30
Offline
Last seen: 1 year 6 months ago
Joined: 2018-06-18 17:20
Posts: 6

I am very interested in a way to use the COMM_SET_MCCONF and COMM_GET_MCCONF commands via uart too. To be precise I want to set a new ERPM and/or Current limit. The VescUart.h libary works like a charm but, I am not able to implement the needed functions myself, does anyone know how to use them?

Would love if anyone can help us.

EDIT: Burned my fingers there a little bit. Made the same mistake as https://www.vesc-project.com/node/248. Bricked the vesc and had to reflash the software with a stlink. Be CAREFUL with uart. Some commands can seriously mess with the vesc.

anli
Offline
Last seen: 5 years 6 months ago
Joined: 2017-09-29 20:17
Posts: 5

Thanks frank, but i want make use of a wifi hotspot and a webserver running on an esp8266 instead of bluetooth for this purpose. Real-time data and cockpit data is already working great. With this concept i do not need to install any app on a smartphone, one only needs a webbrowser.

 

And basti30, thanks (oder danke :) ) for the link. Somehow i didn't see the COMM_GET/SET_MCCONF commands for UART... i thought the usb UART is different to the jst header UART. Ok, the interface is already there.

Just be patient, i will write a library for changing motor config profiles. but at the moment i am busy with moving to another apartment (and with building a battery pack).

 

EDIT:

i prefer the point on benjamin's todo list for adding a command for using a smaller packet and only make volatile changes to the values in the RAM, except for permanent changes... 

https://www.vesc-project.com/node/207

Greetings,

anli

basti30
Offline
Last seen: 1 year 6 months ago
Joined: 2018-06-18 17:20
Posts: 6

That would be awsome, Danke!! :) I'm planning to use a esp8266 too. I've already tried to add the functions to the library myself, but i don't think i could get it to work. The concept seems simple:
1. Send a COMM_GET_MCCONF request (2, 1, 14, 225, 206, 3, NULL, right?) , same as you would do with a COMM_GET_VALUES request (2, 1, 4, 64, 132, 3, NULL). Then put the huge pile of received data in a appropriate struct.
2. Change the values you want.
3. Build the COMM_SET_MCCONF message with the data from the struct and send it back (something like 2, 1, 13, <data> , <crc>, 3, NULL).
But that's far above my skill-level.

Yes, would be great if there would be such a function available. Then you could implement many functionalities which are common on commercial boards and bikes much easier. 

Greetings 

basti30

EDIT: what makes matters worse, the package size is gonna be bigger than 256 bytes.  The answer from the vesc on the COMM_GET_MCCONF request is : 3, 1, 84, 14, 1, 0, 2, ...... what means it got a size of 1*256+84 = 340 Bytes. In the Rolling Gecko Library this isn't implemented.

EDIT 2: got the bigger packagesize to work. Can receive the byte stream. But one thing is for sure: nobody will be able to do this on an arduino. I need two arrays with at least 340 bytes plus an struct with the same amount of bytes. esp8266 is the way to go. It's a pity there isn't currently a different lightweight method available.

TechAUmNu
Offline
Last seen: 2 weeks 5 days ago
VESC Free
Joined: 2017-09-22 01:27
Posts: 575

I had to do this for one of my controllers for someone in Belgium, I used ADC app and modified it so the reverse button divided the output current by 2.5 when pressed. So you just have a little switch to change power modes.

basti30
Offline
Last seen: 1 year 6 months ago
Joined: 2018-06-18 17:20
Posts: 6

Hi everybody,

I have created a github repo. https://github.com/basti30/VescUartControl​ 

Currently I am able to request and read all 340 bytes of mc-config values from the vesc 6 and store them as struct successfully. Had to implement receiving of bigger packages and add the new buffer.cpp and datatypes.cpp from benjamins github. Next step is to pack them into a valid message and send them back. Babysteps i guess.

Keep in mind I'm not a professional, good or efficient programmer by any means.

@TechAUmNu: nice workaround yes

Greeting,

basti

basti30
Offline
Last seen: 1 year 6 months ago
Joined: 2018-06-18 17:20
Posts: 6

Hi,

finally managed to get the library to work! Many things were already available in Benjamins bldc code. To see how it works look at the example included. Works for my Vesc6. Can set the max ERPM (and all the other settings) with my esp8266. laugh Would like to hear your thoughts on it. But use at own risk.

Greetings