Kicad : étaler les empreintes.

Un petit tutoriel pour étaler les empreintes lors de la toute première phase du routage d’un circuit imprimé.

  • Après avoir lu la netlist, vous obtenez tous les composants réunis dans un même bloc :

img1

  • Cliquer sur le bouton “Mode empreinte”:

img2

  • Ensuite, clic droit sur les composants:

img3

  • Étalements de toutes les empreintes:

img4

Voilà, fin du tuto.

 

Lecture des capteurs de sols

Dans ce tutorial vous allez apprendre à utiliser les 3 capteurs de sols du robot MRduino afin de faire du suivi de ligne.

Les capteurs de sols

Le robot MRduino est équipé de 3 capteurs de sols, ils sont situés à l’avant.

Lire un capteur

La fonction pour lire le capteur de sol n°1 du robot :

value = groundSensor(1)
  • La fonction renvoie une valeur entre 0 et 4095.

Exemple de programme pour lire les 3 capteurs :

#include <mrduino.h>

void setup() 
{
  Serial.begin(115200);

}

void loop()
{
int capteur1, capteur2, capteur3;

 capteur1 = groundSensor(1);
 capteur2 = groundSensor(2);
 capteur3 = groundSensor(3);

 Serial.println(capteur1);
 Serial.println(capteur2);
 Serial.println(capteur3);

 delay(1000);

}

 

Partie 2 : Contrôle du robot MRduino Wireless par UDP

Un tutoriel pour contrôler le robot MRduino Wireless par UDP avec un programme python.

UDP = User Datagram Protocol

MRduino-wireless_UDP

Le contrôle du robot est réaliser par un programme en langage python.

Le programme pour le robot

Ce programme permet au robot MRduino Wireless de

Il faut modifier votre SSID et mot de passe de votre réseau Wifi :

const char* ssid = "YOUR_SSID";  
const char* pass = "YOU_PASSWORD";  

Le programme complet :

#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
#include <mrduino.h>

static void read_receptionCommande(String Commande);

int status = WL_IDLE_STATUS;
const char* ssid = "YOUR_SSID";  //  your network SSID (name)
const char* pass = "YOUR_PASS";       // your network password

unsigned int localPort = 12345;  

WiFiUDP Udp;
int tries=0;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);

  // setting up Station AP
  WiFi.begin(ssid, pass);
 
  // Wait for connect to AP
  Serial.print("[Connecting]");
  Serial.print(ssid);
  
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
    tries++;
    if (tries > 30)
    {
      break;
    }
  }
  Serial.println();

  printWifiStatus();

  Serial.println("Connected to wifi");
  Serial.print("Udp server started at port ");
  Serial.println(localPort);
  Udp.begin(localPort);
}

void loop()
{
int noBytes = Udp.parsePacket();
String received_command = "";
byte packetBuffer[512]; 

  if ( noBytes )
  {

    Serial.print("received a packet");

    // We've received a packet, read the data from it
    Udp.read(packetBuffer,noBytes); // read the packet into the buffer

    for (int i=1;i<=noBytes;i++)
    {
      received_command = received_command + char(packetBuffer[i - 1]);
    } // end for
   
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.endPacket();

    // execution de la commande
    Serial.println(received_command);

  } // end if
}

void printWifiStatus() 
{
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
} 

  • Compiler et télécharger le programme dans le robot MRduino Wireless

Le programme de contrôle

  • Lien pour télécharger le programme de contrôle (dossier Zip): MrduinoControler

Remarque : programme pour Windows

  • Dézipper le dossier :

dossier

  • Lancer le programme MRduinoControler.exe

Controler

Ce programme permet de contrôler les mouvements du robot et les trois leds. Ne pas oublier de saisir l’adresse IP correct du robot.

 

 

Configuration Wifi de la carte Pi Zero W

Article pour la configuration de la communication Wifi de la carte Pi Zero W en ligne de commande.

Version Raspian : April 2017 (Raspian Jessie Lite)

  • Ouvrir avec le terminal le fichier wpa_supplicant.conf :
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
  • Modifier ce fichier comme ci-dessous :
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
    ssid="YOUR_SSID"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}
  • Enregistrer et redémarrer votre carte Raspberry Pi:
sudo reboot

Contrôle du robot MRduino Wireless par UDP

Un tutoriel pour contrôler le robot MRduino Wireless par UDP avec un programme python.

UDP = User Datagram Protocol

MRduino-wireless_UDP

Le contrôle du robot est réaliser par un script en langage python.

Le programme pour le robot

Ce programme permet au robot MRduino Wireless de

Il faut modifier votre SSID et mot de passe de votre réseau Wifi :

const char* ssid = "YOUR_SSID";  
const char* pass = "YOU_PASSWORD";  

Le programme complet :

#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
#include <mrduino.h>


int status = WL_IDLE_STATUS;
const char* ssid = "FREEMR";  
const char* pass = "WIFINICO";       

unsigned int localPort = 12345;  
byte packetBuffer[512]; 
WiFiUDP Udp;
int tries=0;

void setup()
{

  Serial.begin(115200);

  // wifi init
  WiFi.begin(ssid, pass);
 
  Serial.print("[Connecting]");
  Serial.print(ssid);
  
  // wait connexion
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
    tries++;
    if (tries > 30)
    {
      break;
    }
  }
  Serial.println();

  printWifiStatus();

  // wifi connexion
  Serial.println("Connected to wifi");
  Serial.print("Udp server started at port ");
  Serial.println(localPort);
  Udp.begin(localPort);
}

void loop()
{
int noBytes = Udp.parsePacket();
String received_command = "";
 
  if ( noBytes )
  {
    // read UDP packet
    Udp.read(packetBuffer,noBytes);

    for (int i=1;i<=noBytes;i++)
    {
      received_command = received_command + char(packetBuffer[i - 1]);
    }
   
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.endPacket();

    // print command
    Serial.print("COMMANDE =");
    Serial.println(received_command);

  }
}

void printWifiStatus()
{

  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());


  IPAddress ip = WiFi.localIP();

  Serial.print("IP Address: ");
  Serial.println(ip);
}
  • Compiler et télécharger le programme dans le robot MRduino Wireless

 

Le script python

Voici un script python pour envoyer une commande au robot :

  • Exemple avec la commande pour allumer la led n°1 :
import socket
UDP_IP_ADDRESS = "192.168.0.20"
UDP_PORT_NO = 12345

Message = "#LED,1,1!"

clientSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

clientSock.sendto(Message, (UDP_IP_ADDRESS, UDP_PORT_NO))
  • Exemple avec la commande pour faire avancer le robot  :
import socket
UDP_IP_ADDRESS = "192.168.0.20"
UDP_PORT_NO = 12345

Message = "#MF,20!"

clientSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

clientSock.sendto(Message, (UDP_IP_ADDRESS, UDP_PORT_NO))

Creative Commons License