Hi Paolo,
da hast du ja jetzt ne Menge Möglichkeiten, die Fahrtregler anzusteuern.
Hier kommt noch eine:
Wenn du meine RP6BaseServoLib für 8 Servos aus diesem Beitrag:
https://www.roboternetz.de/phpBB2/ze...ag.php?t=45180
... nehmen willst, dann hier eine Demo dafür zur Ansteuerung eines Fahrtreglers an der Status LED 1:
Die Änderungen für 2 Fahrtregler an ADC0/1 im Programm und in der Lib sind einfach und werden in der Lib beschrieben.Code:/* * **************************************************************************** * RP6 ROBOT SYSTEM - ROBOT BASE TESTS * **************************************************************************** * Test: Servo Test 2 * Author(s): Dirk * **************************************************************************** * Description: * This is a small test for the RP6 Base Servo Library for the RP6 ROBOT BASE. * * COMMENT: It is a good idea to use a separate power supply for the servos! * * Servo connections: * SERVO1 -> Status LED 1 (SL1) SERVO5 -> Status LED 5 (SL5) * SERVO2 -> Status LED 2 (SL2) SERVO6 -> Status LED 6 (SL6) * SERVO3 -> Status LED 3 (SL3) SERVO7 -> PC0 (I2C bus: SCL) * SERVO4 -> Status LED 4 (SL4) SERVO8 -> PC1 (I2C bus: SDA) * If you want to use the RP6 bumpers in your program, you should not * connect Servos to SL3 and SL6. * It is not possible to use the I2C bus, if Servos are connected to SCL * and/or SDA. Instead of SCL/SDA you could use ADC0/ADC1 for servo 7/8, * if you want to use the I2C bus. * * ############################################################################ * The Robot does NOT move in this example! You can simply put it on a table * next to your PC and you should connect it to the PC via the USB Interface! * ############################################################################ * **************************************************************************** */ /*****************************************************************************/ // Includes: #include "RP6BaseServoLib.h" // The RP6 Base Servo Library. /*****************************************************************************/ // Defines: #define MOTOR_FORWARD_FULL RIGHT_TOUCH #define MOTOR_FORWARD_HALF (MIDDLE_POSITION / 2 + MIDDLE_POSITION) #define MOTOR_STOP MIDDLE_POSITION #define MOTOR_BACK_HALF (MIDDLE_POSITION / 2) #define MOTOR_BACK_FULL 0 /*****************************************************************************/ // Variables: uint16_t pos = 0; /*****************************************************************************/ // Functions: /*****************************************************************************/ // Main function - The program starts here: int main(void) { initRobotBase(); // Always call this first! The Processor will not work // correctly otherwise. // --------------------------------------- // Write messages to the Serial Interface: writeString_P("\n\n _______________________\n"); writeString_P(" \\| RP6 ROBOT SYSTEM |/\n"); writeString_P(" \\_-_-_-_-_-_-_-_-_-_/\n\n"); writeString_P("################\n"); writeString_P("<<RP6 Base>>\n"); writeString_P(" Servo - Test 2 \n"); writeString_P(" Version 1.00 \n"); writeString_P("################\n\n"); mSleep(2500); setLEDs(0b111111); // Turn all LEDs on mSleep(500); // delay 500ms // Initialize the servo lib for use of only servo 1: initSERVO(SERVO1); startStopwatch2(); // Used for the demo pos = 2; // Start with motor stopped servo1_position = MOTOR_STOP; while(true) { // --------------------------------------------------------------------- // The demo code for positioning a drive controller (servo 1): if (getStopwatch2() > 5000) { // Change position every ~5s if (pos == 0) { servo1_position = MOTOR_BACK_FULL;} if (pos == 1) { servo1_position = MOTOR_BACK_HALF;} if (pos == 2) { servo1_position = MOTOR_STOP;} if (pos == 3) { servo1_position = MOTOR_FORWARD_HALF;} if (pos == 4) { servo1_position = MOTOR_FORWARD_FULL;} if (pos == 5) { servo1_position = MOTOR_FORWARD_HALF;} if (pos == 6) { servo1_position = MOTOR_STOP;} if (pos == 7) { servo1_position = MOTOR_BACK_HALF;} pos++; if (pos > 7) {pos = 0;} setStopwatch2(0); } // --------------------------------------------------------------------- task_SERVO(); // The main servo task task_RP6System(); } return 0; } /****************************************************************************** * Additional info * **************************************************************************** * Changelog: * - v. 1.0 (initial release) 08.03.2009 by Dirk * * **************************************************************************** */ /*****************************************************************************/
Die Demo steuert den Motor von Stop auf halbe Kraft vorwärts, volle Kraft vorwärts, wieder halbe Kraft, Stop, halbe Kraft rückwärts, volle Kraft rückwärts, usw. Jede Stellung wird 5 Sekunden gehalten.
Gruß Dirk







Zitieren

Lesezeichen