Affichage des articles dont le libellé est Robotics. Afficher tous les articles
Affichage des articles dont le libellé est Robotics. Afficher tous les articles

lundi 14 septembre 2015

XY Plotter with LabVIEW and STM32F4



Abstract -- the aim of this project is to design and build a XY-Plotter capable of drawing computer processed images or graphs. It details design choices, high-level control processing, and the low-level control algorithms that were used with graphical interfaces programmed in LabVIEW. The control is implemented using the Stm32F4 board 

I. Project Description :
A XY-Plotter is a robot that operates in two axes of motions ("X" and "Y") in order to draw different shapes or write a text. It is composed of two special mechanisms for raising and lowering a pen. The plotter has a hole in its base where the pen goes through. It is designed to print on either paper or any surface such as a wall. The plotter should simply be placed against the surface and the pen will draw away through the hole. Each axis is powered using a single stepper motor and belt. But, is that all what a XY-Plotter can do? Definitely not! It may be useful for young children or persons suffering from writing disabilities, such as having a broken hand; they can write using their smartphones by simply dictating texts. Modulo small changes, it can be used to place electronic components on a Printed Circuit Board (PCB).

a.High-level architecture
The figure below summarized the overall architecture of the XY-Plotter . Indeed, the user can select ether he needs to draw a mathematical curve or extract the shapes from a given picture. An additional interface simulates the robot movement (with adjustable speed) and visualizes the real-time behavior of the robot

b.XY-Plotter Mechanics
To minimize the costs, we decided to realize the XY-Plotter using two old printers. It was very difficult to adapt all the parts and have a good precision. these figures shows some different steps to build and assemble the different parts of the robot.

c. Canny Edge interface
To simplify the use of our plotter, the software application was divided into three interfaces that will be detailed in this section. This interface allows the upload of an image file, extract the shapes of the features it contains and returns the set of their coordinates as text file. This requires of course to go through several steps:
In the first step (reading the image file), the image file is opened using IMAQ ReadFile . The file format can be a standard format (BMP, TIFF, JPEG, JPEG2000, PNG, and AIPD) or a nonstandard format already defined by the user. In all cases, the read pixels are converted automatically into the image type passed by.
The second step is the shape detection. After getting the picture, we invoke the IMAQ CannyEdgeDetection, which uses a specialized edge detection method to accurately estimate the location of edges even under conditions of poor signal-to-noise ratios.
The result is a binary image. It represents a black & white converted image that can be reproduced by the robot using black ink on white paper. It is worth mentioning here that the details level of detected edges is tuneable through the use of a user fixed threshold value.
The final step is the generation of the edge points coordinates. To find the number of edge segments in an image and get the coordinates of the pixels in each segment, we used the IMAQ GetPointsOnContour function. It joins adjoining edge pixels into edge segments.
The image bellow  shows an example of segment information after detecting the Edge and generating coordinate of contour points

As aforementioned, the final job for this interface is to return a text file containing all the coordinates of the detected contour points. 




d. Curve drawer interface
As defined in the NI-LabVIEW documentation, the XY-graph is a general-purpose, Cartesian graphing object that plots multivalued functions, such as circular shapes or waveforms with a varying time base. The XY-graph displays any set of points, evenly sampled or not.
This graphing object will be used along with the LabVIEW formula interpreter supporting the standard mathematical operators (" + ", " - " , " * ", "/ ") and a very large number of mathematical functions (trigonometry functions, logarithm and exponential functions and random numbers generators).
These two LabVIEW objects are two key components for our XY-Plotter. In fact they allow us draw and visualise several plots right before printing them. They both form our so called “Curve drawer interface”


E. Printer interface and 3D-model
The XY plotter GUI shown in figure below allows the user to see a preview and reel time impression with 3d model.
After confirming , the command are send via serial connection.
the serial port would have to be selected properly for appropriate communication between computer and microcontroller. Once the communication was established, the computer was ready to send information to the microcontroller.
The idea is to send a command and wait until the device respond with ‘ok’

II.EXAMPLE OF USES :
A.drawing on paper :
We present here a simple test of our realized robot. It represents a complete built, realized and tested system. As shown in the figure, we succeeded in printing the logo of National Instrument and an arbitrary character.

B.Laser Engraver example
This robot can be easily upgraded to Laser Engraver by adding a 500mW laser engraver


In the image bellow, a list of suggested materials that can be used to engrave with laser is given, that are: wood board, colorful paper cards, dark opaque acrylic, etc. Besides, the list of possible cutter material include among others: colourful paper cards, foam papers, etc.


C.PCB example
Milling a PCB is not an easy task, especially when it is homemade, so with this robot we can add a sharp tools attached to a high performance motor  to make our PCB  more easily , faster , with high accuracy 
After uprating the XY Plotter. The CannyEdge interface do the job by extracting all the path. The Robot can print circuit-traces directly on to a carrier board
 

IIi.Other software Version using Qt
This version is under developing:






 
References
   [1]    J. TRAVIS and J. KRING. “LabVIEW for Everyone: Graphical Programming Made Easy and Fun”, National Instruments Virtual Instrumentation Series. Prentice Hall PTR, 2006.
   [2]     (2012) The Mantis robot website. [Online]. Available: http://www.mantisrobot.com/
   [3]    BLUETOOTH, S. I. G. Specification of the Bluetooth System, version 1.1. http://www. bluetooth. com, 2001.


Team members
This project is realized by Nidhal Mars, an engineering student at ENSI, “Embedded Software and Systems” specialization. It is supervised by Dr.-Ing.Mohamed Amine Abid (Researchgate / Linkedin) and Dr.-Ing.Chadlia JARAD (Researchgate / Linkedin) , associate professors at ENSI.



jeudi 10 septembre 2015

Using ultrasonic Sensor with Arduino and Stm32


1. What is an Ultrasonic Distance Sensor ?  




Ultrasonic Sensor is a popular and low cost solution for non-contact distance measurement function. It is able to measure distances from 2cm to 400cm with an accuracy of about 5mm. This module includes ultrasonic transmitter, ultrasonic receiver and its control circuit. it can be used with all most micro-controller .
HC-SR04/5 module has 4 pins :

  • VCC – 5V of the power supply
  • TRIG – Trigger Pin
  • ECHO – Echo Pin
  • GND – to ground 
TRIG and ECHO pins can be used to interface this module with a microcontroller unit.

2. How Does an Ultrasonic Sensor Work?

- Ultrasonic sensor principle
Ultrasonic sensors emit short, high-frequency sound pulses at regular intervals. These propagate in the air at the velocity of sound. If they strike an object, then they are reflected back as echo signals to the sensor, which itself computes the distance to the target based on the time-span between emitting the signal and receiving the echo.


 
- Interfacing with microcontroller 
  1. Provide TRIGGER signal, at least 10μS High Level (5V) pulse.
  2. The module will automatically transmit eight 40KHz ultrasonic burst.
  3. If there is an obstacle in-front of the module, it will reflect the ultrasonic burst.
  4. If the signal is back, ECHO output of the sensor will be in HIGH state (5V) for a duration of time taken for sending and receiving ultrasonic burst. Pulse width ranges from about 150μS to 25mS and if no obstacle is detected, the echo pulse width will be about 38ms.  
- How to Find the Range of Target ?

The image bellow explain how to calculate the range.



3. How to use it with Arduino or Stm32 : 

- Wire connection and code for Arduino
-  VCC pin to the Arduino 5v
-  GND pin to the Arduino GND
- TRG pin to the Arduino Digital pin 12
-  ECHO pin to the Arduino Digital pin 11
the code example : (source : arduinobasics.blogspot.com)
/*
 HC-SR04 Ping distance sensor:
 VCC to arduino 5v 
 GND to arduino GND
 Echo to Arduino pin 11 
 Trig to Arduino pin 12
 */


#define echoPin 11 // Echo Pin
#define trigPin 12 // Trigger Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}

void loop() {
/* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */ 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 
 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;
 
 if (distance >= maximumRange || distance <= minimumRange){
 /* Send a negative number to computer and Turn LED ON 
 to indicate "out of range" */
 Serial.println("-1");
 digitalWrite(LEDPin, HIGH); 
 }
 else {
 /* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */
 Serial.println(distance);
 digitalWrite(LEDPin, LOW); 
 }
 
 //Delay 50ms before next reading.
 delay(50);
}
wire connection and code for Stm32f4 
-  VCC pin to the stm32f4 5v
-  GND pin to the
stm32f4 GND
- TRG pin to PD10

-  ECHO pin to PD11
You can get all project from my git account HERE 

 
#include "stm32f4_discovery.h"
#include "delay.h"

uint32_t Read_Distance(void);
void Init();

uint32_t distance ;

int main()
{  
    Init();   // initialisation de pin
    SysTick_Init(); // pour pouvoire utiliser la fonction delay :)

    while (1)
    {
    distance=Read_Distance();
    delay_nms(100);
    }
}


void Init()
{
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

    GPIO_InitTypeDef gpioStructure;
       
    gpioStructure.GPIO_Pin = GPIO_Pin_10;
    gpioStructure.GPIO_Mode = GPIO_Mode_OUT;
    gpioStructure.GPIO_Speed = GPIO_Speed_100MHz;
    GPIO_Init(GPIOD, &gpioStructure);
    
    gpioStructure.GPIO_Pin = GPIO_Pin_11;
    gpioStructure.GPIO_Mode = GPIO_Mode_IN;
    GPIO_Init(GPIOD, &gpioStructure);
}
//Les Pins pour le Test sont PD10 (Trig) et PD11(echo) 

uint32_t Read_Distance(void)
{
          __IO uint8_t flag=0;
           __IO uint32_t disTime=0;
    GPIO_SetBits(GPIOD,GPIO_Pin_10);
    delay_nus(10);
    GPIO_ResetBits(GPIOD,GPIO_Pin_10);

  while(flag == 0)
  { 
   while(GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_11) == SET)
   {
     disTime++;
     flag = 1;
   }
  
  }
    return disTime;
}
    

mercredi 9 septembre 2015

Top 4 Stm32 , Arduino and Raspberry Pi Sensors


 May be you are new in embedded system world , this article will help you to know the most popular sensors that you can use in your projects . these sensors are very helpful and can give you many ideas of robotic projects .

1.Line follower module
Line follower module based on the optical reflector TCRT5000 and LM393 amplifier. It connects to a digital input of an Arduino or compatible card. it is very useful for Robots and you can use it also on analog mode .


2. Ultrasonic sensor 
 If you are building an autonomous robot you should have this sensor . it is super easy to use with just 3 pins. 5V, GND and Signal. The effective range is from about 2 centimeters to 300 centimeters . you can find HERE an article about it .



3. Motion sensor 
A motion detector is a device that detects moving objects, particularly people. A motion detector is often integrated as a component of a system that automatically performs a task or alerts a user of motion in an area. Motion detectors form a vital component of security, automated lighting control, home control, energy efficiency, and other useful systems.

 

4. Flex sensor
When you need to detect a flex, a flex sensor is the most helpful part for you. As the sensor is flexed, the resistance across the sensor increases. It is great for detecting how much fingers are bent . 
Here is simple example of uses :