RCKit
Public Member Functions | Protected Member Functions | List of all members
DifferentialSetter Class Reference

Setter class cluster that controls 2 analog outputs based on 2 analog inputs so that a joystic can be used to control 2 motors like on a tank or bulldozer or concentric rotor helicopter. inputA controls forwars/reverse and inputB controls left/right. More...

#include <DifferentialSetter.h>

Inheritance diagram for DifferentialSetter:
Inheritance graph
[legend]
Collaboration diagram for DifferentialSetter:
Collaboration graph
[legend]

Public Member Functions

 DifferentialSetter (Setter *targetA, Setter *targetB)
 
void setTargets (Setter *targetA, Setter *targetB)
 
virtual void input (int value)
 
virtual void inputB (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 ()
 

Protected Member Functions

void doOutput ()
 Internal function that computes the two output vlaues based on themost recent input values.
 

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
 

Detailed Description

Setter class cluster that controls 2 analog outputs based on 2 analog inputs so that a joystic can be used to control 2 motors like on a tank or bulldozer or concentric rotor helicopter. inputA controls forwars/reverse and inputB controls left/right.

Author
Mike McCauley (mikem.nosp@m.@air.nosp@m.spayc.nosp@m.e.co.nosp@m.m)

A Differential is used to drive 2 motors in forward and reverse directions in response to the inputs from 2 joysticks.

It requires 2 HBridges as output: one to drive the left motor forward/reverse and one to drive the right motor forward/reverse.

It also requires 2 inputs, one for the fore-aft and one for the left-right. The 2 outputs drive 2 reversible motors that act like the motors on a tank or bulldozer, allowing forward, reverse and turning under the control of an x-Y joystick.

In general, the fore/aft input (inputA) is replicated on the 2 outputs, but if inputB varies either side of 127, outputA is increased/decreased and outputB in decreased/increased. The outputs are never permitted outside the range 0 - 255.

The standard input (inputA) to this Setter controls the forward/reverse. The left/right controls come through an instance of the DifferentialLRSetter class.

Typically the outputs would be two HBridgeSetter instances to control a pair of motors but could be ServoSetter, AccelStepperSpeedSetter or AccelStepperPositionSetter or any other combination.

Constructor & Destructor Documentation

◆ DifferentialSetter()

DifferentialSetter::DifferentialSetter ( Setter targetA,
Setter targetB 
)
Parameters
[in]targetAThe Setter to use for output A.
[in]targetBThe Setter to use for output B.

Member Function Documentation

◆ failsafe()

void DifferentialSetter::failsafe ( )
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().

◆ input()

void DifferentialSetter::input ( int  value)
virtual

Input the value to be used to set the 2 output Setters.

Parameters
[in]valueThe fore/aft value.

Reimplemented from Setter.

References doOutput().

◆ inputB()

void DifferentialSetter::inputB ( int  value)
virtual

This is the B input, controlling left-right differential. It has to come from an instance of DifferentialLRSetter.

Parameters
[in]valueThe input value to set.

References doOutput().

◆ setTargets()

void DifferentialSetter::setTargets ( Setter targetA,
Setter targetB 
)

Set or change the output pin

Parameters
[in]targetAThe Setter to use for output A.
[in]targetBThe Setter to use for output B.

References Setter::setTarget().


The documentation for this class was generated from the following files: