Tsdz2 firmware open source adapted to vlcd5, vlcd6 and xh18

Electric Motors and Controllers
Post Reply
grecoa   100 mW

100 mW
Posts: 45
Joined: Nov 18 2018 4:51am
Location: UK S.Yorks

Re: Tsdz2 firmware open source adapted to vlcd5

Post by grecoa » May 21 2019 3:24pm

Sergio1990 wrote:
May 21 2019 11:58am
elem wrote:
May 14 2019 11:19pm
zappan wrote:
May 13 2019 10:05am
Hi, a few days ago Marcoq released the ver. 0.3.4 based on 0.18 and which gives the possibility to use the 0.19 casainho versions by checking the "last beta code" box.
The discussion on jobike
http://www.jobike.it/forum/topic.asp?TO ... ichpage=20
the software
http://www.jobike.it/Public/data/marcoq ... _0.3.4.zip
thancks for information .
HI everyone,
I installed the newest version. But the Problem with the backwards resistance is still active. Does everyone have an idea how to fix it? Does everyone have a code witch fix the problem?

Thanks for the Help
Hello Sergio, did you select the box "Backwards Resistance Off" in the Java Configurator?

User avatar
elfnino   100 mW

100 mW
Posts: 48
Joined: Mar 06 2019 5:09am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by elfnino » May 28 2019 5:56am

Has anyone tried to use the Throttle ?
I tried multiple qmarco's version and different Max/Min range values but the behavior is always the same - it works just like on/off switch without smooth speed increase.

Sergio1990   10 µW

10 µW
Posts: 6
Joined: Apr 27 2019 2:49pm

Re: Tsdz2 firmware open source adapted to vlcd5

Post by Sergio1990 » May 28 2019 11:39am

grecoa wrote:
May 21 2019 3:24pm
Sergio1990 wrote:
May 21 2019 11:58am
elem wrote:
May 14 2019 11:19pm
zappan wrote:
May 13 2019 10:05am
Hi, a few days ago Marcoq released the ver. 0.3.4 based on 0.18 and which gives the possibility to use the 0.19 casainho versions by checking the "last beta code" box.
The discussion on jobike
http://www.jobike.it/forum/topic.asp?TO ... ichpage=20
the software
http://www.jobike.it/Public/data/marcoq ... _0.3.4.zip
thancks for information .
HI everyone,
I installed the newest version. But the Problem with the backwards resistance is still active. Does everyone have an idea how to fix it? Does everyone have a code witch fix the problem?

Thanks for the Help
Hello Sergio, did you select the box "Backwards Resistance Off" in the Java Configurator?
Hi grecora

Thanks for the answer. Yes I select the box, but the resistance is still there. Not so much but it is still strong.
Do you don't have such problems with the newest version?

grecoa   100 mW

100 mW
Posts: 45
Joined: Nov 18 2018 4:51am
Location: UK S.Yorks

Re: Tsdz2 firmware open source adapted to vlcd5

Post by grecoa » May 28 2019 1:34pm

[/quote]

Hi grecora

Thanks for the answer. Yes I select the box, but the resistance is still there. Not so much but it is still strong.
Do you don't have such problems with the newest version?
[/quote]

Hi
I am using the latest version but I do not select (Last Beta Code) so still V18. When I select the "Backwards Resistance off" I have no resistance at all.
Other users also report that all backwards resistance is gone.

stein   1 mW

1 mW
Posts: 11
Joined: Aug 30 2009 9:53am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by stein » Jun 04 2019 9:21am

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: Select all

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?
Last edited by stein on Jun 04 2019 9:51am, edited 5 times in total.

stein   1 mW

1 mW
Posts: 11
Joined: Aug 30 2009 9:53am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by stein » Jun 04 2019 9:32am

Also I could use some advice; when opening up the motor I might have put the pas sensor in wrong somehow and don't seem to get a signal anymore. I'm hoping to debug it by temporarily displaying the pass cadence on the vlcd6 instead of the bike speed but can't get it to work.

Has anyone tried use the display for debugging with success?

What I did for testing is putting in a fixed value in the function "uart_send_package" but the display keeps showing 0 where I would expect it to show the values.

Code: Select all

			// wheel speed
			if(ui16_vlcd6_wheel_speed == 0)
			{
			//	ui8_tx_buffer[6] = 0x07; Stein - original value
			//	ui8_tx_buffer[7] = 0x07; Stein - original value
				ui8_tx_buffer[6] = 50; // Stein - value for testing screen output
				ui8_tx_buffer[7] = 20; // Stein - value for testing screen output
			}

vscope   100 mW

100 mW
Posts: 43
Joined: Jun 19 2018 5:42am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by vscope » Jun 04 2019 10:26am

stein wrote:
Jun 04 2019 9:32am
Also I could use some advice; when opening up the motor I might have put the pas sensor in wrong somehow and don't seem to get a signal anymore. I'm hoping to debug it by temporarily displaying the pass cadence on the vlcd6 instead of the bike speed but can't get it to work.

Has anyone tried use the display for debugging with success?

What I did for testing is putting in a fixed value in the function "uart_send_package" but the display keeps showing 0 where I would expect it to show the values.

Code: Select all

			// wheel speed
			if(ui16_vlcd6_wheel_speed == 0)
			{
			//	ui8_tx_buffer[6] = 0x07; Stein - original value
			//	ui8_tx_buffer[7] = 0x07; Stein - original value
				ui8_tx_buffer[6] = 50; // Stein - value for testing screen output
				ui8_tx_buffer[7] = 20; // Stein - value for testing screen output
			}
Hi would need that function too, since my bike lags from time to time and i want to find out if its the torque sensor or the pas sensor....

maybe try setting ui16_oem_wheel_speed to eg 50... before if(ui16_vlcd6_wheel_speed == 0)

or try

Code: Select all

uint16_t ui16_temp;
ui16_temp = (uint16_t) ui8_torque_sensor * (uint16_t) PEDAL_TORQUE_X100;

		ui8_tx_buffer[6] = (uint8_t) (ui16_temp & 0xFF);
		ui8_tx_buffer[7] = (uint8_t) (ui16_temp >> 8);
instead of

Code: Select all

				ui8_tx_buffer[6] = 50; // Stein - value for testing screen output
				ui8_tx_buffer[7] = 20; // Stein - value for testing screen output
				
				

stein   1 mW

1 mW
Posts: 11
Joined: Aug 30 2009 9:53am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by stein » Jun 04 2019 11:48am

Thanks @vscope. I've tried

Code: Select all

				uint16_t ui16_temp;
				ui16_temp = 505;

				ui8_tx_buffer[6] = (uint8_t) (ui16_temp & 0xFF);
				ui8_tx_buffer[7] = (uint8_t) (ui16_temp >> 8);
but still no luck (0.00 on screen). There seems to be more to it but so far I don't fully understand how the function "calc_wheel_speed" works. I'll keep digging.

thineight   100 W

100 W
Posts: 228
Joined: Oct 05 2018 3:53am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by thineight » Jun 04 2019 11:56am

Did you maybe disconnect the torque sensor?
There are 2 wires red-black coming from the drive side to be connected with a small white connector. In my case one was broken (not properly soldered to the torque sensor) since the beginning and the motor did not kick in.. walk assist worked.
MTB KTM Ultra 29" - City bike DAYTONA 28"

stein   1 mW

1 mW
Posts: 11
Joined: Aug 30 2009 9:53am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by stein » Jun 04 2019 12:15pm

It measures 2.5Ohms, so the wire is not broken. It might be shorted though; 2.5ohms looks fairly low at first glance but then I don't have any data on what it should be.

To use the display for debugging I'm wondering if there is some flag that needs to be set before the display to show the data from ui8_tx_buffer[6] and ui8_tx_buffer[7]

marcoq   1 W

1 W
Posts: 63
Joined: Dec 17 2018 3:55am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by marcoq » Jun 04 2019 3:46pm

Very soon I will release the new firmware version and new java configurator ... the programs will be completely compatible with the VLCD5, VLCD6 and XH18 displays.
There will be important implementations and advanced features that will make the bike enjoyable to ride! :D :D :D

User avatar
elem   100 W

100 W
Posts: 135
Joined: May 26 2017 4:27pm
Location: alpes maritimes
Contact:

Re: Tsdz2 firmware open source adapted to vlcd5

Post by elem » Jun 05 2019 2:06pm

marcoq wrote:
Jun 04 2019 3:46pm
Very soon I will release the new firmware version and new java configurator ... the programs will be completely compatible with the VLCD5, VLCD6 and XH18 displays.
There will be important implementations and advanced features that will make the bike enjoyable to ride! :D :D :D
:thumb:
RockRider 9.1 TSDZ2 open source firmware .

wpenner   100 W

100 W
Posts: 104
Joined: May 10 2018 3:27pm

Re: Tsdz2 firmware open source adapted to vlcd5

Post by wpenner » Jun 06 2019 11:32pm

marcoq wrote:
Jun 04 2019 3:46pm
Very soon I will release the new firmware version and new java configurator ... the programs will be completely compatible with the VLCD5, VLCD6 and XH18 displays.
There will be important implementations and advanced features that will make the bike enjoyable to ride! :D :D :D
Awesome. Can’t wait to try out current version. My USB programmer will arrive in a few days. I hope there is a NoLCD option someday as I always ride my bike on turbo mode anyways(LCD5)Not sure if motor can technically run only using battery switch.

zappan   10 W

10 W
Posts: 70
Joined: Sep 27 2018 3:00am
Location: Sicilia

Re: Tsdz2 firmware open source adapted to vlcd5

Post by zappan » Jun 07 2019 3:35am

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

Minatauro   10 mW

10 mW
Posts: 23
Joined: Dec 22 2018 5:59am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by Minatauro » Jun 07 2019 5:17am

Hi, I downloaded and flashed version 3.5 by Marcoq yesterday. I have a 48v with VLCD5 and I had set the configurator K soft ramp to 20. It was not great as the assist was very slow to kick in and then almost had a wave effect and difficult to pedal with a lot of resistance starting off. It was the same for the eMTB setting. I reflashed the firmware again and set the soft ramp to 0 and I changed the magic byte to see if that would help to reinitialize the memory. I was much happier this time, the start is nice and smooth and the power increases steadily. However the top end speed was a bit lower than the previous version 3.3 I was using. This is not an issue as it is only by a few Km/h and overall the bike feels more balanced. The backwards resistance is gone for me even with the last beta ticked. The resistance was still there in 3.3 for me. Overall it is an excellent release and the walk assist also works with a speed of 4km/h which is perfect.

Unfortunately I cannot enjoy it or test it further as the crankshaft snapped and my chainring side pedal came off as I was cycling to work this morning. Luckily I managed to keep my balance and get to the pavement and retrieve my pedal from the middle of the road. Does anyone know if it is possible to replace the shaft? I haven’t looked at my bike properly as I had to just park it and run into the office but it seem I may still be able to slide the motor out without much hassle. I cant believe that it would snap after only 2000km done.

zappan   10 W

10 W
Posts: 70
Joined: Sep 27 2018 3:00am
Location: Sicilia

Re: Tsdz2 firmware open source adapted to vlcd5

Post by zappan » Jun 07 2019 6:05am

Excuse me minotauro but is your broken drive axle standard or stretched for Fat Bike?
As for the missing power, you can always increase the parameters of the PWM Duty Cycle

Minatauro   10 mW

10 mW
Posts: 23
Joined: Dec 22 2018 5:59am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by Minatauro » Jun 07 2019 6:18am

Hi Zappan, It is the standard axel on the motor for the 68-73mm bb. It snapped off at the base of the chainring. I was just wondering if it was replaceable or a new motor needed. I haven't had a chance to take the motor off the bike yet to see. I just threw my pedal and crank arm into my locker :) . I am happy with the software but just bad luck that it happened as I was looking forward to riding it home again this evening.

zappan   10 W

10 W
Posts: 70
Joined: Sep 27 2018 3:00am
Location: Sicilia

Re: Tsdz2 firmware open source adapted to vlcd5

Post by zappan » Jun 07 2019 6:50am

I'm sorry it is very strange that the standard one has broken, I guess it never happened ... certainly if you don't find the spare part, it might be better to buy the engine, but you can contact the Italian importer because they see the change in the workshop may have the original surplus trees.

thineight   100 W

100 W
Posts: 228
Joined: Oct 05 2018 3:53am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by thineight » Jun 07 2019 8:15am

Minatauro wrote:
Jun 07 2019 6:18am
Hi Zappan, It is the standard axel on the motor for the 68-73mm bb. It snapped off at the base of the chainring. I was just wondering if it was replaceable or a new motor needed. I haven't had a chance to take the motor off the bike yet to see. I just threw my pedal and crank arm into my locker :) . I am happy with the software but just bad luck that it happened as I was looking forward to riding it home again this evening.
The axle comes with the torque sensor, and it is a spare part (pswpower). Not sure if you can get the axle only though, anyway you need a bit of skills to disassemble the unit, in particular to put it back again the torque sensor.
MTB KTM Ultra 29" - City bike DAYTONA 28"

Minatauro   10 mW

10 mW
Posts: 23
Joined: Dec 22 2018 5:59am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by Minatauro » Jun 07 2019 9:25am

Oh well, I knew it could not be that simple. It looks like I may now have to buy another motor as I don't know if I could do a good job at stripping it down and replacing it. I'm a bit wary of its reliability now though as it was very creaky and squeaky when I pedaled and there seemed to be a bit of play in the chainring. I tightened all the bolts on the chainring to see if it would help but it did not the squeak was still there. Maybe this bit of sideways play in the chainring increased the strain on the axel and was the cause of the break?? So if anyone else has a squeak or creak from around the chainring then be careful just incase the same thing happens especially if you are travelling at speed.

wpenner   100 W

100 W
Posts: 104
Joined: May 10 2018 3:27pm

Re: Tsdz2 firmware open source adapted to vlcd5

Post by wpenner » Jun 07 2019 10:15am

Minatauro wrote:
Jun 07 2019 9:25am
Oh well, I knew it could not be that simple. It looks like I may now have to buy another motor as I don't know if I could do a good job at stripping it down and replacing it. I'm a bit wary of its reliability now though as it was very creaky and squeaky when I pedaled and there seemed to be a bit of play in the chainring. I tightened all the bolts on the chainring to see if it would help but it did not the squeak was still there. Maybe this bit of sideways play in the chainring increased the strain on the axel and was the cause of the break?? So if anyone else has a squeak or creak from around the chainring then be careful just incase the same thing happens especially if you are travelling at speed.
Mine has been creaking really bad. Hope this doesn’t happen to mine. I will disassemble it in a bit to try to find the creaking. I think I may have crushed the plastic bb spacer I was using. I’m at about 2000km.

Minatauro   10 mW

10 mW
Posts: 23
Joined: Dec 22 2018 5:59am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by Minatauro » Jun 07 2019 10:32am

Attached images for reference
Attachments
ae_1559911195777.jpg
ae_1559911215240.jpg
ae_1559911315126.jpg

ji.ti@seznam.cz   1 µW

1 µW
Posts: 3
Joined: Jun 10 2019 1:25am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by ji.ti@seznam.cz » Jun 10 2019 1:31am

zappan wrote:
Jun 07 2019 3:35am
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.

zappan   10 W

10 W
Posts: 70
Joined: Sep 27 2018 3:00am
Location: Sicilia

Re: Tsdz2 firmware open source adapted to vlcd5

Post by zappan » Jun 10 2019 2:40am

ji.ti@seznam.cz wrote:
Jun 10 2019 1:31am
zappan wrote:
Jun 07 2019 3:35am
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?TO ... ichpage=28

ji.ti@seznam.cz   1 µW

1 µW
Posts: 3
Joined: Jun 10 2019 1:25am

Re: Tsdz2 firmware open source adapted to vlcd5

Post by ji.ti@seznam.cz » Jun 12 2019 10:27am

Is it possible for the torsion sensor to destroy the new firmware upload? Displey VLCD5 shows the RE 70, RE1 70 values even at pedal pressure. The first used java configurator v.3.4 and the second time v.3.5

Post Reply