Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

oEncodedMotor Class Reference

An object to control a simple encoder (oEncoder) attached to a DC motor (oDCmotor). More...

#include <oencodedmotor.h>


Public Member Functions

MILLIMETER speed (void) const
 return current speed of motor in current SPEED units (see oenum.h)

void WSwrite (void)
 Write object to simulator.

void operate (bool b)
 Be sure to turn on :).

void added_power (POWER p)
 Additional power beyond set/calculated power to add (for PID etc.).

bool stable (void) const
 Until scheduler starts, all speed is nonsense.

void mode (ENCODER_MODE_TYPE)
 Switches to FAST_MODE which eliminates direction or NORMAL_MODE which will decrement the encoder count in reverse. Does nothing for single channel encoders--only valid for quadrature encoder!

ENCODER_MODE_TYPE mode (void) const
void forward (void)
 start motor in forward

void forward (POWER)
 start motor forward at specified POWER.

void reverse (POWER)
 starts motor in reverse at specified POWER.

void reverse (void)
 starts motor in reverse.

void brake (void)
 applies brake to motor (both high).

void power (POWER)
 0-100 (percantage of maximum)

void frequency (FREQUENCY f)
 Sets PWM signal frequency. (cycles per second).

void power_resolution (POWER p)
 Sets the number of increments for power from 0...user set maximum.

void priority (PRIORITY p)
 Sets the TPU channel execution priority (Ref. TPU Channel Utilization) for the speed control line. Default MIDDLE_PRIORITY. Priority should be set before you begin operation.

bool stop (void)
 true if motor stoppped. Needed for EncodedMotor to know whether to apply "cruise_control".

MICROSECOND get_hightime (void)
 return current high time [DOS only]

MICROSECOND get_lowtime (void)
 return current low time [DOS only]

void hightime (MICROSECOND high)
 Hightime set the on time for the pulse measured in micro-seconds.

void nexthigh (MICROSECOND high)
 Used when oPWM is not operating to set new hightime when activated.

void lowtime (MICROSECOND low)
 Lowtime is the off time for the pulse measured in micro-seconds.

void nextlow (MICROSECOND low)
 Used when oPWM is not operating to set new lowtime when activated.

void value (bool onoff) const
 For oDO1_TPU.


Static Public Member Functions

int TCR1 (void)
void TMCR (int iarb)
bool HSQR (int chan, int val)
 Configures the host sequence register.

bool HSRR (int chan, int val)
 Configures the host sequence request register.

bool CPR (int chan, int val)
 Configures the channel priority register (Ref. TPU Channel Utilization).

bool CIER (int chan, int cie)
 Configures the channel interrupt enable register.

int CISR (int chan)
 Returns the channel interrupt status register.

void CISR_clear (int chan)
 Clears the channel interrupt status register for the channel.

bool TICR (int cirl, int cibv)
 Configures the TPU interrupt configuration register.

int tpu_vector (IOLINE channel)
 Given a channel, returns the vector number to use for an interrupt.


Detailed Description

An object to control a simple encoder (oEncoder) attached to a DC motor (oDCmotor).

Operation
This object is subclassed from an oDCmotor object. Thus many methods work the same. It also uses the scheduler, thus set the scheduler frequency with this in mind. Obviously, the faster the refresh_rate (and scheduler frequency), the more processing overhead with occur in this object.
Warning:
Currently, you can only declare four bEncodedMotors per internal implementation limits.
Remarks
The oEncodedMotor automatically set the oEncoder's priority to HIGH_PRIORITY. Also, the _forward/_reverse for the simulator is used so simulator can track direction. This in most cases will match the Operational_Data::Motion() but the Motion is only used in Vector_Driver.
The platform_specification must be declared first to initialize the wheel diameter.

I am somewhat undecided whether to make the return value of odometer (MILLIMETER) an int rather than unsigned. There are consequences either way. As an int, with quadrature encoding forward and reverse the same distance will return 0. Is this what is wanted/needed? Likewise, SPEED has also become a vector; i.e., containing both direction (+/-) and magnitude.

Warning:
Strange feature is that if you specify "forward(150)"--this is setting the forward method of the oDCmotor class; not specify speed of the Encodedmotor. You should say "speed(150)" which sets the appropriate power based upon the speed (+/-).
Class Dependencies
Sample Code
#include <hardware/oencodedmotor.h>
oEncodedMotor Lmotor(4,3,PORT_E,2,PORT_E,1,100);
int main()
{
  Lmotor.orientation(false);
  Lmotor.speed(50);
  Lmotor.operate(true);
  Lmotor.brake();
}


Member Function Documentation

bool CIER int  chan,
int  cie
[static, inherited]
 

Configures the channel interrupt enable register.

Parameters:
int: channel
int: 1 enables; 0 disables

bool CPR int  chan,
int  val
[static, inherited]
 

Configures the channel priority register (Ref. TPU Channel Utilization).

Parameters:
int: channel
int: priority

bool HSQR int  chan,
int  val
[static, inherited]
 

Configures the host sequence register.

Parameters:
int: channel
int dependent upon function (CFSR) selected

bool HSRR int  chan,
int  val
[static, inherited]
 

Configures the host sequence request register.

Parameters:
int: channel
int: dependend upon function

ENCODER_MODE_TYPE mode void   )  const [inherited]
 

Returns current encoder mode. Sets whether motors will automatically adjust to desired speed (true) or not.

void nexthigh MICROSECOND  high  )  [inherited]
 

Used when oPWM is not operating to set new hightime when activated.

DCmotor (and maybe like objects) needs this, because the only way to stop the PWM (that I know of) is to set hightime to 0--thus loosing the previous value of hightime. thus if you set the hightime while the object is non-operational, you want it to be set to that value the next time the object goes operational (see dcmotor.cpp to know what I'm talking about).

int TCR1 void   )  [static, inherited]
 

misnomer--should be TCR1 divisor--return number of clocks (PSCK,TCR1P modifications) Globally available object. Can be used in combination with TPU_REGISTER definition to say TPU_REGISTER->CFSR.BITS...

void TMCR int  iarb  )  [static, inherited]
 

was tpu_init Configures the channel function select register


The documentation for this class was generated from the following file:
Generated on Mon Oct 8 19:32:45 2007 for OOMRM Hardware API by doxygen1.3