View previous topic :: View next topic |
Author |
Message |
JC
Joined: 15 Dec 2007 Posts: 584 Location: Cleveland, OH
|
Posted: Fri Nov 21, 2014 4:11 am Post subject: Config 1Wire syntax when using multiple I/O pins? |
|
|
I have a Tiny4313, 20 MHz, 5 V, with an LCD and two, DS18B20 temperature sensors attached.
Each DS18B20 is on a separate I/O pin, all by itself, (with pull up resistors).
If I configure 1wire for only one device, and do not put port and pin addresses on the 1wire commands, it works fine!
I am now trying to use the Bascom 1Wire commands for two sensors, each on a separate pin.
The Help Manual shows how to add the Port and Pin addresses for the 1Wire Read and Write commands.
However, I do not see how to configure the "Config 1Wire" instruction for this mode of operation.
Config 1wire = PortD.5 works for one device in use.
What if TWO devices are being used on PortD.4 and on PortD.5?
Config 1wire PortD fails.
Config 1wire PortD.SID fails, where SID is the Byte variable for the pin to use
Any guidance would be appreciated!
Thank you,
JC
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Nov 21, 2014 11:28 am Post subject: |
|
|
when using multiple busses, you do not need to use config 1wire since in that case:
Quote: | You can however use multiple pins and thus multiple busses. All 1wire commands and functions need the port and pin in that case. |
Code: | For I = 1 To 8
Ar(i) = 0 'clear array to see that it works
Next
1wreset Pinb , 2 'use this port and pin for the second device
1wwrite &H33 , 1 , Pinb , 2 'note that now the number of bytes must be specified!
'1wwrite Ar(1) , 5,pinb,2
'reading is also different
Ar(1) = 1wread(8 , Pinb , 2) 'read 8 bytes from portB on pin 2
For I = 1 To 8
Print Hex(ar(i));
Next
'you could create a loop with a variable for the bit number !
For I = 0 To 3 'for pin 0-3
1wreset Pinb , I
1wwrite &H33 , 1 , Pinb , I
Ar(1) = 1wread(8 , Pinb , I)
For A = 1 To 8
Print Hex(ar(a));
Next
Print
Next
|
_________________ Mark |
|
Back to top |
|
|
JC
Joined: 15 Dec 2007 Posts: 584 Location: Cleveland, OH
|
Posted: Fri Nov 21, 2014 6:02 pm Post subject: |
|
|
Hi Mark,
GREAT!
I leave out the Config 1Wire and the program works perfectly!
Thank you for the great support, as always!
Jay C |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|