Difference between revisions of "Component: One Wire (Comms: Interface)"

From Flowcode Help
Jump to navigationJump to search
Line 44: Line 44:
  
 
A pull up resistor of between 1K and 10K is required between the data I/O pin and VCC.
 
A pull up resistor of between 1K and 10K is required between the data I/O pin and VCC.
 +
 +
 +
===Further Examples===
 +
 +
The One Wire component is a key building block required by a number of other components. Some of which are included below.
 +
 +
[DS18B20]
  
 
==Downloadable macro reference==
 
==Downloadable macro reference==

Revision as of 12:25, 13 August 2021


Author Matrix Ltd
Version 1.3 (Release)
Category Comms: Interface


Image One Wire component

Low level routines for controlling or interacting with a standard one wire interface.

Examples

Device Scanning

To get started with one wire devices it is often useful to collect the unique device serial number for each and every one wire device you are going to connect to your bus.

For example if you have a bus with two temperature sensors connected it is useful to know which sensor is which. Sensor A is monitoring temperature A and sensor B is monitoring temperature B. The only way to tell which is which is to use the serial number.

Here is a program that scans for devices on a one wire bus and outputs the device count and serial numbers using a LCD.

FC6 Icon.png One Wire Device Scan LCD


Here is the same program but this time the device count and serial numbers are output using a UART such as on an Arduino or ESP32.

FC6 Icon.png One Wire Device Scan Serial


OneWireDeviceScan.jpg


To use the examples simply connect a single device to the one wire bus and make a note of the reported serial number.

This serial number can then be entered into the specific one wire component and used to ensure you are communicating with the device you think you are.

A pull up resistor of between 1K and 10K is required between the data I/O pin and VCC.


Further Examples

The One Wire component is a key building block required by a number of other components. Some of which are included below.

[DS18B20]

Downloadable macro reference

DS1820_StartConversion

DS1820 device specific function

Commands all sensors to start a temperature conversion

Parameters

This macro has no parameters


Return value

BYTE


ReceiveByte

Receives a byte from the one wire bus a bit at a time

Parameters

This macro has no parameters


Return value

BYTE


TransmitByte

Transmit a byte to the one wire bus a bit at a time

Parameters

BYTE Command


Return value

This call does not return a value


GetPadByte

Returns a byte from the last read scratchpad at position index. The index byte can go from 0 - 8 to reference the 9 individual scratchpad bytes.

Parameters

BYTE Index
Select which pad byte to use 0-8


Return value

BYTE


BusReset

Issue a 'ping' on the bus. If there is at least one sensor on the bus then it will generate a presence pulse.


Returns 0 if a presense pulse was detected

Returns 1 no device was detected

Parameters

This macro has no parameters


Return value

BYTE


ScanBus

Scans the one wire bus to detect all devices

Parameters

This macro has no parameters


Return value

BYTE


GetDeviceCount

Returns the number of detected devices

Parameters

This macro has no parameters


Return value

BYTE


GetIDByte

Returns byte ectet of the 64-Bit lasered ROM code, 255 on error

Parameters

BYTE device
BYTE octet


Return value

BYTE


DS1820_ReadScratchpad

Reads the scratchpad of the currently selected device

Parameters

This macro has no parameters


Return value

BYTE


ReadDevice

Reads the temperature of the device at location count in the id array

Parameters

BYTE count


Return value

BYTE


DS1820_GetTemp

Returns the two byte value of the temperature sensor

Parameters

This macro has no parameters


Return value

UINT


Simulation macro reference

This component does not contain any simulation macros


Property reference

One Wire Pin

This property is of type Single digital pin and can be referenced with the variable name oo_pin.

I/O pin used to host one wire bus.

CRC Enabled

This property is of type True or false and can be referenced with the variable name crc_en.

Sets the CRC bit based error detection on or off. (cyclic redundancy check)

Label

This property is of type Line of text and can be referenced with the variable name label.

Label to draw on the GUI object for identification

Injector

This property is of type Fixed list of ints and can be referenced with the variable name Injector.

Lists all the current injector components available on the user's panel