Shop OBEX P1 Docs P2 Docs Learn Events
On a BS2, Is it possible to PULSEOUT from one pin to another, then use COUNT to — Parallax Forums

On a BS2, Is it possible to PULSEOUT from one pin to another, then use COUNT to

po2lepo2le Posts: 76
edited 2008-01-23 00:50 in BASIC Stamp
I have been able to produce pulses on pin 0, using this basic program:

DO WHILE (reps <= 3)
PULSOUT 0, 250
reps = reps + 1
PAUSE 3
LOOP
END

I can observe the pulses on my PC oscilloscope, but I would like to count pulses over a period of time by using the··(COUNT Pin, Duration, Variable)·command, for instance as -·· (COUNT 5, "duration", plscount).
Can I feed the pulses from pin 0 to ·pin 5?·

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-23 00:49
    You can feed the pulses there okay, but you can't count them. That's because the BASIC Stamp is single-tasking. This means that it can't both send pulses and count them at the same time. If you had a second Stamp, though, you could count pulses sent from the first one.

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-23 00:50
    You can connect pin 0 to pin 5, but it won't do what you want. The Stamps are "single threaded" processors. They do only one thing at a time. When a Stamp is producing a pulse with PULSOUT, it can't execute a COUNT statement to detect the pulse. When the Stamp is executing a COUNT statement, it's just sitting there counting pulses and can't do anything else.

    A Stamp would need some kind of external circuitry or a co-processor to do this sort of thing. It's possible to do this with the SX or Propeller. The SX uses interrupts to do functions like this. The Propeller has 8 independent processors plus some specialized counters in each processor that can count pulses or generate pulses independently.
Sign In or Register to comment.