Robot EVA

Tenía pendiente publicar el modo en el que había construido mi robot Eva. Este robot hizo el segundo mejor tiempo en la clasificación del cosmobot de 2011 y quedó entre los 8 primeros, desbancado por su hermano VELORP (otro de los robot Zero) en cuartos de final. Básicamente comparte muchas características del robot Zero ya que ha sido también probado en el medialab y se han sacado las mismas conclusiones, sin embargo la placa es distinta y la programación también.

Los componentes que tienen en común son:

Sin embargo las ruedas son las del miniz, ya que logran poner el chasis más pegado al suelo y derrapan menos.

La batería no es una Lipo 1S sino 2S (7,4 V.) enchufada directamente a la baby orangutan. Esta se encuentra entre los motores para dejar el centro de gravedad en medio y centrar más el peso en las ruedas.

Como no tiene conversor DC-DC que mantenga un voltaje continuo hacia los motores, he usado un divisor de tensión que mide el voltaje de la batería y así puede calcular el PWM que tengo que enviar a los motores según esté más o menos cargada la batería. Esto se consigue con la siguiente fórmula:

PWM * 7,4 / batería

  • PWM: Es el PWM que queremos enviar al motor.
  • 7,4: Es el voltaje normal que tiene una batería de Lipo 2S.
  • batería: Es el voltaje que tiene la batería en un momento dado.

Así si le meto 180 de PWM y tengo 8,4 voltios en la batería al final mando al motor 159 de PWM.
Si en el anterior caso en la batería tengo 7,4 voltios entonces da los 180 exactos de PWM.
Si la batería está a 7 voltios le metería al final 190 de PWM.

Como la tensión de la batería no es constante sino que tiene picos, es mejor tener 10 valores de tensión y luego calcular la media arimética para tener un valor más coherente.

El divisor de tensión también es útil para saber cuando la batería está cerca de agotarse y parar el robot, salvando así que las celdas pasen por debajo de los 3 voltios.

Este es el esquema de la placa:

A comentar:

  • Tiene un pin auxiliar por si fuese necesario usarlo para algo.
  • Tiene unos pines para añadirle un módulo bluetooth (se baja la tensión con un par de diodos para lograr 3,6 V.).
  • Usa un 7805 para alimentar los sensores y el bluetooth.

El código fuente que he desarrollado lo expongo a continuación. Este implementa el control Proporcional Derivativo y hace uso de las librerías que provee Pololu para poder manejarse con los sensores y con la baby orangutan.

velocistaB_2.h

velocistaB_2.c

Como habeis podido leer en el código fuente tiene un sistema de calibrado por el cual guarda en la EEPROM los valores minimos y máximos de los sensores la primera vez que se calibra y ya no es necesario hacerlo en futuras ocasiones a no ser que cambien las condiciones de iluminación.

La calibración consiste en dejar el robot en la pista, pulsar el botón y que de unas vueltas sobre sí mismo, lea los valores de blanco y negro y los guarde además en la EEPROM. Las siguientes veces que pulsemos el botón ya no se hará la calibración y empezará a correr el robot.

Para realizar la calibración la EEPROM debe estar vacía, y eso se consigue con el siguiente programa:

Y por último un video (gracias Puck2099) de cómo funcionó en la cosmobot (tuve que bajarle un poco el PWM porque al final derrapa un poco y cambia de sentido):

22 comentarios en “Robot EVA

  1. dragonet80

    Oscar,

    Enhorabuena, aunque ya te felicité allí in-situ, por tu gran trabajo y tus buenos resultados. Y por ser un tío tan majo.

    Espero que en la edición del año que viene nos podamos ver ya con un velocista.

    Un saludo.

    Responder
  2. Oscar

    Gracias.

    Cuando tengas ese velocista comentanos qué tal y si un día quieres pasarte por el medialab ya sabes donde está 😉

    Responder
  3. syvic

    Muchas gracias por publicar todas las especificaciones y código del robot, y enhorabuena por los resultados en Cosmobot.

    La verdad es que la competición estuvo muy entretenida, sobre todo a partir de cuartos. Felicidades!

    Responder
    1. Oscar

      There are a few operating sytems and compilators for avr that use different make files format, so with source code and know how to compile it in your platform should be enough.

      Responder
  4. Carrey

    Hey, Oscar! I really liked your robot! I want to do such a thing, too! Unfortunately, I have weeded from the controller, I collect myself and the controllers want to use a 16 Mhz atmega8. I have a motor controller is the same! Can I use your code on a different microprocessor, if I change the pins, I do not use Arduino IDE, but I write under the winavr. It’s very interesting to know the answer. And here’s another. You’re not using PWM code for motor control?

    Responder
    1. Oscar Autor

      I think you can use an atmega8, however you have to use the same connections as if it were a baby orangutan controller. The code above is compiled with winavr using the pololu library, so the PWM is set by the function set_mX_speed where X is 1 or 2.

      Responder
  5. Carrey

    Many thanks, Oscar!
    Could you explain me this.
    You use the INT0 interrupt. And it’s kind of interruption for the buttons, then there should be a button each time the robot to work?

    Responder
  6. Oscar

    Hey, Oscar! I came a couple of questions about your code, I understand its just a style of writing I do not know, please tell me all the questions.
    a) Where did you initialize the button on the input and how it relates to the variable boton.
    b) Why should you have an array of medidas[]

    Responder
    1. Oscar Autor

      a) By default all pins in atmega are input at beginning, so for the button I only have to activate the interrupt: EIMSK |= (1 << INT0); and sei(); b) An arithmetic mean to get the battery state.

      Responder
  7. Oscar

    «Como no tiene conversor DC-DC que mantenga un voltaje continuo hacia los motores, he usado un divisor de tensión que mide el voltaje de la batería y así puede calcular el PWM que tengo que enviar a los motores según esté más o menos cargada la batería. Esto se consigue con la siguiente fórmula:»
    Oscar, Tell me please, what is it? We do not use PWM, we just serve on the PWM outputs 5V.
    And please tell me where there is a setting in the ADC output code (to get the data from the battery), I just can not use the ADC port 6, and can only be used in your controller, ADC 5.
    And say, make sure the battery should be 7.4V, I want to use the battery to 5V.

    Responder
    1. Oscar Autor

      I don’t understand the phrase «We do not use PWM, we just serve on the PWM outputs 5V» If you don’t use PWM, how do you change the motor speed?

      I use the pololu libraries to read the ADC in mili_voltios function.

      You can use 5V battery if you want, however you have to do some changes in code: 3700 to 2500 & 3100 to the value from you want to stop the robot when low battery (i.e: 2000).

      Responder
  8. Farad

    Hello Oscar!
    I decided to build your robot, because have free time)
    I collect robot Atmega8 16mzh.
    I read the code, and the robot learned that I have issues))
    Tell me please, what you specify in the code that you have an 8-bit ADC, the datasheet for megu168 says that there is 10-bit ADC.
    Tell me please, to work with the robot should have 7.4V battery?
    I have in my mege8 no port PС6, which is used in your controller to exit the STBY in driver motors.
    Where can I change this output in the library rololu and then I can not find (((
    I would like to exit STBY moved to another port

    Responder
    1. Oscar Autor

      In function inicializa I change the ADC to 8 bit with set_analog_mode(MODE_8_BIT);

      You can use a 5V battery, but you have to do the changes that I have told you in the last comment.

      Where did you find the PC6 port? I don’t use it. It is reserved for reset the microncontroller: http://www.pololu.com/docs/0J14/all

      Responder
  9. Farad

    Oscar sorry for the ill-defined question, I have a problem with the English language. I was just with Russia.
    1) in the scheme RC6 baby orangutan is used to output from the STBY TB6612FNG, or rather to run this chip. If it does not apply a high level of the motor will not run (see scheme).
    2)

    Responder

Responder a Oscar Cancelar la respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *