EV3MediumRegulatedMotor

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

moo
New User
Posts: 23
Joined: Thu Apr 06, 2017 2:43 am

EV3MediumRegulatedMotor

Postby moo » Wed Apr 26, 2017 3:26 am

excuse me for asking dumb question.

steering = new EV3MediumRegulatedMotor(MotorPort.A);
steering.setSpeed(500);
steering.forward();

my medium motor doesn't want to move at all???

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3MediumRegulatedMotor

Postby gloomyandy » Wed Apr 26, 2017 7:00 am

Please post a complete (short) test program, and provide the details of....
What version of leJOS.
Is this running on a PC or on the EV3.
Posting a fragment that like is useful, but other parts of your program may be having an impact on what happens, so we need to see a complete test program. As far as I know there is no problem with the medium motor and leJOS. No other users have reported any issues.

Oh and I assume you have checked things like using a different motor in the same port and that this is not a problem with a cable.
leJOS news https://lejosnews.wordpress.com/

moo
New User
Posts: 23
Joined: Thu Apr 06, 2017 2:43 am

Re: EV3MediumRegulatedMotor

Postby moo » Wed Apr 26, 2017 11:55 pm

Thanks for the advice. you are right. Could you take a look at the following code?
Somehow it seems to not go further than car.initialize() although when I put all the code in main() it works.
Using Lejos 0.9.0 beta and JAVA 1.7


I get the following output:
Initialize start
Before setspeed
Initialize end



package AutoPilot2;
import lejos.hardware.lcd.LCD;
import lejos.hardware.motor.*;
import lejos.hardware.port.*;
import lejos.hardware.sensor.*;
import lejos.hardware.Button;
import lejos.hardware.Sound;
import lejos.robotics.RangeFinderAdapter;
import lejos.robotics.SampleProvider;
import lejos.robotics.navigation.*;
import lejos.utility.Delay;


public class MyVehicle {

public static void main(String[] args) throws InterruptedException {



if(false) //this works
{
System.out.println("Running");

EV3LargeRegulatedMotor rightMotor;
EV3LargeRegulatedMotor leftMotor;
EV3MediumRegulatedMotor steering;
EV3IRSensor ir_sensor;
RangeFinderAdapter frontView;
EV3UltrasonicSensor ul_sensor;
RangeFinderAdapter leftView;
rightMotor=new EV3LargeRegulatedMotor(MotorPort.B);
leftMotor = new EV3LargeRegulatedMotor(MotorPort.A);
steering = new EV3MediumRegulatedMotor(MotorPort.C);
ir_sensor = new EV3IRSensor(SensorPort.S4);
frontView = new RangeFinderAdapter(ir_sensor);
ul_sensor = new EV3UltrasonicSensor(SensorPort.S2);
leftView = new RangeFinderAdapter(ul_sensor);

System.out.println("Before setspeed");

steering.setSpeed(500);

System.out.println("After setspeed");

steering.forward();

System.out.println("last");

Button.waitForAnyPress();
}



MyCar car=new MyCar();
car.initialize();
// LCD.drawString("Speed " + car.getSpeed(),0,3);

car.TurnLeft();

Button.waitForAnyPress();
System.exit(0);

}

}

class MyCar{
EV3LargeRegulatedMotor rightMotor;
EV3LargeRegulatedMotor leftMotor;
EV3MediumRegulatedMotor steering;
EV3IRSensor ir_sensor;
RangeFinderAdapter frontView;
EV3UltrasonicSensor ul_sensor;
RangeFinderAdapter leftView;
void initialize()
{
System.out.println("Initialize start");
rightMotor=new EV3LargeRegulatedMotor(MotorPort.B);
leftMotor = new EV3LargeRegulatedMotor(MotorPort.A);
steering = new EV3MediumRegulatedMotor(MotorPort.C);
ir_sensor = new EV3IRSensor(SensorPort.S4);
frontView = new RangeFinderAdapter(ir_sensor);
ul_sensor = new EV3UltrasonicSensor(SensorPort.S2);
leftView = new RangeFinderAdapter(ul_sensor);
System.out.println("Before setspeed");
steering.setSpeed(500);
System.out.println("Initialize end");
}
void turnLeft()
{
System.out.println("Turn left begin");
steering.forward();
System.out.println("Turn left end");
}

}

moo
New User
Posts: 23
Joined: Thu Apr 06, 2017 2:43 am

Re: EV3MediumRegulatedMotor

Postby moo » Wed Apr 26, 2017 11:57 pm

I am very embarrassed. please disregard. I noticed that I am calling TurnLeft() instead of turnLeft().

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3MediumRegulatedMotor

Postby gloomyandy » Thu Apr 27, 2017 7:10 am

No problem, but just a note if you are going to post code in the future, please use the code tag (it is one of the buttons above the area you type into when making a post), it makes reading code much easier!
leJOS news https://lejosnews.wordpress.com/


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest