| BrainStem Eltec Pyroelectric Scanner Example Last Modified: 2008-06-25 | | |
| Acroname Robotics | PDF webpage version | ||
| ![]() Introduction This program pans a servo back and forth and takes readings from an Eltec 442-3 sensor mounted on the servo. The sensor responds to temperature changes in its field of view. A temperature change will cause the analog output of the sensor to produce a large peak (maximum) and a large dip (minimum). Otherwise, the output will stay around 2.5 volts. A large difference between the max and min indicates detection of something warm. The positions where the min and max occur give some indication of where the warm object is. Circuit Schematic The wiring interface is very simple for this system and is shown in the following figure. A power jumper is used to supply the source power to the servos. ![]() Wiring diagram between the BrainStem GP and the Eltec pyroelectric detector. Source Code This code uses the TEA language which is very similar to ANSI C. It is compiled using the BrainStem Console with the steep command. /* pyro.tea */
/* pyroelectric scan test program */
#include <aCore.tea>
#include <aPrint.tea>
#include <aServo.tea>
#include <aA2D.tea>
#define PYROIN 0
#define SRVSCAN 0
#define SSTEP 1
#define SCANDELAY 30
#define DTHR 250
/* global variables for scan statistics */
int max;
int min;
int maxp;
int minp;
int pos1;
int pos2;
/* ********************************************************************* */
/* Resets scan statistics. */
void reset_scan()
{
max = 0;
min = 1023;
maxp = 0;
minp = 0;
}
/* ********************************************************************* */
/* This routine updates the servo position,
delays for a moment, then takes an A2D
reading from the Eltec sensor and updates
the global statistics variables. */
void update_max_min(int npos)
{
int r;
aServo_SetAbsolute(SRVSCAN, (unsigned char)npos);
aCore_Sleep(SCANDELAY);
r = aA2D_ReadInt(PYROIN);
if (r > max) {
max = r;
maxp = npos;
}
if (r < min) {
min = r;
minp = npos;
}
}
/* ********************************************************************* */
/* This routine checks the range between the peaks
and sees if it is big enough to be a valid detection.
If the detection is valid, the function returns the
average of the peak positions. */
int check_min_max()
{
int pos = 0;
int diff;
diff = max - min;
if (diff > DTHR) {
pos = (maxp + minp) / 2;
}
return pos;
}
/* ********************************************************************* */
void main()
{
int i;
int pos1=0;
int pos2=0;
while (1) {
/* scan going in one direction */
reset_scan();
for (i = 2; i < 254; i = i + SSTEP){
update_max_min(i);
}
pos1=check_min_max();
/* scan going in the other direction */
reset_scan();
for (i = 254; i >= 2; i = i - SSTEP) {
update_max_min(i);
}
pos2=check_min_max();
/* print the position of the hot spot for each scan */
/* (may vary a little bit depending on direction) */
aPrint_IntDec(pos1);
aPrint_Char(',');
aPrint_IntDec(pos2);
aPrint_Char('\n');
}
}
Revision History:
| |||||||
Related Links: How to provide servo power for CMUCam2+ and BrainStem GP 2.0 | ||||||||
| voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy © Copyright 1994-2010 Acroname, Inc., Boulder, Colorado. All rights reserved. |