Jump to content

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

From Flowcode Help
No edit summary
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(13 intermediate revisions by 2 users not shown)
Line 17: Line 17:
==Component Source Code==
==Component Source Code==


Please click here for the component source code: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_One_Wire.fcfx FC_Comp_Source_One_Wire.fcfx]
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]
 
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]


==Detailed description==
==Detailed description==




Line 38: Line 48:


==Examples==
==Examples==




Line 95: Line 113:


[[File:OneWire.jpg]]
[[File:OneWire.jpg]]


==Macro reference==
==Macro reference==


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




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===GetDeviceCount===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TransmitByte'''
| width="90%" class="mtx-class-macrohead" | '''GetDeviceCount'''
|-
|-
| colspan="2" | Transmit a byte to the one wire bus a bit at a time 
| colspan="2" | Returns the number of devices found by the last ScanBus operation. 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Command
|-
| colspan="2" |  
|-
| 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''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===GetIDByte===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SkipROM'''
| width="90%" class="mtx-class-macrohead" | '''GetIDByte'''
|-
|-
| colspan="2" | Performs a bus reset and the sends the SkipROM command byte 
| colspan="2" | Returns byte ectet of the 64-Bit lasered ROM code, 255 on error 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Device
|-
| colspan="2" | Device ID - Range: 0 - NumDevices - 1 
|-
| 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 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| 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''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===Initialise===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''BusReset'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| 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 
| colspan="2" | Sets up the 1-Wire output pin ready for communications. 
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
| 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''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MatchROM===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MatchROM'''
| width="90%" class="mtx-class-macrohead" | '''MatchROM'''
|-
|-
| colspan="2" | Performs a reset followed by the MatchROM code and then the 8-bit ROM code. 
| colspan="2" | Performs a reset followed by the MatchROM code and then the 8-bit ROM code. 
Line 178: Line 216:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===ReceiveByte===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ScanBus'''
| width="90%" class="mtx-class-macrohead" | '''ReceiveByte'''
|-
|-
| colspan="2" | Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. 
| colspan="2" | Receives a byte from the one wire bus a bit at a time 
|-
|-
|-
|-
Line 191: Line 230:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===ScanBus===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetDeviceCount'''
| width="90%" class="mtx-class-macrohead" | '''ScanBus'''
|-
|-
| colspan="2" | Returns the number of devices found by the last ScanBus operation. 
| colspan="2" | Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. 
|-
|-
|-
|-
Line 204: Line 244:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===SkipROM===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetIDByte'''
| width="90%" class="mtx-class-macrohead" | '''SkipROM'''
|-
|-
| colspan="2" | Returns byte ectet of the 64-Bit lasered ROM code, 255 on error 
| colspan="2" | Performs a bus reset and the sends the SkipROM command byte 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" | Device
|-
| colspan="2" | Device ID - Range: 0 - NumDevices - 1 
|-
| 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 
|-
| 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''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===TransmitByte===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" class="mtx-class-macrohead" | '''TransmitByte'''
|-
|-
| colspan="2" | Sets up the 1-Wire output pin ready for communications. 
| colspan="2" | Transmit a byte to the one wire bus a bit at a time 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Command
|-
|-
| colspan="2" |  
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| 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''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-
Line 260: Line 295:
| 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 
| 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 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
|-
|-

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