EmbeddedRelated.com
Forums
Memfault Beyond the Launch

KC7783 PIR sensor and BasicX

Started by larzyharzy June 15, 2004
I have just bought a KC7783 PIR sensor and I am trying to connect it
to my BX-24. I actually thought it would just give a logic high when
movement is detected. But it has a TTL output - how do I syncronize
this with the BX?

The datasheet can be found on
http://www.electronics123.com/amazon/datasheet/kc7783.pdf



By looking at the schematic at: http://electronics123.com/amazon/datasheet/k76_spec.jpeg
it looks like the signal is a logic "high" when the KC7783 sees IR.

"TTL" stands for transistor-transistor-logic and the specifications
for that logic family is compatible with a BX-24 I/O pin when configured
as "input".

To see how the PIR actually performs, I would wire up the module to a
5 VDC power source and measure the voltage at the output relative to
ground with a voltmeter. Depending on the IR in view and how you want
to use the sensor will suggest how you will want to write the code.

Depending on your application, it may be as simple as "polling" the
input pin and taking some action as a result of the "poll". There are
various techniques like "doing something on the leading edge of IR signal",
"doing something when the signal ends" or "doing something if the IR signal
is longer than X seconds" etc. These are easily accomplished in a subroutine
that reads the input pin (the IR signal) and compares it to a stored variable
of the last read "IRsignalWAS" and sees if the signal has changed. If it has,
the "IRsignalWAS" variable is updated and the appropriate action taken.
The BX-24 is very, very fast and if your control algorithm is relatively
simple, a DO LOOP using "polling" might be all you need.

Eric

----- Original Message -----
From: larzyharzy
To:
Sent: Tuesday, June 15, 2004 11:29 AM
Subject: [BasicX] KC7783 PIR sensor and BasicX I have just bought a KC7783 PIR sensor and I am trying to connect it
to my BX-24. I actually thought it would just give a logic high when
movement is detected. But it has a TTL output - how do I syncronize
this with the BX?



You would use Pulsein to measure the sensors output.

Something like this: Call PuseIn(12, Data, 1)
or Call PuseIn(12, Data, 0) depending on if the data
is on the high or low pulse. Pin 12 is the assumed i/o pin
in the above examples. Chris ----- Original Message -----
From: "larzyharzy" <>
To: <>
Sent: Tuesday, June 15, 2004 11:29 AM
Subject: [BasicX] KC7783 PIR sensor and BasicX > I have just bought a KC7783 PIR sensor and I am trying to connect it
> to my BX-24. I actually thought it would just give a logic high when
> movement is detected. But it has a TTL output - how do I syncronize
> this with the BX?
>
> The datasheet can be found on
> http://www.electronics123.com/amazon/datasheet/kc7783.pdf > Yahoo! Groups Links >
>




I have tried with the code below. But the PulseWidth is always 0
both when there is motion in front of the sensor and no motion.

What can the problem be Public Sub Main()
dim PulseWidth as Single

' PIR sensor
Do
Call PulseIn(20, 1, PulseWidth)
debug.print cstr(PulseWidth)
call delay(0.01)
Loop

End Sub
--- In , "Chris" <chrish@n...> wrote:
> You would use Pulsein to measure the sensors output.
>
> Something like this: Call PuseIn(12, Data, 1)
> or Call PuseIn(12, Data, 0) depending on if the data
> is on the high or low pulse. Pin 12 is the assumed i/o pin
> in the above examples. > Chris > ----- Original Message -----
> From: "larzyharzy" <larzjessen@h...>
> To: <>
> Sent: Tuesday, June 15, 2004 11:29 AM
> Subject: [BasicX] KC7783 PIR sensor and BasicX > > I have just bought a KC7783 PIR sensor and I am trying to
connect it
> > to my BX-24. I actually thought it would just give a logic high
when
> > movement is detected. But it has a TTL output - how do I
syncronize
> > this with the BX?
> >
> > The datasheet can be found on
> > http://www.electronics123.com/amazon/datasheet/kc7783.pdf
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >




I just read the spec sheet on this device and found that the
minimum pulsewidth is 1/2 second, that is way to slow for
Pulsein to see. I also noted that it requires a 25 second power
up delay. Maybe for it to temperature stabilize?

I would recommend making a do loop to increment a counter
and "roll your own" long pulse counter. Once you get it working
properly you can turn it into a task and let it run in the background.

Quick example:

Dim IR_Raw As Long
Dim IR_Data As Long
Dim New_IR_Data As Boolean
Const IR_Pin As Byte = 20 Sub Main()

New_IR_Data = False
IR_Raw = 0

Do

DoWhile GetPin(IR_Pin) = 0
Call Sleep(5)
Loop

If GetPin(IR_Pin) = 1 Then
IR_Raw = IR_Raw + 1

Else

IR_Data = IR_Raw
New_IR_Data = True
IR_Raw = 0

Call Sleep(5)

Loop

End Sub You may need to switch around the code to look for data on
0 instead of 1, the docs really don't say if the data pulse is high
or low, I'm just assuming it's on the high pulse. Chris ----- Original Message -----
From: "larzyharzy" <>
To: <>
Sent: Wednesday, June 16, 2004 2:52 AM
Subject: [BasicX] Re: KC7783 PIR sensor and BasicX > I have tried with the code below. But the PulseWidth is always 0
> both when there is motion in front of the sensor and no motion.
>
> What can the problem be > Public Sub Main()
> dim PulseWidth as Single
>
> ' PIR sensor
> Do
> Call PulseIn(20, 1, PulseWidth)
> debug.print cstr(PulseWidth)
> call delay(0.01)
> Loop
>
> End Sub >
> --- In , "Chris" <chrish@n...> wrote:
> > You would use Pulsein to measure the sensors output.
> >
> > Something like this: Call PuseIn(12, Data, 1)
> > or Call PuseIn(12, Data, 0) depending on if the data
> > is on the high or low pulse. Pin 12 is the assumed i/o pin
> > in the above examples.
> >
> >
> > Chris
> >
> >
> > ----- Original Message -----
> > From: "larzyharzy" <larzjessen@h...>
> > To: <>
> > Sent: Tuesday, June 15, 2004 11:29 AM
> > Subject: [BasicX] KC7783 PIR sensor and BasicX
> >
> >
> > > I have just bought a KC7783 PIR sensor and I am trying to
> connect it
> > > to my BX-24. I actually thought it would just give a logic high
> when
> > > movement is detected. But it has a TTL output - how do I
> syncronize
> > > this with the BX?
> > >
> > > The datasheet can be found on
> > > http://www.electronics123.com/amazon/datasheet/kc7783.pdf
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links >
>



thanks chris and eserdahl

I tried hooking the PIR up to a voltmeter and I never get a high (regardless of
movement), so I guess it is broken. Also the values I get using getADC are always very
low between 0 and 20. I will get hold of another module to test.

/lars

--- In , "eserdahl@" <eserdahl@p...> wrote:
> By looking at the schematic at: http://electronics123.com/amazon/datasheet/
k76_spec.jpeg
> it looks like the signal is a logic "high" when the KC7783 sees IR.
>
> "TTL" stands for transistor-transistor-logic and the specifications
> for that logic family is compatible with a BX-24 I/O pin when configured
> as "input".
>
> To see how the PIR actually performs, I would wire up the module to a
> 5 VDC power source and measure the voltage at the output relative to
> ground with a voltmeter. Depending on the IR in view and how you want
> to use the sensor will suggest how you will want to write the code.
>
> Depending on your application, it may be as simple as "polling" the
> input pin and taking some action as a result of the "poll". There are
> various techniques like "doing something on the leading edge of IR signal",
> "doing something when the signal ends" or "doing something if the IR signal
> is longer than X seconds" etc. These are easily accomplished in a subroutine
> that reads the input pin (the IR signal) and compares it to a stored variable
> of the last read "IRsignalWAS" and sees if the signal has changed. If it has,
> the "IRsignalWAS" variable is updated and the appropriate action taken.
> The BX-24 is very, very fast and if your control algorithm is relatively
> simple, a DO LOOP using "polling" might be all you need.
>
> Eric
>
> ----- Original Message -----
> From: larzyharzy
> To:
> Sent: Tuesday, June 15, 2004 11:29 AM
> Subject: [BasicX] KC7783 PIR sensor and BasicX > I have just bought a KC7783 PIR sensor and I am trying to connect it
> to my BX-24. I actually thought it would just give a logic high when
> movement is detected. But it has a TTL output - how do I syncronize
> this with the BX? >





--- In , "larzyharzy" <larzjessen@h...> wrote:
> thanks chris and eserdahl
>
> I tried hooking the PIR up to a voltmeter and I never get a high
(regardless of
> movement), so I guess it is broken. Also the values I get using
getADC are always very
> low between 0 and 20. I will get hold of another module to test.
>
> /lars
>

Lars, I have a PIR myself, and to my knowledge they do not implement
that logic you are checking for. Mine is a switch basically..NC
contact when movement is detected it opens, OHM it with your meter
for connectivity, usually the sensors are fed into an and gate..If
one is low=alarm..
Hope it helps
daniel




> >
> >
> > I have just bought a KC7783 PIR sensor and I am trying to
connect it
> > to my BX-24. I actually thought it would just give a logic
high when
> > movement is detected. But it has a TTL output - how do I
syncronize
> > this with the BX?
> >

lars,
just saw your data sheets maybe it is broke...I would ohm it just to
be sure.. :)
Daniel



Memfault Beyond the Launch