Driver for Encoder module on MeAuriga and MeMegaPi.
More...
#include <src/MeEncoderOnBoard.h>
|
| | MeEncoderOnBoard () |
| |
| | MeEncoderOnBoard (int slot) |
| |
| void | reset (uint8_t slot) |
| |
| uint8_t | getSlotNum (void) const |
| |
| uint8_t | getIntNum (void) const |
| |
| uint8_t | getPortA (void) const |
| |
| uint8_t | getPortB (void) const |
| |
| long | getPulsePos (void) const |
| |
| void | setPulsePos (long pulse_pos) |
| |
| void | pulsePosPlus (void) |
| |
| void | pulsePosMinus (void) |
| |
| void | setCurrentSpeed (float speed) |
| |
| float | getCurrentSpeed (void) const |
| |
| int16_t | getCurPwm (void) const |
| |
| void | setTarPWM (int16_t pwm_value) |
| |
| void | setMotorPwm (int16_t pwm) |
| |
| void | updateSpeed (void) |
| |
| void | updateCurPos (void) |
| |
| long | getCurPos (void) const |
| |
| void | runSpeed (float speed) |
| |
| void | setSpeed (float speed) |
| |
| void | move (long position, float speed=100, int16_t extId=0, cb callback=NULL) |
| |
| void | moveTo (long position, float speed=100, int16_t extId=0, cb callback=NULL) |
| |
| long | distanceToGo () const |
| |
| void | setSpeedPid (float p, float i, float d) |
| |
| void | setPosPid (float p, float i, float d) |
| |
| void | setPulse (int16_t pulseValue) |
| |
| void | setRatio (float RatioValue) |
| |
| void | setMotionMode (int16_t motionMode) |
| |
| int16_t | pidPositionToPwm (void) |
| |
| int16_t | speedWithoutPos (void) |
| |
| void | encoderMove (void) |
| |
| void | pwmMove (void) |
| |
| boolean | isTarPosReached (void) const |
| |
| void | loop (void) |
| |
Driver for Encoder module on MeAuriga and MeMegaPi.
Class: MeEncoderOnBoard
- Description
- Declaration of Class MeEncoderOnBoard
- Copyright (C), 2012-2016, MakeBlock
◆ MeEncoderOnBoard() [1/2]
| MeEncoderOnBoard::MeEncoderOnBoard |
( |
| ) |
|
Alternate Constructor which can call your own function to map the Encoder motor to arduino port, no pins are used or initialized here.
- Parameters
-
◆ MeEncoderOnBoard() [2/2]
| MeEncoderOnBoard::MeEncoderOnBoard |
( |
int |
slot | ) |
|
Alternate Constructor which can call your own function to map the Encoder motor to arduino port
- Parameters
-
| [in] | slot | - megapi slot from SLOT1 to SLOT4(Auriga SLOT1 and SLOT2). |
◆ distanceToGo()
| long MeEncoderOnBoard::distanceToGo |
( |
void |
| ) |
const |
- Function
- distanceToGo
- Description
- The distance that encoder should go, units are in degrees.\r
So 360-degree means a circle.
- Parameters
-
- Output
- None
- Return
- long - Return the length that encoder need run.
- Others
- None
◆ encoderMove()
| void MeEncoderOnBoard::encoderMove |
( |
void |
| ) |
|
- Function
- encoderMove
- Description
- This function used for move with PID mode.
- Parameters
-
- Output
- None
- Return
- None
- Others
- None
◆ getCurPos()
| long MeEncoderOnBoard::getCurPos |
( |
void |
| ) |
const |
- Function
- getCurPos
- Description
- This function used to get the current position(The units are degrees).
- Parameters
-
- Output
- None
- Return
- None
- Others
- None
◆ getCurPwm()
| int16_t MeEncoderOnBoard::getCurPwm |
( |
void |
| ) |
const |
- Function
- getCurPwm
- Description
- This function used to get the current pwm setting.
- Parameters
-
- Output
- None
- Returns
- None
- Others
- None
- Function
- getCurPwm
- Description
- This function used to get the current pwm setting.
- Parameters
-
- Output
- None
- Returns
- int16_t - the pwm setting
- Others
- None
◆ getCurrentSpeed()
| float MeEncoderOnBoard::getCurrentSpeed |
( |
void |
| ) |
const |
- Function
- getCurrentSpeed
- Description
- This function used to get the current speed(The unit is rpm).
- Parameters
-
- Output
- None
- Returns
- float - the speed value(The unit is rpm).
- Others
- None
◆ getIntNum()
| uint8_t MeEncoderOnBoard::getIntNum |
( |
void |
| ) |
const |
- Function
- getIntNum
- Description
- This function used to get the Auriga/MegaPi Interrupt number of current objects.
- Parameters
-
- Output
- None
- Returns
- uint8_t - The Interrupt number of current objects
- Others
- None
◆ getPortA()
| uint8_t MeEncoderOnBoard::getPortA |
( |
void |
| ) |
const |
- Function
- getPortA
- Description
- This function used to get the GPIO number of current objects's dir port A.
- Parameters
-
- Output
- None
- Returns
- uint8_t - The GPIO number of current objects's dir port A
- Others
- None
◆ getPortB()
| uint8_t MeEncoderOnBoard::getPortB |
( |
void |
| ) |
const |
- Function
- getPortB
- Description
- This function used to get the GPIO number of current objects's dir port B.
- Parameters
-
- Output
- None
- Returns
- uint8_t - The GPIO number of current objects's dir port B
- Others
- None
◆ getPulsePos()
| long MeEncoderOnBoard::getPulsePos |
( |
void |
| ) |
const |
- Function
- getPulsePos
- Description
- This function used to get the current pos value(pulse counter).
- Parameters
-
- Output
- None
- Returns
- long - current pos value
- Others
- None
◆ getSlotNum()
| uint8_t MeEncoderOnBoard::getSlotNum |
( |
void |
| ) |
const |
- Function
- getSlotNum
- Description
- This function used to get the Auriga/MegaPi slot number of current objects.
- Parameters
-
- Output
- None
- Returns
- uint8_t - The slot number of current objects
- Others
- None
◆ isTarPosReached()
| boolean MeEncoderOnBoard::isTarPosReached |
( |
void |
| ) |
const |
- Function
- isTarPosReached
- Description
- This function used to determine whether the motor come to the target position.
It is mainly applied to function moveTo or function move
- Parameters
-
- Output
- None
- Return
- true - target position is reached, otherwise
- Others
- None
◆ loop()
| void MeEncoderOnBoard::loop |
( |
void |
| ) |
|
- Function
- loop
- Description
- This function should be called without Blocked.
- Parameters
-
- Output
- None
- Return
- None
- Others
- None
◆ move()
| void MeEncoderOnBoard::move |
( |
long |
position, |
|
|
float |
speed = 100, |
|
|
int16_t |
extId = 0, |
|
|
cb |
callback = NULL |
|
) |
| |
- Function
- move
- Description
- encoder motor moves to the relative positions.
- Parameters
-
| [in] | position | - The relative angle encoder motor moves. |
| [in] | speed | - the speed value(The unit is rpm). |
| [in] | extId | - It is used to indicate the ID of motor(Optional parameters). |
| [in] | callback | - callback function when the target position has been reached(Optional parameters). |
- Output
- None
- Return
- None
- Others
- None
◆ moveTo()
| void MeEncoderOnBoard::moveTo |
( |
long |
position, |
|
|
float |
speed = 100, |
|
|
int16_t |
extId = 0, |
|
|
cb |
callback = NULL |
|
) |
| |
- Function
- moveTo
- Description
- encoder motor moves to the absolute position.
- Parameters
-
| [in] | position | - The absolute angle encoder motor moves. |
| [in] | speed | - the speed value(The unit is rpm). |
| [in] | extId | - It is used to indicate the ID of motor(Optional parameters). |
| [in] | callback | - callback function when the target position has been reached(Optional parameters). |
- Output
- None
- Return
- None
- Others
- None
◆ pidPositionToPwm()
| int16_t MeEncoderOnBoard::pidPositionToPwm |
( |
void |
| ) |
|
- Function
- pidPositionToPwm
- Description
- This function used to calculate the PWM motor value of encoder motor(position & speed).
- Parameters
-
- Output
- None
- Return
- None
- Others
- None
◆ pulsePosMinus()
| void MeEncoderOnBoard::pulsePosMinus |
( |
void |
| ) |
|
- Function
- pulsePosMinus
- Description
- This function used to reduction the current pos value(pulse counter).
- Parameters
-
- Output
- None
- Returns
- None
- Others
- None
◆ pulsePosPlus()
| void MeEncoderOnBoard::pulsePosPlus |
( |
void |
| ) |
|
- Function
- pulsePosPlus
- Description
- This function used to increase the current pos value(pulse counter).
- Parameters
-
- Output
- None
- Returns
- None
- Others
- None
◆ pwmMove()
| void MeEncoderOnBoard::pwmMove |
( |
void |
| ) |
|
- Function
- pwmMove
- Description
- This function used for move with PWM mode.
- Parameters
-
- Output
- None
- Return
- None
- Others
- None
◆ reset()
| void MeEncoderOnBoard::reset |
( |
uint8_t |
slot | ) |
|
- Function
- reset
- Description
- Reset the encoder motor available PIN by Auriga/MegaPi slot.
- Parameters
-
| [in] | slot | - MegaPi encoder port from SLOT1 to SLOT4(Auriga SLOT1 and SLOT2). |
- Output
- None
- Returns
- None
- Others
- None
◆ runSpeed()
| void MeEncoderOnBoard::runSpeed |
( |
float |
speed | ) |
|
- Function
- runSpeed
- Description
- The speed of encode, and encoder motor will running with the setting speed.
- Parameters
-
| [in] | speed | - the speed value(The unit is rpm). |
- Output
- None
- Return
- None
- Others
- None
◆ setCurrentSpeed()
| void MeEncoderOnBoard::setCurrentSpeed |
( |
float |
speed | ) |
|
- Function
- setCurrentSpeed
- Description
- This function used to set the current speed(The unit is rpm).
- Parameters
-
| [in] | speed | - the speed value(The unit is rpm). |
- Output
- None
- Returns
- None
- Others
- None
◆ setMotionMode()
| void MeEncoderOnBoard::setMotionMode |
( |
int16_t |
motionMode | ) |
|
- Function
- setMotionMode
- Description
- This function used to set the motion mode of encoder motor.
- Parameters
-
| [in] | motionMode | - motion mode |
- Output
- None
- Return
- None
- Others
- None
◆ setMotorPwm()
| void MeEncoderOnBoard::setMotorPwm |
( |
int16_t |
pwm | ) |
|
- Function
- setMotorPwm
- Description
- This function used to set current pwm setting.
- Parameters
-
- Output
- None
- Returns
- None
- Others
- None
- Function
- setMotorPwm
- Description
- This function used to execute current pwm setting.
- Parameters
-
- Output
- None
- Returns
- None
- Others
- None
◆ setPosPid()
| void MeEncoderOnBoard::setPosPid |
( |
float |
p, |
|
|
float |
i, |
|
|
float |
d |
|
) |
| |
- Function
- setPosPid
- Description
- This function used to set the PID parameters for encoder motor's pos.
- Parameters
-
| [in] | p | - Proportion parameter |
| [in] | i | - Integration Parameters |
| [in] | d | - Differential parameter |
- Output
- None
- Return
- None
- Others
- None
◆ setPulse()
| void MeEncoderOnBoard::setPulse |
( |
int16_t |
pulseValue | ) |
|
- Function
- setPulse
- Description
- This function used to set the pulse number of encoder code disc.
- Parameters
-
| [in] | pulseValue | - pulse number |
- Output
- None
- Return
- None
- Others
- None
◆ setPulsePos()
| void MeEncoderOnBoard::setPulsePos |
( |
long |
pulsePos | ) |
|
- Function
- setPulsePos
- Description
- This function used to Set the current pos value(pulse counter). Generally used for
reset the distance calculation.
- Parameters
-
| [in] | pulsePos | - the value of pos value(pulse counter) |
- Output
- None
- Returns
- None
- Others
- None
◆ setRatio()
| void MeEncoderOnBoard::setRatio |
( |
float |
RatioValue | ) |
|
- Function
- setRatio
- Description
- This function used to set the ratio of encoder motor.
- Parameters
-
| [in] | RatioValue | - ratio number |
- Output
- None
- Return
- None
- Others
- None
◆ setSpeed()
| void MeEncoderOnBoard::setSpeed |
( |
float |
speed | ) |
|
- Function
- setSpeed
- Description
- This function used to set the current speed(The unit is rpm).
Note: used with update function.
- Parameters
-
| [in] | speed | - the speed value(The unit is rpm). |
- Output
- None
- Returns
- None
- Others
- None
◆ setSpeedPid()
| void MeEncoderOnBoard::setSpeedPid |
( |
float |
p, |
|
|
float |
i, |
|
|
float |
d |
|
) |
| |
- Function
- setSpeedPid
- Description
- This function used to set the PID parameters for encoder motor's speed.
- Parameters
-
| [in] | p | - Proportion parameter |
| [in] | i | - Integration Parameters |
| [in] | d | - Differential parameter |
- Output
- None
- Return
- None
- Others
- None
◆ setTarPWM()
| void MeEncoderOnBoard::setTarPWM |
( |
int16_t |
pwm_value | ) |
|
- Function
- setTarPWM
- Description
- This function used for set the target pwm value.
- Parameters
-
| [in] | pwm_value | - the target pwm value. |
- Output
- None
- Return
- None
- Others
- None
◆ speedWithoutPos()
| int16_t MeEncoderOnBoard::speedWithoutPos |
( |
void |
| ) |
|
- Function
- speedWithoutPos
- Description
- This function used to calculate the PWM motor value of encoder motor(single speed).
- Parameters
-
- Output
- None
- Return
- None
- Others
- None
◆ updateCurPos()
| void MeEncoderOnBoard::updateCurPos |
( |
void |
| ) |
|
- Function
- updateCurPos
- Description
- This function used to calculate the current position(The units are degrees).
- Parameters
-
- Output
- None
- Return
- None
- Others
- None
◆ updateSpeed()
| void MeEncoderOnBoard::updateSpeed |
( |
void |
| ) |
|
- Function
- updateSpeed
- Description
- This function used to update current speed.
- Parameters
-
- Output
- None
- Returns
- None
- Others
- None
The documentation for this class was generated from the following files: