maslab.orc
Class Motor

java.lang.Object
  extended by maslab.orc.Motor

public class Motor
extends java.lang.Object

Orc wrapper for a motor.


Constructor Summary
Motor(Orc orc, int motorport, boolean motorflip)
          Create a new Motor wrapper.
Motor(Orc orc, int motorport, boolean motorflip, int quadphaseport, boolean quadflip)
          Create a new Motor wrapper, assuming normal quadrature phase decoding.
Motor(Orc orc, int motorport, boolean motorflip, int quadphaseport, boolean quadflip, Orc.PinMode m)
          Create a new Motor wrapper, using the specified wheel position decoding mode..
 
Method Summary
 double current()
          Get the motor current in amps.
 int encoder()
          Returns the number of counts since the last call to this function.
 long encoderAbsolute()
          Return the total number of encoder counts since the app was started.
 int get()
          Get the motor's (actual) PWM.
 int getGoal()
          Get the requested PWM, as last set.
static void main(java.lang.String[] args)
          A very simple little motor test program.
 void set(int pwm)
          Set the motor's PWM.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Motor

public Motor(Orc orc,
             int motorport,
             boolean motorflip)
Create a new Motor wrapper.

Parameters:
orc - The orc object.
motorport - The port that the motor is connectoed to [0,3]
motorflip - Set to true if the motor runs "backwards'

Motor

public Motor(Orc orc,
             int motorport,
             boolean motorflip,
             int quadphaseport,
             boolean quadflip)
Create a new Motor wrapper, assuming normal quadrature phase decoding.

Parameters:
orc - The orc object.
motorport - The port that the motor is connectoed to [0,3]
motorflip - Set to true to reverse the motor direction.
quadphaseport - The port that the quadphase is connected to (16 or 18)
quadflip - Set to true to reverse the quadphase direction.

Motor

public Motor(Orc orc,
             int motorport,
             boolean motorflip,
             int quadphaseport,
             boolean quadflip,
             Orc.PinMode m)
Create a new Motor wrapper, using the specified wheel position decoding mode..

Parameters:
orc - The orc object.
motorport - The port that the motor is connectoed to [0,3]
motorflip - Set to true to reverse the motor direction.
quadphaseport - The port that the quadphase is connected to (16 or 18)
quadflip - Set to true to reverse the quadphase direction.
m - Set the quadphase to the particular type (fast, normal, mono)
Method Detail

set

public void set(int pwm)
Set the motor's PWM.

Parameters:
pwm - The direction/strength to drive, [-255, 255].

get

public int get()
Get the motor's (actual) PWM. Depending on the slew rate, it takes a while for the read pwm value to reach the requested pwm.


getGoal

public int getGoal()
Get the requested PWM, as last set.


current

public double current()
Get the motor current in amps. (Very approximate.)


encoder

public int encoder()
Returns the number of counts since the last call to this function.


encoderAbsolute

public long encoderAbsolute()
Return the total number of encoder counts since the app was started. Note that even a long will eventually overflow!


main

public static void main(java.lang.String[] args)
A very simple little motor test program.