TSDZ2 mid drive with 860C, 850C or SW102 displays only -- Flexible OpenSource firmware (Casainho code only)

Electric Motors and Controllers
jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » Apr 30 2018 7:33pm

jeanl wrote:
Apr 30 2018 5:59pm
casainho wrote:
Apr 30 2018 5:20pm
The original firmware runs the motor very silently compared to the 6 steps/square wave/block commutation I implemented. I saw the PWM signals and are SVM just like used on FOC but I think they are simple doing "FOC" using motor parameters!!
The development is blocked because I don't know how to implement "FOC" using the motor parameters... Let's see if jur can help ;-)
casainho, I have no specific knowledge of FOC, but I have Electrical Engineering background with lots of math etc, so perhaps I can help with that. I need to have a bit more background though. I perused through the document that was posted above (the lengthy one with all the details on FOC) but I need to read it a lot more carefully if I want to help.
What do you mean by " I don't know how to implement "FOC" using the motor parameters"? Can you quickly summarize where you are and what you think is missing?
Jean
(and kudos for all you're doing, it's awesome)
Same here, electrical engineer in field of power electronics. Power conversion is my bread and butter but I haven't done any motor control so have to learn the stuff from scratch.

BUT @casainho, if your only problem is that floating point math is taking too long, it isn't a problem to use integer math in this case. Our company does digital control of power converters, and floating point isn't used - we simply use integer math and convert at the end. Enough bits and accuracy is not impacted.

For example, duty cycle can be encoded with sufficient resolution using 8 bits (more than enough or even too many, 7 may be enough even with good enough resolution for this application). Voltage, also 7 or 8 bits. To get E, multiply, then right shift keeping the correct MSB. And so on. I am assuming you can do 16 bit operations.

Another question, what PWM frequency are you aiming for? Several issues here: Too high won't work, probably causing magnetising losses in the stator core, and the MOSFET gate drives are also very slow, from a TSDZ2 circuit I saw somewhere. I would measure the existing firmware's frequency and aim for the same, at least as a starting point.

jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » May 01 2018 6:10am

Another item, do we have the motor parameters yet? I have extremely accurate and sensitive inductance and resistance measuring instrumentation at work; but I don't want to take apart my wife's freshly-built bike again if I can avoid it.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 01 2018 6:17am

jur wrote:
May 01 2018 6:10am
Another item, do we have the motor parameters yet? I have extremely accurate and sensitive inductance and resistance measuring instrumentation at work; but I don't want to take apart my wife's freshly-built bike again if I can avoid it.
No, we don't have. And yes, hard to get that parameters. Really great if you can do it.

I expect to receive some donated controllers that I will use to see the board from the backside - I don't want nothing to be missing, I need to make sure the we already know every input and output signals.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

fantasy2   10 W

10 W
Posts: 70
Joined: Apr 30 2018 3:40pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by fantasy2 » May 01 2018 9:04am

casainho wrote:
Apr 30 2018 5:20pm
fantasy2 wrote:
Apr 30 2018 3:46pm
Just registered here after googling around for this motor. Awesome work everyone here is doing!

I'm wondering if you run the engine in the bike with original firmware and modified firmware if the sound/noise level is still the same? It's the thing that's been bothering me. If it's the same, then there is an opportunity to reduce it. If I see it right then this motor is brushless DC as well. With more complex algorithms, these motors can run more smooth and quiet.

If I find time between my other projects and work I'm happy to assist. I'm very familiar with Atmel and ARM(STM) coding and hardware development.
The original firmware runs the motor very silently compared to the 6 steps/square wave/block commutation I implemented. I saw the PWM signals and are SVM just like used on FOC but I think they are simple doing "FOC" using motor parameters!!

The development is blocked because I don't know how to implement "FOC" using the motor parameters... Let's see if jur can help ;-)

Please find free time -- if you believe in electric bicycles, improving the environment, improving people's wealth life, on this project your work will have a widder impact simple because TSDZ2 is very popular!! A lot of activity on this forum thanks to it!!

STM8 is very near STM32, the same datasheet types, almost same development tools, the same peripherals, etc. Will be easy for you.
I once evaluated the STM8S105 for a project but went for an atmel instead(they are still pretty good compared to other chips on MIPS level), I guess it wouldn't be too hard.

On another thread I read that there were some doubts if this 8 bitter could implement a good and fast FOC. I haven't looked at the electronics but I'm wondering if it would be interesting to redesign the controller so it has a bit more juice. Like STM32F1/2/4. It allows for more heavy and faster calculations.

Anyway, I first have to buy a unit.. No reseller here so I have to google around on aliexpress to find a decent one(I'm looking for the 500/750Watt version with XH18 display).

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 01 2018 2:07pm

fantasy2 wrote:
May 01 2018 9:04am
On another thread I read that there were some doubts if this 8 bitter could implement a good and fast FOC. I haven't looked at the electronics but I'm wondering if it would be interesting to redesign the controller so it has a bit more juice. Like STM32F1/2/4. It allows for more heavy and faster calculations.
No, STM8 can't handle "traditional" FOC.

This project is not about design a controller but instead develop the firmware (the best, hopefully) for original motor controller. I was on another projects before were I dreamed with the idea of replacing the controller and found almost no one will want to mess with prototyping hardware and hardware is also a lot expensive to develop -- firmware/software on the other side is cheap and more people can join the project and develop, because the tools for development are cheap, unlike developing hardware.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 01 2018 2:16pm

jur wrote:
Apr 30 2018 7:33pm
BUT @casainho, if your only problem is that floating point math is taking too long, it isn't a problem to use integer math in this case. Our company does digital control of power converters, and floating point isn't used - we simply use integer math and convert at the end. Enough bits and accuracy is not impacted.

For example, duty cycle can be encoded with sufficient resolution using 8 bits (more than enough or even too many, 7 may be enough even with good enough resolution for this application). Voltage, also 7 or 8 bits. To get E, multiply, then right shift keeping the correct MSB. And so on. I am assuming you can do 16 bit operations.
Thanks for the info. For now, I think that even with float operations, for the measured times on my experiences, it should work. Optimizations can come later.
jur wrote:
Apr 30 2018 7:33pm
Another question, what PWM frequency are you aiming for? Several issues here: Too high won't work, probably causing magnetising losses in the stator core, and the MOSFET gate drives are also very slow, from a TSDZ2 circuit I saw somewhere. I would measure the existing firmware's frequency and aim for the same, at least as a starting point.
PWM frequency from original firmware is 16kHz -- I was expecting more thinking that mosfet driver IC would for improving the frequency.

So motors runs at 4000 RPM, that is near of the 520 ERPS limit we are using on our firmware for Kunteng, in a way SVM wave is draw with
at least 30 points.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

fantasy2   10 W

10 W
Posts: 70
Joined: Apr 30 2018 3:40pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by fantasy2 » May 01 2018 2:18pm

Alright, I'll stop dreaming. Let's see how far we can push this thing first. Some assembly and integer math can be pretty efficient(floats are extremely dirty in my eyes on an 8 bitter).

I hope to receive my TSDZ2 soon so I can join the development and testing.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 01 2018 2:41pm

fantasy2 wrote:
May 01 2018 2:18pm
I hope to receive my TSDZ2 soon so I can join the development and testing.
Everyone please see here a list of development tools: https://opensourceebikefirmware.bitbuck ... MWARE.html

Please ignore that of soldering the programming header as TSDZ2 cable already has the needed wires.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » May 01 2018 7:09pm

casainho wrote:
May 01 2018 2:16pm

Thanks for the info. For now, I think that even with float operations, for the measured times on my experiences, it should work. Optimizations can come later.
Could you please state exactly what you need for solving the math:

Inputs, equations to solve and required outputs. I am deep into generating the simplest possible math operations but it would be most efficient if you could please spec what you need.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 01 2018 8:55pm

jur wrote:
May 01 2018 7:09pm
casainho wrote:
May 01 2018 2:16pm
Thanks for the info. For now, I think that even with float operations, for the measured times on my experiences, it should work. Optimizations can come later.
Could you please state exactly what you need for solving the math:

Inputs, equations to solve and required outputs. I am deep into generating the simplest possible math operations but it would be most efficient if you could please spec what you need.
Looking at the documentation from Shane Colton here:
- https://opensourceebikefirmware.bitbuck ... mware.html
- https://github.com/EGG-electric-unicycl ... 3phduo.pdf

1. Without align current with BEMF (inefficient controlling of the motor)
Image

2. Aligning current with BEMF (efficient controlling of the motor)
Image

I know that we want to be at 2.

I think as inputs we have:
- direction of Q axis, as we can measure BEMF by rotating the motor with our hands and BEMF direction is max value of the sinewave measured and then we can reference to hall sensors transition signals
- we don't know phi r (yellow vector) and I think we don't need it. It just represents north pole of one magnet of rotor
- I we can measure. I is the phase current however we just can measure battery current on the shunt and I phase current = I battery current * actual PWM duty_cycle.
- IR is I * motor coil resistance, that is why we need to measure the resistance
- E is the BEMF, which is motor constant of generated volts per RPM, and it can be measured but we know for our motors can be something near as 36V(48V) / 4000 RPM. Knowing the motor speed, that we can measure using hall sensors signals, we can calculate the E
-- phi r (yellow vector) is equal to BEMF
- IwL can be calculated knowing the I, motor speed and L motor inductance, that is why we need to measure the coils motor inductance
- V is the phase voltage we apply to the motor phases, and it is Vbattery that we can measure * currently PWM duty_cycle that we apply

As we can see angle teta increases with IwL and IR, so, depends from motor speed and current. We can measure both and we know that angle between IR and IwL are always 90 degrees. How can we calculate the angle on 1. so we can advance the phase voltage V by that angle value and I will be in aligned with E an so we will get the higher torque per amp??

On the second link for documentation of Shane Colton, he talks about some math to calculate the angle:
Image
Please look at this message of Stancecoke: https://endless-sphere.com/forums/viewt ... 0#p1375474

And please note that we don't need the angle value, we may just need to know if the angle is positive, negative or near zero. On Kunteng controller, in our firmware, we just do that and it works very well!! See here a resume: https://opensourceebikefirmware.bitbuck ... rison.html

This is all the I know for now. And the PWM signal on TSDZ2 motor controller is just the same as on Kunteng, that we already implemented and works very well. On TSDZ2, there is no phase current sensor and I think it is not needed because it just need to work with a specific motor with a know R and L values unlike on Kunteng that should work with most hub and even mid driver motors -- for instance, the PWM frequency on Kunteng is just the same 16kHz.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » May 01 2018 9:57pm

casainho wrote:
May 01 2018 8:55pm
jur wrote:
May 01 2018 7:09pm
Could you please state exactly what you need for solving the math:

Inputs, equations to solve and required outputs. I am deep into generating the simplest possible math operations but it would be most efficient if you could please spec what you need.
Looking at the documentation from Shane Colton here:
- https://opensourceebikefirmware.bitbuck ... mware.html
- https://github.com/EGG-electric-unicycl ... 3phduo.pdf

1. Without align current with BEMF (inefficient controlling of the motor)
Image

2. Aligning current with BEMF (efficient controlling of the motor)
Image

I know that we want to be at 2.

I think as inputs we have:
- direction of Q axis, as we can measure BEMF by rotating the motor with our hands and BEMF direction is max value of the sinewave measured and then we can reference to hall sensors transition signals
- we don't know phi r (yellow vector) and I think we don't need it. It just represents north pole of one magnet of rotor
- I we can measure. I is the phase current however we just can measure battery current on the shunt and I phase current = I battery current * actual PWM duty_cycle.
- IR is I * motor coil resistance, that is why we need to measure the resistance
- E is the BEMF, which is motor constant of generated volts per RPM, and it can be measured but we know for our motors can be something near as 36V(48V) / 4000 RPM. Knowing the motor speed, that we can measure using hall sensors signals, we can calculate the E
-- phi r (yellow vector) is equal to BEMF
- IwL can be calculated knowing the I, motor speed and L motor inductance, that is why we need to measure the coils motor inductance
- V is the phase voltage we apply to the motor phases, and it is Vbattery that we can measure * currently PWM duty_cycle that we apply

As we can see angle teta increases with IwL and IR, so, depends from motor speed and current. We can measure both and we know that angle between IR and IwL are always 90 degrees. How can we calculate the angle on 1. so we can advance the phase voltage V by that angle value and I will be in aligned with E an so we will get the higher torque per amp??

On the second link for documentation of Shane Colton, he talks about some math to calculate the angle:
Image
Please look at this message of Stancecoke: https://endless-sphere.com/forums/viewt ... 0#p1375474

And please note that we don't need the angle value, we may just need to know if the angle is positive, negative or near zero. On Kunteng controller, in our firmware, we just do that and it works very well!! See here a resume: https://opensourceebikefirmware.bitbuck ... rison.html

This is all the I know for now. And the PWM signal on TSDZ2 motor controller is just the same as on Kunteng, that we already implemented and works very well. On TSDZ2, there is no phase current sensor and I think it is not needed because it just need to work with a specific motor with a know R and L values unlike on Kunteng that should work with most hub and even mid driver motors -- for instance, the PWM frequency on Kunteng is just the same 16kHz.
Thanks for the clarification. Back to playing with math...

jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » May 01 2018 10:46pm

I am a bit confused by seemingly redundant information:

1. The needed phase angle advance called phi by Colton, will always be of the same sign. Current will always lag voltage, no sign is needed.
2. The sine of the phase advance angle phi can be calculated by
sinphi = IwL/V; where we measure and calc I, w is measured by Hall sensor, L is a constant, and V is also measured, right? I thought V is an output of the control scheme, driven by torque sensor demand?
3. The cosine of phi can be calculated by
cosphi = (E+IR)/V
4. The tangent is given by
tanphi = IwL/(E+IR)

It seems to me redundant to need both R and L. If we have V, sinphi can be calculated without needing R.

Of course if we don't have V, the we need to calculate the tangent.

So the big question is, do we have V? I think not since it is an output of the algorithm. The magnitude and phase are the outputs.

HOWEVER: We can estimate V by using the previous fast loop's value! It will be out by a small amount but that may be OK. So, my suggestion for a starting point is to calculate the sinphi according to point 2 above and plug that straight into the control algorithm.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 01 2018 10:55pm

jur wrote:
May 01 2018 10:46pm
I am a bit confused by seemingly redundant information:

1. The needed phase angle advance called phi by Colton, will always be of the same sign. Current will always lag voltage, no sign is needed.
2. The sine of the phase advance angle phi can be calculated by
sinphi = IwL/V; where we measure and calc I, w is measured by Hall sensor, L is a constant, and V is also measured, right? I thought V is an output of the control scheme, driven by torque sensor demand?
3. The cosine of phi can be calculated by
cosphi = (E+IR)/V
4. The tangent is given by
tanphi = IwL/(E+IR)

It seems to me redundant to need both R and L. If we have V, sinphi can be calculated without needing R.

Of course if we don't have V, the we need to calculate the tangent.

So the big question is, do we have V? I think not since it is an output of the algorithm. The magnitude and phase are the outputs.

HOWEVER: We can estimate V by using the previous fast loop's value! It will be out by a small amount but that may be OK. So, my suggestion for a starting point is to calculate the sinphi according to point 2 above and plug that straight into the control algorithm.
1. Not sure, what if we advance to much the phase voltage??

Yes, I think V is the value we apply to motor phases.

Do you think that calculating the angle like you suggest will also apply to image 1. Or just to 2.???
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » May 01 2018 11:56pm

casainho wrote:
May 01 2018 10:55pm
1. Not sure, what if we advance to much the phase voltage??
If we advance a little bit too much, the calculation will still come out positive because we use magnitude values for I and V. For the next fast loop cycle the value of phi is re-calculated so it will be self-correcting.
casainho wrote:
May 01 2018 10:55pm
Yes, I think V is the value we apply to motor phases.
So we can just use the previous fast loop value as it won't change much between fast loop cycles. Or, as a refinement the value can be calc'ed.
casainho wrote:
May 01 2018 10:55pm
Do you think that calculating the angle like you suggest will also apply to image 1. Or just to 2.???
I was looking at #2. The phase angle advance will be iteratively corrected with each successive fast loop cycle. As a phase advance is applied to V, the current will change somewhat, affecting the next calculation, and so on until the error is zero. But as far as I can see, the error will start small anyway.

jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » May 02 2018 2:07am

Tomorrow I will try to see if I can remove the covers without taking the motor off the bike, in order to measure motor winding R and L.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 02 2018 2:09am

jur wrote:
May 02 2018 2:07am
Tomorrow I will try to see if I can remove the covers without taking the motor off the bike, in order to measure motor winding R and L.
Good!! I think you need at least to remove left cover and that means removing the left pedal crank to be able to remove the cover.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 02 2018 12:30pm

Got a 48V motor and 48V controller and finally were able to drive my ebike with TSDZ2!! Really good, now I understand why they are so popular!!

The cables of the controller couldn't be inserted on the original hole because of the sockets so I quick and dirty did a hole -- the metal is very soft.

The LCD has the symbol watts, we can see that when we turn on the display, but the LCD can't show the watts of the motor. Don't even show the voltage of the battery... LCD3 is much better!!

Did run both 36V and 48V motors with the same 36V controller to see if I got a different sound but both did run silent -- but they were without load, maybe that is why even if they are different, there should no be much different on the algorithm.

Image
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » May 02 2018 8:49pm

casainho wrote:
May 02 2018 2:09am
jur wrote:
May 02 2018 2:07am
Tomorrow I will try to see if I can remove the covers without taking the motor off the bike, in order to measure motor winding R and L.
Good!! I think you need at least to remove left cover and that means removing the left pedal crank to be able to remove the cover.
Unfortunately I didn't look at it before coming to work today, so now I don't have the necessary tools with me - I assumed that the cover could be taken off without taking the crank arm off.

So I will take our small hand-held meter home tonight and do the measurements tonight. It is also quite accurate. Why I didn't think of this yesterday, I don't know. Senior moment I suppose.

Is there a rough estimate for motor L that will allow you to move forward? For example, is the Kunteng motor L known?

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 03 2018 4:18am

jur wrote:
May 02 2018 8:49pm
Is there a rough estimate for motor L that will allow you to move forward? For example, is the Kunteng motor L known?
No and I never saw values for L on chinese ebike motors.

Right now I am looking to improve the current motor control code for Kunteng, are there some piece of code works but I think with some luck. I need to improve it and validate, so I can learn it better and then I will use for TSDZ2. The code should be almost the same...
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 03 2018 4:22am

jur wrote:
May 01 2018 11:56pm
casainho wrote:
May 01 2018 10:55pm
1. Not sure, what if we advance to much the phase voltage??
If we advance a little bit too much, the calculation will still come out positive because we use magnitude values for I and V. For the next fast loop cycle the value of phi is re-calculated so it will be self-correcting.
Can you think in a way that we can go even quick and dirty, like knowing if we simple are near our target or if we are on right or left side. If on left, we just increase by a step, on right decrease a step and near the target just keep current angle value. That is how it works on Kunteng...
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

jur   100 mW

100 mW
Posts: 36
Joined: Apr 07 2017 1:07am

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by jur » May 03 2018 4:47am

casainho wrote:
May 03 2018 4:22am
jur wrote:
May 01 2018 11:56pm
casainho wrote:
May 01 2018 10:55pm
1. Not sure, what if we advance to much the phase voltage??
If we advance a little bit too much, the calculation will still come out positive because we use magnitude values for I and V. For the next fast loop cycle the value of phi is re-calculated so it will be self-correcting.
Can you think in a way that we can go even quick and dirty, like knowing if we simple are near our target or if we are on right or left side. If on left, we just increase by a step, on right decrease a step and near the target just keep current angle value. That is how it works on Kunteng...
Ah, I see. I will look into it.

The measured values are:
L=270uH
R=0.25ohm

This is between 2 windings. I am assuming very little or no mutual inductance, which makes the individual phase values half those values.

So,
L=135u = 0.000135
R=0.125

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 03 2018 5:01am

jur wrote:
May 03 2018 4:47am
The measured values are:
L=270uH
R=0.25ohm

This is between 2 windings. I am assuming very little or no mutual inductance, which makes the individual phase values half those values.

So,
L=135u = 0.000135
R=0.125
GREAT!!! :-)

To evaluate the algorithm, I would implement:
- the angle calculation and print it to outside, then I would accelerate the motor and try put some load and see if the angle value increases as expected
- when angle is applied:
-- expecting a lower noise of the motor, at least so good as original firmware
-- with a constant PWM duty-cycle and constant load and speed (on bike training roller), adjust the angle manually up to get the lowest current - then enable the algorithm and expect the same lowest current
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

nieles   10 kW

10 kW
Posts: 682
Joined: Jul 14 2008 5:39pm
Location: The Netherlands

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by nieles » May 03 2018 6:11am

jur wrote:
May 03 2018 4:47am
casainho wrote:
May 03 2018 4:22am
jur wrote:
May 01 2018 11:56pm
casainho wrote:
May 01 2018 10:55pm
1. Not sure, what if we advance to much the phase voltage??
If we advance a little bit too much, the calculation will still come out positive because we use magnitude values for I and V. For the next fast loop cycle the value of phi is re-calculated so it will be self-correcting.
Can you think in a way that we can go even quick and dirty, like knowing if we simple are near our target or if we are on right or left side. If on left, we just increase by a step, on right decrease a step and near the target just keep current angle value. That is how it works on Kunteng...
Ah, I see. I will look into it.

The measured values are:
L=270uH
R=0.25ohm

This is between 2 windings. I am assuming very little or no mutual inductance, which makes the individual phase values half those values.

So,
L=135u = 0.000135
R=0.125
isn't that depended of the configuration of the motor? delta or wye

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 03 2018 7:13am

@jur, are that values for 48v or 36v motor?
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   10 GW

10 GW
Posts: 4099
Joined: Feb 14 2011 2:43pm

Re: TSDZ2 mid drive -- Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Post by casainho » May 03 2018 12:35pm

Might sound crazy that I am just starting new projects with finish the others... that's why I alone can't do everything, it is really important that you guys help on this project!!

I really hope to use LCD3 with TSDZ2 as the original LCD is very limited. Why can't I see the motor power in real time? Why can't I see the battery voltage??

This is the new project: LCD3 firmware -- Flexible OpenSource firmware for Kunteng LCD3
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of the Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Post Reply