View previous topic :: View next topic |
Author |
Message |
DeleneMulley Guest
|
multiple dallas readers |
Posted: Tue May 13, 2008 8:10 am |
|
|
I have two dallas touch button readers connected to pic16f877A.
Each reader is assigned to one pin.
#define Reader1 pin_b6
#define Reader2 pin_b7
I have two functions to read the dallas button. Both functions are identical, except for one uses Reader1 and the other Reader2.
Is there away that I can make this into one function?
I am wanting to add upto 25 dallas readers onto 25 pins and dont want to have the functions duplicated that many times..
Thanks
Delene |
|
|
KU5D
Joined: 10 Feb 2008 Posts: 46 Location: Asheville, North Carolina
|
|
Posted: Tue May 13, 2008 8:14 am |
|
|
Might try labeling the pins and passing that label to the function as an argument... _________________ Confidence is the feeling you have right before you fully understand the situation... |
|
|
DeleneMulley Guest
|
|
Posted: Tue May 13, 2008 8:23 am |
|
|
how would you label the pins? (I thought I had done that by with the #define Reader1 pin_b7)
Then how do you pass that label to a function?
Thanks |
|
|
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
|
Posted: Tue May 13, 2008 9:38 am |
|
|
Does it have to be two seperate readers? each device has unique id and you usually have a option to discover devices on the bus with the search rom command if memeory serves me correct.
Make an array of two int16 values then assign them the value found in the device.h file under the pin defines, then in your driver switch between the two array elements.
Regards |
|
|
delene
Joined: 13 Oct 2003 Posts: 32
|
|
Posted: Tue May 13, 2008 9:45 am |
|
|
They do have to be separate readers..
Your memory is correct on how they work, but for my app they each need to have a separate reader.. |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Tue May 13, 2008 1:25 pm |
|
|
Each dallas device on a separate touchpin and up to 25 of them seems very kludgey but I assume it makes sense to you. You may decide since the hardware is duplicated 25 times that if there is enough program memory why not go for the gold and duplicate your software as well. Now you won't have to duplicate your routines 25 times if you pass a variable with the touchpin number into your routine. Search this board for examples of assigning PIC pins via a variable at run time. |
|
|
|