Need help in writing program to read a waveform. Thanks.


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2008
    Posts
    6

    Smile Need help in writing program to read a waveform. Thanks.

    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.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Oct 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default memory for PIC16F628

    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.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by steng View Post
    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.

  6. #6
    Join Date
    Oct 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default timer generation

    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

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by steng View Post
    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
    try http://www.picbasic.co.uk/forum/showthread.php?t=190
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  2. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. difference in 'read all' and 'program all'
    By cheezy1963 in forum General
    Replies: 10
    Last Post: - 21st November 2007, 04:22
  5. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts