View previous topic :: View next topic |
Author |
Message |
Swys
Joined: 24 Feb 2010 Posts: 22
|
Fast dynamic pin selection |
Posted: Mon Apr 12, 2010 8:05 am |
|
|
Hi all,
Is there any way to call a function, specifying a certain pin, but doing it fast enough for 1-Wire comms?
As an example, I want to have something like the following:
Code: | int16 my_pin;
void main()
{
my_pin = PIN_A1;
do_one_wire_function(my_pin);
my_pin = PIN_A2;
do_one_wire_function(my_pin);
} |
Is there any way of doing this, without messing up the timing for 1-Wire comms? I realize that it sort of defeats the purpose of 1-Wire comms. I've been struggeling for a week with the SEARCH ROM algorithm and finally got it working today. But, while I was working on it, it struck me that I wouldn't even use it.
I am using the DS18B20 1-Wire temperature sensors. I need to connect a sensor on each of 6 microcontroller pins. This is so that I know exactly which sensor is measuring which temperature (ambient, water, etc.) So you can see why I want to follow this route.
Can anyone please help me with this? I have compiler version 4.106 |
|
![](templates/subSilver/images/spacer.gif) |
mskala
Joined: 06 Mar 2007 Posts: 100 Location: Massachusetts, USA
|
|
Posted: Mon Apr 12, 2010 8:18 am |
|
|
Look at how the sensor works. You can put them all on the same pin, because each one has a unique address. |
|
![](templates/subSilver/images/spacer.gif) |
Swys
Joined: 24 Feb 2010 Posts: 22
|
|
Posted: Mon Apr 12, 2010 8:29 am |
|
|
Thanks for the reply.
That's correct, but the problem is that I won't know in the field which sensor has what address when I pick one out of a toolbox and put it in the circuit. That is why I want to use a differrent pin for each sensor. |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Apr 12, 2010 12:41 pm |
|
|
If the pin count is 8 or less, you can use a bit number in all port accesses to select the respective pin. You have to
rewrite the OW low-level I/O routines however. But it's a rather simple programming roblem. |
|
![](templates/subSilver/images/spacer.gif) |
|