Categories
Uncategorized

Ultra Sonic Radar

//this is the whole code running via Processing 3.3.6. (MicroLab-Greece)
//All parts tests carried out in Arduino IDE. The plastic parts are made via 3D printer
import processing.serial.*; //import library in order serial interface data
import java.awt.event.KeyEvent; //import library for reading data from serial port
import java.io.IOException;
Serial myPort;//defines serial object
//variable definition
String angle="";
String distance="";
String data="";
String noObject;
float pixsDistance;
int iAngle, iDistance;
int index1=0;
int index2=0;
PFont orcFont;

void setup() {
 
  size (860, 860); 

 smooth();
 myPort = new Serial(this,"COM5", 57600); //starting communication with specofic port
 myPort.bufferUntil('.'); //reads data from port delimited by '.'

}

void draw() {
 
 fill(98,245,31); 
 //simulation of moving line (motion and fade)
 noStroke();
 fill(0,4); 
 rect(0, 0, width, height); 
 fill(7,246,23);
//draws the radar calling functions
 drawRadar(); 
 drawLine();
 drawObject();
 drawText();
}

void serialEvent (Serial myPort) { //start reading data from specified port
 //reads data from port delimited by (.) and assigns them in string defined variable "data"
 data = myPort.readStringUntil('.');
 data = data.substring(0,data.length()-1);

 index1 = data.indexOf(","); //detect charachter ',' and assign it to the defined string variable 'index1'
 angle= data.substring(0, index1); // read the data from position "0" to position of the variable index1 or the value of the angle, via bluetooth, sents into the Serial Port
 distance= data.substring(index1+1, data.length()); //reads the data from index() from first to last (distance)
 //convert stings variables into integer
 iAngle = int(angle);
 iDistance = int(distance);
}

void drawRadar() {
 pushMatrix();
 translate(420,420); //moving the coordinats start
 noFill();
 strokeWeight(1);
 stroke(255,245,255);
 // draws the arc lines
  arc(0,0,860,860,0,TWO_PI);
 arc(0,0,720,720,0,TWO_PI);
 arc(0,0,580,580,0,TWO_PI);
 arc(0,0,440,440,0,TWO_PI);
 arc(0,0,300,300,0,TWO_PI);
 arc(0,0,160,160,0,TWO_PI);
 arc(0,0,20,20,0,TWO_PI);
//darw of angle lines
 line(-width/2.0,0,width/2.0,0);
 line(0,0,-width*cos(radians(30)),-width*sin(radians(30)));
 line(0,0,-width*cos(radians(60)),-width*sin(radians(60)));
 line(0,0,-width*cos(radians(90)),-width*sin(radians(90)));
 line(0,0,-width*cos(radians(120)),-width*sin(radians(120)));
 line(0,0,-width*cos(radians(150)),-width*sin(radians(150)));
 line(0,0,-width*cos(radians(180)),-width*sin(radians(180)));
 line(0,0,-width*cos(radians(210)),-width*sin(radians(210)));
 line(0,0,-width*cos(radians(240)),-width*sin(radians(240)));
 line(0,0,-width*cos(radians(270)),-width*sin(radians(270)));
 line(0,0,-width*cos(radians(300)),-width*sin(radians(300)));
 line(0,0,-width*cos(radians(330)),-width*sin(radians(330)));
 line(0,0,-width*cos(radians(360)),-width*sin(radians(360)));
 line(-width*cos(radians(30)),0,width/2.0,0);
 popMatrix();
}
 //this function draws the detected object converting the distance into pixels on screen according the angle
void drawObject() {
 pushMatrix();
 translate(420,420);
 strokeWeight(3);
 stroke(255,10,10); 
 pixsDistance = iDistance*2; //converting distance from cm into pixels
 //with (if) we define the limit range to 2meter  (200cm) ! anyone can change the limits according to sensors specifications and drwas the line converting distance into pixel
 if(iDistance<200){
   line(pixsDistance*cos(radians(iAngle)),-pixsDistance*sin(radians(iAngle)),950*cos(radians(iAngle)),-950*sin(radians(iAngle)));
  }
 popMatrix();
}
//this function draws the radar rotatable line
void drawLine() {
 pushMatrix();
 strokeWeight(6);
 stroke(10,74,250);
 translate(420,420); 
 line(0,0,950*cos(radians(iAngle)),-950*sin(radians(iAngle))); 
 popMatrix();
}
//function drawing text on screen nad its values taking from sensors
void drawText() {
 
 pushMatrix();
 
 fill(0,0,0);
 noStroke();
 rect(0, 1010, width, 600);
 textSize(15);
 fill(5,255,5);
 
 translate(640,294);
 rotate(-radians(-5));
 text("30°",0,0);
 resetMatrix();
 translate(548,200);
 rotate(-radians(-5));
 text("60°",0,0);
 resetMatrix();
 translate(420,160);
 rotate(radians(0));
 text("90°",0,0);
 resetMatrix();
 translate(292,199);
 rotate(radians(-30));
 text("120°",0,0);
 resetMatrix();
 translate(202,296);
 rotate(radians(-60));
 text("150°",0,0);
 resetMatrix();
 translate(166,422);
 rotate(radians(-90));
 text("180°",0,0);
 resetMatrix();
 translate(197,550);
 rotate(radians(-110));
 text("210°",0,0);
 resetMatrix();
 translate(292,641);
 rotate(radians(360));
 text("240°",0,0);
 resetMatrix();
 
 translate(420,677);
 rotate(radians(-360));
 text("270°",0,0);
 resetMatrix();
 
 translate(544,640);
 rotate(radians(-380));
 text("300°",0,0);
 resetMatrix();
 
 translate(641,547);
 rotate(radians(-5));
 text("330°",0,0);
 resetMatrix();
 
  translate(674,422);
 rotate(radians(-360));
 text("360°",0,0);
 resetMatrix();
 
 translate(50,50);
 rotate(radians(0));
 textSize(17);
 fill(255,103,1);
 text("MicroLab Radar",0,0);
 
 resetMatrix();
 
 if(iDistance>200) {
noObject = "Out of Range";
}
else {
noObject = "In Range";
}
fill(0,0,0);
noStroke();
rect(0, 1010, width, 1080);
fill(26,230,32);

textSize(20);
text("Object: " + noObject, 250, 50);
text("Angle: " + iAngle +" °", 500, 50);
text("Distance: ", 650, 50);
if(iDistance<200) {
text(" " + iDistance +" cm", 750, 50);
}
 
 popMatrix(); 
 
 

 }
Categories
Uncategorized

Blynk

There is an application for IoTs and it is called Blynk.

Categories
Uncategorized

CUPS – HPLIP

How to clean the history, list the details of jobs in CUPS

sudo cancel -a -x
lpstat -W all -o
lpstat -l -W all -o
Categories
Uncategorized

Pi – Home Assistant

Pihome /Home Assistant will be installed in a new home.

Home Networking can be simple and complicated as this. Therefore, please think about it before you plan your wiring. For the installation tips, it can be discussed in here.

For the Raspbian in Pi3, we need python-3.6.1 or above for setting up home assistant. Therefore, please follow this link. For my case with Raspbian, then I install it in venv.

中文設定

Categories
Uncategorized

How to set up Alexa on the Raspberry Pi 3

Solo and web control of GPIO pin

Control with web server or python or web control

Categories
Uncategorized

Wave guide for Ultrasonic Sensor (HC-SR04)

Ultrasonic level sensors work by measuring the time of flight of a sound wave. The wave must travel in a clear path to and from the top of the liquid being measured in order to provide an accurate liquid level measurement.

As with any wave, the sound pulse generated by the ultrasonic sensor does not travel in a straight line, but rather expands as a function of the distance traveled. As the wave widens, it will bounce off of anything in its path. In many cases this is not an issue, but, occasionally, conditions within the tank or vessel being measured cause sound waves to be reflected from objects or surfaces other than the intended target.

Detecting the wrong target causes inaccuracy or false readings from the sensor. Things like large weld seams, pipes, mixers, or access hatches inside tanks can present false targets to the sensor. The use of a standpipe as a waveguide for the sensor can help eliminate these problems. 

This rule of thumb gives you a pretty good indication of whether the ultrasonic transducer will work in a standpipe (or nozzle). The necessary ratio of standpipe diameter to height is 3:1. So if you have a 6″ diameter standpipe or nozzle, and it’s 18″ high, your transducer should work without problem.
And ideally, the standpipe nozzle should be cut at a 45° angle (as shown), and the standpipe side wall should be seamless and smooth.

A standpipe serves as a waveguide to focus the sound wave away from possible false targets and directly onto the desired liquid target. Any smooth-walled tube or pipe can serve as a waveguide as long as care is taken to de-burr the end of the tube and cut the end at a 45° angle. This avoids the creation of standing waves inside the tube.

Use of a standpipe may affect the maximum sensing range of the level sensor because the waveguide also serves to limit the sound energy coming back to the face of the sensor. This should be taken into consideration when applying a waveguide.

Let us know if you have any questions about using a standpipe as a waveguide for an ultrasonic sensor. Level measurement can be drastically improved when the circumstances are just right, and the standpipe is applied properly.

Categories
Uncategorized

Bluetooth Input

If you have an amplifer or speaker system, you may add an input onto it. Balena offers a solution.

Categories
Uncategorized

Quick Release Motor Mount

There are many designs in the quick released system. In general, it is a locking device to press the object with a wedge by simple mechanically forces. A hinge with lever arm or it’s combination of wedge effect.

Categories
Uncategorized

Revolutionary Air Conditioning System

Cooling of air was caused by evapouration of water via the water drops passing through materials with great surface area and then water vapor, drops or mist of water condensed back to water via chemicals.

Categories
Uncategorized

3d – printed – AntRobo

First Trial of Ultra-sonic Sensor on AntRobo

This is an AntRobo which was designed for fun. Recently, I discovered this RoboMaster from DJI.