Mirobot

De FunLab Documentation
Aller à : navigation, rechercher
Robot Arduino

Auteur : Hervé

Matos nécessaire

version 3D

[1]

pour l'original

Mirobot.sch.png

1*ULN2803A

  • 2 x 28BYJ-48 stepper motors. These can be picked up pretty easily on eBay. Make sure you get the ones with a 1:64 gear ratio

2 Prises abracadra pour les steppers 28BYJ-48

  • 1 x Pololu caster wheel.
  • 1 x conteneur de batteries 5 fois type AA
  • 2 x elastique
  • 2 x M3 x 16 machine screws

1 servo SG92S pour activer le stylo

un arduino nano ou micro (VERIFIEZ!) un module wifi ESP-12

Du MDF sur 1,3m² en 3mm d'épaisseur.

ces Git:

https://github.com/mirobot/mirobot-arduino https://github.com/mirobot/mirobot-pcb

Une découpeuse laser...

Pour notre version

2*ULN2003A

  • 2 x 28BYJ-48 stepper motors. These can be picked up pretty easily on eBay. Make sure you get the ones with a 1:64 gear ratio

2 Prises abracadra pour les steppers 28BYJ-48

  • 1 x Pololu caster wheel.
  • 1 x conteneur de batteries 5 fois type AA
  • 2 x elastique
  • Une breadboard ou un protoshield
  • Optionnel (porte-stylo):2 vis plates M3 x 16
  • Optionnel (porte stylo):1 servo SG92S
  • un arduino nano ou micro (VERIFIEZ!)
  • un module wifi ESP-12
  • Du MDF sur 1,3m² en 3mm d'épaisseur.
  • Une découpeuse laser...

https://github.com/tuxun/mirobot-pcb

les fichiers

NOTE PDF A REVOIR: double passages!

(vérifier svg avant utilisation!)

Fichier:Mirobot chassis lasercut Modif.pdf

Le svg, pour modification avant export en PDF...

Notice de montage (en anglais)

démo:

SAM 0782.JPG

400px

un premier kit

J'ai découpé le pdf un peu au dessus et ai remarqué que des découpes étaient doubles. L'assemblage s'est plutôt bien passé, heureusement que j'avais des vis en rab d'un autre projet! La prochaine fois je prévoirai des trous pour fixer deux fins de courses, un capteur à ultrasons, un ball "caster" imprimé (il faudra aussi prévoir une bille, voir http://www.instructables.com/id/Low-Cost-Arduino-Compatible-Drawing-Robot/ ), un pied pour supporter la carte mère (que je devrais aussi dessiner entre temps).


J'ai galéré un peu pour trouver le code source distribué par Mirobot pour faire fonctionner leur bestiole. Le lien vers leurs dépôts git se trouvaient tout bêtement dans le pied de page de leur blog (sous opensource en plus!). Il faut importer le dossier src situé dans l'archive master.zip présent sur https://github.com/mirobot/mirobot-arduino dans votre dossier de librairies, votre environnement de développement Arduino devrait vous permettre de charger les librairies Mirobot.h et EEPROM.h sans raler. ensuite, un premier test m'indiqua que mon câblage n'était pas bon, le bon pour les modules ULN2803A du lab est commenté au début du code.

Ce code est tiré des exemples fourni sur le git a propos d'arduino mis à dispo par Mirobot, c'est normalement le dossier "Examples" fourni dans l'archive "master.zip" dont je parle si dessus. Merci à eux! (encore une fois l'archive est téléchargeable ici: https://github.com/mirobot/mirobot-arduino )

première collisions
collisions.ino
#include <Mirobot.h>
#include <EEPROM.h>

/*
* les fins de courses semblent etre sur  A3 et A4 reliant le GND a ces pins.
* moteur1:
arecabler
i1=P8,
i2=P10,
i3=P11,
i14=p12

moteur2:
i1=P4,
i2=P5,
i3=P6,
i4=P7

speaker: pin9

This sketch demonstrates simple collision detection without using the built in library
code from https://github.com/mirobot/mirobot-arduino by http://www.Mirobot.io
*/

Mirobot mirobot;
typedef enum {M_NORMAL, M_RIGHT_REVERSE, M_RIGHT_TURN, M_LEFT_REVERSE, M_LEFT_TURN} collideState_ty;
collideState_ty collideState;

void setup(){
  mirobot.setup();
}

void loop(){
  boolean collideLeft = !digitalRead(LEFT_COLLIDE_SENSOR);
  boolean collideRight = !digitalRead(RIGHT_COLLIDE_SENSOR);
  if(collideState == M_NORMAL){
    if(collideLeft){
      collideState = M_LEFT_REVERSE;
      mirobot.back(50);
    }else if(collideRight){
      collideState = M_RIGHT_REVERSE;
      //recule de 50
      mirobot.back(50);
    }else{
      //avance de 10
      mirobot.forward(10);
    }
  }else if(mirobot.ready()){
    switch(collideState){
      case M_LEFT_REVERSE :
        collideState = M_LEFT_TURN;
        mirobot.right(90);
        break;
      case M_RIGHT_REVERSE :
        collideState = M_RIGHT_TURN;
        mirobot.left(90);
        break;
      case M_LEFT_TURN :
      case M_RIGHT_TURN :
        collideState = M_NORMAL;
    }
  }


}
dessins, collisions et wifi

le code suivant est un test de dessin, puis de collisions/wifi simultanée...

Il est a mettre sur le UNO du Funrobot.

ATTENTION: deconnectez le module WIFI ESP8266 pour programmer l'Arduino UNO!!! (voir sketch du module wifi en dessous de celui la)

funrobot.ino
#include <Mirobot.h>
#include <EEPROM.h>
/*
* les fins de courses semblent etre sur  A3 et A4 reliant le GND a ces pins.
* moteur1:
arecabler
i1=P8,
i2=P10,
i3=P11,
i14=p12
 
moteur2:
i1=P4,
i2=P5,
i3=P6,
i4=P7

pen servo:p3
 
speaker: pin9
 
This sketch demonstrates simple collision detection without using the built in library
code from https://github.com/mirobot/mirobot-arduino by http://www.Mirobot.io
*/
 
Mirobot mirobot;
typedef enum {M_NORMAL, M_RIGHT_REVERSE, M_RIGHT_TURN, M_LEFT_REVERSE, M_LEFT_TURN} collideState_ty;
collideState_ty collideState;

void star(){
    //draw a star
  mirobot.pendown();
  for(char i=0; i<5; i++){
    mirobot.forward(100);
    mirobot.right(144);
  }
  mirobot.penup();
}

void square(){
    //draw a square
  mirobot.pendown();

  for(char i=0; i<4; i++){
    mirobot.forward(100);
    mirobot.right(90);
  }
  mirobot.penup();
}
void setup(){
  mirobot.setup();
    mirobot.penup();

   square();
  mirobot.forward(15);
star();

  Serial.begin(57600);
  mirobot.setup(Serial);
}
 
void loop(){
  boolean collideLeft = !digitalRead(LEFT_COLLIDE_SENSOR);
  boolean collideRight = !digitalRead(RIGHT_COLLIDE_SENSOR);
  if(collideState == M_NORMAL){
    if(collideLeft){
      collideState = M_LEFT_REVERSE;
      mirobot.back(50);
    }else if(collideRight){
      collideState = M_RIGHT_REVERSE;
      //recule de 50
      mirobot.back(50);
    }else{
      //avance de 10
      mirobot.forward(10);
    }
  }else if(mirobot.ready()){
    switch(collideState){
      case M_LEFT_REVERSE :
        collideState = M_LEFT_TURN;
        mirobot.right(90);
        break;
      case M_RIGHT_REVERSE :
        collideState = M_RIGHT_TURN;
        mirobot.left(90);
        break;
      case M_LEFT_TURN :
      case M_RIGHT_TURN :
        collideState = M_NORMAL;
    }
  }
    mirobot.process();


<br>
}
programmez le module wifi

5 cables suffisent:

TX->RXD
RX->TXD
GND_POWER->GND->GND_USBSERIAL
+3,3V_POWER->VCC
GND_POWER->GPIO0 (gnd pour programmer, redemarrer le module, devrait resoudre esp_open() failed  )

Ensuite le code pour l'esp8266:

wificode.ino
/* 
  WiFiTelnetToSerial - Example Transparent UART to Telnet Server for esp8266

  Copyright (c) 2015 Hristo Gochkov. All rights reserved.
  This file is part of the ESP8266WiFi library for Arduino environment.
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

//how many clients should be able to telnet to this ESP8266
#define MAX_SRV_CLIENTS 1
const char* ssid = "FUNDRAWBOTUX";
const char* password = "funlab37";

WiFiServer server(23);
WiFiClient serverClients[MAX_SRV_CLIENTS];

void setup() {
  delay(1000);
 Serial1.begin(57600);
  //WiFi.begin(ssid, password);
    WiFi.softAP(ssid, password);
   delay(1000);

  Serial1.print("Ready! Use 'telnet ");
  Serial1.print(WiFi.localIP());
  Serial1.println(" 23' to connect");
    server.begin();

}

void loop() {
  uint8_t i;
//    server.handleClient();

  //check if there are any new clients
  if (server.hasClient()){
    for(i = 0; i < MAX_SRV_CLIENTS; i++){
      //find free/disconnected spot
      if (!serverClients[i] || !serverClients[i].connected()){
        if(serverClients[i]) serverClients[i].stop();
        serverClients[i] = server.available();
       // Serial1.print("New client: "); Serial1.print(i);Serial1.println();
        continue;
      }
    }
    //no free/disconnected spot so reject
    WiFiClient serverClient = server.available();
   //& serverClient.stop();
  }
  //check clients for data
  for(i = 0; i < MAX_SRV_CLIENTS; i++){
    if (serverClients[i] && serverClients[i].connected()){
      if(serverClients[i].available()){
        //get data from the telnet client and push it to the UART
        while(serverClients[i].available()) Serial1.write(serverClients[i].read());
      }
    }
  }
  delay(1);


}

il suffit de relier un module ESP8266 via son serial TXD1+RXD0 sur le port serie de l'Arduino (ATTENTION AU VOLTAGE!) pour le piloter via wifi et telnet.

dhcp non inclus, mettez vous en IP fixe dans la plage 192.168.4.[2/100]! (voir sketch ci dessus...):

Circuit du mirobot 2.0 avec fritzing:

vous pouvez importer les "parts" ESP8266 dans fritzing si vous voulez "vous amuser un peu" https://github.com/nkolban/fritzing