PDA

View Full Version : Can we have multiple 1-wire devices on single pin?



CuriousOne
- 23rd September 2020, 07:45
Arduino supports that, but I have not found anything about for that in PBP reference manual...
I want to hook up 4 pcs of DS18B20 to single pin. As I have read, each has unique identifier, so it should be possible, but how?

Charlie
- 23rd September 2020, 12:22
It is quite doable, you just need to write your own code. Do a search of the forum - I know there is a code example because I've used it 8-9 years ago. There are no native commands in any language I'm aware of. This is not PBP vs C or PIC vs Arduino.

Dave
- 23rd September 2020, 14:33
Here is a program I wrote some years ago to do a search of 1 wire devices present on a single bus.

towlerg
- 23rd September 2020, 18:23
I've never understood the logic behind the find all the serial numbers function, unless you know what each device (using it's serial number) is measuring it seems pointless. For example in s asystem with three devices, one measuring ambient, one measuring input temp and another measuring output temp - how does it help to be able to determine the serial numbers of the devices when you don't know which ones which?

pedja089
- 23rd September 2020, 18:54
You just add one device at time. And search after you add one.

Dave
- 24th September 2020, 13:20
Exactly correct. What I do is scan each sensor 1 at a time and take the serial number and attach it to the sensor lead with a piece of paper under a piece of transparent film. That way I can replace any sensor in my system with another one and just change the serial number in the code.

towlerg
- 24th September 2020, 16:14
True, but isn't it easier to know which serial as you install each device.

towlerg
- 24th September 2020, 16:16
Works even better if you but the serial numbers in an array, easy to ammend, or add or iterate.

CuriousOne
- 25th September 2020, 09:09
I want to use PIC16F1503 and have to chain thermometers due to pin count. I guess, running above, complex code might not be possible on this wimpy chip?

The task is as follows:
There are 3 fans with PWM input and tachometer output, MAX7219 display and array of buttons. Circuit will monitor fan rpm and adjust it according to individual thermometer reading.

I have 12 IO pins on that chip, I'm thinking about allocating them in the following way:
3 pins - hardware PWM outputs.
3 pins - tachometer inputs.
3 pins - driving MAX7219
1 pin (MCLR), used as ADCIN, to attach several buttons.
1 pin - relay driver, for emergency shutdown.

So I have only 1 pin, for attaching 3 DS18B20....

Dave
- 25th September 2020, 15:01
So... Do it....

pedja089
- 25th September 2020, 18:18
I want to use PIC16F1503 and have to chain thermometers due to pin count. I guess, running above, complex code might not be possible on this wimpy chip?


You can read address, without searching, if it is only one device present at bus. Just write command $33, and collect next 64bit. Do this 3 time, one for each sensor.
Connect all DS to bus.
Write $CC,$44 to start temperature conversion on all DS simultaneously.
Then use match ROM($55) followed by address, to read data from one DS.
Look at page 11 in this datasheet https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

CuriousOne
- 25th September 2020, 19:15
I have an idea, fan tachometer output will be tied to VDD via 4.7k resistor, as DS18B20 should be. Fan outputs pulses not so fast, so what if I attach DS18B20 to same pin as fan tachometer output? and say, after falling edge of tachometer pulse, perform all DS18B20 stuff, while fan pulls pin high again?

Dave
- 26th September 2020, 13:41
I believe it takes ~750 Ms. to complete 1 conversion. With that being said, How are you going to discern if the next pulse is the tach output or the DS output?

CuriousOne
- 27th September 2020, 08:37
Yes, so I came to different solution. I also have PWM output pin, which goes into fan PWM in. So I'll hook DS18B20 to it - When I need to use thermometer, I will stop HPWM output on that pin, read the thermometer and then resume HPWM operation. I guess, fan will have enough inertia to have no significant impact on it's rpm.

towlerg
- 27th September 2020, 16:53
You do realize 750ms is three quarters of a second? Fan speed will be very wobbly.

CuriousOne
- 28th September 2020, 09:07
Fan won't stop in absence of PWM signal. most fans, without PWM signal applied, will default to 30-50% RPM.

scrwld
- 3rd October 2020, 02:44
hello, you can read several ds18b20 sensors and execute the part of the control that you want to carry out, see the attached file the routine I use in a device for the control of air conditioning and lighting with serial communication.8949

CuriousOne
- 19th October 2020, 08:53
And a side question, can we use 1-wire protocol to communicate between 2 PICs?

Ioannis
- 4th November 2020, 08:14
The idea is to have the PIC as a master device and the PIC to request a communication.

So, with the available commands, it is not possible to make a PIC react as a slave 1-wire device.

You have to write your own code for that.

Ioannis