Eltec 442-3 to OOPic Example
Last Modified: 2007-03-08
find:

basket

Acroname Robotics PDF webpage version Eltec 442-3 to OOPic Example PDF

Related
Products

Product image for Pyroelectric sensor package
Pyroelectric sensor package
Product image for OOPIC II Starter Package
OOPIC II Starter Package

Contents

Eltec 442-3 interfaced to an OOPic
Eltec 442-3 interfaced to an OOPic

Introduction

In this example, an OOPic microcontroller takes continuous readings from an Eltec 442-3 pyroelectric detector, scales the raw value and converts it to a text string, and transmits the text over a serial link.  A terminal program on a computer with a serial port can display the data. 

Circuit Schematic

The interface to the Eltec 442-3 detector is quite simple.  Its current draw is small so the OOPic's onboard voltage regulator can supply power.  The output of the detector goes directly to an OOPic pin with ADC capability.  An RS-232 voltage-level converter ensures reliable serial communication.  This circuit uses a MAX232A from Maxim Electronics

Schematic of Eltec 442-3
Schematic of Eltec 442-3

Source Code

' Eltec-2.osc ' send decimal text to terminal dim eltec as new oA2D dim rv as new oByte ' raw value from ADC dim w1 as new oWord ' use for math dim dig1 as new oByte dim dig2 as new oByte dim dig3 as new oByte dim ch as new oByte dim sc as new oSerial dim buff as new oBuffer(8) sub main() sc.Baud=cv2400 sc.Operate=cvTrue sc.Mode=0 ' locations 0-3 of buffer contain digits ' locations 4-5 are carriage return - line feed ' location 6 is string terminator buff.Location=4 buff.value=10 buff.Location=5 buff.value=13 buff.Location=6 buff.value=0 eltec.IOLine=1 eltec.ExtVRef=0 eltec.Operate=cvTrue do call read_val call sendbuffer loop end sub '-------------------------------- sub sendch() sc.value=ch while sc.Transmitting=1 wend end sub sub sendbuffer() buff.Location=0 while buff.value<>0 ch=buff.value call sendch buff.Location=buff.Location+1 wend end sub '----------------------------------- sub read_val() ' raw value is 0-255 ' scale = 128 ' decimal ratio ranges from 0.00 to 1.99 rv=eltec.value w1=rv*100/128 dig1=w1/100 w1=w1-(dig1*100) dig2=w1/10 w1=w1-(dig2*10) dig3=w1 ' add 48 to convert decimal digit to ASCII digit buff.Location=0 buff.value=dig1+48 buff.Location=1 buff.value=46 ' ASCII code for decimal point buff.Location=2 buff.value=dig2+48 buff.Location=3 buff.value=dig3+48 end sub

Comments

In addition to demonstrating voltage measurement, the source code shows some techniques for getting text representations of decimal values using only integer arithmetic.  It also provides an example of how to use the OOpic oSerial object. 

This circuit also demonstrates several things about the Eltec Pyroelectric detector package.  The detector is quite sensitive.  Try this example out in a large room and notice that the detector can pick up a person's movement from quite a distance. 

Notice that the detector's output is relative.  You can either move in front of the detector or move the detector across an area (sweep it) to get a measurement. 

Revision History:

  • 2000-08-11: Example Created.
 
 
voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy
© Copyright 1994-2008 Acroname, Inc., Boulder, Colorado. All rights reserved.