15 กล้องความร้อน Arduino
อุปกรณ์ทำงานโดยการกวาดตารางคะแนนและรวบรวมภาพชิ้นส่วน เอาท์พุทประกอบด้วยสองภาพ: 1) ภาพอะคูสติกที่บอกระยะทางไปยังวัตถุในมุมมองและ 2) ภาพความร้อนที่ให้อุณหภูมิของวัตถุในมุมมอง ฉันใช้ gnuplot เพื่อประกอบภาพ ดูสคริปต์ด้านล่าง
ฉันวางแผนที่จะใช้ Finder ช่วงเพื่อกำหนดขนาดจุดของเครื่องอ่าน IR ขนาดจุด spot โดย dh_o / dL = 2sin (5) ตำแหน่ง dh_o คือการเปลี่ยนแปลงเส้นผ่านศูนย์กลางจุดและ dL คือการเปลี่ยนระยะห่างจากเซ็นเซอร์ไปยังวัตถุ ห้าเป็นค่าคงที่ตามมุมมอง 5degree ของเซ็นเซอร์ IR
ฉันได้รับแนวคิดสำหรับโครงการจากเว็บไซต์นี้: http://www.cheap-thermocam.tk/
รายชื่อวัสดุ:
- Arduino ( http://www.sparkfun.com/products/9950 )
- ฮาร์ดแวร์ Pan / Tilt ( http://www.sparkfun.com/products/10335 )
- เซอร์โว 2x, ปานกลาง ( http://www.sparkfun.com/products/10333 )
- 1 "คณะกรรมการ Square Cicuit (sparkfun)
- เลเซอร์ ( http://www.sparkfun.com/products/594 )
- เลเซอร์เมาท์ ( http://www.sparkfun.com/products/8674 )
- ค้นหาช่วงความถี่อัลตราโซนิก - XL-Maxsonar EZ2 ( http://www.sparkfun.com/products/9493)
- Ir Sensor, 5FOV (http://www.futureelectronics.com/en/Technologies/Product.aspx?ProductID=MLX90614ESFDCIMELEXIS3003055 )
- สายไฟที่เป็นของแข็ง (Radioshack)
- ตัวต้านทานโอห์ม 2 เท่า 4.7k (Radioshack)
- ตรึงให้คณะกรรมการ (Radioshack)
- Photobox พลาสติก (Hobbylobby)
ความก้าวหน้าของการประกอบ:
- ประกอบ Pan / Tilt ด้วยเซอร์โว ใช้เซอร์โวที่มีขนาดปานกลางเนื่องจากมีขนาดเล็กมากเกินไปภายใต้ torqued สำหรับการดำเนินการเอียง (สังเกต jerkyness ในวิดีโอ) เซอร์โวต้อง 5V
- แนบตัวแปลงสัญญาณอัลตร้าโซนิคกับบอร์ดโปรโตรโดยวางสายผ่านรูและการบัดกรีทั้งสองด้าน (หลุมควรจัดให้อยู่บนบอร์ดทั้งสองข้าง) วางตำแหน่งเซนเซอร์อัลตราโซนิคไว้ตรงกลางของเมนบอร์ดเพื่อให้เซ็นเซอร์ ir ตรงกับศูนย์กลางของเซ็นเซอร์อัลตราโซนิก
- ติดตั้งเลเซอร์ติดกับ Pan / Tilt ฮาร์ดแวร์เพื่อให้ทั้งสองด้านของรูติดตั้งด้านขวาอยู่ด้านบนเพื่อเชื่อมต่อบอร์ด ฉันใช้สกรูที่เหลือจากเซอร์โวในการเชื่อมต่อเลเซอร์เมาท์ ฉันเจาะหลุมแรกที่มีขนาดเล็กกว่าเส้นผ่านศูนย์กลางเกลียวเล็กน้อย
- ผลักเลเซอร์ลงในเลเซอร์ติดทุกทาง หยุดและยุ่งกับเลเซอร์และแอ็พพลิเคเซอร์โวแบบง่ายๆ
- ตอนนี้ใช้สายไฟ 3V และสาย GND เพื่อออกจากสายพิเศษ ตัวแปลงสัญญาณแบบอัลตราโซนิคสามารถใช้ 3V หรือ 5V (ความละเอียดดีกว่า 5V) เซ็นเซอร์ IR สามารถใช้เวลา 3V เท่านั้น การสร้างของฉันใช้ 3V สำหรับทั้ง ir และ sonar
- ตอนนี้วาง senator ในอย่างระมัดระวังและเพียงแค่การประสานนำไม่ตัดแต่ง เรียกใช้ตัวต้านทานโอห์ม 4.7K ของคุณจากพลังงานไปยังด้านตรงข้ามของบอร์ดเหนือเซนเซอร์ ir
- ตอนนี้ฟอร์มการเชื่อมต่อระหว่างกันบนกระดาน
- เพิ่มสายไฟสามสายจากบอร์ดไปที่ arduino มีหนึ่งสำหรับเซ็นเซอร์อัลตราซาวด์และสองสำหรับเซ็นเซอร์ ir
- ติดเซ็นเซอร์เข้ากับที่ยึดเลเซอร์ ใช้รูที่ให้มากับที่ยึดเลเซอร์ ฉันยังใช้สกรูพิเศษจากเซอร์โวและเจาะรูที่ตรงกับบอร์ดเซนเซอร์ เป็นสิ่งสำคัญที่ทุกอย่างเป็นรูปสี่เหลี่ยม
- เชื่อมต่อสายเลเซอร์เข้ากับสายไฟ 3V (สายสีแดง) และ GND (สีขาว)
- เชื่อมต่อสายไฟสองเส้นและสายข้อมูลสามเส้นเข้ากับบอร์ดระดับกลาง (มีหนึ่งอันจากตู้วิทยุและตัดให้ครึ่งหนึ่งด้วยเลื่อยสายพาน) บอร์ดระดับกลางนี้จะอนุญาตให้คุณเปลี่ยนไปใช้หมุด arduino ฉันเพิ่มส่วนหัวของตัวผู้ (3 พิน) ลงในบอร์ดระดับกลางเพื่อรับขั้วต่อเซอร์โว ดังนั้นถ้าฉันเป่า servo ฉันไม่จำเป็นต้องประสานอีกครั้ง
- เมื่อใช้กระดานกลางคุณสามารถสร้างพื้นดินทั่วไปได้
- ตอนนี้ปรับเปลี่ยนกล่องภาพพลาสติกที่จะยอมรับเซอร์โวที่ด้านบนและสายที่จะมาถึงด้านบน ฉันพบจุดศูนย์กลางของด้านบนและตรวจสอบขนาดของเซอร์โวที่ด้านบนและเจาะรูและเอาออกจากรู จากนั้นฉันเจาะหลุมบางส่วนเพื่อยึดเข้ากับพลาสติกโดยใช้ฮาร์ดแวร์สำหรับติดตั้งบนเซอร์โว นอกจากนี้ฉันตัดส่วนสี่เหลี่ยมออกจากด้านข้างเพื่อยอมรับ USB และพลังงาน ฉันวาง arduino ไว้ในตู้และตรวจสอบรูปทรงทั่วไปและใช้อีกครั้งเพื่อรับมือกับการเลื่อย
- ฉันเพิ่ม standoffs ที่ด้านล่างของ arduino ของฉันและเพียงแค่ร้อนติดกาวยืนไม่ชอบกับสิ่งที่แนบและด้านล่างของ arduino
- ตอนนี้ฟีดสายไฟจากเซนเซอร์ผ่านรูไปยังบอร์ดระดับกลางและตัวประสาน นอกจากนี้ยังเพิ่มสายบนกระดานกลางเพื่อเชื่อมต่อกับ arduino
- ฉันเพิ่มกาวร้อนเข้ากับสายไฟ arduino เพื่อให้แน่ใจว่าไม่ได้ดึงออก
- ตอนนี้ปิดทุกอย่างขึ้นและเพิ่มกาวร้อนบางส่วนที่ขอบของกรงเพื่อให้ทุกอย่างเข้าด้วยกัน
- เสียบ USB และเปิดเครื่องและอัปโหลดโค้ดต่อไปนี้
รหัส Arduino:
โปรแกรมจะไม่เริ่มทำงานจนกว่าคุณจะเปิดการเชื่อมต่อแบบอนุกรมและกด '1' และ Enter จากนั้นจะร่างพื้นที่ที่น่าสนใจ หากต้องการดำเนินการต่อให้กด '1' และป้อนอีกครั้ง Arduino จะเริ่มเก็บข้อมูลในอาร์เรย์ 2 มิติที่จะส่งออกไปยังหน้าจอเมื่อเสร็จสิ้น
//Arduino Thermal Camera
#include <i2cmaster.h>
#include <Servo.h>
Servo mvert;
Servo mhorz;
// Pins: 7=sonar; 4&5=ir sensor; 8=vert servo; 9=horz servo
//
//
//
const int pwPin = 7;
const int dev = 0x5A<<1;
long count = 0;
///Servo Ranges
int home_p = 0;
int j_done = 0;
int even = 0;
int xskip = 1;
int yskip = 1;
int xstart = 60;
int xstop = 75;
int ystart = 80;
int ystop = 70;
const int xnum = abs(xstart-xstop)+1;
const int ynum = abs(ystart-ystop)+1;
double therm[16][11];
double acous[16][11];
void setup(){
//sonar pin
pinMode(pwPin, INPUT);
//Servo pins
mvert.attach(8);
mhorz.attach(9);
//Home position servos
mvert.write(xstart); //1485
mhorz.write(ystart); //1530
Serial.begin(9600);
Serial.println("Setup...");
i2c_init(); //Initialise the i2c bus
PORTC = (1 << PORTC4) | (1 << PORTC5);//enable pullups
}
void loop(){
int i,j,jt;
int hpos,vpos,hpos2,vpos2;
double tempData1 = 0x0000; // zero out the data
double sonrData1 = 0x0000;
if(Serial.available()){
if(home_p == 0){
i = 0;
Serial.flush();
Serial.println("Sweeping Viewing Space");
Serial.println("Enter 1 to confirm space");
mvert.write(ystart);
mhorz.write(xstart);
delay(30);
do
{
//This will sweep through window of view
for(int hpos=xstart;hpos<=xstop;hpos++){
mvert.write(ystart);
mhorz.write(hpos);
delay(20);
}
for(int vpos=ystart;vpos>=ystop;vpos--){
mvert.write(vpos);
mhorz.write(xstop);
delay(20);
}
for(int hpos=xstop;hpos>=xstart;hpos--){
mvert.write(ystop);
mhorz.write(hpos);
delay(20);
}
for(int vpos=ystop;vpos<=ystart;vpos++){
mvert.write(vpos);
mhorz.write(xstart);
delay(20);
}
i=Serial.read();
}while (i<=0);
Serial.println("Starting Calculation");
home_p=1;
}
if(j_done == 0){
for(int i=ystart;i>=ystop;i-=yskip){
for(int j=xstart;j<=xstop;j+=xskip){
if(even == 0){
jt = j;
mhorz.write(j);
delay(20);
}
else{
jt=xstop-(j-xstart);
mhorz.write(jt);
delay(20);
}
sonrData1 = readSonar(1);
tempData1 = readMLX(1);
//58uS per cm
double cm = sonrData1;
double celcius = tempData1 - 273.15;
//double fahrenheit = (celcius*1.8) + 32;
//Serial.print("temp,dist,i,j: ");
//Serial.print(celcius);
//Serial.print(", ");
//Serial.print(cm);
//Serial.print(", ");
//Serial.print(ystart-i);
//Serial.print(", ");
//Serial.println(xstop-jt);
//Serial.print("Fahrenheit,inches: ");
//Serial.println(fahrenheit,inches);
therm[xstop-jt][ystart-i] = celcius;
acous[xstop-jt][ystart-i] = cm;
delay(400); // wait a second before printing again
}
mvert.write(i);
delay(20);
if(even == 0){
even = 1;
}else{
even = 0;
}
}
//Output data
Serial.println("Outputting Data");
for(int j=0;j<ynum;j++){
for(int i=0;i<xnum;i++){
Serial.print(therm[i][j]);
Serial.print(", ");
Serial.print(acous[i][j]);
Serial.print(", ");
Serial.print(i);
Serial.print(", ");
Serial.println(j);
Serial.flush();
}
Serial.println(" ");
}
j_done = 1;
}
}}
double readMLX(int Tt) {
int data_low = 0;
int data_high = 0;
int pec = 0;
i2c_start_wait(dev+I2C_WRITE);
i2c_write(0x07);
// read
i2c_rep_start(dev+I2C_READ);
data_low = i2c_readAck(); //Read 1 byte and then send ack
data_high = i2c_readAck(); //Read 1 byte and then send ack
pec = i2c_readNak();
i2c_stop();
//This converts high and low bytes together and processes temperature, MSB is a error bit and is ignored for temps
double tempFactor = 0.02; // 0.02 degrees per LSB (measurement resolution of the MLX90614)
double tempData = 0x0000; // zero out the data
int frac; // data past the decimal point
// This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
tempData = (double)(((data_high & 0x007F) << 8) + data_low);
tempData = (tempData * tempFactor)-0.228;
return tempData;
}
double readSonar(int St) {
long pulse;
//Used to read in the pulse that is being sent by the MaxSonar device.
//Pulse Width representation with a scale factor of 147 uS per Inch.
pulse = pulseIn(pwPin, HIGH);
double sonrData = (double) ((pulse)/58.0);
return sonrData;
}
Gnuplot code:
I will fix this but for now copy and paste the data outputted to the screen from the code above to a file called data.txt. It is the temperature in celcius, distance in cm and x-y coordinate. Now create another file call _plot.gnu and paste the code below into that file. Then execute the gnuplot script by typing gnuplot ./_plot.gnu . Make sure the data.txt and _plot.gnu are in the same folder.
If you have a fancier way to plotting the data send me a comment.
set term postscript enhanced color
set pm3d map
set size square
set title 'Thermal Image'
set output "thermal.eps"
splot 'data.txt' using 4:3:1 title 'Celcius'
set title 'Acoustic Image'
set output "sonar.eps"
splot 'data.txt' using 4:3:2 title 'Cenimeters'
ความคิดเห็น
แสดงความคิดเห็น