TSDZ8 OSF (open source firmware)

You can also buy a jlink chinese clone from amazon/aliexpress...
Then you have to make your own cable to connect it to the controller. This cable can be done with a TSDZ2 speed sensor extension cord.
Thanks. I don’t mind making the cable, but most on Amazon appear to be V8. A lot of the aliexpress ones have pretty long shipping time (July).
 
On the ebikestuff.eu, I'm just looking for a place to get a JLINK V9 delivered to the US within a reasonable timeframe.
We ship to the US, but it is the postal service shipping (USPS), so it won't be fast. Usually up to two weeks for US orders.
As mentioned above, locally sourcing a J-Link clone and a 6-pin extension cable (to get the matching connector) will be quicker. If you have any manual skills, you should be able to make the programming cable yourself.
Regarding the heating issues. We had no reports of overheated motors so far. Unless your use is very extreme, I wouldn't worry about it.

Back to OSF.
@mstrens, I know that you mentioned that you will be working on smoothing the assistance. Is it possible to have a configuration setting for that? Currently, the response of the torque sensor is phenomenal. There's virtually no delay. I assume that applying filters will increase that delay and slow the torque sensor response. Having any control over that would be great. I know there was a configuration setting for the torque sensor filtering and strength on ToSeven motors. Something similar would be great
 
We ship to the US, but it is the postal service shipping (USPS), so it won't be fast. Usually up to two weeks for US orders.
As mentioned above, locally sourcing a J-Link clone and a 6-pin extension cable (to get the matching connector) will be quicker. If you have any manual skills, you should be able to make the programming cable yourself.
Regarding the heating issues. We had no reports of overheated motors so far. Unless your use is very extreme, I wouldn't worry about it.

Back to OSF.
@mstrens, I know that you mentioned that you will be working on smoothing the assistance. Is it possible to have a configuration setting for that? Currently, the response of the torque sensor is phenomenal. There's virtually no delay. I assume that applying filters will increase that delay and slow the torque sensor response. Having any control over that would be great. I know there was a configuration setting for the torque sensor filtering and strength on ToSeven motors. Something similar would be great
About OSF and smoothing the assistance.
New code (for 860c) is ready to be tested but not yet published on github.
I hope that the solution I imagined will not slow down of the torque sensor response.
It will apply only a small filtering on raw values (even less than in current version).
The major difference is that it will use as torque value the maximum of
- actual value (with little filtering)
- the max value during the current pedal rotation (automatically reset to 0 after each rotation)
- the max value during the previous pedal rotation
So if pressure on the pedal increases suddenly, response should be immediate (because I use always max and not averages/smoothing)

The drawback is that there will be a delay when pressure on the pedal decreases.
When pressure decreases slowly, it will take one pedal rotation before it is taken into accout.
Still I have forseseen that:
- when cadence is 0
or
- when "actual" value is less than 50% of max
then only the "actual" value is taken into account.

Tests should show is this is a valid solution.
 
You need a ST-Link V2 emulator, cheap as chips, plenty of info on the net and here on this site.
 
We ship to the US, but it is the postal service shipping (USPS), so it won't be fast. Usually up to two weeks for US orders.
As mentioned above, locally sourcing a J-Link clone and a 6-pin extension cable (to get the matching connector) will be quicker. If you have any manual skills, you should be able to make the programming cable yourself.
Regarding the heating issues. We had no reports of overheated motors so far. Unless your use is very extreme, I wouldn't worry about it.
Thanks. I found one that delivers in a week or two. Extension cable comes in a couple days.

You need a ST-Link V2 emulator, cheap as chips, plenty of info on the net and here on this site.
That's for the TSDZ2, correct?
 
Thanks. I found one that delivers in a week or two. Extension cable comes in a couple days.
Be aware that:

1) I have seen wrong schematics in the Internet for making the cable.
2) In my case, extension cable had few colors other than in the schematics. I used pinouts instead of colors.
3) Do not power your motor with battery when the J-Link is connected. There's a high chance that you will fry the controller. As the alternative, do not use VREF pin from J-Link and then you can power the controller from battery. But do not use both power sources in one moment.

And ST-Link V2 is for TSDZ2, indeed.
 
Be aware that:

1) I have seen wrong schematics in the Internet for making the cable.
2) In my case, extension cable had few colors other than in the schematics. I used pinouts instead of colors.
3) Do not power your motor with battery when the J-Link is connected. There's a high chance that you will fry the controller. As the alternative, do not use VREF pin from J-Link and then you can power the controller from battery. But do not use both power sources in one moment.

And ST-Link V2 is for TSDZ2, indeed.
Thanks for the tips!! #3 especially.
 
Yep, I have mostly programed bare TSDZ2(B) controllers with them just plug into my laptop via the ST-Link V2 emulator and no other connection and got a clean uploads of the OSF every time now. At the same time run the OSF 860C into one controller and then run the firmware into a 860C via a CP2102 module with a dc - dc step up power module.
 
As far I know, TSDZ8 firmware does not support temperature sensor.
That's interesting, has it been confirmed that it's not the case? I would be pretty surprised given you forked the same code that supports it (LM35 temp sensor in place of throttle input).
Ah, I see, you commented it out:

Heating issue is not a problem cause we're not pushing the motor to the limit yet. I am sure some users would want to push it beyond 20A once the OSF becomes more stable and more popular.

I think it's a core safety feature to have.
 
Last edited:
@E-HP , ST-Link on-board ST development board's can be converted to Segger J-Link as mentioned here. Possible ST development boards are mentioned there.

I had converted ST-Link on board ST Discovery board (IIRC, STM32F429I-DISC1) to J-Link a few years back. ATM, I don't remember the details, but probably had noted it down. If you want to go that route, I will dig out my old notes & share the details.
 
@E-HP , ST-Link on-board ST development board's can be converted to Segger J-Link as mentioned here. Possible ST development boards are mentioned there.

I had converted ST-Link on board ST Discovery board (IIRC, STM32F429I-DISC1) to J-Link a few years back. ATM, I don't remember the details, but probably had noted it down. If you want to go that route, I will dig out my old notes & share the details.
Thanks for the offer. I’ll keep it in mind if my order gets screwed up for some reason.
 
@E-HP , ST-Link on-board ST development board's can be converted to Segger J-Link as mentioned here. Possible ST development boards are mentioned there.

I had converted ST-Link on board ST Discovery board (IIRC, STM32F429I-DISC1) to J-Link a few years back. ATM, I don't remember the details, but probably had noted it down. If you want to go that route, I will dig out my old notes & share the details.
In the specifications, it is said that this stlink uograded to Jlink can be used to flash/debug... STM32 devices. I am not sure if it will work with MCU that are not from STM. TSDZ8 uses a infineon MCU and not an STM32. Should be tested to know if it works or not.
 
For information, I made some tests with my new version of OSF (not yet on github).

I noticed an unexpeced behavior of the torque sensor on my motor.
The values provided by the torque sensor depends on the position of the pedal.
E.g. with no load on the pedal, the torque sensor return a value that varies between 170 and 180 depending on the position of the pedal. I expect that the distance between the two induction coils varies and so also the values measured by MCU for the torque.
This difference of 10 ADC steps correspond to a pressure of about 3Kg on the pedal.
This can already explain, at least partly, the fluctuations that most users encountered with OSF on TSDZ8.
To avoid this, the firmware has to manage the assistance based on a value calculated over a whole rotation.
This is just what I planned in next OSF version.

Perhaps some other users could also check if they have the same behaviour with their torque sensor. The ADC values of the torque sensor can be displayed on all displays (VLCD5 and 860C). They could then report here their min and max values with no load.
 
Values from 156 to 190.
P. S. : Pedals horizontal.
 

Attachments

  • IMG_20250530_204519.jpg
    IMG_20250530_204519.jpg
    918.5 KB · Views: 4
  • IMG_20250530_204610.jpg
    IMG_20250530_204610.jpg
    1,020.4 KB · Views: 4
Last edited:
Interestingly, OEM software, including test3, has no problem with this.
 
Last edited:
In the specifications, it is said that this stlink uograded to Jlink can be used to flash/debug... STM32 devices. I am not sure if it will work with MCU that are not from STM. TSDZ8 uses a infineon MCU and not an STM32. Should be tested to know if it works or not.

Yes, ST-Link converted to J-Link is for STM targets, I did not properly check TSDZ8 processor earlier.

Upon checking my earlier notes, the J-Link couldn't connect to one STM processor - it was actually a clone.

Sorry for giving false hope.
 
The values provided by the torque sensor depends on the position of the pedal.
E.g. with no load on the pedal, the torque sensor return a value that varies between 170 and 180 depending on the position of the pedal. I expect that the distance between the two induction coils varies and so also the values measured by MCU for the torque.

I have TSDZ2 with LCD3 display. Are their Torque sensor assembly different? They look the same!

On my TSDZ2, 11.2 Torque sensor ADC value (no weight on pedals) is 113 (pedals horizontal) and 111 (pedals vertical), but only when the left pedal is pointing forward do I get 113. If the right pedal is pointing forward, I get 111.

Is the difference of Torque sensor ADC values I see due to "distance between the two induction coils varying"?

edit:
Hung a 5 lb weight on left pedal (verified horizontal with bubble level), value =122. With 5 lb weight on right pedal, value = 118
 
Last edited:
Perhaps some other users could also check if they have the same behaviour with their torque sensor. The ADC values of the torque sensor can be displayed on all displays (VLCD5 and 860C). They could then report here their min and max values with no load.

In my case, the torque sensor values are more stable. The bike is on the bike stand. The rear wheel is not touching the ground. The right crank is rotated by hand.
 
For all those who have a problem with jerking with 860c, try to upload 15.hex again, but before uploading get an erase chip. I'm also adding my settings that I ride on and I have no problem with jerking. I tested different combinations and it seems that lowering Torque offset adj e.g. to about 10 also helps with jerking, Foc works quite well for me in the range of 23-25. I'm uploading photos of my settings. My observations also worked for other users of OSF 860c, so maybe it will help.
If you have jerkinv, it may be helpful to turn the engine off and on and wait at least 10 seconds for the TQ sensor to calibrate.
 

Attachments

  • 20250527_045957.jpg
    20250527_045957.jpg
    1.8 MB · Views: 6
  • 20250526_063128.jpg
    20250526_063128.jpg
    2.2 MB · Views: 6
  • 20250526_063156.jpg
    20250526_063156.jpg
    3.9 MB · Views: 6
  • 20250526_063250.jpg
    20250526_063250.jpg
    1.5 MB · Views: 6

In my case, the torque sensor values are more stable. The bike is on the bike stand. The rear wheel is not touching the ground. The right crank is rotated by hand.
Just tried your test with my TSDZ2 (rear wheel off ground, broom stick through rear rack supported by 2 tables).
3,6,9,12 are o'clock positions as I rotate the right crank.

11.2 Torque sensor ADC value varies between 112 to 114.

Motor currently @ 1400 trouble free miles. Recently, I started to ride in Torque mode 95% of the time in level 1 (multiplier set to 20, 1/2 the default of 40) , assist is smooth, no jerkiness, makes me feel like I have bionic legs.

 
Last edited:
Is the difference of Torque sensor ADC values I see due to "distance between the two induction coils varying"?
Just found this video from Varstrom, who says the TSDZ8 torque sensor is same as the TSDZ2 except TSDZ8 has a compression bearing on the induction coils instead of plastic spacers on TSDZ2. When I had my motor completely apart (to swap everything over to a new motor casing- old one was broken in half when I got it), I noted the 2 induction coils had a slight film of grease between them, which together with static attraction between the coils, cannot be any movement in distance between them.

 
I just put on github a version 0.1.16 for 860C display.
In this version I made some changes in the way the torque sensor is managed.
I noticed that on some TSDZ8 motors (not all) the value returned by the torque sensor varies with the position of the pedal even if load does not change (easy to test with no no load).
Then I made changes in order to calculate
- the "actual" torque sensor value (with just a small filtering). This value can change very fast because it is updated every 52usec
- the "current rotation" torque value = the maximum of "actual" torque sensor during current 360° pedal rotation.
- the "previous rotation" torque value = the "current rotation" torque value during the previous rotation.
The assistance is based on the maximum of the 3 calculated values.
It allows to keep a fast reaction of the motor (because based on the max of 3 values) and to discard cyclic variations (present on some TSDZ8 but also inherent to a pedal system).

The drawback is that when you release the pressure on the pedal, the assistance will decrease only after one or two pedal rotation.
This add a delay.
To limit the drawback, the assistance change immediately to reflect the "actual" torque when the cadence become 0.
I could change it later on (if tests are positive) in order to do the same when cadence is lower than a thresehold of if cadence decreases by more than x% in a short time.

I tested 0.1.16 and it seems me much better than version 0.1.15.

Still you have to take care of some new points in your config in torque sensor menu:
- Coast brake ADC : This concept is not used in OSF TSDZ8. Still this field has been "reused" in order to let the user specify the "FOC multiplier" that is used to calculate "FOC angle" that play a role in motor efficiency and stability when current are high. So enter here a value for "FOC multiplier". It seems that a value in the range 24/28 is good. Feel free to experiment but be careful with values that would be very different.
- calibration MUST be disabled. If you enable it, 860C transmit some false data to the controller.
- Torque ADC step must be correct in order to get a correct value of the human power
- Torque ADC step adv is not used (860c value is discarded)
- Torque offset adj is used. The value in 860C is transmitted to the controller and is added to the Torque ADC offset (see below) to calculate a "total" offset. The logic is that there is no assistance when torque sensor value is less than ( Torque ADC offset + Torque offset adv). Please note that if calibration is enabled, the value transmitted to the controller is not the value on screen. That is one of the reason why calibration must be disabled. You can try with a value of 6. When you increase this value, it means that you will have to press more on the pedal before you get some assistance. Avoid a to low value because this increase the risk that you get assistance even with no load on the pedal.
- Torque range adj is currently not used. In a future version, I plan to use this field to let the user modify the way torque sensor generate assist (getting more or less assistance with low pressure on the pedal for the same maximum assistance for high pressure)
- Torque angle adj is not used (860c value is discarded)
- Torque ADC offset is very important. In TSDZ2 or in previous versions, the firmware read the torque sensor during the first 3 seconds and consider this value as the reference when no load is applied. This was done in order to get an automatic recalibration at each power on. This process is not good for TSDZ8 because, for some TSDZ8, the value varies significantly with the position of the pedal. So in this version of OSF, there is no autocalibration of the torque sensor with no load. Instead, the user has to fill in Torque ADC offset the value that will become the reference. To find the value to be encoded, you must use the menu technical and look at the field ADC torque sensor. When no load is applied on the pedal, turn manually the pedal and look at the values in ADC torque sensor. Note the MAXIMUM and enter it in Torque ADC offset (in Torque sensor menu). For TSDZ8, I expect that value should be between 150 and 190 depending on your motor.
- Torque ADC max has to be filled : to find the value, go to technical menu, look at field ADC torque sensor when you apply the max pressure on the pedal (about 80 kg = full human weight) while holding the brakes.

For other fields of Torque sensor menu, see the 860c manual provided by mbrusa.

As this version, use the maximum values of torque sensor during one pedal rotation (instead of some kind of averages), it could be that you have to adapt the values you introduced in the menu assist for the different levels to get the same feeling.

Note:
In previous version, "FOC angle" depends also on pwm duty cycle. As there were lot of fluctuations of PWM duty cycle in previous version, I made a change in 0.1.16 version in order not to use it anymore for FOC angle. This could have an impact on the value to be used for FOC multiplier. Perhaps it is a mistake. Should be tested.

I hope this version will provide a better feeling (avoiding jerking).
 
I just put on github a version 0.1.16 for 860C display.
In this version I made some changes in the way the torque sensor is managed.
I noticed that on some TSDZ8 motors (not all) the value returned by the torque sensor varies with the position of the pedal even if load does not change (easy to test with no no load).
Then I made changes in order to calculate
- the "actual" torque sensor value (with just a small filtering). This value can change very fast because it is updated every 52usec
- the "current rotation" torque value = the maximum of "actual" torque sensor during current 360° pedal rotation.
- the "previous rotation" torque value = the "current rotation" torque value during the previous rotation.
The assistance is based on the maximum of the 3 calculated values.
It allows to keep a fast reaction of the motor (because based on the max of 3 values) and to discard cyclic variations (present on some TSDZ8 but also inherent to a pedal system).

The drawback is that when you release the pressure on the pedal, the assistance will decrease only after one or two pedal rotation.
This add a delay.
To limit the drawback, the assistance change immediately to reflect the "actual" torque when the cadence become 0.
I could change it later on (if tests are positive) in order to do the same when cadence is lower than a thresehold of if cadence decreases by more than x% in a short time.

I tested 0.1.16 and it seems me much better than version 0.1.15.

Still you have to take care of some new points in your config in torque sensor menu:
- Coast brake ADC : This concept is not used in OSF TSDZ8. Still this field has been "reused" in order to let the user specify the "FOC multiplier" that is used to calculate "FOC angle" that play a role in motor efficiency and stability when current are high. So enter here a value for "FOC multiplier". It seems that a value in the range 24/28 is good. Feel free to experiment but be careful with values that would be very different.
- calibration MUST be disabled. If you enable it, 860C transmit some false data to the controller.
- Torque ADC step must be correct in order to get a correct value of the human power
- Torque ADC step adv is not used (860c value is discarded)
- Torque offset adj is used. The value in 860C is transmitted to the controller and is added to the Torque ADC offset (see below) to calculate a "total" offset. The logic is that there is no assistance when torque sensor value is less than ( Torque ADC offset + Torque offset adv). Please note that if calibration is enabled, the value transmitted to the controller is not the value on screen. That is one of the reason why calibration must be disabled. You can try with a value of 6. When you increase this value, it means that you will have to press more on the pedal before you get some assistance. Avoid a to low value because this increase the risk that you get assistance even with no load on the pedal.
- Torque range adj is currently not used. In a future version, I plan to use this field to let the user modify the way torque sensor generate assist (getting more or less assistance with low pressure on the pedal for the same maximum assistance for high pressure)
- Torque angle adj is not used (860c value is discarded)
- Torque ADC offset is very important. In TSDZ2 or in previous versions, the firmware read the torque sensor during the first 3 seconds and consider this value as the reference when no load is applied. This was done in order to get an automatic recalibration at each power on. This process is not good for TSDZ8 because, for some TSDZ8, the value varies significantly with the position of the pedal. So in this version of OSF, there is no autocalibration of the torque sensor with no load. Instead, the user has to fill in Torque ADC offset the value that will become the reference. To find the value to be encoded, you must use the menu technical and look at the field ADC torque sensor. When no load is applied on the pedal, turn manually the pedal and look at the values in ADC torque sensor. Note the MAXIMUM and enter it in Torque ADC offset (in Torque sensor menu). For TSDZ8, I expect that value should be between 150 and 190 depending on your motor.
- Torque ADC max has to be filled : to find the value, go to technical menu, look at field ADC torque sensor when you apply the max pressure on the pedal (about 80 kg = full human weight) while holding the brakes.

For other fields of Torque sensor menu, see the 860c manual provided by mbrusa.

As this version, use the maximum values of torque sensor during one pedal rotation (instead of some kind of averages), it could be that you have to adapt the values you introduced in the menu assist for the different levels to get the same feeling.

Note:
In previous version, "FOC angle" depends also on pwm duty cycle. As there were lot of fluctuations of PWM duty cycle in previous version, I made a change in 0.1.16 version in order not to use it anymore for FOC angle. This could have an impact on the value to be used for FOC multiplier. Perhaps it is a mistake. Should be tested.

It could be that with this version you have also to change acceleration and deceleration in Motor menu.

I hope this version will provide a better feeling (avoiding jerking).
 
Back
Top