Carsten Svendsen

[Powered Up] How do I make the motors turn at the same rate?

Recommended Posts

I have an application where I need 4 motors to turn at the exact same rate at all times. They've got built-in rotary sensors but I can't seem to figure out how to program it on the app. Frankly it would be nice with tooltips or text on the buttons rather than meaningless pictures. 

I also know that they have a constant current function, but even if I set all of them to the same speed, eventually they will go out of sync which is not good. Is there a way to make them stay synced at the same speed?

Share this post


Link to post
Share on other sites
7 minutes ago, Carsten Svendsen said:

Frankly it would be nice with tooltips or text on the buttons rather than meaningless pictures.

I agree.

8 minutes ago, Carsten Svendsen said:

I have an application where I need 4 motors to turn at the exact same rate at all times. They've got built-in rotary sensors but I can't seem to figure out how to program it on the app.

I also know that they have a constant current function, but even if I set all of them to the same speed, eventually they will go out of sync which is not good. Is there a way to make them stay synced at the same speed?

Are buttons allowed or do you need slider, adjustable speed, reverse, etc?

This could work if all you need is simple control.

Spoiler

6D8022E8-420F-4FEC-92B5-2CDB0A9567F7.png

 

Share this post


Link to post
Share on other sites

No that doesn't work at all. The motors are all jumpy and non-fluid motion so that's terrible.

I just need simple stuff. An on/off button to start or stop the motors as one. They should all act as one motor control-wise, same speed, same tacho, same everything. Stay in sync. It's a real pain on the phone, it's so small. I wish there was a PC app for it. It's a real deterrent honestly. Maybe someone can help me in some python?

I found a site where I can see the block description. Honestly lego? This shouldn't be necessary. https://racingbrick.com/powered-up-code-block-guide-full/

Edited by Carsten Svendsen

Share this post


Link to post
Share on other sites
6 minutes ago, Carsten Svendsen said:

No that doesn't work at all. The motors are all jumpy and non-fluid motion so that's terrible.

Sorry. I would recommend pybricks in that case.

7 minutes ago, Carsten Svendsen said:

I found a site where I can see the block description. Honestly lego? This shouldn't be necessary. https://racingbrick.com/powered-up-code-block-guide-full/

This is really good. I spent an hour looking at it then I was able to make the thing I needed.

Share this post


Link to post
Share on other sites
7 hours ago, Carsten Svendsen said:

No that doesn't work at all. The motors are all jumpy and non-fluid motion so that's terrible.

 

That's because the block sets speed until motor turned 5°. You need the speed-block (the one with the arrow up) with only two inputs (ports and speed).

Besides that:

" I have an application where I need 4 motors to turn at the exact same rate at all times. "

What does that mean exactly? The speed is of course always in some relation to power, therefore the speed in % has its limits and the real rpm depends on the properties of every single motor. And if you add different outputs to every motor, the load on each motor will be different. You can tell every motor to turn at 100 % speed as often as you want, if that's beyond the available power it will not reach 100% speed.

If you want all 4 motors with different and variable loads turn at the same speed all the time you have to make sure that the maximum load is always below 100 % or you have to track all real RPMs of each motor and slow down every other motor if one or more motors slow down because they reached the load limit.

Share this post


Link to post
Share on other sites

The surest way to achieve this would be to hard-link the motors mechanically by connecting all motors to each other with gears with 1:1 ratio. If that's not feasible, you'll have a quite hard problem to solve, as Gimmick said above.

Share this post


Link to post
Share on other sites
28 minutes ago, Gimmick said:

What does that mean exactly? The speed is of course always in some relation to power, therefore the speed in % has its limits and the real rpm depends on the properties of every single motor. And if you add different outputs to every motor, the load on each motor will be different. You can tell every motor to turn at 100 % speed as often as you want, if that's beyond the available power it will not reach 100% speed.

If you want all 4 motors with different and variable loads turn at the same speed all the time you have to make sure that the maximum load is always below 100 % or you have to track all real RPMs of each motor and slow down every other motor if one or more motors slow down because they reached the load limit.

so something like this but 4x and slightly adjusted?

700x400.png

 

Edited by Jayden

Share this post


Link to post
Share on other sites
1 hour ago, howitzer said:

The surest way to achieve this would be to hard-link the motors mechanically by connecting all motors to each other with gears with 1:1 ratio. If that's not feasible, you'll have a quite hard problem to solve, as Gimmick said above.

This is what I have come to terms with. I will be linking the motors together with liftarms on 5 diameter circle. Preliminary tests show it'll be fine, but we'll see when I'm done. There's quite a lot of rebuilding to do.

1 hour ago, Jayden said:

so something like this but 4x and slightly adjusted?

700x400.png

 

I see what you're doing. Comparing the tacho of one motor to the other 3. This is a very intensive task for the cpu, I don't know how good the processor is in this thing, but I'm also not confident it will work. If anything, just compare the tacho of 3 motors to 1 other motor and go from there, though I'm pretty sure that it's not going to be flawless and will quite likely go out of sync fast.

Share this post


Link to post
Share on other sites

@Jayden

Hmm, not sure if that's enough. If there realy is variable load on each motor you would have to check the load-%, too. Otherwise you cannot tell if a motor is slow because it wants to fit the others or slow because of load and the system will stop after a few iterations.

Share this post


Link to post
Share on other sites
1 hour ago, Carsten Svendsen said:

This is what I have come to terms with. I will be linking the motors together with liftarms on 5 diameter circle. Preliminary tests show it'll be fine, but we'll see when I'm done. There's quite a lot of rebuilding to do.

This is the best way to do this.

1 hour ago, Carsten Svendsen said:

I see what you're doing. Comparing the tacho of one motor to the other 3. This is a very intensive task for the cpu, I don't know how good the processor is in this thing, but I'm also not confident it will work.

I believe the pressing happens on the device not the hub.

2 hours ago, Carsten Svendsen said:

though I'm pretty sure that it's not going to be flawless and will quite likely go out of sync fast.

Yeah probably.

2 hours ago, Carsten Svendsen said:

If anything, just compare the tacho of 3 motors to 1 other motor and go from there.

Yes I just tried it and it only worked if 3 were slowed.

2 hours ago, Gimmick said:

Hmm, not sure if that's enough. If there really is variable load on each motor you would have to check the load-%, too.

True.

Share this post


Link to post
Share on other sites

To give some context, this is what I'm working on. There's an input on all four corners, and the red end is fast, the blue end is slow. I need to have all these inputs running at the same speed or the whole thing stalls as soon as load is added.

I've spent a good week getting all the gearing done in the corners. It's goes 1:1, 1:2, 1:3, 1:4 and then 1:5. The clutches are there to get everything lined up and to not break anything.

So unless it's possible to get motors to run 100% the same speed and rate 100% of the time, then I will be hard-linking all the inputs together with old fashioned steam engine linkages.

Overview

 

Corners

 

Share this post


Link to post
Share on other sites
On 6/28/2022 at 11:26 AM, Gimmick said:

If there realy is variable load on each motor you would have to check the load-%, too.

I believe this is the best option - and leave the rest to the firmware's speed control algorithm. It does not get any faster, as the adjustment is done on the hub w/o much critical BLE communication. Setting identical motors to the same speed should do it - within "degree" resolution errors, that is. I believe monitoring power is sufficient though, as load is not an input parameter for speed control as this is the deviation causing parameter; there usually is "set point" (speed), "signal" (rotations per time/degrees per time) as inputs, and "power" as output. In this case, the control algorithm should also "know" the mass of the object and how much torque the power source can build at given rpm. This is mostly not feasible, instead, the parameters within the algorithm are adjusted (optimized). 

Changing the load on one motor though will need time to correct for - I believe the hub algorithm is of "generic" nature, as it has to serve many (and very different) builds. An "optimized" PID algorithm - reaching as fast as possible the set point (your selected speed) after detected deviation w/o overshooting - needs the P, I, and D parameters, well, optimized. Which is usually a chore to do manually. I don't know whether these parameters are accessible - I believe so, when you use other programming environments than the LEGO app.

Pivotal to the success of PID control (speed setting) - generic or optimized - is what @Gimmick wrote above: Required power should never come close to 100% to maintain a selected speed. At 90% power level, slowing of all four motors (speed reduction) should kick in and then maybe attempting to recover at 70%. This would be handled within the app program. The required BLE traffic for that may be tolerable, critical speed control is done in the hub, as said.

Good luck! This is an interesting project!

All the best,
Thorsten       

Share this post


Link to post
Share on other sites

I'm not sure what the ultimate goal is (although the picture looks intriguing), but if you want them perfectly in sync I'm virtually certain the best option will be simply to physically connect the motor outputs. This should be done before gearing down, and ideally I think the motors should share electrical power. That way any electrical and mechanical power should automatically balance each other, compensating for any differences in motor characteristics.

Edited by aeh5040

Share this post


Link to post
Share on other sites
9 hours ago, Toastie said:

Setting identical motors to the same speed should do it - within "degree" resolution errors, that is.

An "optimized" PID algorithm - reaching as fast as possible the set point (your selected speed) after detected deviation w/o overshooting - needs the P, I, and D parameters, well, optimized.    

Yeah, I tried setting two motors to 30% speed and hardlinked them and they seemed to run perfectly fine. I am very aware of a PID regulator and if one is built into the Hub, it's pretty darn good. I've done enough manual fiddling to even attempt it lol

 

5 hours ago, aeh5040 said:

I'm not sure what the ultimate goal is (although the picture looks intriguing), but if you want them perfectly in sync I'm virtually certain the best option will be simply to physically connect the motor outputs. This should be done before gearing down, and ideally I think the motors should share electrical power. That way any electrical and mechanical power should automatically balance each other, compensating for any differences in motor characteristics.

Indeed the linking should be done before the gearing. All the gearing are as you see in the pictures. The motors will connect straight onto the 20T bevel gears with a 12T gear. Good idea with the same power source. Maybe if I'm doing it this way, I don't even need the control Hub, I could just straight up use power functions as I originally intended.

 

3 hours ago, ord said:

I think, by chance, I just came across exactly what you are working on @Carsten Svendsen . Very cool indeed!

I'm not sure how to understand this comment, but you will all have to wait and see what this is.

Edited by Carsten Svendsen

Share this post


Link to post
Share on other sites
18 minutes ago, Carsten Svendsen said:

I'm not sure how to understand this comment, but you will all have to wait and see what this is.

As in I came across a certain GIF which would be an insane coincidence if it's not what you are replicating :P

I won't mention it in case you want to keep it as a surprise for others.

Share this post


Link to post
Share on other sites

Hello again, I'm still struggling with this stupid app. All I want is to start/stop motors with a button and control the speed with a slider. It shouldn't be that hard.

So right now in the program below, when I start the program, the motors spin initially about one or two rotations which is annoying and I wish I could disable but anyway, I start the motors with the button and I can control the speed forward and reverse. So that's good, but when I press the button again to stop the motors, they just keep going. I can only stop the motors when the switch is on and turn the slider to neutral. How do I fix this? Also, the speed dial doesn't work, it only displays zero. I'd like that to work as well.

9d4a2d3ac9.jpg

4e0c7c34a1.jpg

Edited by Carsten Svendsen

Share this post


Link to post
Share on other sites
3 hours ago, Carsten Svendsen said:

Hello again, I'm still struggling with this stupid app. All I want is to start/stop motors with a button and control the speed with a slider. It shouldn't be that hard.

So right now in the program below, when I start the program, the motors spin initially about one or two rotations which is annoying and I wish I could disable but anyway, I start the motors with the button and I can control the speed forward and reverse. So that's good, but when I press the button again to stop the motors, they just keep going. I can only stop the motors when the switch is on and turn the slider to neutral. How do I fix this? Also, the speed dial doesn't work, it only displays zero. I'd like that to work as well.

Try this: :wink:

900x500.jpeg

Also if you have the slider as return-to-center replace the X on the if else to a wait 0 seconds.

Share this post


Link to post
Share on other sites
9 hours ago, Carsten Svendsen said:

Hello again, I'm still struggling with this stupid app. All I want is to start/stop motors with a button and control the speed with a slider. It shouldn't be that hard.

So right now in the program below, when I start the program, the motors spin initially about one or two rotations which is annoying and I wish I could disable but anyway, I start the motors with the button and I can control the speed forward and reverse. So that's good, but when I press the button again to stop the motors, they just keep going. I can only stop the motors when the switch is on and turn the slider to neutral. How do I fix this? Also, the speed dial doesn't work, it only displays zero. I'd like that to work as well.

9d4a2d3ac9.jpg

4e0c7c34a1.jpg

 

1. You switched value and control ID on the gauge

2. Your motor control only switches between "slider controls the speed" and "slider does not control the speed". All you have to add is a start block, like you already have, that is true, when the button is false. And attach break/stop-blocks to it. Or even better: The start block the only fires once if the condition "switches to"(!) true, so the breaking signal will be send only once. It's the one with the vertical signal flank on the symbol.

3. You can reduce the number of motor blocks by two, if you select AB and CD as ports instead of A,B,C and D.

There is one limit to this:

You cannot change the slider value with code. That can be usefull if you want to keep the last speed setting and you only want to turn it on/off, but if you want to move the slider by code, you have to use the older presets with fixed controls.

The "initial rotation" never happend to me. Maybe detach all motor blocks and check if it still happens.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.