Zweiter Frühling für ION-Antrieb --- Sparta, Batavus, Koga ...

Diskutiere Zweiter Frühling für ION-Antrieb --- Sparta, Batavus, Koga ... im Nabenmotoren Forum im Bereich Fertig-Pedelecs; Here are two log files of using the throttle in parking mode. The first log starts after initialisation with assist level 1. I push the down...
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
Here are two log files of using the throttle in parking mode. The first log starts after initialisation with assist level 1. I push the down button twice to go into "park assist mode". Then is slowly open the throttle to full and shut it again. The second log shows the same thing, put with 3x pushing the down button to go into "reverse park assist mode".
Do you guys have a script to analyse the logs? Staring at a hex editor becomes boring very quickly :)
 

Anhänge

  • park_fwd.txt
    25 KB · Aufrufe: 2
  • park_rwd.txt
    22,3 KB · Aufrufe: 3
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
I made a third log of the throttle control, this time whilst driving with assist enabled. In the log I use the throttle 2 times. The first time, I slowly open it, hold it open for a few seconds and then close it. The second time, I open the throttle, hold it open until the boost function hits the time limit (you feel the boost dropping away after +/-10 sec) and then close the throttle again.
 

Anhänge

  • boost whilst driving.txt
    37,9 KB · Aufrufe: 2
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
Today I also implemented a (badly) working battery meter.

There are 2 bytes to give back the battery voltage to the display. The first time, the battery needs to return the maximal value of these bytes. I decided to use 0xFF and 0x00 as the maximum values. When sending a value to the display, I only use the first byte. For the other byte (probably the least significant byte) I always return 0x00.
A value of 0x18 corresponds to 0%. I don't know why the display uses this offset. My suspicion is that it wants to get back a battery voltage and load and it does fancy calculations itself to derive the battery charge status from these values. That could mean the second byte is not the least significant of the two, but would indicate the current consumed. Since we're not measuring current at the moment, I will ignore it.
A value of 0xFF corresponds to 100%.

I used the espressif example code to read the ADC with calibration. The results are quite accurate, within 1% of my voltmeter. The maximum permissible voltage is 3V, but to be more accurate you should scale your voltage divider to stay a bit below that. I used 118K and 8K4 as resistor values with my 36V battery (peak voltage: 41-42V).
The result is just like expected: when the battery is not moving, my display indicates 88% charge (correct). When the motor starts working, this drops to around 60% with boost enabled. When only pedaling lightly, it is more like 65%. When the motor stops working, the value slowly climbs back to 88% over a minute or so.
Note that I don't do any averaging. The value shown is only 1 measurement made at the moment the display asks us.

To make a more reliable battery meter, we should implement something like the algorithm I proposed. But for that I'll wait for @void-spark to return. I'm not too much of a programmer and I don't know the ESP32 architecture, but I think that if we'll introduce time-based operations like reading voltage every second, the main code loop might better be refactored to an interrupt driven approach (uart, button and timer).

Maybe we can even indicate the "charging: xx%" indicator on the display, that would be cool.
 
Hochsitzcola

Hochsitzcola

Themenstarter
Dabei seit
04.09.2009
Beiträge
4.459
Punkte Reaktionen
4.375
Details E-Antrieb
Gazelle mit BionX IGH3 + OpenSource Firmware
herman74

herman74

Dabei seit
28.04.2022
Beiträge
49
Punkte Reaktionen
15
Ort
Utrecht
Kodel

do you have that firmware locally or on github?

I wanted to test how much my battery sinks under load here I have a pretty heavy battery 17ah

did you make some more changes to the firmware?
 
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
We should count the Wh for that purpose, just looking at the voltage will never give an accurate SOC.
I know. But like @herman74 suggested, we could see if with some clever mathematics we can't come up with a usable indication. In any case, if a circuit board is designed it should include a current sensor. And probably also an inrush current limiter. And maybe a low quiescient current voltage regulator. For my motorcycle, I made a controller (ignition, lights, blinkers, alarm system, charger) that only uses 45uA in standby by replacing the voltage regulator on an Arduino. I don't know what is possible with the ESP32.
For now, I still have the same board with 2 relais that @herman74 is using laying around. I might build up a first HW version with this board, now that my BMS has arrived. Then I can close the battery case again and ride the bicycle normally. I only need to find out how to do OTA updates or I'll have to open up the battery on each build :)
 
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
Kodel

do you have that firmware locally or on github?

I wanted to test how much my battery sinks under load here I have a pretty heavy battery 17ah

did you make some more changes to the firmware?
No, I'm not too familiar with how to make a branch without offending anyone :) So only local. And I can't post the file, since I changed quite some code, amongst others running at 19200 baud.
The adaptations you need to make are limited to 3 places in main.cpp:

1) to be added after "static const char *TAG = "app";"
C:
//Start koen add ADC code
#include "driver/adc.h"
#include "esp_adc_cal.h"
bool cali_enable = false;
unsigned char byte_voltage=0xE0;
static int adc_raw[2][10];
static esp_adc_cal_characteristics_t adc1_chars;
//ADC Channels
#if CONFIG_IDF_TARGET_ESP32
#define ADC1_EXAMPLE_CHAN0          ADC1_CHANNEL_7
#else
#define ADC1_EXAMPLE_CHAN0          ADC1_CHANNEL_2
#endif
//ADC Attenuation
#define ADC_EXAMPLE_ATTEN           ADC_ATTEN_DB_11
//ADC Calibration
#if CONFIG_IDF_TARGET_ESP32
#define ADC_EXAMPLE_CALI_SCHEME     ESP_ADC_CAL_VAL_EFUSE_VREF
#elif CONFIG_IDF_TARGET_ESP32S2
#define ADC_EXAMPLE_CALI_SCHEME     ESP_ADC_CAL_VAL_EFUSE_TP
#elif CONFIG_IDF_TARGET_ESP32C3
#define ADC_EXAMPLE_CALI_SCHEME     ESP_ADC_CAL_VAL_EFUSE_TP
#elif CONFIG_IDF_TARGET_ESP32S3
#define ADC_EXAMPLE_CALI_SCHEME     ESP_ADC_CAL_VAL_EFUSE_TP_FIT
#endif

static bool adc_calibration_init(void)
{
    esp_err_t ret;
    bool cali_enable = false;

    ret = esp_adc_cal_check_efuse(ADC_EXAMPLE_CALI_SCHEME);
    if (ret == ESP_ERR_NOT_SUPPORTED) {
        ESP_LOGW(TAG, "Calibration scheme not supported, skip software calibration");
    } else if (ret == ESP_ERR_INVALID_VERSION) {
        ESP_LOGW(TAG, "eFuse not burnt, skip software calibration");
    } else if (ret == ESP_OK) {
        cali_enable = true;
        esp_adc_cal_characterize(ADC_UNIT_1, ADC_EXAMPLE_ATTEN, ADC_WIDTH_BIT_12, 0, &adc1_chars);
    } else {
        ESP_LOGE(TAG, "Invalid arg");
    }
    return cali_enable;
}
//End koen add ADC code

2) To be changed in "HandleMotorMessageResult"
C:
    } else if(message.type == MSG_CMD_REQ && message.payloadSize == 2 && message.command == CMD_GET_DATA && message.payload[1] == 0x18) {
        // GET DATA 1418 14:18(Battery level)
        // KOEN start adc changes
        //uint8_t payload[] = {0x00, message.payload[0], message.payload[1], 0x1e, 0xb5};
        uint8_t payload[] = {0x00, message.payload[0], message.payload[1], byte_voltage, 0x00};
        // KOEN end adc changes
        writeMessage(cmdResp(message.source, MSG_BMS, message.command, payload, sizeof(payload)));
        return CONTROL_TO_MOTOR;
    } else if(message.type == MSG_CMD_REQ && message.payloadSize == 4 && message.command == CMD_GET_DATA && message.payload[1] == 0x18 && message.payload[3] == 0x1a) {
        // GET DATA 9418141a 14:18(Battery level) 14:1a(Max battery level)
        // KOEN start adc changes
        //uint8_t payload[] = {0x00, message.payload[0], message.payload[1], 0x1e, 0xb5, message.payload[2], message.payload[3], 0x1f, 0x53};
        uint8_t payload[] = {0x00, message.payload[0], message.payload[1], byte_voltage, 0x00, message.payload[2], message.payload[3], 0xff, 0x00};
        // KOEN end adc changes

3) To be added after "const bool calibrate = (buttonBits & CALIBRATE_BIT) != 0;" in the while loop in my_task:
C:
        //Start koen add adc code
        uint32_t voltage = 0;
        uint32_t realvoltage = 0;
        unsigned char batterypercentage=1;
        adc_raw[0][0] = adc1_get_raw(ADC1_EXAMPLE_CHAN0);
        if (cali_enable) {
            voltage = esp_adc_cal_raw_to_voltage(adc_raw[0][0], &adc1_chars);
            // voltage is in millivolts
            // 2.65V is 40.1V in realty due to voltage divider
            // ratio is 15.13
            // divider is3K3+5K1=8K4 and 118K, total 126,4; 126,4/8,4= 15
            // real voltage= voltage/1000*15.13
            // full= 4.2V empty= 3.0V, difference= 1.2V
            // (realvoltage - 3V)/1.2V * 100 -> that is the percentage of charge
            // MAX value is set to 0xFF and 0x00, 0% is 0x19 (decimal 24) as offset
            // determined by testing
            realvoltage= (uint32_t)(((float)voltage)*1.53);
            if (realvoltage < 3000) realvoltage=3000;
            batterypercentage= (unsigned char)(((float)(realvoltage-3000))/12);
            byte_voltage = 24 + (unsigned char)(((float)(231*batterypercentage))/100);
            //ESP_LOGI(TAG, "Voltage: %d, Realvoltage: %d, Percentage: %d, Byte: %d", voltage, realvoltage, batterypercentage, byte_voltage);
        }
        //End koen add adc code
 
herman74

herman74

Dabei seit
28.04.2022
Beiträge
49
Punkte Reaktionen
15
Ort
Utrecht
I Will try to put the code in mijn GitHub fork


i also need ota here i want to build the board in my battery

my wife doesn't want to use the bike like this with the controller on the back

I hope oto will come in via a web interface so that the file can be uploaded via a web interface

and that you just connect to the esp via wifi so the esp pretends to be a router and you can connect if you have the password
 
herman74

herman74

Dabei seit
28.04.2022
Beiträge
49
Punkte Reaktionen
15
Ort
Utrecht
kodel

i change 1 and 3 but dont now how to change 2

you say To be changed in "HandleMotorMessageResult"

i see 3 times HandleMotorMessageResult in the file, at row 153 and row 230 and row 394

and ware to change the adc pin? i tink i will use IO34 6 I GPIO34, ADC1_CH6, RTC_GPIO4

please tell my how to change HandleMotorMessageResult and how to change te adc pin so itworks on my eps32 wroom

ion1/main.cpp at master · martijn456/ion1
 
Zuletzt bearbeitet:
Mike747

Mike747

Dabei seit
11.03.2021
Beiträge
256
Punkte Reaktionen
44
In any case, if a circuit board is designed it should include a current sensor. And probably also an inrush current limiter. And maybe a low quiescient current voltage regulator.
That seems quit ambitious, I like the idea (y).
I am still waiting for the VOM chip. I hope to build a more advanced version of the board soon. This setup should deal with the inrush current.

The voltage regulator (type) you mention, I find interesting. For now we use a "generic" voltage convertor, for example:
0.88€ 39% OFF|Abwärtswandler Leistungsmodul 5 40 V bis 3 V / 3,3 V / 3,7 V / 5 V / 6 V / 7,5 V / 9 V / 12 V 1A Konverterplatine Einstellbares Leistungslademodul Heißer Verkauf Abwärtswandler Abwärts Aufwärtswandler|Integrierte Schaltkreise| - AliExpress
The convertor is always on and takes up some current even in standby. Besides the ESP32 chip, it also (always) powers the voltage divider of the bow-bus. I am curious how much power is drawn in standby, but probably a bit more than the ESP32 chip itself consumes. On the other hand: used with the rather large batteries, the consumption might still be relatively small.
 
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
Indeed, if power consumption in hibernation is only 2mA, it still gives 4000 hours of shelf life before an 8Ah battery is drained. That is over 5 months. So if you recharge the battery monthly, it won't be a problem. I will rewire my hardware with the ESP32 with integrated 5V, 3.3V regulator and two relais and I'll report back the findings on current consumption.
 
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
I also found out how the throttle works (I found the python script)

Parking mode is simply communicated by the display as assist level 4. Rearwards parking is sent as assist level 5:
Code:
tgt:BT typ:1 src:DP [10-21c1-1d04-14] [1d04] - CU3: SET ASSIST 04
tgt:DP typ:2 src:BT [10-c220-1d-7b] [1d] - CU3: SET ASSIST - OK
tgt:MT typ:1 src:BT [10-0120-32-75] [32] - ENABLE ASSIST
tgt:BT typ:2 src:MT [10-2200-32-ea] [32] - ENABLE ASSIST - OK
tgt:DP typ:1 src:MT [10-c100-20-03] [20] - GET DISPLAY SERIAL#
tgt:MT typ:2 src:DP [10-02c8-20c211280000003776-50] [20c211280000003776] - GET DISPLAY SERIAL# - OK c211 3776 (c211280000003776)
tgt:MT typ:1 src:BT [10-0121-3404-2c] [3404] - SET ASSIST LEVEL 04
tgt:BT typ:2 src:MT [10-2200-34-49] [34] - SET ASSIST LEVEL - OK

The throttle position is communicated constantly from display to motor. The motor does it's own thing with it, depending on the assist level (boost the existing assistance whilst pedaling or move forward/backward without pedaling at a maximum of walking pace)
Throttle levels vary from 0x04 (closed) to 0xE7 (fully opened).
Code:
tgt:MT typ:1 src:DP [10-01c1-3604-e3] [3604]
tgt:DP typ:2 src:MT [10-c200-36-5e] [36]

tgt:MT typ:1 src:DP [10-01c1-362c-fd] [362c]
tgt:DP typ:2 src:MT [10-c200-36-5e] [36]

tgt:MT typ:1 src:DP [10-01c1-36e7-9a] [36e7]
tgt:DP typ:2 src:MT [10-c200-36-5e] [36]

You could create a "boost" button that fakes the message from the display :)
 
herman74

herman74

Dabei seit
28.04.2022
Beiträge
49
Punkte Reaktionen
15
Ort
Utrecht
Indeed, if power consumption in hibernation is only 2mA, it still gives 4000 hours of shelf life before an 8Ah battery is drained. That is over 5 months. So if you recharge the battery monthly, it won't be a problem. I will rewire my hardware with the ESP32 with integrated 5V, 3.3V regulator and two relais and I'll report back the findings on current consumption.
You switch to same board as mine?


please tell my how to change HandleMotorMessageResult and how to change te adc pin so itworks on my eps32 wroom
 
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
@herman74 I'll probably switch to the same board as the one you have. It is a bit too tall to fit in my battery, but at a slight angle it might work.

To change the HandleMotorMessageResult function, you need to find the 2 lines containing "0x1e, 0xb5" and changes these 2 lines to the lines in the code I posted above. Note that any line starting with "//" is a comment and can be omitted. Currently I'm using pin 35 to sense the voltage. If you want another pin, you should replace "ADC1_CHANNEL_7" in the code by the value you find here: https://docs.espressif.com/projects/esp-idf/en/v3.3/api-reference/peripherals/adc.html
 
Mike747

Mike747

Dabei seit
11.03.2021
Beiträge
256
Punkte Reaktionen
44
Parking mode is simply communicated by the display as assist level 4. Rearwards parking is sent as assist level 5:
The throttle position is communicated constantly from display to motor. The motor does it's own thing with it, depending on the assist level (boost the existing assistance whilst pedaling or move forward/backward without pedaling at a maximum of walking pace)
Throttle levels vary from 0x04 (closed) to 0xE7 (fully opened).
Quite interesting:unsure:. I wonder if your bike had 3 or 5 assist levels originally (I would guess 5 actually). If it was 3: 4 and 5 are "added" for throttle it seems. Can you give the type of bike you have and maybe motorserial?
Since the motor does its own calculating and acting on the throttle: it seems throttle functionality depends on motorsoftware. The same could be true for 3 or 5 support-modes then.
 
K

kodel

Dabei seit
28.07.2022
Beiträge
32
Punkte Reaktionen
22
The bicycle model is batavus socorro easy. According to an old review I found, it has 3 support levels, which correponds to what I see on my display.
The motor serial is M312024765.
 
Mike747

Mike747

Dabei seit
11.03.2021
Beiträge
256
Punkte Reaktionen
44
The brochure does not mention the amount of support-levels, the is also no mention of the throttle (which does show on the pictures :) ).
Motor is the 40 Nm version 💪.

Something funny came up:
https://autoverkoopdehaan.nl/gebrui...tavus-socorro-easy-slechts-2560-km-goede-accu
The bike looks very original, the display is the "newer" HD-version (CU3V2), but in the "older" CU3 housing :unsure: .
Can you tell which version came with your bike? I wonder what the sticker on the back of the display says.
 
Mike747

Mike747

Dabei seit
11.03.2021
Beiträge
256
Punkte Reaktionen
44
G

gpu7990

Dabei seit
11.08.2022
Beiträge
20
Punkte Reaktionen
2
Hello again, i found cu3 display , and now i see that it automatically start after connecting to 5V. After couple of seconds cu3 goes to standbay mode- "Ion tehnologies" on sccreen.
Then i connect esp32 board and display had turnen on.
After i press EN botton on esp32 for couple of seconds - display automatically restarts.
So now i need connect the motor and try to calibrate/run?
 
Thema:

Zweiter Frühling für ION-Antrieb --- Sparta, Batavus, Koga ...

Zweiter Frühling für ION-Antrieb --- Sparta, Batavus, Koga ... - Ähnliche Themen

Sparta ION Akku defekt?: Hallo zusammen, ich bin neu hier, vielen Dank für die Aufnahme...und ich komme gleich mit einem Problem/Frage. Meine Frau fährt (wenig, da sie...
Sparta Ion, Hercules emove, Batavus, Koga auf Li-Ion Akku umbauen reparieren.: Ich bin Besitzer zweiter solcher Bikes und habe diese nach einem Akkudefekt erfolgreich umgebaut. Gleich vorweg, es ist zeitaufwendig, man sollte...
Sparta M7e ion Antrieb von 2016: Hallo Leute, kurz zu mir: Ich bin seinerzeit mit einem Bausatz aus China angefangen (mit dem ich mich entsetzlich auf die Nase gelegt habe), dann...
verkaufe Koga E-Runner, Rh 47cm, ION-Antrieb, wie neu, super ausgestattet: Schnäppchen: Koga E-Runner, nur EUR 2.050,-/Neupreis EUR 3.000,- muß wg OP leider verkaufen, Fahrrad kaum genutzt, Heck-Motor ION-Antrieb (33 Nm)...
erledigt E-Bike SPARTA Blackline ION mit Garantie: BeschreibungHalle verkaufe hier ein E-Bike von Sparta, Model Black Line kompl. mit Ladegerät. Das E-Bike war ein Ausstellungsstück und hat das...
Oben