TSDZ2 EBike wireless standard (like Specialized Turbo Levo) - OpenSource

casainho said:
I once get the Code Studio and OpenOCD working for the STM8 but I deleted the files by mistake. But it was hard to get it working.

I use Eclipse only for the STM8 but I do not have written notes how to make it working...

Ok - i got some semblance of debugging going today. It's a bit flaky and needs to be restarted a lot - plus for some inexplicable reason breakpoints only seem to work in main.c

I still can't see why in assist level 3 the packets stutter more and are sent at a lower rate. Not sure if you can do profiling using these tools - but as yet I can't find how to see where the cpu is spending most time...

I did however remove motor_controller and almost all of the ebike_app_controller loop -
Code:
void ebike_app_controller(void)
{
  //throttle_read();
  //torque_sensor_read();
  //read_pas_cadence();
  //calc_pedal_force_and_torque();
  //calc_wheel_speed();
  //calc_motor_temperature();
  ebike_control_motor();
  communications_controller();
  check_system();
}

And the problem of the stutter (comms pauses for about 0.2s i reckon) still remains... that was as much I could remove easily from the loop without it crashing.

I can see what I believe is a problem though - in the function below - the last //ui8_comm_error_counter++; I think is unnecessary.

Because communications_controller() runs every cycle that there is enough time to run ebike_app_controller(); - if there isn't a packet ready for it to process - it increments the error counter. I think it's enough to only inc the error counter if the crc fails to validate. If you do this - then I typically get one error in level 3 - as opposed to 11...

It might be that the stutter is actually the UART refusing to receive for whatever reason for a short period and so the loop runs a few times with no packets to process -hence this code causing the too many errors to trigger.



Code:
static void communications_controller(void)
{
  uint8_t ui8_frame_type_to_send = 0;
  uint8_t ui8_len;

  if (ui8_received_package_flag)
  {
    // just to make easy next calculations
    ui16_crc_rx = 0xffff;
    ui8_len = ui8_rx_buffer[1];
    for (ui8_i = 0; ui8_i < ui8_len; ui8_i++)
    {
      crc16(ui8_rx_buffer[ui8_i], &ui16_crc_rx);
    }

    // if CRC is correct read the package
    if (((((uint16_t) ui8_rx_buffer[ui8_len + 1]) << 8) +
          ((uint16_t) ui8_rx_buffer[ui8_len])) == ui16_crc_rx)
    {
      ui8_comm_error_counter = 0;

      if (ui8_m_motor_init_state == MOTOR_INIT_STATE_RESET)
        ui8_m_motor_init_state = MOTOR_INIT_STATE_NO_INIT;

      ui8_frame_type_to_send = ui8_rx_buffer[2];
      communications_process_packages(ui8_frame_type_to_send);
    }
    else
    {
      ui8_received_package_flag = 0;
      ui8_comm_error_counter++;
    }
  }
  else
  {
    //ui8_comm_error_counter++;
  }

Another oddity i see - is that empty config (and other short) packets are sent with a short length - but are then padded up to 29 bytes. This looks like errors to my receiver as it violates the spec as i've interpreted it but I guess it's tolerated by the wireless controller... It's because UART_NUMBER_DATA_BYTES_TO_SEND (=29) is used as the packet length to send - not the actual packet length - is that intended?

e.g. the below packet should only be 3 bytes as it has zero length.

rE480:cE480 43 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Code:
void UART2_TX_IRQHandler(void) __interrupt(UART2_TX_IRQHANDLER)
{
  if (UART2_GetFlagStatus(UART2_FLAG_TXE) == SET)
  {
    if (ui8_m_tx_buffer_index < UART_NUMBER_DATA_BYTES_TO_SEND)  // bytes to send
    {
      // clearing the TXE bit is always performed by a write to the data register
      UART2_SendData8(ui8_tx_buffer[ui8_m_tx_buffer_index]);
      ++ui8_m_tx_buffer_index;
      if (ui8_m_tx_buffer_index == UART_NUMBER_DATA_BYTES_TO_SEND)
      {
        // buffer empty
        // disable TIEN (TXE)
        UART2_ITConfig(UART2_IT_TXE, DISABLE);
      }
    }
  }
  else
 
casainho said:
rananna said:
casainho said:
rananna said:
Are you thinking that you would make a pass through connection on the TSDZ2 wireless module to allow users to connect displays if they wish and gain the advantage of the android app for configuration as well as an alternate control technique?
It seems to me if you did that it would merge both projects together.
We still did not yet finish this project, so I think is to soon to increase the scope of the project. For now, I think the users will need to choose to use 860C and SW102 or the wireless system.
Of course I agree, it far to early to do this, but down the road it would be very helpful to have a SINGLE source of information that new users could go to like https://opensourceebike.github.io/ that describes possible configuration options for your firmware in order of increasing complexity and features:
1. Basic firmware + 860 display
2. Basic firmware + 860 display + wireless control and configuration
3. Basic firmware + wireless control and configuration (optional ANT LEV display)
4 Basic firmware + wireless control and configuration ( optional ANT LEV display) + remote control

This might increase the interest in the firmware when a user can see the big picture and not have to gather info from lots of sources.

I just wanted to know if you agree on that vision for the future.
I think there is yet a lot of TODO on this wireless project. Also we need much more effort to prove this idea of wireless because is new, but a regular display is already established for ebikes.

And there are other new opportunities, making this system for other motors like the Bafang BSSHD which the OpenSource firmware is being developed. Also maybe the interest can grow and then the KT and Lishui firmware may also want to join. And I would prefer to develop the technology, like a better mobile app, to be able to easily adapt for that different motors and their specific configurations.
So, I would prefer to grow to support other motors and not just focus on TSDZ2 alone - because if we keep investing on the 860C and SW102 displays, that is a dead end and only for TSDZ2!! because is to hard to develop for that displays!! everyone can quick develop the mobile app but only VERY FEW can develop on the displays, it is too hard and so that will not happen!! The ANT+ LEV is a good example of a standard to be used on many different motors and hardware like the GPS displays that is hard to develop for, so, the solution is to simplify a lot the options / data for the motor.

I think in future we need to have a firmware to is easy to adapt for other motors and a mobile app that is easy to also adapt for other motors, like maybe a configuration file (JOSN??) to define which variables to use for configurations and for the main screen.
Thanks for sharing this.
I was unaware that the Bafang BBSHD has an opensource project. I thought everyone had been stalled by the difficulties programming the chip.
Anyway, that is very interesting given the size of the user base for Bafang motors.
I have a bike with a bafang motor which is very robust and has wonderful performance for mountain biking, but I prefer the TSDZ2 torque sensing for everything else.
If that firmware could be developed that would be huge!
Using available standards is certainly the way to develop a large developer support network.
But all this is a problem for another day..... :)
 
rananna said:
casainho said:
rananna said:
casainho said:
We still did not yet finish this project, so I think is to soon to increase the scope of the project. For now, I think the users will need to choose to use 860C and SW102 or the wireless system.
Of course I agree, it far to early to do this, but down the road it would be very helpful to have a SINGLE source of information that new users could go to like https://opensourceebike.github.io/ that describes possible configuration options for your firmware in order of increasing complexity and features:
1. Basic firmware + 860 display
2. Basic firmware + 860 display + wireless control and configuration
3. Basic firmware + wireless control and configuration (optional ANT LEV display)
4 Basic firmware + wireless control and configuration ( optional ANT LEV display) + remote control

This might increase the interest in the firmware when a user can see the big picture and not have to gather info from lots of sources.

I just wanted to know if you agree on that vision for the future.
I think there is yet a lot of TODO on this wireless project. Also we need much more effort to prove this idea of wireless because is new, but a regular display is already established for ebikes.

And there are other new opportunities, making this system for other motors like the Bafang BSSHD which the OpenSource firmware is being developed. Also maybe the interest can grow and then the KT and Lishui firmware may also want to join. And I would prefer to develop the technology, like a better mobile app, to be able to easily adapt for that different motors and their specific configurations.
So, I would prefer to grow to support other motors and not just focus on TSDZ2 alone - because if we keep investing on the 860C and SW102 displays, that is a dead end and only for TSDZ2!! because is to hard to develop for that displays!! everyone can quick develop the mobile app but only VERY FEW can develop on the displays, it is too hard and so that will not happen!! The ANT+ LEV is a good example of a standard to be used on many different motors and hardware like the GPS displays that is hard to develop for, so, the solution is to simplify a lot the options / data for the motor.

I think in future we need to have a firmware to is easy to adapt for other motors and a mobile app that is easy to also adapt for other motors, like maybe a configuration file (JOSN??) to define which variables to use for configurations and for the main screen.
Thanks for sharing this.
I was unaware that the Bafang BBSHD has an opensource project. I thought everyone had been stalled by the difficulties programming the chip.
Anyway, that is very interesting given the size of the user base for Bafang motors.
I have a bike with a bafang motor which is very robust and has wonderful performance for mountain biking, but I prefer the TSDZ2 torque sensing for everything else.
If that firmware could be developed that would be huge!
Using available standards is certainly the way to develop a large developer support network.
But all this is a problem for another day..... :)
Here the OpenSource firmware for Bafang BBSHD:
- Github: https://github.com/danielnilsson9/bbshd-fw
- Forum: https://endless-sphere.com/forums/viewtopic.php?f=28&t=102148&start=25#p1609247

And about more work, there developer of ESP32 did good improvements to the TSDZ2 motor controller firmware and is sharing technical details about it, I wish later to try implement that!!
 
@rananna, some quick feedback and ideas for the remote

I am testing the remote. I really like the feedback of when the remote is connected to the TSDZ2 wireless board, I tested when I power on and then power off the board, etc. It is very good.

The brake as a strange visual signal, like if is done incorrectly because first maybe 0.5s is very strong and then quick changes to a lower value... no fade from one to other value, maybe would be best to be all the time at the same intensity.
Brake makes the signal of connected / not connect board to fail!

I think using red light for both not connected and brake, is good.

I do not like at all not have having visual feedback when I press any button, I do not know if the remote is working or not (I only know when I am looking at the mobile app). I need always a blink when I press a button. And which color? could it be the green to signal everything is ok and I just pressed a button and the remote did processed as expected.

Other thing is very important to have feedback is when motor is turned on or off. Maybe when pressing a button and if motor is off, the blink can not be green but red instead.

Also when increasing assist level, if assist level >= 7, then blink maybe 3 times so user understand the max was achieved. The same when decreasing the assist level.

I tested the turn on / off of the motor and works well. The important thing missing is the visual feedback WHILE the motor is turning on!! Since the user can not touch the pedals while turning on the motor, this is very critical. I only see the feedback I think at the end of turn on.

The battery SOC indication is good.

When a button is pressed or released (button_event_handler) or app timer happens, the system will leave the low power mode and so the main loop while (true) will run one time. I suggest you to implement a function with a state machine only for the state of the remote, like if the motor is on just blink green LED or such, if motor if off this and that, etc. So you could focus the code there and not be separated on the various parts, will be easier for you to see and implement the flow of the system.
 
beemac said:
Ok - i got some semblance of debugging going today. It's a bit flaky and needs to be restarted a lot - plus for some inexplicable reason breakpoints only seem to work in main.c
I remember that, and now that I think on this, I think I just got up to this state. If you get it better, please document it as I also would prefer to use Code Studio to also flash and debug the STM8.

beemac said:
I did however remove motor_controller and almost all of the ebike_app_controller loop -

And the problem of the stutter (comms pauses for about 0.2s i reckon) still remains... that was as much I could remove easily from the loop without it crashing.
Remember that the motor code on the interrupt is still running...

beemac said:
Another oddity i see - is that empty config (and other short) packets are sent with a short length - but are then padded up to 29 bytes. This looks like errors to my receiver as it violates the spec as i've interpreted it but I guess it's tolerated by the wireless controller... It's because UART_NUMBER_DATA_BYTES_TO_SEND (=29) is used as the packet length to send - not the actual packet length - is that intended?

e.g. the below packet should only be 3 bytes as it has zero length.

rE480:cE480 43 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
UART_NUMBER_DATA_BYTES_TO_SEND since I remember the max possible number of bytes!! that padded zeros is because of bad implementation for sure.

Good work!!
 
casainho said:
beemac said:
Ok - i got some semblance of debugging going today. It's a bit flaky and needs to be restarted a lot - plus for some inexplicable reason breakpoints only seem to work in main.c
I remember that, and now that I think on this, I think I just got up to this state. If you get it better, please document it as I also would prefer to use Code Studio to also flash and debug the STM8.

beemac said:
I did however remove motor_controller and almost all of the ebike_app_controller loop -

And the problem of the stutter (comms pauses for about 0.2s i reckon) still remains... that was as much I could remove easily from the loop without it crashing.
Remember that the motor code on the interrupt is still running...

Sure - but the 'long' pause/stutter only occurs in level 3... with a particular assist level.. that's what I'd love to understand!

But if we remove the final error increment and only leave it to inc on bad crc I think we're good.

On the note of the CRC - is performance of absolute importance here - could you do with extra cycles to do other things? Or is space a problem - or neither? Since the CRC algorithm is only used in two places - and gets called a lot - I'd move it inline\macro and not use pointers. Then hopefully it compiles to something that just uses a 16bit register for the CRC calcs and so runs faster (not that the STM8 has many registers it appears - it's more like a 6502 than my favourite z80...)

Code:
  // prepare crc of the package
  ui16_crc_tx = 0xffff;
  for (ui8_i = 0; ui8_i < ui8_len; ui8_i++)
  {
    //crc16(ui8_tx_buffer[ui8_i], &ui16_crc_tx);
    //don't call the CRC routine - move it inline here and not use pointers
    unsigned int i;

    ui16_crc_tx = ui16_crc_tx ^(uint16_t)ui8_tx_buffer[ui8_i];
    for (i = 8; i > 0; i--)
    {
        if (ui16_crc_tx & 0x0001)
            ui16_crc_tx = (ui16_crc_tx >> 1) ^ 0xA001;
        else
            ui16_crc_tx >>= 1;
    }
  }

To replace calls to the code below. I've no idea what the compiler would optimise this to exactly - but I assumed it would keep things in memory locations rather than use registers...

Code:
void crc16(uint8_t ui8_data, uint16_t* ui16_crc)
{
    unsigned int i;

    *ui16_crc = *ui16_crc ^(uint16_t) ui8_data;
    for (i = 8; i > 0; i--)
    {
        if (*ui16_crc & 0x0001)
            *ui16_crc = (*ui16_crc >> 1) ^ 0xA001;
        else
            *ui16_crc >>= 1;
    }
}

I'll make my changes to a clean clone of the repo and test - and then perhaps do my first pull request! :)

Edit: Do you know how long the reset takes if the watchdog timer expires? I wish I could get breakpoints working...
 
Here the link of stl file, but i suggest you to wait... It's a first sketch, i had to verify all the measures and tolerances!
I've take a look of FreeCAD, i don't like it at all...

https://mega.nz/file/5V8TSIgD#pRTsiJ_R4Cwsp0AgmhgDSOhqcAR3xYqHbXHeX0ndKeE
 
Filippods said:
Here the link of stl file, but i suggest you to wait... It's a first sketch, i had to verify all the measures and tolerances!
I've take a look of FreeCAD, i don't like it at all...

https://mega.nz/file/5V8TSIgD#pRTsiJ_R4Cwsp0AgmhgDSOhqcAR3xYqHbXHeX0ndKeE
Thanks. And FreeCad is not a priority at all. And yes, I think I understand why you say you do not like it, it is probably very limited compared to other professional softwares... But has the advanced than is free and OpenSource, anyone can install and use.
 
casainho said:
The brake as a strange visual signal, like if is done incorrectly because first maybe 0.5s is very strong and then quick changes to a lower value... no fade from one to other value, maybe would be best to be all the time at the same intensity.
understood. I believe this is a PWM startup issue, when it starts it is at 100% and then immediately drops to 50%. I'll look into it.

casainho said:
Brake makes the signal of connected / not connect board to fail!

I'm sorry, I do not understand. could you please elaborate?

casainho said:
I do not like at all not have having visual feedback when I press any button, I do not know if the remote is working or not (I only know when I am looking at the mobile app). I need always a blink when I press a button. And which color? could it be the green to signal everything is ok and I just pressed a button and the remote did processed as expected.
A brief green flash seems like a good idea. I will implement.
casainho said:
Other thing is very important to have feedback is when motor is turned on or off. Maybe when pressing a button and if motor is off, the blink can not be green but red instead.
good idea. I will implement a brief red flash when the motor is on

casainho said:
Also when increasing assist level, if assist level >= 7, then blink maybe 3 times so user understand the max was achieved. The same when decreasing the assist level.
good idea - I will implement

casainho said:
I tested the turn on / off of the motor and works well. The important thing missing is the visual feedback WHILE the motor is turning on!! Since the user can not touch the pedals while turning on the motor, this is very critical. I only see the feedback I think at the end of turn on.
That is strange. In the code I only flash the LED when the motor is turning on.
I have confirmed this several times by watching the Android app which displays yellow when the LED is flashing.
When the motor turns on it flashed quicly to indicate that state
So, I am confused why you do not see that.

casainho said:
When a button is pressed or released (button_event_handler) or app timer happens, the system will leave the low power mode and so the main loop while (true) will run one time. I suggest you to implement a function with a state machine only for the state of the remote, like if the motor is on just blink green LED or such, if motor if off this and that, etc. So you could focus the code there and not be separated on the various parts, will be easier for you to see and implement the flow of the system.
Good idea. I will look into
Thanks for the feedback.
 
rananna said:
casainho said:
Brake makes the signal of connected / not connect board to fail!
I'm sorry, I do not understand. could you please elaborate?
After you use brakes, the signal of missing connection never happens again.

rananna said:
casainho said:
I do not like at all not have having visual feedback when I press any button, I do not know if the remote is working or not (I only know when I am looking at the mobile app). I need always a blink when I press a button. And which color? could it be the green to signal everything is ok and I just pressed a button and the remote did processed as expected.
A brief green flash seems like a good idea. I will implement.
This more advanced and complex what I will say, I am not asking this: on Garmin GPS Edge display, when you change the assist level, you will see the button blocked / click for some little time and I am pretty sure the system is validating / waiting that the assist level really changed before release / make the button available again to be clicked. We could do the same... on the mobile app, I didn´t but maybe someday :) -- but I think it is important that user have feedback from the remote that it had processed the button press.

rananna said:
casainho said:
I tested the turn on / off of the motor and works well. The important thing missing is the visual feedback WHILE the motor is turning on!! Since the user can not touch the pedals while turning on the motor, this is very critical. I only see the feedback I think at the end of turn on.
That is strange. In the code I only flash the LED when the motor is turning on.
I have confirmed this several times by watching the Android app which displays yellow when the LED is flashing.
When the motor turns on it flashed quicly to indicate that state
So, I am confused why you do not see that.
You are probably correct. I just did remember that I am using a board to simulate the TSDZ2 and the removed the 6 seconds waiting at startup, so the startup is very fast and that is probably why I did not understand all this.
 
I think would be nice to implement a "smartkey" linked via bluetooth to the controller (it could also be the smartphone)...
The ebike would turn on only if the smartkey is connected, if not it could activate a tilt sensor linked to an alarm.

Are you planning something like this in the next future of this project?

Thank you
 
I just flashed the bootloader on an nRF52480 eval board. The openocd config files at opensourceebike.github.io are outdated. After using nrf52.cfg and stlink.cfg (not stlink-v2.cfg!) taken from the present openocd release it worked.

Is there a newer compiled firmware version than V0.3.0 available for some trials with wireless motor controller?
 
casainho said:
I updated the schematics:

TSDZ2 wireless board:
TSDZ2_wireless-schematic.png


TSDZ2 wireless remote:
ebike_remote_wireless-schematic.png

Hi casainho, I'm was far for a long time... I've no words, your work is awesome!

I've some questions, please take a look when you have some time:

I own a 15s battery a bit undercharge for my setup (I use BT BMS for set 4,09 maximum cell voltage, so a total 61,35v full battery) whit SW102 and works very for over 2000km no one problem till now.

Now I want to try the wireless board, but I'm bit confusing if the BTS4140N would be enough for my maximum voltage. The datasheet says 60v max so what can I use? Does the BTS6163D could work?

Also the battery pack have an USB port inside, so can I use the 5v USB output to powering the nRF52840 instead of DC-DC converter? Why the DC-DC OUT- is connect to VDD_out and not to GND?

And also, another question about the nRF52840 TSDZ2 wireless board: can I directly connect the brake sensors by wire to pin 1-2 and VLCD5 remote to pin 1-7-8-9-10 and use them without the wireless remote?

According to the documentation the ANT communication is only active on the wireless remote and not on the wireless TSDZ2 controller, right? But I still able to connect to the wireless TSDZ2 controller for use an Bluetooth phone as display, also without the wireless remote, is it correct?

I'm pretty worried about relying on the wireless connection to handle the controls above all because of the inevitable latency that creates an extra component in the middle. In my opinion, the immediacy of the controls is much more useful than the ability to remove the control cable from the engine to the handlebar! During use on my trips, I often change assistance even 2-3 levels in rapid sequence, but above all a delay of even half a second in the activation of the brakes would be very uncomfortable.

Thank you so much for your time and your work
 
casainho said:
Brake makes the signal of connected / not connect board to fail!
casainho said:
After you use brakes, the signal of missing connection never happens again.
@casainho,

I am assuming by your statement 'missing connection' that you mean a the power on/off sequence to the motor controller, not to ANT LEV connection to the motor. Is that right?

Anyway, with the assumption that you are referring to the motor on/off sequence, I have tested the motor connections again today and do not see any issue.

ie: the PWR ON sequence is:
The off-white LED flashes until the motor is ready and on, at which time there is a brief fast flash followed by a display of the battery state with the green LED.

the PWR OFF sequence:
The remote displays the SOC of the battery and turns the motor off.

I have repeated pressed the BRAKE during both PWR ON and PWR off sequences to see if I can create any issue, but it all works as expected. The RED LED flashes during either the off-white flashing or the SOC display, but no errors are created.
 
casainho said:
beemac said:
Ok - i got some semblance of debugging going today. It's a bit flaky and needs to be restarted a lot - plus for some inexplicable reason breakpoints only seem to work in main.c
I remember that, and now that I think on this, I think I just got up to this state. If you get it better, please document it as I also would prefer to use Code Studio to also flash and debug the STM8.

I will document when I get the debugging working better. Openocd is wonderful - but it's also only as good as so many other links in the chain..

@rananna - i know you couldn't get the assist level 3 bug to reproduce the other day. I think it's because you have the temp sensor enabled...

From what I can see - to make the bug apparent:

1. Set any assist level to 0.028. Set the corresponding startup boost assist level to 0.028 also.
2. Set the temperature probe to disable.

Move to assist level that you set the same values for - and watch the motor disable...

Edit: Also - when should a big fat configuration packet be sent by the wireless controller. I've never seen one... when would the app send one - after any config change? If so, I don't see it... Only ever see short periodic packet type 2...

i only see one configuration packet when the android app first connects - then never again.... even when config changes

r6F2B:c6F2B 59 56 03 A4 01 34 08 10 02 10 14 23 4B 55 50 00 9D 00 14 00 CF 00 14 00 E6 00 15 00 F1 00 24 00 FA 00 42 00 04 01 96 00 0A 01 E9 00 17 01 88 01 A1 00 14 00 E9 00 14 00 F5 00 21 00 02 01 2E 00 0A 01 3E 00 14 01 64 00 1B 01 C8 00 2C 01 2C 01 0A 0F 00 14 14 00
 
I flashed V0.3.0 on the wireless board and did a connection test with the motor (at home). Assist levels 1 and 2 worked. At 3 and higher there was no more motor support and I had to switch all off to make it work again.
After changing 0.028 at level 3 it worked. So the same strange error you are observing at the moment?!

However sometimes I don't get motor support at all. It seems like the communication works only from TSDZ2 to the nRF but not vice versa.
Could it be that the missing level shifter (3.3V up to 5V) might cause problems?
 
Beli said:
I flashed V0.3.0 on the wireless board and did a connection test with the motor (at home). Assist levels 1 and 2 worked. At 3 and higher there was no more motor support and I had to switch all off to make it work again.
After changing 0.028 at level 3 it worked. So the same strange error you are observing at the moment?!

However sometimes I don't get motor support at all. It seems like the communication works only from TSDZ2 to the nRF but not vice versa.
Could it be that the missing level shifter (3.3V up to 5V) might cause problems?

Yes, this is the problem I'm trying to pin down. The issue occurs when these particular combination of settings are set:

1. temp probe/throttle set to disabled.
2. For any Assist level/start up boost level - both factors set to 0.028

Then when that assist level is selected - the main comms cycle on the motor controller thinks it's not receiving complete packets (even though it seems that the packets are fine) for about 11 cycles every couple of seconds and incs the error counter each cycle -quickly pushing it above >10 so the error detection disables the motor assist.

It's not related to comms errors from what I can see - there are actually very few comms errors - sniffing the serial traffic shows no problems - frames are complete and checksums validate.

I've had sporadic time to look into it over the last few days - getting debugging working properly over openocd is probably where I should focus efforts - as littering the code with timers and other things - echoing values back in serial is a slow way to do things...
 
beemac said:
It's not related to comms errors from what I can see - there are actually very few comms errors - sniffing the serial traffic shows no problems - frames are complete and checksums validate.
But you do the sniffing just at the connecting wire? Are you sure the TSDZ2 recognises it correctly?

How are you compiling? With Visual Studio Code?
I don't have the current Github version so it's more difficulty to get the same comparable effects.
 
Beli said:
beemac said:
It's not related to comms errors from what I can see - there are actually very few comms errors - sniffing the serial traffic shows no problems - frames are complete and checksums validate.
But you do the sniffing just at the connecting wire? Are you sure the TSDZ2 recognises it correctly?

How are you compiling? With Visual Studio Code?
I don't have the current Github version so it's more difficulty to get the same comparable effects.

I am - so that is true - but I can see counters telling me how many packets fail CRC etc.

I can easily set the motor controller to echo back all that it receives - to confirm 100%.

Issue happens on the release binaries - as I first encountered on my bike. For debugging/code testing I'm using a spare motor controller - so it's all run from 5v from the stlink clone powering the motor controller, wireless board - don't need a battery connected which is nice.

Yes VSCode on Windows with SDCC as the compiler - with the same GNU Arm tools version that casainho uses - didn't go for the latest just in case. Also had to find a win32 version of srec_cat

https://developer.arm.com/-/media/F...edded Toolchain,ZIP,,Windows,7-2018-q2-update
http://sdcc.sourceforge.net/
http://srecord.sourceforge.net/windows.html

For debugging - openocd, stm8-debug from vscode extensions and a cheap stlinkv2 clone but as yet it's flaky. Loses connection after a couple of steps - and breakpoints only seem to fire in main.c!
 
beemac said:
Beli said:
But you do the sniffing just at the connecting wire? Are you sure the TSDZ2 recognises it correctly?

How are you compiling? With Visual Studio Code?
I don't have the current Github version so it's more difficulty to get the same comparable effects.

I am - so that is true - but I can see counters telling me how many packets fail CRC etc.

I can easily set the motor controller to echo back all that it receives - to confirm 100%.
I see.

I just thought that with my different hardware setup communication might be slightly worse (but therefore more likely showing the problem):

Eval-Kit.jpg

It's not for permanent use at the bike but this Waveshare kit is quite nice for development - and rather cheap.

beemac said:
Yes VSCode on Windows with SDCC as the compiler
I have difficulties to get it work. But it might make sense to deal more with VSCode for my own project (display with ESP32).
 

I've tried to elaborate a design with removable keypad, but i think it will be too difficult to realize, most of 3d printers have too high tolerances to allow this, furthermore i've no idea on how to link a plug and play keypad.

In my design i reuse vlcd5 keypad (top housing), both leds are visible (bottom housing), there is a lateral housing for 2032 case, the 3 housings are linked by holes for wiring.
Based on what i've read on this topic i've designed also 2 brake connector housings, but not for shift sensor.
[/quote]

maybe this wahoo/garmin plug adapter could be helpful. if the button design has a flat surface you can glue this mount adapter to it and put it on your standard garmin/wahoo mount
 

Attachments

  • 5EFC75E9-C57E-4555-B2AF-933450825E09.jpeg
    5EFC75E9-C57E-4555-B2AF-933450825E09.jpeg
    207.1 KB · Views: 283
  • 6FE0A964-5335-45A0-93E5-4400F75FBC51.jpeg
    6FE0A964-5335-45A0-93E5-4400F75FBC51.jpeg
    154.6 KB · Views: 283
fi7ippo said:
Hi casainho, I'm was far for a long time... I've no words, your work is awesome!

I've some questions, please take a look when you have some time:

I own a 15s battery a bit undercharge for my setup (I use BT BMS for set 4,09 maximum cell voltage, so a total 61,35v full battery) whit SW102 and works very for over 2000km no one problem till now.

Now I want to try the wireless board, but I'm bit confusing if the BTS4140N would be enough for my maximum voltage. The datasheet says 60v max so what can I use? Does the BTS6163D could work?

Also the battery pack have an USB port inside, so can I use the 5v USB output to powering the nRF52840 instead of DC-DC converter? Why the DC-DC OUT- is connect to VDD_out and not to GND?

And also, another question about the nRF52840 TSDZ2 wireless board: can I directly connect the brake sensors by wire to pin 1-2 and VLCD5 remote to pin 1-7-8-9-10 and use them without the wireless remote?

According to the documentation the ANT communication is only active on the wireless remote and not on the wireless TSDZ2 controller, right? But I still able to connect to the wireless TSDZ2 controller for use an Bluetooth phone as display, also without the wireless remote, is it correct?

I'm pretty worried about relying on the wireless connection to handle the controls above all because of the inevitable latency that creates an extra component in the middle. In my opinion, the immediacy of the controls is much more useful than the ability to remove the control cable from the engine to the handlebar! During use on my trips, I often change assistance even 2-3 levels in rapid sequence, but above all a delay of even half a second in the activation of the brakes would be very uncomfortable.
That is true that I put the seed on some of this OpenSource EBike projects but luckily there are some developers as also users helping a lot!

I only use with 14S battery so I do not know.

Thanks, I just updated the schematic.

Yes, you do not need to use the wireless remote and just use the mobile app.

We want to use the brake signal by wireless and ti should have almost no delay!! See the bluetooth joysticks that are not noticeable any delay.

beemac said:
Issue happens on the release binaries - as I first encountered on my bike. For debugging/code testing I'm using a spare motor controller - so it's all run from 5v from the stlink clone powering the motor controller, wireless board - don't need a battery connected which is nice.
If you can, please try latest SDCC version. This bug is so strange...

Peacepirate said:
maybe this wahoo/garmin plug adapter could be helpful. if the button design has a flat surface you can glue this mount adapter to it and put it on your standard garmin/wahoo mount
Seems the users are 3D printing that plug:



Installed%20Isometric.jpg
 
My TSDZ2 wireless box:

As it uses the not recommended DC-DC with a specific size, I will not share the 3D model. Maybe if later I will build another with one of the recomended DC-DC, then I will share the 3D file for 3D printing:



 
Peacepirate said:
maybe this wahoo/garmin plug adapter could be helpful. if the button design has a flat surface you can glue this mount adapter to it and put it on your standard garmin/wahoo mount

Hi, thank you for your suggestion @Peacepirate, quoting @casainho: "VLCD5 keypad that you can install or remove from the handle bars without removing the other installed parts like the brake levers, etc, so, it should be easy and fast to install or remove from the handle bar".

So... with wahoo mount we have to split the two parts of the project (connector + board/keypad) leading to a bulkier solution while i think the enclosure should be as small as possible, in-line with the advantages of a wireless solution, but if it's what you want i try to design it.

casainho said:
Seems the users are 3D printing that plug:

Installed%20Isometric.jpg

These designs seems weak and poorly made, but i'm trying to find a solution that fits with what you told:
-Integrated VLCD5 keypad
-Visible RGB led
-Suitable to 2032 battery case
-With brake connectors
-Removable (find connectors is the hardest thing)
 
casainho said:
My TSDZ2 wireless box:

As it uses the not recommended DC-DC with a specific size, I will not share the 3D model. Maybe if later I will build another with one of the recomended DC-DC, then I will share the 3D file for 3D printing:




very nice!
What 3D printer would you recommend for printing the remote control with the required accuracy ?
There are so many to choose from on the market.
The motor controller will not need fine tolerances....
 
Back
Top