BotoX / xiaomi-m365-firmware-patcher

Automatize patching of Xiaomi Mijia M365 electric scooter firmware
https://m365.botox.bz
406 stars 107 forks source link

Feature request: Allow for instant on at zero wheel speed #29

Closed galstaf closed 5 years ago

galstaf commented 5 years ago

Hey David, et al,

I am very much a novice when it comes to coding, but would love to see this added as an option on the Firmware maker. I would like the option of the scooter taking off from zero motion like many electric bikes do. I understand this could be dangerous in some circumstances, but I would at least like it to be an option. Any chance that could be added easily to the webpage that creates the BIN file?

I am assuming the code below controls that? (Is there any verbose newbie compatible documentation for what the parameters do?)

Many many thanks for sharing your work!! Ric (based in USA)

def motor_start_speed(self, kmh): val = struct.pack('<H', int(kmh * 345)) sig = [0xF0, 0xB4, None, 0x4C, 0x26, 0x68, 0x40, 0xF2, 0xBD, 0x67] ofs = FindPattern(self.data, sig) + 6 pre, post = PatchImm(self.data, ofs, 4, val, MOVW_T3_IMM) return [(ofs, pre, post)]

BotoX commented 5 years ago

Have you tried setting the motor start speed to 0 yet? However I can't recommend this because the original firmware wasn't made for this. It's also really inefficient for the motor.

galstaf commented 5 years ago

Why do you say that it is really inefficient for the motor? Obviously having momentum makes it easier to get going, but I can't see it being any worse than going up a steep hill. So wondering why you would think that?

galstaf commented 5 years ago

I did set Motor Start to zero, however it seems to still need a bit of a kick to get it going (not much). Sometimes it doesn't and goes straight from the get go. I am wondering if it is the hall effect sensors not being aligned properly... however a lot of electric motors can be forced to start up and have torque from zero rpm.

So any idea how to get these things going no matter what the hall sensor position?

BotoX commented 5 years ago

So any idea how to get these things going no matter what the hall sensor position?

Not possible without making your own firmware that implements sensor less zero start. It's not a very nice solution either, basically the motor controller applies a high current at the beginning to align the motor to a known position and then drives it with some sensor less guessing until it hits a certain RPM where the hall sensors or back emf works fast enough.

If you look at motor efficiency curves the efficiency at 0 RPM is almost 0 :D So do yourself a favor and set it to 3km/h and give the scooter a small kick.

galstaf commented 5 years ago

"Not possible without making your own firmware that implements sensor less zero start. It's not a very nice solution either, basically the motor controller applies a high current at the beginning to align the motor to a known position and then drives it with some sensor less guessing until it hits a certain RPM where the hall sensors or back emf works fast enough."

I understand the ramifications in terms of efficiency.. but I am using scrap xiaomi parts I got in an auction (Front wheels, batteries, ESC and BLE) and want to apply them to another project where I do need instant start. (This would be for a mobility chair for a disabled relative. )

I really appreciate your advice, however would this be difficult to change in the firmware? I am a novice coder, so wouldn't really know where to begin. Could you let me know what part of the firmware I would need to modify, and level of difficulty.

Thanks so much man.. I really appreciate your efforts!

BotoX commented 5 years ago

It's not really possible without access to the source code and extensive knowledge about motor control / microcontrollers.

I'd suggest you sell the xiaomi ESC and BLE and use the motor with another motor controller. A good motor controller is the VESC, it's a little pricey though - around $70 for the cheapest one. There's other controllers too that can do zero start, maybe this: https://opensourceebikefirmware.bitbucket.io/FLEXIBLE_OPENSOURCE_FIRMWARE.html take a look at https://endless-sphere.com/forums/ tons of resources there.

galstaf commented 5 years ago

Copy that. Like I mentioned, I don't know what I don't know! :-/

Yeah $70 is a bit pricey especially as I want to make it 2 or 3 wheel drive and each wheel will need it's own ESC. Given we are on a pretty strict budget, I don't think the VESC is affordable.
I am guessing there aren't any <=$20 ESCs from Alibaba or the like that would do the job that you know off the top of your head?

Given my relative lack of knowledge, it makes it difficult to figure out something appropriate.

Thanks again my friend!

galstaf commented 5 years ago

Hey David…

Sorry …. This ended up in my spam. Yes I did set to zero… it will work if the motor is lined up just so. Otherwise it just needs the gentlest of kicks to get it going. However it is eating batteries as predicted… range is pretty terrible right now.

Experimenting with additional power settings currently. The default power only gets me up a slight hill at 10kph, so I definitely need more. I have set the minimum speed to 2kph. That is working fine for the scooter.

Thanks again for all your work on this and for sharing!

Ricky

From: BotoX [mailto:notifications@github.com] Sent: Wednesday, December 12, 2018 22:42 To: BotoX/xiaomi-m365-firmware-patcher Cc: galstaf; Author Subject: Re: [BotoX/xiaomi-m365-firmware-patcher] Feature request: Allow for instant on at zero wheel speed (#29)

Have you tried setting the motor start speed to 0 yet? However I can't recommend this because the original firmware wasn't made for this. It's also really inefficient for the motor.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BotoX/xiaomi-m365-firmware-patcher/issues/29#issuecomment-446832348, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Anz_Gl0ZsOTw9zCEnnrXgY7ykLm6qFgpks5u4cyYgaJpZM4ZQGOs.

ambrisht commented 4 years ago

Hey David… Sorry …. This ended up in my spam. Yes I did set to zero… it will work if the motor is lined up just so. Otherwise it just needs the gentlest of kicks to get it going. However it is eating batteries as predicted… range is pretty terrible right now. Experimenting with additional power settings currently. The default power only gets me up a slight hill at 10kph, so I definitely need more. I have set the minimum speed to 2kph. That is working fine for the scooter. Thanks again for all your work on this and for sharing! Ricky From: BotoX [mailto:notifications@github.com] Sent: Wednesday, December 12, 2018 22:42 To: BotoX/xiaomi-m365-firmware-patcher Cc: galstaf; Author Subject: Re: [BotoX/xiaomi-m365-firmware-patcher] Feature request: Allow for instant on at zero wheel speed (#29) Have you tried setting the motor start speed to 0 yet? However I can't recommend this because the original firmware wasn't made for this. It's also really inefficient for the motor. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#29 (comment)>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Anz_Gl0ZsOTw9zCEnnrXgY7ykLm6qFgpks5u4cyYgaJpZM4ZQGOs.

Hi @galstaf, Did you every find a way to start the motor from absolute zero. I've been trying the same thing as you asked here before (changing the firmware setting to 0 for motor start speed). However, it always needs a little bit of push to take off. Also noticed that if you keep the throttle on and then push/rotate the wheel, it doesn't work. You have to rotate the wheel and then push the throttle.

Any tips would be really appreciated!