PDA

View Full Version : Need help in writing program to read a waveform. Thanks.



steng
- 17th December 2008, 09:24
Hi, I am using a PIC16F628 for my project connected to a PIR sensor to detect movement. However, a square wave was detected which I suspect was from the mains as it has 50Hz frequency. Using a comparator, the signal do change when there are movements detected. I've tried many ways but i still can't eliminate the squarewave.

I am using PICBasic Pro to program the PIC. How can I write the program such that the PIC will give a low when the waveform is square (combination of high and low signals) and will give a high when there are movements (change in frequency and change in signal)?

Thanks.

mackrackit
- 17th December 2008, 10:53
This may not be the best solution.

Assuming the square wave is steady the COUNT command can be used to count the number of pules in a given time period and write that value to a Variable.

After the COUNT is finished check the Variable. If it is something other than the known value when there is no movement have the code goto the routine of your choice.

kevlar129bp
- 17th December 2008, 20:11
steng,
Just a shot-in-the-dark here, but the square waves you see are coming from the NC terminals of the motion? If that's the case, you may be seeing the "double pulse" (for pet immunity), to circumvent false alarms. Most motions I deal with give you the ability to shut that feature off. Generally, 360 degree PIR's don't have that feature. Hope that helps?

Good Luck,
C

steng
- 18th December 2008, 02:33
hey u guys, another one. Do you guys know the basic codes for storing the waveform in the memory? Do you use banks? thanks. and how do you determine the number of counts of the waveform. thanks again.

skimask
- 18th December 2008, 02:37
hey u guys, another one. Do you guys know the basic codes for storing the waveform in the memory? Do you use banks? thanks. and how do you determine the number of counts of the waveform. thanks again.

You aren't going to store a whole lot of anything on an F628A in the first place with only 224 bytes of ram available.
Take a look at PULSIN in the PBP 2.50 manual. I'll bet you could do something with that.

steng
- 24th December 2008, 05:12
hey everyone, can u guys spare me some codes for activating the timer feature of the PIC16F628? i want to setup a counter that counts for 10 seconds.

i also want to know if there's a command to retrieve the current time store it and then compare it with a later time, so that the time elapsed between the two instances can be used in a loop (instead of sleeping the chip). like in Java.
looking forward to your wisdom
thanks

Archangel
- 24th December 2008, 06:24
hey everyone, can u guys spare me some codes for activating the timer feature of the PIC16F628? i want to setup a counter that counts for 10 seconds.

i also want to know if there's a command to retrieve the current time store it and then compare it with a later time, so that the time elapsed between the two instances can be used in a loop (instead of sleeping the chip). like in Java.
looking forward to your wisdom
thankstry http://www.picbasic.co.uk/forum/showthread.php?t=190