Liam Owen Posted March 21, 2024 Posted March 21, 2024 Hey, I am trying to code my motor to rotate 45 degrees one way, stop, then rotate 90 degrees the other way and 90 degrees the other way and loop so I get a rocking back and forwards motion, thought this would be easy to do, but I am find so many problems! Firstly its not simple to get the engine to go back to 0 position, so at the moment I am doing this manually before I start the sequence. Then I seem to have problems with the positioning never being precise over time it ends up not going back to the center and can be over 90 degrees out after a few minutes! Also within my code (which is probably wrong) it seems to juts decide to jump past come commands without any reason. Attached the method that I ended up with that still didnt work (Sorry I accidentally downloaded the latest version of Powered Up app!!!) Currently I am looking at building the motion mechanically with techic lego bits rather than motor motion, any tips on a good build would also be appreciated. Thanks Liam Quote
Stereo Posted March 21, 2024 Posted March 21, 2024 (edited) The method used in, for example, windshield wipers, is you have a shorter spinning arm connected to a larger arm that only moves back and forth. For the angle to be 90 degrees, the ratio of the two arms is around sqrt(2) times longer. Though if they aren't aligned exactly parallel at the center, it changes the ratio. Blue dotted line showing that the center of the circle is aligned to the endpoints of the arc, thus the linkage arm moves exactly 2R side to side for both. If you keep the longer arm pivot point and move the shorter one up and down, it'll increase the angle moved by the long arm. Edited March 21, 2024 by Stereo Quote
Lok24 Posted March 21, 2024 Posted March 21, 2024 You could use a sensor to calibrate the whole thing Quote
Liam Owen Posted March 21, 2024 Author Posted March 21, 2024 5 hours ago, Stereo said: The method used in, for example, windshield wipers, is you have a shorter spinning arm connected to a larger arm that only moves back and forth. For the angle to be 90 degrees, the ratio of the two arms is around sqrt(2) times longer. Though if they aren't aligned exactly parallel at the center, it changes the ratio. Blue dotted line showing that the center of the circle is aligned to the endpoints of the arc, thus the linkage arm moves exactly 2R side to side for both. If you keep the longer arm pivot point and move the shorter one up and down, it'll increase the angle moved by the long arm. Thank you v ery much for your reply, it looks very intresting but unfortunatley I have no idea how I would actually implement this! Quote
Stereo Posted March 21, 2024 Posted March 21, 2024 Here's one way you could do it - the red 3L beam goes to the motor, the grey 3x3 turns 90 degrees back and forth as it spins. Middle shows one extremity, bottom shows the other. Depends what space you're fitting things into. The yellow 5L and grey 3x5 can be made longer if that works better. Quote
vascolp Posted March 22, 2024 Posted March 22, 2024 15 hours ago, Liam Owen said: Firstly its not simple to get the engine to go back to 0 position, so at the moment I am doing this manually before I start the sequence. Then I seem to have problems with the positioning never being precise over time it ends up not going back to the center and can be over 90 degrees out after a few minutes! Also within my code (which is probably wrong) it seems to juts decide to jump past come commands without any reason. Going mechanical is the Lego way Anyway, it seems you are codding like this: move 90º, move -90º, move 90º….. Doing it this way means that errors accumulate, and you might get what you got, 90 degrees out of sync. Instead, I suggest something like: go to 45º angle, go to -45º angle, go to 45º angle… this way, errors do not accumulate... and you wont even need to go to 0 to initialize. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.