Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 19573|回復: 31
打印 上一主題 下一主題

EZ1超音波連接運用在ARDUINO上大問題!

[複製鏈接]
跳轉到指定樓層
1#
發表於 2011-9-16 19:24:18 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
本帖最後由 yao412030 於 2011-9-16 19:32 編輯

小弟我的專題是運用EZ1兩顆超音波和ARDUINO做防碰撞自走車,我超音波裝置電源有和馬達分開用
現在我遇到一個很大的問題就是兩顆超音波同時工作時會出現干擾...輸出的類比值非常不穩定
數值會突然降低又拉上去
而我用單一顆超音波就不會有這個問題,我現在的接法是GND +5V AN直接拉ARDUINO
現在的問題就是兩顆同時工作會出現干擾造成我的車明明前面沒障礙物他就是會自己左右亂轉...
想請問這邊的神人有沒有辦法可以解決我的問題阿??
是否可以提供我兩顆EZ1串接同時使用時可以正常運作不互相干擾的電路圖或接法呢??
這個問題我已經卡了3個月了還是無解
真的是拜託大家幫幫我!!
謝謝!
nichal 該用戶已被刪除
2#
發表於 2011-9-17 07:16:12 | 只看該作者
把一顆石頭丟在水裡
水的漣漪遇到物體邊緣會產生反射漣漪
所以收到反射波就知道哪邊有障礙物

ok
那如果丟兩個石頭下去
還沒碰到障礙物就撞在一起的發射波
你會如何處理呢?
朝這個方向思考看看吧!!

如果是我
我可能會一次丟一個石頭就好
等上一個漣漪不見了
再丟下一個.....
不過丟石頭的位置可以不一樣
隨我高興~~~

試著用一個臉盆裝水
裡面直立幾根棒子 (模擬接收器的位置)
然後丟彈珠在水裡 (模擬發射器的波形)
觀察一下水波撞到棒子前的動作現象
應該可以找到很多想法.......
3#
發表於 2011-9-17 20:31:28 | 只看該作者
本帖最後由 vegewell 於 2011-9-17 20:39 編輯

仔細看這裡有調整的軟體可下載 及How can I use more than one MaxSonar®-EZ1
in the same system?


http://www.maxbotix.com/tutorials.htm#What_are_the_differances_between_the_Original_MaxSonar_EZ1_and_the_LV_MaxSonar_EZ1
=====================================
How can I chain multiple MaxSonar® sensors together?
There are multiple ways to use the sensors without interference.  Three ways are described below.

Daisy Chaining using a Commanded Loop

Figure 6.5.


To chain the sensors, and have them operate in sequential daisy-chained fashion, you do so by linking the TX of unit 1 to RX of unit 2 and so on.  The BW pin is tied high on all of the parts.  Then just strobe the first sensor's RX pin and all of the sensors will read the range in sequence.  The analog values can then be read. The example in Figure 6.5 would use one pin to command the chain, and three analog to digital inputs. Please click the link to the download the  PDF file.Commanded Loop PDF File

Daisy Chaining with Constantly Looping


Figure 6.6.

If you want them to keep running and constantly loop and always provide the latest range reading you will have to do two things.



First, add a resistor between the last sensor's TX back to the Rx of the first unit through a 1K resistor as shown in Figure 6.6.

Second, you will have to "kick start" them, (at least 250mS or more after power is applied to the sensors to give the sensors this time to boot-up).  To do this, pull the RX pin high on the first sensor for at least 20uS.  Then controller will have to return it's pin to a high impedance state so that the next time around the TX output from the last sensor will make it's way to the RX of the first sensor.  Then all of the sensors in the chain will run in sequence.  This "ring of sensors" will cycle around and around, constantly maintaining the validity of their analog values.  You can then read the latest range reading (i.e. the analog value) at any time.  This is the easiest way to use them.


After pulling the RX pin low,  you can read the analog pin about 50mS (100mS if this is the first time reading the sensor as it calibrates upon the first commanded range cycle after power up, i.e. the sensor must complete a range cycle). In addition, the most recent range reading is always ready to be read on the analog voltage pin, so once you start the chain, and if you are using it in continuous mode,  you can read the values at any time. Please click the link to download the PDF file. Constantly Looping PDF File




Simultaneous Operation


Figure 6.7.


You can also run them all at the same time (and for some uses this is preferred as the measurement speed is maximum, but it is only for selected applications).   Just tie all of the RX pins together and command them with a pin from your microcontroller as shown in figure 6.7.  Hold the pin high for more than 20uS.  Do not continuously leave this pin high, as then all of the sensors will free run as described above.  Command the sensors every 50mS or whenever a new range reading is desired. Please click the link to download the PDF file. Simultaneous Operation PDF File
nichal 該用戶已被刪除
4#
發表於 2011-9-17 21:46:51 | 只看該作者
V大提供的連結很讚唷~~~
5#
 樓主| 發表於 2011-9-17 22:07:18 | 只看該作者
回復 3# vegewell
V大您好....你PO這個東西小弟我之前就有找到了....
只是這三種方式我不太清楚用哪一個,我現在認為應該是用Simultaneous Operation
他那個電路圖有幾條線我真的搞不懂要怎麼接才好...
他的RX線是串聯EZ1  AN旁邊寫Wire AN to an AD input
和BW旁邊寫Wire BW to Logic High我就真的看不懂他到底要我接哪條線
可否請V大幫幫我....
我昨天去問專題老師還被罵說我沒做功課....我猜他也不會
只能請教神人們,幫幫小弟我吧!!!
6#
發表於 2011-9-18 19:20:31 | 只看該作者
本帖最後由 vegewell 於 2011-9-18 21:23 編輯

這裡有人用四個, 放置 前 後 左 右不同方向,
http://www.ecs.umass.edu/ece/sdp/sdp11/soules/files/mdr_draft.pdf
你有沒有試過不同方向?
另外他們使用 LV-MaxSonar-EZ1 不是MaxSonar-EZ1,
我再多看看,知道再提供意見,
這裡只有 nichal大 比較像似可愛的神人,
nichal大會解釋得很清楚,難不倒他的.
7#
發表於 2011-9-18 21:28:03 | 只看該作者
回復 5# yao412030
這裡有很詳細的說明(6 SENSORS):
http://arduino.cc/forum/index.php?topic=66765.0

請仔細看過後,有問題再逐一的提出,

下圖除了藍色線有問題外, 其餘的就照著做看看

    http://s3.amazonaws.com/twitpic/photos/full/349405101.png?AWSAccessKeyId=AKIAJF3XCCKACR3QDMOA&Expires=1316352760&Signature=%2FZbA6RpkjFafVqfZYKZQo%2BMtY2E%3D
8#
 樓主| 發表於 2011-9-18 21:57:25 | 只看該作者
回復  yao412030
這裡有很詳細的說明(6 SENSORS):


請仔細看過後,有問題再逐一的提出,

下圖除了藍 ...
vegewell 發表於 2011-9-18 21:28

大大您第二個網址我不能開欸....
小弟我還會多多研究!!!
先謝謝您!
9#
 樓主| 發表於 2011-9-18 21:59:32 | 只看該作者
本帖最後由 yao412030 於 2011-9-18 23:03 編輯
這裡有人用四個, 放置 前 後 左 右不同方向,

你有沒有試過不同方向?
另外他們使用 LV-MaxSonar-EZ1 不是 ...
vegewell 發表於 2011-9-18 19:20

大大您好~不同方向當然是不會有干擾問題
不過小弟我是要做自走車車子前方必須左右兩端需架設感測器,如果兩個感測器朝同方向發射就會干擾
我的是要同一方向放在左右邊不同位置,而我是買MaxSonar-EZ1請問還可以照接嗎??
http://twitpic.com/5s0yp9/full這是我找到的圖....他好像是Daisy Chaining with Constantly Looping
他的藍色線我有點搞不懂,他是三個sensor的AN拉出來接在一起在拉到ARDUINO的ANALOG即可??
還是三個連線一起之後再一個一個另外拉線出來到ARDUINO的ANALOG接腳呢??
有點看不懂還請大大指導!!!
nichal 該用戶已被刪除
10#
發表於 2011-9-19 10:31:19 | 只看該作者
我發現大家都把問題想得很複雜
然後找一堆更複雜的答案想盡辦法要理解它
卻忘了最根本應該知道的概念......

波形在傳遞有兩個特質
一個就是會衰減
另一個就是會碰撞反彈
所以我前面才提到要用臉盆裝水做一下實驗
應該不會花多少時間的

觀察後得到的第一個結論就是
波形同時發射一定會有問題
除非障礙物的條件是已知的
不然一定會有不同的發射波互相碰撞的問題發生
V大提供的連結資料有用示波器去觀察信號的強度
其實就是要說明能量衰減的問題
超音波不像水波用眼睛就看得到
必須透過示波器才能推論

舉個例來說
前面裝了左右兩側的發射器
也裝了左右兩側的接收器
先考慮左右輪替發射的情況
左邊發射時理論上左邊的接受器會立刻收到回應波
(通常程式都會用延遲來避開這一段信號不收)
那麼在沒有障礙物的情況下
右邊會緊接著左邊也收到回應波
問題這都不是反射信號
是在一發射就收到的........
所以決定在何時打開哪個接收器去收到信號
就是大大您目前迫切需要解決的問題
接收信號不一定要隨時都接收的
只要在該接收的時間才打開接收就好
超過就當成沒障礙物
概念就是這樣囉~~~~

然後
有一個已經發射的波形正在傳遞中
就一定要等到它衰減到夠小以後再發射另一個
不然一定會搞不清楚到底哪一個才是剛剛發射的
多小才叫夠小?
用示波器看就知道了......
11#
發表於 2011-9-19 17:20:08 | 只看該作者
回復 10# nichal


    nichal大 已經把波形概念解釋得很清楚,
對此原理很清楚之後,寫起程式就會有秩序合邏輯.
12#
發表於 2011-9-19 17:21:33 | 只看該作者
大大您第二個網址我不能開欸....
小弟我還會多多研究!!!
先謝謝您!
yao412030 發表於 2011-9-18 21:57



    這個網址我一下子就能開啟了,
你也應該開入去得到關鍵知識,
標題是   Wire logic high, multiple sensors.
http://arduino.cc/forum/index.php?topic=66765.0
13#
發表於 2011-9-19 17:23:07 | 只看該作者
本帖最後由 vegewell 於 2011-9-19 17:24 編輯
我的是要同一方向放在左右邊不同位置,而我是買MaxSonar-EZ1請問還可以照接嗎??
http://twitpic.com/5s0yp9/full這是我找到的圖....他好像是Daisy Chaining with Constantly Looping
他的藍色線我有點搞不懂,他是三個sensor的AN拉出來接在一起在拉到ARDUINO的ANALOG即可??
還是三個連線一起之後再一個一個另外拉線出來到ARDUINO的ANALOG接腳呢??
有點看不懂還請大大指導!!!

yao412030 發表於 2011-9-18 21:59

你找到的圖http://twitpic.com/5s0yp9/full,
就是我要說的那個圖,
Daisy Chaining with Constantly Looping
藍色的線,做者的說法是:
[blue lines were a little lazy, each AN from the sensor is going to a separate Analog pin on the board.
So Sensor 1 is going into ANalog pin 0 sensor 2 into Analog pin 1, etc.]
不過我認為都連結在一個pin也行,
========================
LV-MaxSonar-EZ1 比 MaxSonar-EZ1 容易連結使用幾個 sensors,(你要先努力嘗試使用手上的MaxSonar-EZ1)
如下圖serial timing那列有介紹:
14#
發表於 2011-9-19 17:25:49 | 只看該作者
依照那國外做者,請先試試下圖的接法:


arduino的程式如下

int ultraSoundSignalPins[] = {0,1}; // 2 Ultrasound signal pins
int ultraSoundTriggerPin = 6;        // output pin to start Ultrasound signals


void setup() {
   Serial.begin(9600);
   for(int i=0; i < 2; i++) {
       pinMode(ultraSoundSignalPins, INPUT); // Switch signalpin to input
   }
   pinMode(ultraSoundTriggerPin, OUTPUT); // set this pin to output
  //give the sensors time to boot up
   delay(250);
   // send RX pin high to signal to chain to ping
   digitalWrite(ultraSoundTriggerPin, HIGH);
   delayMicroseconds(30);
   digitalWrite(ultraSoundTriggerPin, LOW);
   pinMode(ultraSoundTriggerPin, INPUT); // electrically disconnects the pin
   delay(50);
}
void loop()
{
   unsigned long ultrasoundValue;
   unsigned long echo;
   delay(50);
   for(int i=0; i < 2; i++)
   {
//Now the values from each sensor can be read:
       echo = analogRead(ultraSoundSignalPins); //Listen for echo
       ultrasoundValue = (echo / .58138);


       Serial.println();
       Serial.print("UltraSound Value");
       Serial.print( ultraSoundSignalPins);
       Serial.print(  "= ");
       Serial.print(ultrasoundValue);
      

      
   delay(500);
   
   }
  
}
==================
如有問題,
pin0 and pin1的線互換看看,
another 有沒有接 1 k 的電阻?
依照做者的說法,在測至一米前,都蠻(準確度)的 ,
15#
 樓主| 發表於 2011-9-19 21:04:10 | 只看該作者
小弟我今天花了2小時把文章看了看一下,這幾天會開始實際操作~
謝謝大大們的詳細解說,如果有問題還要麻煩大大了~感恩
16#
 樓主| 發表於 2011-9-19 22:33:04 | 只看該作者
回復 14# vegewell
大大您好
小弟我剛剛看了你PO的程式碼發現我編譯檢查時ARDUINO說有錯誤
sketch_sep19a.cpp: In function 'void setup()':
sketch_sep19a:8: error: invalid conversion from 'int*' to 'uint8_t'
sketch_sep19a:8: error: initializing argument 1 of 'void pinMode(uint8_t, uint8_t)'
sketch_sep19a.cpp: In function 'void loop()':
sketch_sep19a:28: error: invalid conversion from 'int*' to 'uint8_t'
sketch_sep19a:28: error: initializing argument 1 of 'int analogRead(uint8_t)'
sketch_sep19a:34: error: call of overloaded 'print(int [2])' is ambiguous
C:\Program Files\Arduino\arduino-0022\hardware\arduino\cores\arduino/Print.h:44: note: candidates are: void Print::print(const String&) <near match>
C:\Program Files\Arduino\arduino-0022\hardware\arduino\cores\arduino/Print.h:46: note:                 void Print::print(char, int) <near match>
C:\Program Files\Arduino\arduino-0022\hardware\arduino\cores\arduino/Print.h:47: note:                 void Print::print(unsigned char, int) <near match>
C:\Program Files\Arduino\arduino-0022\hardware\arduino\cores\arduino/Print.h:48: note:                 void Print::print(int, int) <near match>
C:\Program Files\Arduino\arduino-0022\hardware\arduino\cores\arduino/Print.h:49: note:                 void Print::print(unsigned int, int) <near match>
C:\Program Files\Arduino\arduino-0022\hardware\arduino\cores\arduino/Print.h:50: note:                 void Print::print(long int, int) <near match>
C:\Program Files\Arduino\arduino-0022\hardware\arduino\cores\arduino/Print.h:51: note:                 void Print::print(long unsigned int, int) <near match>

好像是這行開始出錯的pinMode(ultraSoundSignalPins, INPUT); // Switch signalpin to input
請問我該如何修改呢??
17#
發表於 2011-9-20 09:43:15 | 只看該作者
解釋是:
[Analog pins are INPUT only, so there is no reason to set the pin mode for them.
As a result, the pinMode() function only applies to digital pins.
So, you just set digital pins 0 to 5 as input, including the ones managed by the Serial instance.]
所以你把下列幾行刪除試試(多餘的):
for(int i=0; i < 2; i++) {
       pinMode(ultraSoundSignalPins, INPUT); // Switch signalpin to input
   }
======================
18#
發表於 2011-9-20 11:12:54 | 只看該作者
回復 16# yao412030


不過,沒有刪的原程式,
我現在自己用  Arduino Mega 去編譯 是 Done Compiling,
而且 Done uploading,
我是用最新版本 Arduino 0022,
你是怎麼用的?
原程式在此
http://arduino.cc/forum/index.php/topic,65727.0.html
  
19#
 樓主| 發表於 2011-9-20 12:29:25 | 只看該作者
回復 18# vegewell
大大我發現你PO給我的程式碼和你給我樓上網址PO的程式碼有個地方不一樣才造成編譯錯誤!!
這次你PO給我的程式碼
pinMode(ultraSoundSignalPins, INPUT); // Switch signalpin to input
   }
這是樓上網址PO裡面的
pinMode(ultraSoundSignalPins, INPUT); // Switch signalpin to input
   }
我剛剛用樓上網址PO的程式碼進行編譯就OK了~
20#
 樓主| 發表於 2011-9-20 18:19:19 | 只看該作者
依照那國外做者,請先試試下圖的接法:


arduino的程式如下

int ultraSoundSignalPins[] = {0, ...
vegewell 發表於 2011-9-19 17:25


小弟我現在在測試大大這張電路圖接法還有這個的程式碼http://arduino.cc/forum/index.php/topic,65727.0.html
小弟我發現當我使用5V的時候感測器都沒動作....
之後我降成3.3V之後感測器有動作而且兩顆不會互相干擾....
可是小弟我發現一個問題是當我手指整個蓋住感測器他的類比值是10
可是我把手拉到離感測器約8公分時類比值也差不多顯示10~12左右
請問大大有辦法解決這類比值數據上的間隔吧....這樣間隔實在是太小了
感謝囉!
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-4-29 02:45 , Processed in 0.278616 second(s), 8 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表