Dominic,
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.
pseudo-code:
if sensor1_present = 1 then read_sensor(sensor1)
.
.
.
if sensorn_present...
If the sensor is hot-plugable you can re-scan the sensors every
minute/hour/day/whatever
I don't use picbasic so, I can't help you with real code.
Hope this helps
Ricardo Seixas
{Quote hidden}>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
>ideas.
>
>Many thanks
>
>Dominic
>
>--
>
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
>use
.....listservKILLspam
.....mitvma.mit.edu?body=SET%20PICList%20DIGEST
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
use EraseMElistservspam_OUT
TakeThisOuTmitvma.mit.edu?body=SET%20PICList%20DIGEST
>