Différences entre versions de « Projets:Roboto »

De wikilab
Ligne 837 : Ligne 837 :
  
 
== Durée de fabrication du prototype final ==
 
== Durée de fabrication du prototype final ==
 
  
 
[[Category:Projets]]
 
[[Category:Projets]]
 +
[[Category:Réalisés]]
 +
[[Category:Mobilité]]

Version du 20 novembre 2019 à 14:01

Description du projet

Projet de robot sur roulette télécommandé en bluetooth. Ce prototype est un robot conteur sur roulettes télécommandé en bluetooth avec une manette nunchuck pour les déplacaments. Sur le chassis est fixé une tablette sur laquelle il y a des contes que l'on peut lire en manipulant la tablette. Il a été réalisé en collaboration avec l' artiste Mari Gwalarm pour l'habillage du robot et a été réalisé de manière collaborative auprès d'un public diversifié de 6 à 99 ans avec le soutien de My Human Kit.

Ce prototype est un objet pédagogique avec la finalité de servir dans des médiathèques.

Roboto final.jpg


Liens utiles

Cahier des charges

Analyse de l'existant

Equipe (Porteur de projet et contributeurs)

  • Porteur de projet :Sébastien Lutz
  • Contributeurs :Yves Le chevalier
  • Fabmanager référent : Delphine Bézier

Matériel nécessaire

Bois de palette récupération
Robotmaurebzh2vers.jpg




Plaque aluminium support moteur
Cotes plaque moteur roboto.jpg


Fichier svg:Fichier à télécharger

roues robot

Lien vers le fournisseur

Roue robot.png


entretoise roues robot

Lien vers le fournisseur

Entretoise roues robot.png


Visses et boulonnerie

A ajuster suivant la construction et l'épaisseur du bois

batterie 12volt 12AH + Chargeur de batterie 12V

Batterie 12v 12ah.jpg

2 led ring12

Les anneaux de LED étaient prévus initialement pour faire des yeux multicolores mais n'ont finalement pas été implanté. Pour information voici la référence.

Neopixel rond.jpg

Lien vers le fournisseur

Un support pour les anneauux a été modélisé en 3D, à retrouver dans les fichiers sources.

Interrupteurs
Interrupteur pour le boitier 3d

Lien vers le fournisseur

Interrupteur_robot_boitier.jpg

Interrupteur pour le boitier électrique pour éviter une consommation de courant inutile

Lien vers le fournisseur

moteur à démultiplication
Description

Takanawa motoréducteur 555 métallique 12v - 24v motoréducteur à courant continu

spécification
  • modèle dcmotor RS- 555
  • tension appropriée 12v-24v
  • vitesse 10-20-40-80 tr / min
  • courant de charge 2.5a
  • Vitesse à vide DC12V 3000-3500r / min
  • dc la 7000-8000r / min
  • grandeur diamètre : 37 mm
  • longueur: 65 mm
  • poids 502g
  • longueur de l'arbre 16mm


https:/www.banggood.com/fr/TAKANAWA-555-Metal-Gear-Motor-12V-24V-DC-Gear-Motor-p-995307.html?rmmds=myorder&cur_warehouse=CN

Dimension moteur.png Moteur-takanawa2.jpg

carte arduino uno

Arduino uno.jpg

carte arduino nano

Arduino-nano-microprocessor.jpg

Contoleur moteur

Lien vers fournisseur


Controleur moteur robot.png

manette de wii filaire

Nunchuck2.jpg

Adaptateur nunchuck

Lien vers fournisseur

Adaptateur nunchuk.png

hc05 :module bluethooth à configurer en maitre et exclave

Hc05-1.jpg Hc05 2.jpg

pile 9volt

200pix

impression 3d du boitier commande avec LED

Le boitier est conçu pour ne pas arracher le fil de la nunchuk

Media:stl_robot.zip

Boitier-commande.png

coffret électrique

bien vérifier les dimensions pour la batterie suivant l'emplacement

Découpe à l'intérieur pour faire de la place mais attention si vous voulez garder l’étanchéité, acheter un coffret électrique Coffret electrique.png


Préparation du châssis

Robot plan de réalisation.pdf


Robot plan de réalisation.pdf
Capture robot.PNG

Schéma branchement Arduino batterie motor shield

Shema robot batterieetc .pdf

Intro

Nous avons deux HC-05 qui sont maîtres par défaut. Il faut d'abord configurer les deux HC-05 (l'un en maitre et l'autre en esclave avant de pouvoir les faire communiquer.

Cette procédure se passe en mode commande (AT mode).

Nous allons d'abord configurer l'esclave puis le maître.

Pour cela, réaliser les deux montages (maître et esclave en mode AT).

Schéma Esclave Mode AT

On peut brancher le module HC-05 sur 5V (et pas 3V3).

Le key est connecté au 3.3V en mode AT

Hc-05 master modeat.jpg

Schéma Maître Mode AT

Hc-05 master modeat.jpg

Code

Avant de téléverser le programme sur la carte arduino, débrancher le module HC-05 de l'alimentation

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX

void setup()
{
  pinMode (10, INPUT);
  pinMode (11, OUTPUT);
  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);
  Serial.begin(38400);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more
}

void loop()
{
  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());
  
  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());
}

Configurer deux HC-05 master : un maitre et l'autre esclave

Source:http://blog.zakkemble.net/getting-bluetooth-modules-talking-to-each-other/

Configuration du maitre comme esclave

Reset to defaults: AT+ORGL

Clear any paired devices: AT+RMAAD

Set PIN: AT+PSWD=1234

Slave mode: AT+ROLE=0

Get the address of the device: AT+ADDR?

Now that you have the address you can skip the AT+INQ and AT+RNAME? parts for configuring the master.

Turn off the module, disconnect key from 3.3V and turn back on. <note warning>Eteindre la board, déconnecter le Key du 3.3V et rallumer la board</note>

Schema Esclave Mode COM

Hc-05 slave modecom ok2.jpg

Configuration du maitre

Now, to get the master to connect to the slave module you will need to find the address of the slave. **Make sure the slave module is powered up** and enter these commands into the master module:

Reset to defaults: AT+ORGL

Clear any paired devices: AT+RMAAD

Master mode: AT+ROLE=1

Need to restart after changing role: AT+RESET

Allow connecting to any address: AT+CMODE=1

Inquire mode – Standard, stop after 5 devices found, (or) stop searching after 5 seconds: AT+INQM=0,5,5

Set PIN, should be the same as the slave: AT+PSWD=1234

Start SPP profile lib (needed to do any Bluetooth transmitting/receiving): AT+INIT Note: If it says Error:(17) then that means it’s already loaded, you can carry on.

Start searching: AT+INQ

A short list of devices found should appear, one of them will be the slave module.

The format of the output is as follows: +INQ:address,type,signal

Type can be ignored. The signal will be 7FFF since inquire is in standard mode, in RSSI mode you’ll get a load of the same device but with different signal levels which you don’t want at the moment.

Copy the address part of the devices found, for example 12:3:289431 and change the colons to commas – 12,3,289431. To find out which device is the slave module you will need to query each address for its name: AT+RNAME? <address>

Replace <address> with address of device like 12,3,289431

Response should be +RNAME:linvor if you’re using a normal slave module or +RNAME:HC05 if you’re using a master module as a slave.

Now you’ve got the address of the slave module you need to pair with it: AT+PAIR=<address>,<timeout> Note: If you are going to make the master connect to your phone then you need to set the timeout long enough for you to type in the PIN.

Bind address: AT+BIND=<address>

Only allow connecting to the bound address: AT+CMODE=0

And now to actually connect: AT+LINK=<address>

If successful the slave LED should be on solid and the master LED should have a heartbeat flash pattern.

The modules have now been configured! They should automatically connect to each other whenever possible.

A full list of commands for master modules can be found in the download below.

Sending data

Now, if you entered AT mode on the master module by connecting key to 3.3V before turning on the module, you will need to turn off the module, disconnect key (if not enough plug it to Ground) and turn it back on. If you connected key while the module was on then all you need to do is disconnect key.

Maître Mode COM

Arduino:hc-05 master modecom ok.jpg?direct&600


Envoyer et recevoir des données en Mode COM

Si vous voulez avoir sur le même ordinateurs les deux consoles série d'ouverte, il faut lancer deux instances de l'IDE d'Arduino, afin de tester la communication entre les deux sketchs (maitre et esclave). Ouvrez 2 consoles série et envoyer un message. Vérifier qu'il est bien reçu dans l'autre console. Cela doit fonctionner dans les deux sens.

Sketchs pour envoyer des données depuis une variable (msg)

Source: https://www.instructables.com/id/How-to-Configure-HC-05-Bluetooth-Module-As-Master-/

Sketch maître

#include <SoftwareSerial.h>
//SoftwareSerial ArduinoSlave(2,3);
SoftwareSerial ArduinoSlave(10, 11); // RX | TX
//SoftwareSerial ArduinoSlave(10, 11); // RX | TX

String answer;
String msg;
void setup(){
 Serial.begin(38400);
 Serial.println("ENTER Commands:");
 ArduinoSlave.begin(38400);
               
}
void loop(){
 //Read command from monitor
 readSerialPort();
 
 //Read answer from slave
  while (ArduinoSlave.available()) {
  delay(100);  
  if (ArduinoSlave.available() >0) {
    char c = ArduinoSlave.read();  //gets one byte from serial buffer
    answer += c; //makes the string readString
  }
}
 //Send data to slave
 if(msg!=""){
   Serial.print("Master sent : ");
   Serial.println(msg);
   ArduinoSlave.print(msg);
   msg="";
 }
 //Send answer to monitor
 if(answer!=""){
   Serial.print("Slave received : ");
   Serial.println(answer);
   answer="";
 }
}
void readSerialPort(){
while (Serial.available()) {
  delay(10);  
  if (Serial.available() >0) {
    char c = Serial.read();  //gets one byte from serial buffer
    msg += c; //makes the string readString
  }
}
Serial.flush();
}

Sketch esclave

#include <SoftwareSerial.h>
//SoftwareSerial ArduinoMaster(2,3);
SoftwareSerial ArduinoMaster(10, 11); // RX | TX
String msg;
void setup(){
 Serial.begin(38400);
 ArduinoMaster.begin(38400);    
}
void loop(){
 readSerialPort();
 
 // Send answer to master
 if(msg!=""){
   Serial.print("Master sent : " );
   Serial.println(msg);
   ArduinoMaster.print(msg);
   msg=""; 
 }
}
void readSerialPort(){
while (ArduinoMaster.available()) {
  delay(100); 
  if (ArduinoMaster.available() >0) {
    char c = ArduinoMaster.read();  //gets one byte from serial buffer
    msg += c; //makes the string readString
  }
}
ArduinoMaster.flush();
}


Photos montage

600px

600px

600px

Schemas trouvés en ligne

https://www.gme.cz/data/attachments/dsh.772-148.2.pdf

Arduino:img 4657.jpg?direct&600

Arduino:hc-05 connections.jpg?direct&600


AT commands

Les commandes les plus utiles

AT : Vérifier la connection

AT+NAME :Voir le nom par défaut

AT+ADDR : Voir l'adresse par défaut

AT+VERSION : Voir la version

AT+UART : Voir le baudrate

AT+ROLE: Voir le rôle du module bluetooth (1=master/0=slave)

AT+RESET : Réinitialiser et quitter le mode AT

AT+ORGL : restaurer la configuration usine

AT+PSWD: Voir le mot de passe par défaut

Circuit maitre : Nano+Nunchuck+BT

Test avec TEST_BLUETOOTH.ino

Role 1 attribué en bluetooth ok.


AT+BIND=>pour trouver l'adresse à laquelle il est lié

Role maître : +BIND:98d3:31:f41bcf (adresse esclave)

Circuit esclave Uno+Moteurs+BT

Role 0 attribué en bluetooth ok.


https://www.aranacorp.com/fr/votre-arduino-communique-avec-le-module-hc-05/


https://letmeknow.fr/blog/2013/10/09/tuto-commander-un-relais-en-bluetooth/

https://www.instructables.com/id/How-to-Configure-HC-05-Bluetooth-Module-As-Master-/

AT+STATE?

AT+IRQ

https://arduino.stackexchange.com/questions/52846/scan-bluetooth-devices-using-hc-05

https://cdn.instructables.com/ORIG/FI9/7NJR/IRXT0JIG/FI97NJRIRXT0JIG.pdf


https://www.youtube.com/watch?v=hyME1osgr7s


AT+RMAAD pour annuler pairing

https://cdn.instructables.com/ORIG/FI9/7NJR/IRXT0JIG/FI97NJRIRXT0JIG.pdf

https://www.instructables.com/id/HOW-TO-HC-05-Bluetooth-MODULE-AT-Commands-With-But/


AT+UART (config du baudrate)

http://sti2d-sin-isn.blogspot.com/2018/02/auto-connexion-de-deux-modules.html

https://electronics.stackexchange.com/questions/101572/hc-05-bluetooth-module-not-responding-to-certain-commands

Le TUTORIEL avec toutes les étapes

Attention à l'ordre dans lequel on branche/débranche le key.

Faire une AT+reset après avoir débranché le key ou l'inverse, regarder ce lien pour la procédure

Brancher le pin enable sur le GROUND pour switcher en mode communication

essayer en laissant le pin key sur 3.3V (apres avoir éteint la board) pour switcher du mode AT

https://www.teachmemicro.com/hc-05-bluetooth-command-list/

https://arduino.stackexchange.com/questions/16954/problems-connecting-reliably-using-hc-05-as-bluetooth-master

https://forum.core-electronics.com.au/t/solved-how-could-i-take-my-hc05-module-out-of-at-command-mode-without-disconnecting-the-arduino/1792/5


http://forum.hobbycomponents.com/viewtopic.php?f=39&t=1567

Bluetooth+motor+joystick example

https://forum.arduino.cc/index.php?topic=413699.15

https://www.instructables.com/id/Wireless-Wii-Nunchuck-control-of-Arduino-projects/

Reconstruire un nombre en recevant ses éléments un par un

https://openclassrooms.com/forum/sujet/hc-06-et-arduino

// Variable globale (à placer en dehors du loop)
int pwmval = 0;
 
 
// Partie traitement (à placer dans le loop)
if ( Serial.available() ) {
    char c = Serial.read();
    if ( ( c >= '0' ) && ( c <= '9' ) ) {
        pwmval = ( ( pwmval * 10 ) + ( c - '0' ) );
    } else if ( c == 'x' ) {
        analogWrite(pinX, pwmval);
        pwmval = 0;
    } else if ( c == 'y' ) {
        analogWrite(pinY, pwmval);
        pwmval = 0;
    }
}

Librairie pour retrouver les données reçues

https://github.com/jlebunetel/WiiExpansion

code final

/*
# Product: DC Motor Driver 2x15A_lite
  # SKU    : DRI0018
  # Description:
  # Drive 2 motors with this DC Motor Driver module
  # Hardwares:
  1. Arduino UNO
  2. DC Motor Driver 2x15A_lite
  3. DC motors x2
  #Steps:
  1.Connect the DMotD_PWM & DMotG_PWM to UNO digital 5 & 6
  2.Connect the DMotD_EN & DMotG_EN to UNO digital 4 & 7
  3.Connect +5V & GND to UNO 5V & GND
*/
//Bluetooth
#include <SoftwareSerial.h>
SoftwareSerial ArduinoMaster(10, 11); // RX | TX

//nunchuck+bluetooth
int joyX;
int joyY;
int joyC;
int joyZ;

int valeurs_joystick[4] = {0, 0, 0, 0};
int valeurs_joystick_precedent[4] = {0, 0, 0, 0};

//DC Motor Driver pins
int VMotD = 5;     //VMotD Speed Control  mot droit
int VMotG = 6;     //VMotG Speed Control mot gauche
int DMotG = 7;     //DMotD Direction Control
int DMotD = 4;     //DMotD Direction Control

//infos moteurs
boolean p;//détection d'un pivotement
int smg;//sens moteur gauche
int smd;//sens moteur droite
int vmg;//vitesse moteur gauche
int vmd;//vitesse moteur droite
float b;//valeur(amplitude) du braquage
int v1;//valeur vitesse moteur 1
int v2;//valeur vitesse moteur 2

int var [4] = {0, 0, 0, 0};
int k = 0;

void setup() {
  //motor driver
  int i;
  for (i = 4; i <= 7; i++)
    pinMode(i, OUTPUT);
  Serial.println("Run keyboard control");
  digitalWrite(VMotD, LOW);
  digitalWrite(VMotG, LOW);

  //bluetooth serial
  Serial.begin(38400);
  Serial.println("Bluetooth nunchuck esclave start");
  ArduinoMaster.begin(38400);
}






void loop() {

 while (ArduinoMaster.available() > 0 ) {
   char car = ArduinoMaster.read();
  //  while (Serial.available() > 0 ) {
     // char car = Serial.read();
//    Serial.print(car);
    switch (car) {
      case '\n':    // fin de données
        renvoi();
        execution();
        k = 0;
        break;
      case ';':     // séparateur
        k++;
        break;
      default:
        var[k] = (var[k] * 10) + (car - 48);
        break;
    }
   // delay(50);
  }
  delay(10);
}

void renvoi() {
  joyX = var[0];
  joyY = var[1];
  joyC = var[2];
  joyZ = var[3];
      Serial.print("Brut    ");
      Serial.print("joyX :");
      Serial.print(joyX);
      Serial.print("   joyY :");
      Serial.println(joyY);
      Serial.print("   joyC :");
      Serial.print(joyC);
      Serial.print("   joyZ :");
      Serial.println(joyZ);      
  for (k = 0; k < 4; k++) {
    Serial.println(var[k]);       // renvoi des valeurs reçues
    var[k] = 0;
  }
 // delay(50);
}

void execution()  {   // execution ordre recu
 // v1 = 0;
   //v2 = 0;
    int joyX1 = map(joyX, 26, 231, -255, +255);
    int joyY1 = map(joyY, 35, 226, -255, +255);
    joyX = constrain (joyX1, -255, +255);
    joyY = constrain (joyY1, -255, +255);
      Serial.print("Remappé   ");
      Serial.print("   joyX :");
      Serial.print(joyX);
      Serial.print("   joyY :");
      Serial.println(joyY);

  //Pour éviter de consommer du courant on attribue une plage neutre plus large que zéro
  if ((joyX < 32) && (joyX > -32)) {
    joyX = 0;
     Serial.print("   joyXX :");
      Serial.print(joyX);
  }

  if ((joyY < 25) && (joyY > -25)) { 
    joyY = 0;
    Serial.print("   joyYY :");
      Serial.println(joyY);
  }

  //détection du pivotement x
  if ((joyX != 0)&& (joyY == 0))  {
    p = 1;
  } else   p = 0;

 

  //calcul du sens de rotation des moteurs (attention les moteurs sont montés en miroir)
  if (p == 1) {
    if (joyX < 0) { //tourne à gauche
      smg = 0;
      smd = 0;
    } else { //tourne à droite
      smg = 1;
      smd = 1;
    }
  } else if (joyY < 0) { //recule
    smg = 0;
    smd = 1;
  } else { //avance
    smg = 1;
    smd = 0;
  }


  //calcul valeur du braquage  (amplitude du braquage)

  if (joyX < 0) {
    b = joyX * -1;
  } else {
    b = joyX;
  }

  //si pivotement (cad que le centre de rotation est entre les deux moteurs), les deux moteurs vont à la même vitesse
  if (p == 1) {
    vmg = b;
    vmd = b;
  }
  else {
    if (joyY < 0) {    //calcul de 2 vitesses v1 et v2 qui seront affectées au moteur
      
      v1 = joyY * -1;   //on calcule la valeur absolue de la vitesse moteur 1
    } 
    else { v1 = joyY; }
    Serial.print("v1 :");
    Serial.println(v1);
    Serial.print("v2 :");
    Serial.println(v2);
    v2 = v1 - (v1 * (b / 255));
    Serial.print("v1 :");
    Serial.println(v1);
    Serial.print("v2 :");
    Serial.println(v2);

// ajout ylc du 30/03/19
    /* compte tenu des moteurs (24v utilisés en 12v) il est nécéssaire de "doper" les vitesses qui leurs sont affectées
       lors des virages en affectant à la roue la plus rapide la vitesse maximale et en augmentant la vitesse de la roue
       la moins rapide dans la même proportion.           */
    float c = 255 / v1;
    v1 = 255;
    v2 = v2 * c;
// fin ajout ylc du 30/03/19
    
    // Affectation des vitesses de rotation des moteurs des moteurs selon la direction où aller (droite ou gauche)
   if ((joyX == 0) && (joyY == 0)) {
      v1 = 0;
      v2 = 0;            
    }
    if (joyX < 0) {
      vmg = v2;
      vmd = v1;
    }
    else {          
      vmg = v1;
      vmd = v2;     
    }
  
  /*  if (joyX < 0) {
      vmg = v2;
      vmd = v1;
    }
    else if (joyX > 0) {
      vmg = v1;
      vmd = v2;



      
    }
  else if ((joyX == 0)&& (joyY == 0)) {
      vmg = 0;
      vmd = 0;
      smg=0;
      smd=0;
    }
    */
    }

  Serial.print("vmg :");
  Serial.println(vmg);
  Serial.print("vmd :");
  Serial.println(vmd);
  Serial.print("p :");
  Serial.println(p);
  Serial.print("smg :");
  Serial.println(smg);
  Serial.print("smd :");
  Serial.println(smd);
  control_moteur();
}


////motor driver
void control_moteur() {        //Move forward
  analogWrite (VMotG, vmg);     //PWM Speed Control
  digitalWrite(DMotG, smg); //DMotD, direction control=p
  analogWrite (VMotD, vmd);
  digitalWrite(DMotD, smd);
}

Outils nécessaires

Coût

Délai estimé

Fichiers source

Étapes de fabrication pas à pas

Préparation du chassis

Configuration des modules bluetooth HC05 en maitre et esclave

Configuration du maitre

Configuration de l'esclave

Téléverser le code final pour le module maitre

Téléverser le code final pour le module esclave

Durée de fabrication du prototype final