ev3 motor guidefd

Upload: bob-lobby

Post on 05-Jul-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/16/2019 EV3 Motor Guidefd

    1/6

    Matthew OwensEV3 Motor Guide

    There are two motors for the EV3 system, large and medium. The largemotor is larger and more powerful than the medium motor, but the medium motorresponds faster. The large motor’s top speed is between 1 ! and 1"! rpm #$ !%1!&! deg's(, it has a stall tor)ue of *! + m, and running tor)ue of &! + m. Thestall tor)ue of a motor is the amount of for e the motor will apply when somethingis pre-enting it from mo-ing. The hardware spe s of the medium motor are &*!%&/! rpm #1**!%1/!! deg's(, 1& + m stall tor)ue, and 0 + m tor)ue. 1

    The large and medium motors are ontrolled through theEV3 arge2egulatedMotor and EV3Medium2egulatedMotor lasses respe ti-ely. Theyan be set to run until interrupted, rotate a ertain number of degrees, and rotate toa ertain position. The motors are ontrolled to one degree a ura y. Motors anmo-e either forward or ba ward. &

    The following methods are ommon to both types of motors. 3

    4ontrolling the MotorsetSpeed(int speed): 5ets the desired speed #in degrees per se ond( for themotor to rotate on e it is started. This method does not ause the motor to mo-e6 itonly hanges the settings for when it does mo-e.

    setAcceleration(int acceleration) 5ets the a eleration in degrees'se 'se forall motor operations. 7efault -alue is !!!, whi h is meant to get the motor to thedesired speed as )ui ly as possible. 5maller -alues should be spe i8ed to get asmoother operation.

    rotate(int displacement) 2otates the motor the spe i8ed angle from its urrentposition. 9f you all rotate#3 !( the motor will rotate forward 1 re-olution no matterwhat its starting position is. 5pe ifying a negati-e angle as the argument ausesthe motor to rotate ba wards.

    rotateTo(int targetAngle) 2otates the motor to the spe i8ed angle relati-e to themotor’s starting position. 4alling rotateTo#&/!( will result in the motor mo-ing inwhate-er dire tion it needs to in order to get to &/! degrees past its startingposition. This holds true e-en after alling a method su h as forward#( and forspe ifying negati-e angles.

    forward() auses the motor to rotate forward until a stopping method is alled orthe program e:its.

    backward(): auses the motor to rotate ba ward until a stopping method is alledor the program e:its..

    stop() ;pplies bra es to stop the motor, an els any running motor operations.

    t() ;llows the motor to

  • 8/16/2019 EV3 Motor Guidefd

    2/6

    resetTachoCount() resets the starting position #for methods su h as rotateTo( tothe urrent position. This an els any urrently running motor operations.

    waitComplete() waits to return until the urrent motor operation has ompleted.

    Getting information from the motorgetAcceleration() returns the urrent a eleration in deg'se 'se .

    getTachoCount() returns the urrent ta hometer ount.

    getPosition() returns the urrent position as al ulated by the regulator. 9fe-erything goes a ording to plan, this will be the same -alue returned bygetTa ho4ount and orresponds to the motor’s a tual position.

    getPosition() returns the urrent position of the motor, as al ulated by theregulator. This may be di=erent from the motor’s a tual position if the motor hasbeen for ed to mo-e.

    isMo ing() returns a >oolean -alue orresponding to whether the motor isattempting to rotate or not. 9f the motor is trying to rotate but is stalled #be ause itis being held in pla e by some for e( isMo-ing will return true.

    isStalled() returns true if the motor is attempting to mo-e but annot.

    get!imitAngle() returns the angle the motor is urrently rotating to as a result ofa rotateTo or rotate all.

    getSpeed() returns the target speed of the motor in deg'se . This may not mat hthe a tual speed depending on load.

    Many of the methods ha-e a >oolean immediate2eturn argument, whi h spe i8eswhether the method returns immediately or if the method returns after theoperation is arried out. 9t appears default beha-ior is to return immediately. Thisan ause motor a tions to not beha-e as e:pe ted if the program e:its while anoperation is in progress.

    Motors an also be a essed as unregulated motors, whi h is desirable forappli ations that re)uire the power of the motor to be ontrolled instead of thespeed. This ould be useful for robots where you are trying to laun h somethingbe ause you would set the power to 1!!, instead of setting the speed of the motor.;lthough this is not o? ially supported for EV3 motors, they will be treated as +@Tmotors when a essed in unregulated mode. Aere is an e:ample

    En oderMotor m B new CnregulatedMotor#MotorDort.;(6m.setDower#1!!(6 '' ull powerm.forward#(6

    Thread.sleep#/!!!(6m.setDower#1!(6 ''Dainfully slowm.ba ward#(6

    Thread.sleep#/!!!(6

  • 8/16/2019 EV3 Motor Guidefd

    3/6

    9 wrote a sample program that demonstrates the basi motor fun tions. 9t aneasily be run on any robot with * wheels and a large motor atta hed to the ; port.

  • 8/16/2019 EV3 Motor Guidefd

    4/6

    package edu.scranton.mowens;

    import lejos.hardware.lcd.LCD;import lejos.hardware.motor.EV3LargeRegulatedMotor;import lejos.hardware.port.MotorPort;

    pu lic class MotorDemo !pu lic static "oid main#$tring%& args' throws (nterruptedE)ception !

    LCD.draw$tring#*Motor Demo*+ ,+ ,';

    EV3LargeRegulatedMotor m - new EV3LargeRegulatedMotor#MotorPort. ';m.set$peed#/,,';

    00Mo"e ack and 1orth 3 times1or#int i-,; i 2 3; i ' !

    LCD.clear#';LCD.draw(nt#i+ ,+ ,';m.1orward#';

    4hread.sleep#5,,,';

    m. ackward#';

    4hread.sleep#5,,,';

    m.stop#';

    4hread.sleep#6,,,';7

    00Rotate 38, Degrees in each directionLCD.clear#';LCD.draw$tring#*Rotation test*+ ,+ ,';m.rotate#38,';

    4hread.sleep#6,,,';m.rotate#938,';

    00Rotate to speci1ic degreesLCD.clear#';LCD.draw$tring#*(ncremental Rotation*+ ,+ ,';m.rotate4o#,';4hread.sleep#:,,';m.rotate4o# :';4hread.sleep#:,,';m.rotate4o#/,';4hread.sleep#:,,';m.rotate4o#63:';4hread.sleep#:,,';m.rotate4o#6

  • 8/16/2019 EV3 Motor Guidefd

    5/6

  • 8/16/2019 EV3 Motor Guidefd

    6/6

    1 EV3 Cser Guide, http ''www.nr.edu' s &!!'labs%e-3'e-3%user%guide%E+.pdf & eFO5 EV3 i i, http ''sour eforge.net'p'leHos'wi i'Motors'3 eFOs 7o umentation,http ''www.leHos.org'e-3'do s'leHos'hardware'motor'>ase2egulatedMotor.htmlIforward%%

    http://www.nr.edu/csc200/labs-ev3/ev3-user-guide-EN.pdfhttp://sourceforge.net/p/lejos/wiki/Motors/http://www.lejos.org/ev3/docs/lejos/hardware/motor/BaseRegulatedMotor.html#forward--http://www.lejos.org/ev3/docs/lejos/hardware/motor/BaseRegulatedMotor.html#forward--http://sourceforge.net/p/lejos/wiki/Motors/http://www.lejos.org/ev3/docs/lejos/hardware/motor/BaseRegulatedMotor.html#forward--http://www.lejos.org/ev3/docs/lejos/hardware/motor/BaseRegulatedMotor.html#forward--http://www.nr.edu/csc200/labs-ev3/ev3-user-guide-EN.pdf