しぐれめも

何か作る過程をメモとして残したり、あと雑記

2値出力距離センサ(2013/08/04)

(これは旧Blog 2013/08/04の記事を移したものです)

 

 Switch Scienceで売っているPololu製 2値出力距離センサを試してみました。

 検出距離が5cmのもの(GP2Y0D805Z0F搭載)10cmのもの(GP2Y0D810Z0F搭載)があり、両方買ってみました。

 センサと対象物の距離が5cm/10cm 以上ならHigh、以内ならLowを出力するモジュールです。(ただし近すぎてもHighになる。)

 

f:id:mashigure:20150110094829j:plain

 

センサ側面の数字(S805 or S810)でどちらかを見分けることができるようです。

f:id:mashigure:20150110094814j:plain

 

このセンサは基板の裏にLEDが実装されているので電源を供給するだけでテストできて便利です。ところが、試しに(5cmの方を)使ってみると、障害物が 5cm離れたあたりにあるときはLowが出力される(LEDが光る)のですが、それよりも遠くても近くてもHigh(LED消灯)になり、明らかに挙動が 違う。

 で、色々調べた結果Pololu製品ページのFAQsにこんな記述がありました:

This sensor isn’t behaving as I expect: I’m getting intermittent detection much farther than the maximum range of the sensor and it’s not detecting objects within the advertised detection range. What’s wrong?
Issues like this can be the result of power supply problems, especially since this sensor draws power in short, large bursts, so make sure your power supply is capable of delivering the necessary current. If you experience this problem, try adding a 10 μF or so capacitor across the sensor’s power and ground near the sensor; this compensates for an inadequate power supply and typically restores normal functionality.

 要するに、センサが期待したように動作しないという問いに対して電源供給の問題ではないかと答えています。ここではコンデンサ挟めと言っていますが、実は私のばあいセンサに供給する電源をUSBからとってきてたんですね。で、過去にUSBから電源をとるとマイク入力にノイズがのる問題に直面した事があったので、もしやと思い電源を電池(eneloop)に変更。するとデータシート通りにセンサが出力を返すようになりました。

 と、言うわけでUSBからの供給電源はノイジーなのでセンサに供給するのはよくないよ。という話でした。