Jump to content

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

From Flowcode Help
XML import
 
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(41 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{| style="width:50%"
 
{| width="50%"
|-
|-
| width="20%" style="color: gray;" | Author
| width="20%" style="color:gray;" | Author
| Matrix Ltd
| Matrix Ltd
|-
|-
| width="20%" style="color: gray;" | Version
| width="20%" style="color:gray;" | Version
| 1.3 (Release)
| 1.4
|-
|-
| width="20%" style="color: gray;" | Category
| width="20%" style="color:gray;" | Category
| Comms: Interface
| Comms: Interface
|}
|}




 
==One Wire component==
==[[File:Component Icon 64b26b13_68cf_4a92_8616_e882b7c71023.png|Image]] One Wire component==
Low level routines for controlling or interacting with a standard one wire interface.
Low level routines for controlling or interacting with a standard one wire interface.


==Examples==
==Component Source Code==
''<span style="color:red;">No additional examples</span>''


Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_One_Wire.fcfx FC_Comp_Source_One_Wire.fcfx]


==Downloadable macro reference==
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_One_Wire.fcfx FC_Comp_Source_One_Wire.fcfx]


===<span style="font-weight: normal;"><u><tt>DS1820_StartConversion</tt></u></span>===
==Detailed description==
DS1820 device specific function


Commands all sensors to start a temperature conversion


'''Parameters'''


:''This macro has no parameters''




'''Return value'''


:[[Variable Types|BYTE]]




===<span style="font-weight: normal;"><u><tt>ReceiveByte</tt></u></span>===
Receives a byte from the one wire bus a bit at a time


'''Parameters'''


:''This macro has no parameters''




'''Return value'''


:[[Variable Types|BYTE]]




===<span style="font-weight: normal;"><u><tt>TransmitByte</tt></u></span>===
Transmit a byte to the one wire bus a bit at a time


'''Parameters'''


:[[Variable Types|BYTE]] ''Command''




'''Return value'''


:''This call does not return a value''




===<span style="font-weight: normal;"><u><tt>GetPadByte</tt></u></span>===
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'''
''No detailed description exists yet for this component''


:[[Variable Types|BYTE]] ''Index''
==Examples==
::Select which pad byte to use 0-8




'''Return value'''


:[[Variable Types|BYTE]]




===<span style="font-weight: normal;"><u><tt>BusReset</tt></u></span>===
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'''


:[[Variable Types|BYTE]]




===<span style="font-weight: normal;"><u><tt>ScanBus</tt></u></span>===
Scans the one wire bus to detect all devices


'''Parameters'''


:''This macro has no parameters''




'''Return value'''


:[[Variable Types|BYTE]]




===<span style="font-weight: normal;"><u><tt>GetDeviceCount</tt></u></span>===
Returns the number of detected devices


'''Parameters'''


:''This macro has no parameters''
===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.


'''Return value'''
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.


:[[Variable Types|BYTE]]
Here is a program that scans for devices on a one wire bus and outputs the device count and serial numbers using a LCD.


{{fcfile|OneWire_Device_ID_LCD.fcfx|One Wire Device Scan LCD}}


===<span style="font-weight: normal;"><u><tt>GetIDByte</tt></u></span>===
Returns byte ectet of the 64-Bit lasered ROM code, 255 on error


'''Parameters'''
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.


:[[Variable Types|BYTE]] ''device''
{{fcfile|OneWire_Device_ID_Serial.fcfx|One Wire Device Scan Serial}}


:[[Variable Types|BYTE]] ''octet''


[[file:OneWireDeviceScan.jpg]]


'''Return value'''


:[[Variable Types|BYTE]]
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.


===<span style="font-weight: normal;"><u><tt>DS1820_ReadScratchpad</tt></u></span>===
A pull up resistor of between 1K and 10K is required between the data I/O pin and VCC.
Reads the scratchpad of the currently selected device


'''Parameters'''


:''This macro has no parameters''
===Further Examples===


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


'''Return value'''
*[[Component:_Temperature_(DS1822)_(Environmental)|DS1822 Temperature Sensor]]
*[[Component:_Temperature_(DS18B20)_(Environmental)|DS18B20 Temperature Sensor]]
*[[Component:_Temperature_(DS18S20)_(Environmental)|DS18S20 Temperature Sensor]]
*[[Component:_EEPROM_(DS28E07)_(Storage)|DS28E07 128 Byte EEPROM]]
*[[Component:_IButton_(DS1990)_(Storage)|DS1990 iButton Unique 48-bit ID]]


:[[Variable Types|BYTE]]


Example One Wire comms component being referenced by several specific One Wire device library components.


===<span style="font-weight: normal;"><u><tt>ReadDevice</tt></u></span>===
[[File:OneWire.jpg]]
Reads the temperature of the device at location count in the id array


'''Parameters'''


:[[Variable Types|BYTE]] ''count''




'''Return value'''


:[[Variable Types|BYTE]]




===<span style="font-weight: normal;"><u><tt>DS1820_GetTemp</tt></u></span>===
Returns the two byte value of the temperature sensor


'''Parameters'''


:''This macro has no parameters''




'''Return value'''
==Macro reference==


:[[Variable Types|UINT]]
===BusReset===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''BusReset'''
|-
| colspan="2" | 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&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




===GetDeviceCount===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''GetDeviceCount'''
|-
| colspan="2" | Returns the number of devices found by the last ScanBus operation.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
===GetIDByte===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''GetIDByte'''
|-
| colspan="2" | Returns byte ectet of the 64-Bit lasered ROM code, 255 on error&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Device
|-
| colspan="2" | Device ID - Range: 0 - NumDevices - 1&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | ByteIndex
|-
| colspan="2" | Index of the data byte. 0=FamilyCode, 1-6=Serial, 7=CRC&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


==Simulation macro reference==


''This component does not contain any simulation macros''
===Initialise===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
| colspan="2" | Sets up the 1-Wire output pin ready for communications.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




==Property reference==
===MatchROM===
<span style="font-weight: normal;"><u>One Wire Pin</u></span>
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''MatchROM'''
|-
| colspan="2" | Performs a reset followed by the MatchROM code and then the 8-bit ROM code.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | FamilyCode
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | SerialNumber
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


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.
===ReceiveByte===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''ReceiveByte'''
|-
| colspan="2" | Receives a byte from the one wire bus a bit at a time&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


<span style="font-weight: normal;"><u>CRC Enabled</u></span>


This property is of type ''True or false'' and can be referenced with the variable name ''crc_en''.
===ScanBus===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''ScanBus'''
|-
| colspan="2" | Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


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


<span style="font-weight: normal;"><u>Label</u></span>
===SkipROM===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''SkipROM'''
|-
| colspan="2" | Performs a bus reset and the sends the SkipROM command byte&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


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
===TransmitByte===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''TransmitByte'''
|-
| colspan="2" | Transmit a byte to the one wire bus a bit at a time&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Command
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


<span style="font-weight: normal;"><u>Injector</u></span>


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


Lists all the current injector components available on the user's panel
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" class="mtx-class-macrohead" | '''Properties'''
|-
|-
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
| width="90%" | One Wire Pin
|-
| colspan="2" | I/O pin used to host one wire bus.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
| width="90%" | Max Devices
|-
| colspan="2" | Controls the maximum number of devices that can be detected during a ScanBus. For each additional device we require 8 bytes to store the ROM ID. Default: 8 = 64 Bytes of RAM&nbsp;
|-
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | API
|-
| colspan="2" | Lists all the current injector components available on the user's panel&nbsp;
|}

Latest revision as of 14:37, 13 July 2026

Author Matrix Ltd
Version 1.4
Category Comms: Interface


One Wire component

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

Component Source Code

Please click here to download the component source project: FC_Comp_Source_One_Wire.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_One_Wire.fcfx

Detailed description

No detailed description exists yet for this component

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.

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.

One Wire Device Scan Serial



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.


Example One Wire comms component being referenced by several specific One Wire device library components.






Macro reference

BusReset

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 
- BOOL Return


GetDeviceCount

GetDeviceCount
Returns the number of devices found by the last ScanBus operation. 
- BYTE Return


GetIDByte

GetIDByte
Returns byte ectet of the 64-Bit lasered ROM code, 255 on error 
- BYTE Device
Device ID - Range: 0 - NumDevices - 1 
- BYTE ByteIndex
Index of the data byte. 0=FamilyCode, 1-6=Serial, 7=CRC 
- BYTE Return


Initialise

Initialise
Sets up the 1-Wire output pin ready for communications. 
- VOID Return


MatchROM

MatchROM
Performs a reset followed by the MatchROM code and then the 8-bit ROM code. 
- BYTE FamilyCode
 
- BYTE SerialNumber
 
- VOID Return


ReceiveByte

ReceiveByte
Receives a byte from the one wire bus a bit at a time 
- BYTE Return


ScanBus

ScanBus
Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. 
- BYTE Return


SkipROM

SkipROM
Performs a bus reset and the sends the SkipROM command byte 
- VOID Return


TransmitByte

TransmitByte
Transmit a byte to the one wire bus a bit at a time 
- BYTE Command
 
- VOID Return


Property reference

Properties
One Wire Pin
I/O pin used to host one wire bus. 
Max Devices
Controls the maximum number of devices that can be detected during a ScanBus. For each additional device we require 8 bytes to store the ROM ID. Default: 8 = 64 Bytes of RAM 
Simulation
API
Lists all the current injector components available on the user's panel