- 12V Akku mit 280 Ah bauen         
Ergebnis 1 bis 4 von 4

Thema: SRF08 + Servo + avoid obstacle

  1. #1
    Neuer Benutzer Öfters hier
    Registriert seit
    23.02.2018
    Beiträge
    6

    SRF08 + Servo + avoid obstacle

    Anzeige

    Powerstation Test
    Hello,
    I have got a RP6 Base system. I have connected SRF08 in I2C (#define SRF_ADR 0xE2) and Servo to XBUS 2 (Servo out SDA).
    I am getting data in RP6 loader terminal and servo is also moving quite nicely.

    I am not so much good in programming. I have mounted srf08 with servo.
    Now, I want to avoid obstacle with SRF08.

    Could anybody provide the code for that?


    Regards
    Arnob

  2. #2
    Erfahrener Benutzer Robotik Einstein Avatar von i_make_it
    Registriert seit
    29.07.2008
    Ort
    Raum DA
    Alter
    56
    Beiträge
    2.814
    No code but principles.

    So rc-servos don't give a feedback, you give a setpoint to the servo and has to wait a time so it is finish moving (typically rc-servos can turn 60°/s).
    Then start ranging and read SRF08 til you don't get 0xFF anymore (ranging is finish).
    Than you can read the echo register 1-17 (register 2-35), til a 16 bit register (8-bit high-byte and 8-bit low-byte) is 0, what means no further echos for this reading stored.

    That is the principle of one measure cycle.

    Description and example code you can find here:
    http://coecsl.ece.illinois.edu/ge423...onicRanger.pdf

  3. #3
    Neuer Benutzer Öfters hier
    Registriert seit
    23.02.2018
    Beiträge
    6
    I am just a Beginner with RP6.
    First thing first.
    I have connected SRF08 to I2C.
    and Servo to XBUS 2 ( Servo out SDA). I think it supposed to be changed because SRF already there.
    Where should I Connect it and what change should do in the following Dirk's code.

    #include "RP6RobotBaseLib.h"

    #define SERVO_OUT SDA
    #define LEFT_TOUCH 554
    #define RIGHT_TOUCH 254
    #define PULSE_ADJUST 8
    #define PULSE_REPETITION 19

    void initSERVO(void)
    {
    DDRC |= SERVO_OUT;
    PORTC &= ~SERVO_OUT;
    startStopwatch1();
    }

    void pulseSERVO(uint8_t position)
    {
    cli();
    PORTC |= SERVO_OUT;
    delayCycles(LEFT_TOUCH);
    while (position--) {
    delayCycles(PULSE_ADJUST);
    }
    PORTC &= ~SERVO_OUT;
    sei();
    }

    void task_SERVO(void)
    {static uint8_t pos;
    if (getStopwatch1() > PULSE_REPETITION) {
    pulseSERVO(pos);
    if (getStopwatch2() > 4 {
    pos++;
    if (pos > RIGHT_TOUCH) {pos = 0;}
    setStopwatch2(0);
    }
    setStopwatch1(0);
    }
    }

    int main(void)
    {
    initRobotBase();

    mSleep(2500);

    setLEDs(0b111111);
    mSleep(500);
    setLEDs(0b000000);

    initSERVO();
    startStopwatch2();

    while(true)
    {
    task_SERVO();
    task_RP6System();
    }
    return 0;
    }

  4. #4
    Erfahrener Benutzer Robotik Einstein Avatar von Dirk
    Registriert seit
    30.04.2004
    Ort
    NRW
    Beiträge
    3.803
    Hi arnob,

    you may not use SDA for a servo, if you are using the I2C-Bus with SRF08.

    You can use other I/O pins on the RP6 Base.

    There is a RP6Base Servo Library.
    With this library you can use other pins for your servo.
    Gruß
    Dirk

Ähnliche Themen

  1. SRF08-Probleme mit I2C
    Von merviux im Forum Sensoren / Sensorik
    Antworten: 6
    Letzter Beitrag: 18.03.2016, 12:44
  2. RP6 Ultraschallsensor SRF08
    Von Marian Otte im Forum Robby RP6
    Antworten: 23
    Letzter Beitrag: 16.02.2013, 15:32
  3. Ultraschallsensor SRF08
    Von AR@HTL im Forum Sensoren / Sensorik
    Antworten: 1
    Letzter Beitrag: 16.04.2007, 16:46
  4. SRF08 Eigenschaften
    Von Chris29 im Forum Sensoren / Sensorik
    Antworten: 1
    Letzter Beitrag: 19.02.2007, 16:33
  5. SRF08 - I²C Fehler...
    Von tobimc im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 1
    Letzter Beitrag: 23.03.2005, 15:01

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

LiFePO4 Speicher Test