Shop OBEX P1 Docs P2 Docs Learn Events
Using Counter — Parallax Forums

Using Counter

RafaelRafael Posts: 2
edited 2008-02-08 15:28 in BASIC Stamp
I am using a BS2 with Board of Education and a waveform generator set to square wave. I just started programming so I really don't know what I'm doing.

This is what I have so far:

Counter VAR Byte
INPUT 8
OUTPUT 7
COUNT 7, 10000, Counter

Main:
DEBUG DEC Counter
END

I have tried implementing a loop and also just using an input without output. I have tried counting pins 8 and 7 (input and output).

I want the debug message to give me the value of the amount of peaks that it detected from the square wave generator. I have the generator set to 2 Hz so in 10 seconds it should be displaying 40 peaks. However I keep getting random numbers or 0. Ultimately I want to send the value of the "Counter" variable to an LCD screen, I could use·any info for that too.

- Thanks

Comments

  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2008-02-07 23:43
    I think if you look through the Stampworks manual that you can find what you need to do.

    http://www.parallax.com/dl/docs/books/sw/Web-SW-v2.1.pdf
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-02-08 15:12
    As a note…INPUT makes the I/O pin an input…OUTPUT makes the pin an output. You’re making pin 8 an INPUT then pin 7 an OUTPUT then doing a COUNT on pin 7, which to do this needs to be an input. Of course, COUNT makes the pin an input but you should never make a pin an output that is connected to an output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • BeanBean Posts: 8,129
    edited 2008-02-08 15:28
    Rafael,
    Do you have the generator and stamp grounds connected together ? If not, it won't work.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
Sign In or Register to comment.