The following information is written by Göte Haluza, thanks!
Dallas Semiconductor (DS) 1wire. This is a brief description of DS 1wirebus when used in combination with BASCOM. For more detailed explanations about the 1w-bus, please go to http://www.dalsemi.com/techbriefs/tb1.html. Using BASCOM, makes the world a lot easier. This paper will approach the subject from a "BASCOM-user-point-of-view".
1wire-net is a serial communication protocol, used by DS devices. The bus could be implemented in two basic ways :
With 2 wires, then DQ and ground is used on the device. Power is supplied on the DQ line, which is +5V, and used to charge a capacitor in the DS device. This power is used by the device for its internal needs during communication, which makes DQ go low for periods of time. This bus is called the 1wirebus.
With 3 wires, when +5V is supplied to the VDD line of the device, and DQ + ground as above. This bus is called the 2wirebus.
So, the ground line is "not counted" by DS. But hereafter we use DS naming conventions.
How it works. (1wire)
The normal state of the bus is DQ=high. Through DQ the device gets its power, and performs the tasks it is designed for.
When the host (your micro controller (uC)) wants something to happen with the 1w-bus, it issues a reset-command. That is a very simple electric function that happens then; the DQ goes active low for a time (480uS on original DS 1w-bus). This put the DS-devices in reset mode; then (they) send a presence pulse, and then (they) listen to the host.
The presence pulse is simply an active low, this time issued by the device(s).
Now, the host cannot know what is on the bus, it is only aware of that at least 1 DS device is attached on the bus.
All communication on the 1w-bus is initialized by the host, and issued by time-slots of active-low on a normally high line (DQ), issued by the device, which is sending at the moment. The devices(s) internal capacitor supplies its power needs during the low-time.
How you work with 1w-bus
Thereafter, you can read a device, and write to it. If you know you only have 1 sensor attached, or if you want to address all sensors, you can start with a "Skip Rom" - command. This means; take no notice about the Ids of the sensors - skip that part of the communication.
When you made a 1w-reset, all devices of the bus are listening. If you chose to address only one of them, the rest of them will not listen again before you have made a new 1w-reset on the bus.
I do not describe BASCOM commands in this text - they are pretty much self-explaining. But the uC has to write the commands to the bus - and thereafter read the answer. What you have to write as a command depends on devices you are using - and what you want to do with it. Every DS chip has a datasheet, which you can find at http://www.dalsemi.com/datasheets/pdfindex.html. There you can find out all about the actual devices command structure.
There are some things to have in mind when deciding which of the bus-types to use.
The commands, from BASCOM, are the same in both cases. So this is not a problem.
The +5V power-supply on the VDD when using a 2wire-bus has to be from separate power supply, according to DS. But it still works with taking the power from the same source as for the processor, directly on the stabilising transistor. I have not got it to work taking power directly from the processor pin.
Some devices consume some more power during special operations. The DS1820 consumes a lot of power during the operation "Convert Temperature". Because the sensors knows how they are powered (it is also possible to get this information from the devices) some operations, as "Convert T" takes different amount of time for the sensor to execute. The command "Convert T" as example, takes ~200mS on 2wire, but ~700mS on 1wire. This has to be considered during programming.
And that power also has to be supplied somehow.
If you use 2wire, you don't have to read further in this part. You can simultaneously "Convert T" on all the devices you attach on the bus. And save time. This command is the most power-consuming command, possible to execute on several devices, I am aware of.
If you use 1wire, there are things to think about. It is about not consuming more power than you feed. And how to feed power? That depends on the devices (their consumption) and what you are doing with them (their consumption in a specific operation).
Short, not-so-accurate description of power needs, not reflecting on cable lengths
Only the processor pin as power supplier, will work < 5 sensors. (AVR, 1w-functions use an internal pull-up. 8051 not yet tested). Don't even think of simultaneous commands on multiple sensors.
With +5V through a 4K7 resistor, to the DQ-line, 70 sensors are tested. But, take care, cause issuing "Convert T" simultaneously, would cause that to give false readings. About ~15 sensors is the maximum amount of usable devices, which simultaneously performs some action. This approach DS refers to as "pull-up resistor".
With this in mind, bus up to 70 devices has been successfully powered this way.
The resistor mentioned, 4K7, could be of smaller value. DS says minimum 1K5, I have tested down to 500 ohm - below that the bus is not usable any more. (AVR). Lowering the resistor feeds more power - and makes the bus more noise -resistant. But, the resistor minimum value is naturally also depending on the uC-pin electric capabilities. Stay at 4K7 - which is standard recommendation.
DS recommends yet another approach, called "strong pull-up" which (short) works via a MOS-FET transistor, feeding the DQ lines with enough power, still on 1wire, during power-consuming tasks. This is not tested, but should naturally work. Cause this functionality is really a limited one; BASCOM has no special support for that. But anyway, we tell you about it, just in case you wonder. Strong pull-up has to use one uC pin extra - to drive the MOS-FET.
Cable lengths (this section is only for some limited understanding)
For short runs up to 30 meters, cable selection for use on the 1W bus is less critical. Even flat modular phone cable works with limited numbers of 1-Wire devices. However, the longer the 1W bus, the more pronounced cable effects become, and therefore the greater importance placed on cable selection.
For longer distances, DS recommends twisted-pair-cable (CAT5).
DS standard examples show 100 meters cable lengths, so they say, that's no problem. They also show examples with 300m cabling, and I think I have seen something with 600-meter bus (but I cant find it again).
Noise and CRC
The longer cable and the noisier environment, the more false readings will be made. The devices are equipped with a CRC-generator - the LSByte of the sending is always a checksum. Look in program examples to learn how to re-calculate this checksum in your uC. AND, if you notice that there are false readings - do something about your cables. (Shield, lower resistor)
On the original 1w-bus, DS says the transfer speed is about 14Kbits /second. And, if that was not enough, some devices has an overdrive option. That multiplies the speed by 10. This is issued by making the communication-time-slots smaller (from 60 uS to 6uS ) which naturally will make the devices more sensitive, and CRC-error will probably occur more often. But, if that is not an issue, ~140Kbit is a reachable speed to the devices. So, whatever you thought before, it is FAST.
The BASCOM scanning of the bus is finds about 50 devices / second , and reading a specific sensors value to a uC should be about 13 devices / second.
Of the 1w-net - that is an issue we will not cover so much. Star-net, bus-net? It seems like you can mix that. It is a bus-net, but not so sensitive about that.
The benefit of the 1w-bus
Each device is individual - and you can communicate with it over the media of 2 wires. Still, you can address one individual device, if you like. Get its value. There are 64 ^ 2 unique identifications-numbers.
Naturally, if lot of cables are unwanted, this is a big benefit. And you only occupy 1 processor pin.
DS supplies with different types of devices, which all are made for interfacing an uC - directly. No extra hardware. There are sensors, so you can get knowledge about the real world, and there are also potentiometers and relays, so you can do something about it. On the very same bus.
And the Ibutton approach from DS (ever heard of it?) is based on 1wire technology. Maybe something to pick up.
BASCOM let you use an uC with 1wire-devices so easy, that (since now) also has to count as a benefit - maybe one of the largest. ;-)
The disadvantages of the 1w-bus
So far as I know, DS is the only manufacturer of sensors for the bus. Some people think their devices are expensive. And, until now, it was really difficult to communicate with the devices. Particularly when using the benefit of several devices on one bus. Still some people say that the 1w-bus is slow - but I don't think so.