1, PCB board size is only 2.2 * 3.6CM
2, at least only one IO data port can accept the measurement of distance hexadecimal data;
with data output enable terminal, you can control or directly through the IO port ground handling!
3, measuring the distance of only 18ms, greatly reducing the measurement time, especially for robot control is particularly suitable;
4, reached the theoretical no blind zone, basically no blind zone test range;
5, AAAA automatically returns over-range data to reduce the wait time after over-range;
6, the back of the red LED indicates the working status, when there are obstacles, LED will light.
Ultrasonic Ranging Module Wiring:
Five 2.54mm pitch pins:
VCC - wide voltage input: support 3v-5.5v
TxD - (serial output, then microcontroller or TTL small board RXD;)
Enable - (module enabled, = 0 when module is active, = 1 is not active, PCB is printed with Trig),
GND - power ground
GND - power ground
Data Format:
Each time the module outputs 4 bytes, the format is: 0XFF + H_DATA + L_DATA + SUM
1. 0XFF: a set of starting data, used to judge.
2. H_DATA: the upper 8 bits of the data.
3. L_DATA: the lower 8 bits of the data.
SUM: data and, for the effectiveness of. 0XFF + H_DATA + L_DATA = SUM (only lower 8 bits)
Note: H_DATA and L_DATA combine 16-bit data, that is, the distance in millimeters.
H_DATA * 256 + L_DATA
Over-range fixed output: FF AA AA 53
The back of the red LED indicates the working status, when there are obstacles, LED will light.
Electrical parameters:
Operating Voltage: DC 3.0-5.5V
Working current : 8mA
working frequency : 40KHz
Ranging range : 0mm-2000mm
Resolution : 1mm
Measurement angle : Related to the distance, see the next angle
Serial port baud rate : 9600,8, n, 1
Response cycle : 18ms
예제코드
#include "reg51.h"
#include "sio.h"
void main (void)
{
com_initialize (); /* initialize interrupt driven serial I/O */
com_baudrate (9600); /* setup for 9600 baud */
EA = 1; // Enable Interrupts
while (1)
{
unsigned char head,dh,dl,sum;
head = com_getchar();
if (head != 0xff) continue;
dh = com_getchar();
dl = com_getchar();
sum = com_getchar();
head = head + dh + dl;
if (head != sum) continue;
}
}