mahjqa

Mindstorms; using a loop to set a motor's speed, and failing.

Recommended Posts

Well, I'd hoped that things didn't go south so quickly, but here we are.

21196567883_4eb19a372f.jpg

The idea is that I use a single variable to set the state of my machine. Altering that variable should switch the machine to different modes.

Right now, I have a single mode. Setting the variable to "1" should set the motor to a certain speed. 50%. Or 20%. Or even 1%, as in this example.

However, when I tell the motor to run at any speed, pretty soon it increases until it's at 100% speed. It starts out at the right speed, and pretty soon it's running at max.

Can anyone here tell me what's happening, and what the hell I'm doing wrong?

Share this post


Link to post
Share on other sites

I wish I understood that diagram, sadly I don't at all. Though the fact the speed increases means the input value to the motor is adding up. And since you mention 'loop' in the title, I guess we are talking some feedback controll sysze. Feedback controll is a part of my branch and when this happens, first thing I check is whether my feedback is positive or negative, should always be negative. With negative feedback loop the system tries to keep your desired input value.

Share this post


Link to post
Share on other sites

well ima bit rusty in mindstorms and I don't have it near me. but , working from memory, I think you need to make loop, then within the loop put the variable then a math block then the motor. now set the math block to add 1, drag the "=" wire to the motor power and to the variable and If im not forgeting something, it should work :grin:

Share this post


Link to post
Share on other sites

I think you need a wait timer after the decision block, where the time should be found via experimentation. The reason behind is that your loop will execute very fast, and the motor will not stop from the previous input while picking up a new input in power from the next execution of the loop.

Share this post


Link to post
Share on other sites

I just created a copy of your program but mine works fine.

Had the motor run for about 1-2min with no noticeable change in speed.

So the behavior you describe is kinda strange. Since you have nothing in the program that adds or change the speed of the move block. And it should not increase the speed just becouse its in a loop.

The image shows the complete program, right?

Below is some things you could try, not sure if it will do much :(

- What if you just put the "move" block inside a loop, do you get the same behavior?

- What happends if you use the speed "0".

- change motor, cable, port

- check firmware (my firmware was V1.06X)

I have had some strange connection/program fenomenon when i have had more then 1 software that can connect to the ev3 unit running at the same time. In my case labview and the lego software. So if you have some other software aswell make sure only one is running.

Also when you download the program use the "Download and run", if you just use "download" and then press the center button on the unit it dosent necessarily run the program you just downloaded. I have done that some times and it can be quite confusing until you realise that you are running another program.

/Hknssn

Edited by hknssn

Share this post


Link to post
Share on other sites

Done, it increases variable 'speed' if 'speed' is less than 100 and sets Motor "a" power to speed, then it runs motor "a" at 100 power( so the variable 'speed' never goes over 100). Download for the program

Edit: re-read the question and realized it's not what you wanted, so I re-wrote it. Top loop, increases 'speed' by 1 each time touch sensor in port 1 is pressed, middle loop sets motor speed to variable 'speed', bottom reduces 'speed' by 1 each time touch sensor in port 2 is pressed Download for new program. so to change the speed just write variable 'speed' to something hope this helps.

Edited by That_LEGO_Guy

Share this post


Link to post
Share on other sites

Apparently, the problem was with a faulty cable and/or connection. After some switching of ports/motors/sensors and cables everything is now running as it should. Thanks for the assistance.

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.