DS18B20 And One Wire!

For general Flowcode discussion that does not belong in the other sections.
Post Reply
jgu1
Posts: 602
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 494 times
Been thanked: 132 times

DS18B20 And One Wire!

Post by jgu1 »

Hi!

I have made a project with a DS18B20. I want to measure some temperature in my floorheating. I use 4 DS18B20. In the project I was able to read the serial/adress number from each device with the program from the helpmenu Component: One Wire (Comms: Interface) One wire device scan. This program work very well, I can recomend to try. ;)

In my program I create 4 macro one for each device. My question is: Every time I want to read next device Is it nessesary to "scan all device" and what is "Adress next device" and "Adress specific device" .
The program I made is working perfect. :D But I do not know if I have done it correctly 100%. I hope someone will check my program and very velcome correct the program.
Br Jorgen
Attachments
kOKKEN_DS18B20_aDRESSERET D Nano.fcfx
(37.18 KiB) Downloaded 85 times

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: DS18B20 And One Wire!

Post by BenR »

Hello,

Glad you have got on well with the new one wire components.

The OneWire ScanBus macro looks at all the devices on the bus in that instant and makes a log of all devices. The maximum number that can be logged is specified by the OneWire component.

The OneWire ScanBus macro is automatically called for you as part of the DS18B20 initialise. If devices are being hot plugged and unplugged then you can refresh the log at any time by calling the OneWire ScanBus macro.

The DS18B20 AddressNextDevice macro looks for the next matching DS18B20 device in the log. If there is only one device then it will address the same device, if there are multiple devices then it will address each device in turn. The downside with this is if you have multiple sensors connected then you don't know which sensor is which without recording the ID. GetSerialString macro returns the ID as a string so you can print to a LCD etc.

The DS18B20 AddressSpecificDevice macro bypasses the log and allows you to specify a device ID ensuring you are communicating with a known specific device. The downside to this is you need to know the device ID ahead of time.

In your program in say the Input macro there are a few macro calls that are unnessisary.

SampleAllDevices will make all the connected DS18B20 devices do a temperature conversion together at the same time. You can then use the AddressSpecificDevice and GetTemperature macros to address the device and read the result of the temperature conversion. This will be much faster and will yield synchronised samples for all devices.

Or you can do a conversion at a time on each device by using AddressSpecificDevice then SampleAddressedDevice and GetTemperature macros.

At the moment you seem to be doing a bit of both. I have made a few minor changes to your program here.
kOKKEN_DS18B20_aDRESSERET D Nano.fcfx
(37.88 KiB) Downloaded 106 times

Hope this makes sense.

jgu1
Posts: 602
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 494 times
Been thanked: 132 times

Re: DS18B20 And One Wire!

Post by jgu1 »

Hi Ben!

Thank´s for the explanation and thakk´s for the correction in the program, yes it make sense absolutely. It´s only to be sure that I have made it as correctly as possible.

And very good working component/macro you have made.

Thank´s

Jorgen

Post Reply