Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Purpose

Automatically implements an Arcade style drive controlled, where left and right motors (1 or 2 by side) are controlled by 2 dedicated inputs (most probably remote controller joystick channels).

When to use

If you have a tank styled drive system configuration, where a channel controls TO DO

Where to use

In the void loop() part of your .ino file, since it’s a one time calculation that needs to be re-executed at short intervals.

This function requires the use of the following functions at some point of your .ino file in order to work properly:

Returns

This function does not return a value once it has completed its tasks.

Main prototype and parameters

static void Crc::CrcLib::MoveTank(int8_t leftChannel, int8_t rightChannel, unsigned char frontLeftMotor, unsigned char backLeftMotor, unsigned char frontRightMotor, unsigned char backRightMotor)

The following parameters must be passed to the function for it to work properly:

  • leftChannel: The speed value used to control the left drive motor. Must be of the type int8_t (also called signed char), so ranging [-128, 127].

  • rightChannel: The speed value used to control the right drive motor. Must be of the type int8_t (also called signed char), so ranging [-128, 127].

  • frontLeftMotor: The name of the PWM pin to wich is connected the front left motor. Must be of the type unsigned char.

  • backLeftMotor: The name of the PWM pin to wich is connected the back left motor. Must be of the type unsigned char.

  • frontRightMotor: The name of the PWM pin to wich is connected the front right motor. Must be of the type unsigned char.

  • backLeftMotor: The name of the PWM pin to wich is connected the back right motor. Must be of the type unsigned char.

Overloads

#1: Using only one motor per side

static void Crc::CrcLib::MoveTank(int8_t leftChannel, int8_t rightChannel, unsigned char leftMotor, unsigned char rightMotor)

The following parameters must be passed to the function for it to work properly:

  • leftChannel: The speed value used to control the left drive motor. Must be of the type int8_t (also called signed char), so ranging [-128, 127].

  • rightChannel: The speed value used to control the right drive motor. Must be of the type int8_t (also called signed char), so ranging [-128, 127].

  • leftMotor: The name of the PWM pin to wich is connected the left motor. Must be of the type unsigned char.

  • rightMotor: The name of the PWM pin to wich is connected the right motor. Must be of the type unsigned char.

#2: Directly using remote controller joystick values, with 2 motors per side

static void Crc::CrcLib::MoveTank(ANALOG leftChannel, ANALOG rightChannel, unsigned char frontLeftMotor, unsigned char backLeftMotor, unsigned char frontRightMotor, unsigned char backRightMotor)

The following parameters must be passed to the function for it to work properly:

  • leftChannel: The remote controller joystick channel used to control the left drive motors. Must be of the type ANALOG.

  • rightChannel: The remote controller joystick channel used to control the right drive motors. Must be of the type ANALOG.

  • frontLeftMotor: The name of the PWM pin to wich is connected the front left motor. Must be of the type unsigned char.

  • backLeftMotor:The name of the PWM pin to wich is connected the back left motor. Must be of the type unsigned char.

  • frontRightMotor: The name of the PWM pin to wich is connected the front right motor. Must be of the type unsigned char.

  • backLeftMotor:The name of the PWM pin to wich is connected the back right motor. Must be of the type unsigned char.

#3: Directly using remote controller joystick values, with only 1 motor per side

static void Crc::CrcLib::MoveTank(ANALOG leftChannel, ANALOG rightChannel, unsigned char leftMotor, unsigned char rightMotor)

The following parameters must be passed to the function for it to work properly:

  • leftChannel: The remote controller joystick channel used to control the left drive motor. Must be of the type ANALOG.

  • rightChannel:The remote controller joystick channel used to control the right drive motor. Must be of the type ANALOG.

  • leftMotor:The name of the PWM pin to wich is connected the left motor. Must be of the type unsigned char.

  • rightMotor: The name of the PWM pin to wich is connected the right motor. Must be of the type unsigned char.

Examples

 #1 We want to control 2 power motors, part of a tank style drive system, controlled via motor controllers connected to PWM Port #1 and #2. We want the speed to be directly controlled using the vertical axis of each joystick on the remote controller connected via a CrcConnect module. The left joystick controls the left motor, and the right joystick controls the right motor.
 

More on this function

There is sadly nothing more to be said about this function…

  • No labels