Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Purpose

Easily implement a Tank style drive for a mobile robot.

When to use

If you have a Tank styled drive system configuration, where a signal controls right side motors another one controls controls left side motors.

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.

Note

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

Objectif

Facilement ajouter un contrôle de style « tank » à votre base de robot.

Quand l’utiliser

Si vous avez une base de robot en configuration « tank », où un signal contrôle les moteurs du côté droit et un autre les moteurs du côté gauche.

Où l’utiliser

Dans la partie void loop() de votre fichier .ino, puisqu’il faut qu’elle soit appelée en boucle le plus rapidement possible.

Note

Cette fonction requiert l’utilisation des fonctions suivantes dans votre programme:

Valeur de retour

Cette fonction ne retourne aucune valeur après avoir exécuté ses tâches.

Prototype principal

static void 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

Les paramètres suivants sont requis par la fonction:

  • leftChannel: La vitesse à laquelle les moteurs gauches devrait aller. De type int8_t (also called aussi appelé signed char), so ranging [soit entre -128 , et 127].

  • rightChannel: The speed value used to control the right drive motor. Must be of the La vitesse à laquelle les moteurs droits devrait aller. De type int8_t (also called aussi appelé signed char), so ranging [soit entre -128 , et 127].

  • frontLeftMotor: The name of the PWM pin to wich is connected the front left motor. Must be of the type unsigned charLe port PWM auquel est connecté le moteur avant gauche.

  • backLeftMotor: The name of the PWM pin to wich is connected the back left motor. Must be of the type unsigned charLe port PWM auquel est connecté le moteur arrière gauche.

  • frontRightMotor: The name of the PWM pin to wich is connected the front right motor. Must be of the type unsigned char.backRightMotor:The name of the PWM pin to wich is connected the back right motor. Must be of the type unsigned charLe port PWM auquel est connecté le moteur avant droit.

  • backRightMotor: Le port PWM auquel est connecté le moteur arrière droit.

Overloads

#1: Using only one motor per sideUn seul moteur par côté

static void 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

Les paramètres suivants sont requis par la fonction:

  • leftChannel: La vitesse à laquelle les moteurs gauches devrait aller. De type int8_t (also called aussi appelé signed char), so ranging [soit entre -128 , et 127].

  • rightChannel: The speed value used to control the right drive motor. Must be of the La vitesse à laquelle les moteurs droits devrait aller. De type int8_t (also called aussi appelé signed char), so ranging [soit entre -128 , et 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
  • Le port PWM auquel est connecté le moteur gauche.

  • rightMotor: Le port PWM auquel est connecté le moteur droit.

#2: Utiliser directement les valeurs de la manettes, 2 moteurs par côté

static void 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 properlyLes paramètres suivants sont requis par la fonction:

  • 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.

  • backRightMotor: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
  • Le « channel » de joystick à utiliser pour contrôler les moteurs gauches. De type ANALOG (voir CrcLib: accéder aux boutons de la télécommande )

  • rightChannel: Le « channel » de joystick à utiliser pour contrôler les moteurs droits. De type ANALOG (voir CrcLib: accéder aux boutons de la télécommande )

  • frontLeftMotor: Le port PWM auquel est connecté le moteur avant gauche.

  • backLeftMotor: Le port PWM auquel est connecté le moteur arrière gauche.

  • frontRightMotor: Le port PWM auquel est connecté le moteur avant droit.

  • backRightMotor: Le port PWM auquel est connecté le moteur arrière droit.

#3: Utiliser directement les valeurs de la manettes, 1 seul moteur par côté

static void 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 properlyLes paramètres suivants sont requis par la fonction:

  • 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

Exemples

Expand
title#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 motorNous souhaitons contrôler 2 moteurs de puissance faisant partie d'une base de style « tank » dirigée par des contrôleurs de moteur connectés aux ports PWM #1 et #2. Nous souhaitons que la vitesse des moteurs soit directement contrôlée par la position verticale des deux joysticks de la manette connectée au CRCconnect.
Code Block
languagecpp
#include <CrcLib.h> 

void setup() {
    CrcLib::Initialize();

    CrcLib::InitializePwmOutput(CRC_PWM_1);
    CrcLib::InitializePwmOutput(CRC_PWM_2);
    
    /* 
    TheReste restdu ofcode yourd'initialisation
setup code     ...
     */
}
void loop() {
    CrcLib::Update();

    CrcLib::MoveTank(ANALOG::JOYSTICK1_Y, ANALOG::JOYSTICK2_Y, CRC_PWM_1, CRC_PWM_2);
    
    /* 
    TheReste restde ofla yourboucle loopingprincipale
code     ...
    */
}

More on this function

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

Related articles

Articles reliés

Filter by label (Content by label)
sorttitle
excerptTyperich content
cqllabel = "ar-crclib_funct_drive"