Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Finally got my programmer and loaded up the firmware. Was easy to just use the shrink wrap on the programming leads and not having to buy speedo extension cable. Took a while to get the pinout scouring the forum though.

What is the max Watts for the controller I can set? It has less power than the original firmware when set at 625Watts

I’ve heard the amp limit is 18amps. So is 48x18 = 864watts the max I could set it to?

My BMS used to say it was using around 800watts when fully charged 48v 13s
 
Now set to battery 18amps and 750Watts. It has much more power now. I still can't figure out how to turn off the 28km/h speed limit though. Speed on LCD5 in secret menu just says "---" now. I even unchecked the street mode check box. Tried setting to MPH in LCD5 also did not help. Next i will try writing 00 to the motor before programming, as that seems to have fixed errors for others.
 
wpenner said:
Now set to battery 18amps and 750Watts. It has much more power now. I still can't figure out how to turn off the 28km/h speed limit though. Speed on LCD5 in secret menu just says "---" now. I even unchecked the street mode check box. Tried setting to MPH in LCD5 also did not help. Next i will try writing 00 to the motor before programming, as that seems to have fixed errors for others.

The disable street mode option didn't work for me either. In power level 1 press the light button twice it should say E04 on the screen for off-road mode. Press it again twice and get E03 for street mode
 
JaiCee said:
wpenner said:
Now set to battery 18amps and 750Watts. It has much more power now. I still can't figure out how to turn off the 28km/h speed limit though. Speed on LCD5 in secret menu just says "---" now. I even unchecked the street mode check box. Tried setting to MPH in LCD5 also did not help. Next i will try writing 00 to the motor before programming, as that seems to have fixed errors for others.

The disable street mode option didn't work for me either. In power level 1 press the light button twice it should say E04 on the screen for off-road mode. Press it again twice and get E03 for street mode

Awesome. I just tried it and see it changes between E04 or E03. Setting it to 18amps 750watt my motor was still cooler than default firmware as I can ride at much higher cadence, but i get way more power. Much slower ramp up is nice also. I’ll be adding temp sensor soon.

This firmware is a great option because didn’t have to purchase new LCD and mess with cutting LCD cable etc. Thanks to marcoq for spending the time to write the software.
 
stein said:
Hi all, great job on the development .

I'm new on this project but have programming experience and have been looking at the code for a few weeks now with a 48v tsdz2 with vlcd5 display and can confirm all the settings so far have been working well on the vlcd5 display.

As for the backwards resistance, it seems to have to do with the pwm signal staying active and the duty cycle being at zero when at standstill. This results in maximum braking resistance (regen) when running the wheel backwards. When running the wheel forward you wont feel this since the clutch on the small blue gear prevents rotation from going in but as it is a one way clutch it does transfer rotation to the motor in reverse.

I managed to stop this from happening by adding a "pwm_deinit_bipolar_4q" to "pwm.c" and calling it when the motor speed falls below 50ERPS.
Code:
void pwm_deinit_bipolar_4q (void)
{
  // verify if PWM N channels are active on option bytes, if so, disable
  FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);
  if (FLASH_ReadOptionByte (0x4803) != 0x20)
  {
    FLASH_Unlock (FLASH_MEMTYPE_DATA);
    FLASH_EraseOptionByte(0x4803);
    FLASH_ProgramOptionByte(0x4803, 0x20);
    FLASH_Lock (FLASH_MEMTYPE_DATA);
  }

  TIM1_TimeBaseInit(0, // TIM1_Prescaler = 0
        TIM1_COUNTERMODE_CENTERALIGNED1,
        (512 - 1), // clock = 16MHz; counter period = 1024; PWM freq = 16MHz / 1024 = 15.625kHz;
        //(BUT PWM center aligned mode needs twice the frequency)
        1); // will fire the TIM1_IT_UPDATE at every PWM period cycle



  TIM1_OC1Init(TIM1_OCMODE_PWM1,
#if 1
         TIM1_OUTPUTSTATE_DISABLE,
         TIM1_OUTPUTNSTATE_DISABLE,

#else
         TIM1_OUTPUTSTATE_ENABLE,
         TIM1_OUTPUTNSTATE_ENABLE,
#endif
         255, // initial duty_cycle value
         TIM1_OCPOLARITY_HIGH,
         TIM1_OCPOLARITY_HIGH,
         TIM1_OCIDLESTATE_RESET,
         TIM1_OCNIDLESTATE_SET);

  TIM1_OC2Init(TIM1_OCMODE_PWM1,
         TIM1_OUTPUTSTATE_DISABLE,
         TIM1_OUTPUTNSTATE_DISABLE,
         255, // initial duty_cycle value
         TIM1_OCPOLARITY_HIGH,
         TIM1_OCPOLARITY_HIGH,
         TIM1_OCIDLESTATE_RESET,
         TIM1_OCIDLESTATE_SET);

  TIM1_OC3Init(TIM1_OCMODE_PWM1,
#if 1
         TIM1_OUTPUTSTATE_DISABLE,
         TIM1_OUTPUTNSTATE_DISABLE,
#else
         TIM1_OUTPUTSTATE_ENABLE,
         TIM1_OUTPUTNSTATE_ENABLE,
#endif
         255, // initial duty_cycle value
         TIM1_OCPOLARITY_HIGH,
         TIM1_OCPOLARITY_HIGH,
         TIM1_OCIDLESTATE_RESET,
         TIM1_OCNIDLESTATE_SET);

  // OC4 is being used only to fire interrupt at a specific time (middle of DC link current pulses)
  // OC4 is always syncronized with PWM
  TIM1_OC4Init(TIM1_OCMODE_PWM1,
         TIM1_OUTPUTSTATE_ENABLE,
         285, // timming for interrupt firing (hand adjusted)
         TIM1_OCPOLARITY_HIGH,
         TIM1_OCIDLESTATE_RESET);

  // break, dead time and lock configuration
  TIM1_BDTRConfig(TIM1_OSSISTATE_ENABLE,
      TIM1_LOCKLEVEL_OFF,
      // hardware nees a dead time of 1us
      16, // DTG = 0; dead time in 62.5 ns steps; 1us/62.5ns = 16
      TIM1_BREAK_DISABLE,
      TIM1_BREAKPOLARITY_LOW,
      TIM1_AUTOMATICOUTPUT_DISABLE);

  TIM1_ITConfig(TIM1_IT_CC4, ENABLE);
  TIM1_Cmd(ENABLE); // TIM1 counter enable
  TIM1_CtrlPWMOutputs(ENABLE);
}

It disables TIM1_OC1Init, TIM1_OC2Init and TIM1_OC3Init pwm outputs but keeps TIM4_OC1Init active so the interrupt that detects motor erps etc stays active. This is needed to detect PAS when starting to pedal again so we can call pwm_init_bipolar_4q () at that point to reactivate the motor.

An added bonus of disabling those pwm outputs is that the idle current at standstill drops from 0.1A(5W@50v) to 0.03A(1.4W@50v) keeping the controller cooler :D . This seems to be consistent with how the stock firmware works (it measured 0.03A at standstill).

What do you guys think, would this be a good way of implement it given some refactoring and prettying up the code snippet from above?

HI Stein

Thanks for the code but it doesn't work. I just copy paste it in the end of the pwm.c file. I use the version vM0.16. All is fine, no error but the backwards resistance is very strong.... What I do wrong?
Is it possible to send me the whole file with the codes that don't have a backwards resistance?

Thanks for your great work
 
Hi Sergio1990, the Marcoq code already provides for the elimination of backward resistance using the "Backwards Res. Off" option and works well confirmed by many users. Keep in mind that the latest version of Marcoq can use Casainho's SW 0.19.08 which has also eliminated backward resistance.
 
zappan said:
Hi Sergio1990, the Marcoq code already provides for the elimination of backward resistance using the "Backwards Res. Off" option and works well confirmed by many users. Keep in mind that the latest version of Marcoq can use Casainho's SW 0.19.08 which has also eliminated backward resistance.

Hi Zappan

Thanks for Information. I will try the new one of the software but where I can find it? On Github is only the M0.16.D....

Thanks for your help.

Bests
Sergio
 
zappan said:
ji.ti@seznam.cz said:
zappan said:
Hi, in the Italian forum the Beta vMO 0.18.I version and the related Java v configurator have been released. 3.5 of Marcoq, among other things the EMTB function is implemented, a gem that is not present in Casainho's Opensurce SW. :D

Hi. For a few days I am looking for a java configurator v.3.5 Can someone please help where to find it.

Italian forum Jobike
http://www.jobike.it/forum/topic.asp?TOPIC_ID=76426&whichpage=28

Sergio1990 the link is on the previous page.
 
Hi,
Does the Marcoq fw have Cruise control in it?
I know that lcd3 and Casainhos fw has it, but I have vlcd5 and waiting for the sw102 fw to be released...

Thanks
 
Can someone please provide a basic step by step guide of how to flash the motor with Marcoq's firmware?
 
Chewy said:
Can someone please provide a basic step by step guide of how to flash the motor with Marcoq's firmware?
Hello, I report, translated with google, a guide to programming some time ago taken from a post by Marcoq:

"how to use the Configurator in Java.
First of all, what is needed:
- Install JRE runtime on the PC.
- Install the SDCC compiler as explained by casainho here https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Development
- An original STLINK-V2 programmer or Chinese clone (those in the shape of a USB flash drive).
- the self-made programming cable to connect the motor to the programmer.
- Install the ST Visual Programmer program on the PC.

How to program the motor via the Java Configurator.
- Unzip the file you downloaded from the Repository and save everything where you want (it's a folder).
- In the newly saved folder you will find the TSDZ_Configurator_vx.x.x.jar file, open it with a double click.
- Once the Configurator is open you can make the changes you want, even if by default it is already OK for 36V motors ...
eventually the characteristics of the battery and the max power of the motor must be changed. Connect the programmer to the motor and to the USB port of the PC. Click on the "Compile" button, once finished click on the "Program" button, the Configurator will program the engine without the help of the STVP software ... and you're done.
When "Compiling" with the Configurator a file is always created with the extension .ihx (equivalent to the .hex) which is then used to program the motor directly using the "Program" button.
The file with the .hex extension found in the releases folder is a file compiled with the default parameters of the Configurator and can be written to the motor microcontroller using the ST Visual programmer program (STVP).


The Wheel perimeter check and Wheel max speed indicate that these parameters are received by the VLCD6, if the check is disabled the data is read from the eeprom (Default wheel perimeter and Default wheel max speed).
Motor working flags and Wheel turning flags are used to indicate to the VLCD6 that the engine or wheel are turning, otherwise it would go to standby, if you want to keep the display always on, just enable the flag VLCD6 always on.
If brake sensors are installed, the relevant flag must be enabled.
Magic Byte should be used when producing a .hex file and programming the micro with the STVP softare without executing the eeprom deletion procedure, because the magic byte is the eeprom key, if it changes with respect to the one saved in memory, they will come automatically update all the data resident in eeprom ...... we say that this option is for expert users ...
I've already fixed the "break" write error ....
 
The user Ashrambo has a very interesting blog about how to install and configure the Marcoq SW:
https://ashthinkings.blogspot.com/
Also on the Italian forum you will find something prepared by the user Bic3r:
http://www.jobike.it/forum/topic.asp?TOPIC_ID=77830
Good job.
 
Would anyone have have advice on how to tune the soft start parameters? It is far too soft for navigating in traffic. I want rapid acceleration. I'm an avid cyclist and prefer to modulate torque with my feet rather than software, and am willing to risk damaging the nylon gear.
 
Hi. I also made fork with VLCD5 / VLCD6 / no display support.
Based on OpenSource-EBike-firmware/TSDZ2-Smart-EBike (casainho, buba, endlesscadence) and added TSDZ2 VLCD display protocol code (hurzhurz, marcoq), no other changes at all.
All configs are in config.h. Need to configure manually and compile by yourself.
https://github.com/Demion/TSDZ2-Smart-EBike

Update: added control functions toggled by lights button (similar to marcoq).

Code:
lights button = function toggle

level	page	function

0	0	lights
1	0	street mode
2	0	boost
3	0	power limit
4	0	page switch

0	1	lights
1	1	pedal power / 10
2	1	voltage
3	1	current
4	1	page switch

Update 2: added VLCD support for different versions as branches.
https://github.com/Demion/TSDZ2-Smart-EBike/tree/vlcd_v0.18.2
https://github.com/Demion/TSDZ2-Smart-EBike/tree/vlcd_v0.19.0
 
Demion said:
Hi. I also made fork with VLCD5 / VLCD6 / no display support.
Based on OpenSource-EBike-firmware/TSDZ2-Smart-EBike v0.19.0 and marcoq vlcd display protocol code, no other changes.
All configs are in config.h. Need to configure manually and compile by yourself.
https://github.com/Demion/TSDZ2-Smart-EBike

Update: added control functions toggled by lights button (similar to marcoq).
...

Hello Demion, meanwhile congratulations for your work :thumb: , can you be more clear on the functioning and configuration of the parameters inside config.h, and also, the option without display means that you can use the bike without a display with a standard configuration? how do you turn on the system? thank you.
 
zappan said:
Hello Demion, meanwhile congratulations for your work :thumb: , can you be more clear on the functioning and configuration of the parameters inside config.h, and also, the option without display means that you can use the bike without a display with a standard configuration? how do you turn on the system? thank you.

It is practically original TSDZ2-Smart-EBike v0.19.0 with no changes at all, except VLCD display support (show speed, change assist level, set lights, wheel size, max speed) and extra functions (set street mode, boost, show pedal power, voltage, current) using lights button (hold down on VLCD6) as toggle.

You need to manually change config.h file and then compile and flash. Configs are similar used in KT-LCD3, feel free to ask about any specific configs.

I made this fork for my own use with VLCD6 while waiting for SW102 display development.
I havent actually tested with VLCD5 or without display, but, according to wiki, I think you need to connect white Vin with green P+ battery voltage for 6 pin or red Vin with blue P+ battery voltage for 8 pin.
https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Wire-KT-LCD3-to-TSDZ2
 
I cant get the java configurator to work.

How do I directly flash using the STVP programmer?

I have tried loading one of the .hex files from the 'release' folder and flashing it to 'program memory' tab, however the motor lost all power.

How do I flash Marqocs firmware to the motor using STVP?
 
Is there a compiled version of this firmware with VLCD6 support ? I’m not a software developer and would like to flash my motor and use the vlcd6. My long term goal is to be able to compile the code myself, but for just now I’d like to download. Thanks.
 
Bartman said:
Is there a compiled version of this firmware with VLCD6 support ? I’m not a software developer and would like to flash my motor and use the vlcd6. My long term goal is to be able to compile the code myself, but for just now I’d like to download. Thanks.

Compiling is just a matter of installing sdcc compiler and running batch file. Not any different from flashing. You can even automatically compile and flash with one button in marcoq configurator, as I recall.

To compile from source code install sdcc 3.8.0 version (check add to PATH option in installer) and just run src/controller/compile.bat or src/controller/compile_and_flash.bat or release.bat in root folder.
Result firmware file will be src/controller/main.ihx.

https://sourceforge.net/projects/sdcc/files/sdcc-win64/3.8.0/sdcc-3.8.0-x64-setup.exe/download

https://github.com/OpenSource-EBike-firmware/TSDZ2_wiki/wiki/Development
 
Translated by Google Translator:

Hi guys.
With this publication I officially released version 3.6 of the Java configurator and version M0.19.A for the controller board firmware.
What has been done:
- In the last release released, the eMTB mode started from TOUR assistance (up to TURBO), now with the configurator it is possible to define the starting assistance level "eMTB Start Assist Level", for example you can set it to 10, 20, 50, etc ... but must not exceed the level of SPORT assistance.
- I introduced the parameter eMTB Motor Pull Factor, which can be set from 0.0 to 1.0, this determines "the pull of the motor", or if I put a low value I get that the motor reaches the highest assistance values ​​with "less effort", if I put a low value, I'll have to "commit" a little more with the pedals.
- In the project folder there is an eMTB.xls spreadsheet that can be used to do some "paper" tests.
- I deleted the check to enable the "Last Beta Code" ... now the firmware has been aligned with the stable 19.0 version released by Casainho, of course all the customizations and implementations entered by the undersigned remain.
- I entered the VLCD5 Battery SOC 4 Bars checkbox which allows VLCD5 owners to implement the 4-bar battery status display as on the VLCD6. I did this because it would be a problem to manage the VLCD5 with the accuracy as in VLCD6 but with 6 notches ... I should add some fields in the Java interface .. but now it's full ... and it would be too expensive in time to move all. This solution should solve the problem of "misaligned" display with battery status.
- I have solved some small bugs ... and optimized the startup of the CPU.

On Endless they are discussing the "human power" factor, the calibration of the torsion sensor, and how to obtain a more accurate reading ... furthermore the developers want to release a firmware version that also includes the eMTB mode.
The big advantage of the Java configurator is that you can "experiment" with various settings without having to go through the code ... so do your tests !!!
Good rides to everyone !!!
 

Attachments

  • TSDZ2_Controller_vM0.19.A_and_TSDZ2_Configurator_Beta_0.3.6_con_codice_0.19_Stable.zip
    4.7 MB · Views: 157
marcoq said:
Translated by Google Translator:

Hi guys.
With this publication I officially released version 3.6 of the Java configurator and version M0.19.A for the controller board firmware.
What has been done:
- In the last release released, the eMTB mode started from TOUR assistance (up to TURBO), now with the configurator it is possible to define the starting assistance level "eMTB Start Assist Level", for example you can set it to 10, 20, 50, etc ... but must not exceed the level of SPORT assistance.
- I introduced the parameter eMTB Motor Pull Factor, which can be set from 0.0 to 1.0, this determines "the pull of the motor", or if I put a low value I get that the motor reaches the highest assistance values ​​with "less effort", if I put a low value, I'll have to "commit" a little more with the pedals.
- In the project folder there is an eMTB.xls spreadsheet that can be used to do some "paper" tests.
- I deleted the check to enable the "Last Beta Code" ... now the firmware has been aligned with the stable 19.0 version released by Casainho, of course all the customizations and implementations entered by the undersigned remain.
- I entered the VLCD5 Battery SOC 4 Bars checkbox which allows VLCD5 owners to implement the 4-bar battery status display as on the VLCD6. I did this because it would be a problem to manage the VLCD5 with the accuracy as in VLCD6 but with 6 notches ... I should add some fields in the Java interface .. but now it's full ... and it would be too expensive in time to move all. This solution should solve the problem of "misaligned" display with battery status.
- I have solved some small bugs ... and optimized the startup of the CPU.

On Endless they are discussing the "human power" factor, the calibration of the torsion sensor, and how to obtain a more accurate reading ... furthermore the developers want to release a firmware version that also includes the eMTB mode.
The big advantage of the Java configurator is that you can "experiment" with various settings without having to go through the code ... so do your tests !!!
Good rides to everyone !!!

Awesome. My friends bike came with a different wiring harness and a 850c display, i guess it uses the stock firmware? Do you think your firmware might be compatible with the display if i select LCD5?

I think it is the same as this one:
https://www.youtube.com/watch?v=DHdp9PnKqkI
 
Back
Top