Jump to content

Recommended Posts

Posted

Hello everyone!

 

After expending a couple of afternoons trying to find a solution, I have to ask is someone among you can help me. The situation is easy: I have a motor and I want to limit its rotation. Asuming that the starting angle is always 0, lets say I want to allow the motor to rotate between +/-180º. I found one solution (which is making a loop that allows move when the angle is below 180º, but the issue is that once reached the limit, the loop is finished and no move is then allowed. 

 

Is there any function to easely limit the rotation of a certain motor? 

All help or feedback will be more than welcome! Thanks a lot!

 

H. 

Posted

If you turn backwards and the - 180° is reached you have to allow forward turning only.

What programming tool do you use?

Posted

Thanks, no problem at all.

The way LEGO does:
The limitation is given by mechanical(!) stops.
Then when starting the programm it moves the complete range (calibration) and from then it uses onle that range.

Is that a solution for you, i.e when steering a car?

Or would you learn programming with explicit blocks like "loop" and "if" ?
And: what is the input for you program, the angle or the speed?

Is there a picture of what you have now?

 

Posted

Thanks for the help! :)

Indeed I am trying to program a MOC which, by now, it doesn't have a mechanical stop and it is a requirement that, when it is switched ON the motor is at a certain possition. My idea was to program with blocks, yes. And the input is the angle.

When I arrive home, I will post some descriptive pics of the MOC and the program that I have so far.

Posted

This is a simple PoweredUp program

800x370.jpeg

You need to create three buttons (1, 0, 2) that in this examples moves moter A to a certain position -180, 0, 180 with speed 50

Posted

While I was heading home I just came up to an idea for my issue. So:

-I wanted to have a button that, when pressed, returns the bed to the original possition. For convenience, I also introduced a "reset button". I didn't find a solution in which this button and the rotation control of the bed are both active at the same time. So, I had to introduce a switch that blocks the rotation and then allows the "return to original possition" button to work. Is not perfect, but it works. 

-The idea that I came up to set limits to the roation of the bed is, as you see, two consecutive "IF" that only allows to continue when the angle of the motors is lower or higher than 260 or -260º (which is the converted angle after the gearing in the model that corresponds to 90º). As you can see in the video, it works... more or less. To avoid blocking the program because overpassing the set limits, I set a difference for the limit and the possition to which it returns when the limit is thresspassed. Unfortunately, this causes a "negative movement" caused by continuous attemps of rotation if one keeps trying to continue the rotation of the bed. 

As I said, I am very naive at programming and I am sure that are better and easier solutions than this one, but well, i tried! :) 

Has someone any alternative to the issues (the need of a swich for the "return to original possition" button and the bed control, the limits of the rotation themselves, and the "negative movement" in the solution I drafted)?

Screenshot_20220425-191130.png

Screenshot_20220425-190952.png

 

https://bricksafe.com/files/HectorMB/public/diverse/JCB 6t test.mp4

PS: Please, I am very sorry if the descriptions are not very clear. As I said I am not familiar with the language to speak about programing and so on. Please, speak up if they are not understandable at all and I will do my best to re-phrase :)

 

2 hours ago, GerritvdG said:

The code block TachoMotorSpeedPosition is the one you need, see @kbalage documentation for more information:

https://racingbrick.com/powered-up-code-block-guide/

Search the guide for 'TachoMotorSpeedPosition' and click on the + icon for full documentation. Does this solves you problem?

Cheers, Gerrit

Thanks! Indeed I knew about this block, but when you mentioned I though that I could use it.

11 minutes ago, GerritvdG said:

This is a simple PoweredUp program

800x370.jpeg

You need to create three buttons (1, 0, 2) that in this examples moves moter A to a certain position -180, 0, 180 with speed 50

THANKS! :)

I see that I was not very sucessful explaining the problem :pir-murder:. Is not that I want to have thre fixed positions, but to have free movement within certain max and min values.  

Posted

Maybe this is better, it turns the bed clockwise and counterclockwise with the joystick and returns to center when the joystick is released. But I'm not sure if you want the return to center functionality....

800x370.jpeg

 

Posted

Thanks a lot  @GerritvdG! The advantage of your program is that the bed doesn't tremble. On the other side, as you pointed out, it returns to the center as the joystick is released... which is quite unconvenient. The idea is to hold a possition in rotation and then go up and down, but keeping the rotation position. 

 

I am still squeezing my brains to find a good solution! :)

Posted

That's exactly what I think I need! Indeed, before using joysticks, I was trying them, but as I couldn't find a way to plip them to horizontal, I used the joysticks.

I have implemented the program quite significantly (I will post the pics and a new video with the performance, which I think it will gain with the sliders). 

The question now is: doeas someone know if it's possible -and how- to rotate the sliders to horizonal?

Thanks you all for the help!!! :)

Posted
4 minutes ago, HectorMB said:

The question now is: doeas someone know if it's possible -and how- to rotate the sliders to horizonal?

Yes, the horizontal sliders are available standard, you don’t have to rotate them.

looking forward to the end result!

 

Posted
7 minutes ago, HectorMB said:

That's exactly what I think I need! Indeed,

You are most welcome. :sweet:

7 minutes ago, HectorMB said:

The question now is: does someone know if it's possible -and how- to rotate the sliders to horizontal?

Just scroll down a bit, if you hit the dials you have gone to far.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...