Searching \ for '[PIC]: PULSIN & Unknown Number of Sensors' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'PULSIN & Unknown Number of Sensors'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: PULSIN & Unknown Number of Sensors'
2000\09\12@122109 by dominic.berry

I'm new to PICS & want to create a device with 1 or more sensors (the number
of sensors is unknown & variable ie the device could have 1 sensor or 2 or 3
or 4).  I want to use the picbasic command PULSIN to measure the pulse width
on each sensor.  The problem is I don't want to use PULSIN if a sensor does
not exist as it takes ~0.5s to time out (is this correct?).  So if I test 4
inputs with PULSIN and only 1 sensor exists, the sampling rate will be once
every ~1.5s.  Any ideas how I get around this?

The only way I can think of is to tie a pin high if a sensor is connected on
another pin, & then test for that high pin before running PULSIN.  This will
double the number of inputs required though which I am not keen on.  Any other

Many thanks


-- Going offline? Don't AutoReply us!

2000\09\12@130934 by Bruce Cannon

picon face

As you're going with the Stamp-like approach you could perhaps have the
presence of each sensor add a resistive value to a ladder, maybe with the
values being an order of magnitude or somesuch apart for differentation, and
read the total with the POT command.  Then you'd only need one extra pin for
multiple sensors (I think this might work for 3 or 4).

Bruce Cannon
Style Management Systems
(510) 787-6870
1228 Ceres ST Crockett CA 94525

Remember: electronics is changing your world...for good!

{Quote hidden}

-- Going offline? Don't AutoReply us!

2000\09\12@131956 by Ricardo Seixas

picon face

At pic startup you can look for the sensors, for ex:
Try to read sensor 1, if you get a timeout then there's no sensor so,
you clear a flag to indicate no sensor present (ie: sensor1_present=0)
otherwise set a flag (ie: sensor1_present=1)
Do this until you tried all possible sensors then, go to the main loop
to process all connected sensors using the flag you've set.


     if sensor1_present = 1 then read_sensor(sensor1)
     if sensorn_present...

If the sensor is hot-plugable you can re-scan the sensors every
I don't use picbasic so, I can't help you with real code.

Hope this helps

Ricardo Seixas

{Quote hidden}

-- Going offline? Don't AutoReply us!

2000\09\12@132156 by Bob Ammerman

picon face
How about this idea:

Bring your sensor signal into the PIC via a resistor of about 1K, and also
connect all your sensor pins, each via a 30K resistor to a single PIC output

If the sensor pin tracks the output pin then no sensor is attached.

If the sensor pin doesn't track the output pin then a sensor is attached.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...