DYP-ME007.pdf 데이터시트 (총 12 페이지) - 파일 다운로드 DYP-ME007 데이타시트 다운로드

No Preview Available !

40Hz Ultrasonic Range Detection Sensor
A guide to using the DYP-ME007 with Arduino in order to calculate distances from objects. In
this case I’m also altering the output of an LED with PWM according to how close an object is to
the sensor. So the nearer you are the brighter the LED.
So if we start with the DYP-ME007, it’s an IC that works by sending an ultrasound pulse at
around 40Khz. It then waits and listens for the pulse to echo back, calculating the time taken in
microseconds (1 microsecond = 1.0 × 10-6 seconds). You can trigger a pulse as fast as 20 times a
second and it can determine objects up to 3 metres away and as near as 3cm. It needs a 5V power
supply to run.
Adding the DYP-ME007 to the Arduino is very easy, only 4 pins to worry about. Power, Ground,
Trigger and Echo. Since it needs 5V and Arduino provides 5V I’m obviously going to use this to
power it. Below is a diagram of my DYP-ME007, showing the pins. There are 2 sets of 5 pins, 1
set you can use, the other is for programming the PIC chip so don’t touch them!
1Specification
Working Voltage : 5V(DC)
Working Current : max 15 ma
Working frequency : 40HZ
Output Signal : 0-5V (Output high when obstacle in range)
Sentry Angle : max 15 degree
Sentry Distance : 2cm - 500cm
High-accuracy : 0.3cm
Input trigger signal : 10us TTL impulse
Echo signal : output TTL PWL signal

No Preview Available !

Size : 45*20*15mm
Note : This module is not suitable to connect with electric power, if you need to connect this
module with electronic power,then let the GND terminal of this module to be connected
first,otherwise, it will affect the normal work of the module
2Interface
Pin:
1VCC 2trigT);3echoR);4OUT ( Don't Connect ) ; 5GND
3Usage

No Preview Available !

Supply module with 5V, the output will be 5V while obstacle in range, or 0V if not.
The out pin of this module is used as a switching output when anti-theft module, and without the
feet when ranging modules,
Note : the module should be inserted in the circuit before been power, which avoid producing high
level of misoperation if not, then power again.
Module Working Principle:
(1) Adopt IO trigger through supplying at least 10us sequence of high level signal,
(2) The module automatically send eight 40khz square wave and automatically detect whether
receive the returning pulse signal,
(3) If there is signals returning, through outputting high level
and the time of high level continuing is the time of that from the ultrasonic transmitting to
receiving.
Test distance = (high level time * sound velocity (340M/S) / 2,
The circuit:
Very, very simple circuit, I’ve used the breadboard to share the GND connection and to add the
LED which I could probably have done with out the breadboard. You’ll see the most complex
thing is the code later on.

No Preview Available !

The sketch:
All the work is done here, I’ve added code that averages the distance readings to remove some of
the jitter in the results as the DYP-ME007 is calculating distances very rapidly and there can be a
lot of fluctuation. Also I convert the time in microseconds to distance by dividing the time by 58.
Why 58? Well because if you take the time in microseconds for a pulse to be sent and received
e.g. for 1 meter it takes about 5764 microseconds – at least from my wall anyway. If I divide this
time by the distance in cm in I will get 57.64 so I just round this up – you can calculate distance in
any other unit with this method.
Here I’ve also decided that for every cm under 255 my LED will get 1 step brighter. I’ve been lazy
here for the sake of the sensors 3 metre range I didn’t see the point in making this any more
complicated. Otherwise I would calculate the brightness on the percentile of proximity out of total
range.
Official test Code Example - 1:
#include <c8051f020.h>
#define uchar unsigned char
#define uint unsigned int
sbit P0_0=P0^0;
sbit P0_1=P0^1;
bit flag;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=0;y<110;y++);
}
void T0T1_Init()
{
CKCON=0x00;
TMOD=0x11;
TH0=(65535-25)/256;
TL0=(65535-25)%256;
TH1=0;
TL1=0;
TR0=0;
TR1=0;

No Preview Available !

ET0=1;
ET1=1;
EA=1;
}
void main()
{
WDTCN = 0xde;
WDTCN = 0xad;
// OSCXCN=0x67;
// delay(100);
// OSCICN=0x08;
P0MDOUT=0x00;
flag=0;
P0_1=0;
P0_0=1;
T0T1_Init();
// P1MDOUT=0xff;
// P3MDOUT=0XFF;
P74OUT=0xff;
P4=0x01;
XBR2=0x40;
XBR1=0x04;
// duan=0;
// wei=0;
P0_1=1;
TR0=1;
while(!flag);
TR0=0;
P0_1=0;
flag=0;
while(!P0_0);
TR1=1;
IT0=1;
EX0=1;
while(1)
{