RCKit
|
Setter class that outputs its value to a MotorController configured on 1 digital and one analog output pins. More...
#include <MotorControllerSetter.h>
Public Member Functions | |
MotorControllerSetter (Setter *targetA, Setter *targetB) | |
void | setTargets (Setter *targetA, Setter *targetB) |
virtual void | input (int value) |
virtual void | failsafe () |
Public Member Functions inherited from Setter | |
Setter () | |
Constructor. More... | |
Setter (Setter *target) | |
Constructor with setting the target. | |
virtual void | setTarget (Setter *target) |
void | setFailsafeValue (int failsafeValue) |
Sets the failsafeValue. | |
int | failsafeValue () |
Additional Inherited Members | |
Protected Attributes inherited from Setter | |
Setter * | _target |
This is the instance of Setter that will be given the transfotmed output value. | |
int | _failsafeValue |
Setter class that outputs its value to a MotorController configured on 1 digital and one analog output pins.
A MotorController is used to drive a motor in forward and reverse directions. It requires 2 Setters as output: one to specify the direction, and one to specify the speed.
Inputs 0 to 127 set direction to 0 (reverse) and speed to 254 to 0 respectively Inputs 128 to 255 set direction to 1 (forward) and speed to 0 to 256 respectively This means than an input of 0 will produce full speed reverse, and input of 127 will produce stop and 255 will produce full speed forward. Truth table: input A B 0 0 254 100 0 54 127 255 0 128 255 2 203 255 146 255 255 256
This is compatible with many motor controllers, such as the Arduino Motor Shield (L298N) (SKU:DRI0009) and many others
Typically the outputs would be a DigitalSetter and an AnalogSetter to control a motor through a digital (direction) and an analog (PWM speed) outputs
[in] | targetA | The Setter to use for direction, typically a DigitalSetter. |
[in] | targetB | The Setter to use for speed, typically an AnalogSetter. |
|
virtual |
Called when the source of input data is lost, and the Setter is required to fail in a safe way. Calls the failsafes of targetA and targetB
Reimplemented from Setter.
References Setter::failsafe().
|
virtual |
Input the value to be used to set the 2 output Setters. Input of 127 produces 255 on A and 0 on B (forward but stopped) Input of 128 to 255 translates to output Setter A to 256 (forward) and output Setter B at 0 to 254 (full speed). Input of 127 to 0 translates to output Setter A to 0 (reverse) and output Setter B at 0 to 254 (full speed).
[in] | value | The input value to set. |
Reimplemented from Setter.
References Setter::input().
Set or change the output pin
References Setter::setTarget().