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""
 
(24 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==


===Device Scanning===
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]


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.
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]


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.
==Detailed description==


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}}




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.


{{fcfile|OneWire_Device_ID_Serial.fcfx|One Wire Device Scan Serial}}




[[file: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.


*[[Component:_Temperature_(DS1822)_(Environmental)|DS1822 Temperature Sensor]]
*[[Component:_Temperature_(DS18B20)_(Environmental)|DS18B20 Temperature Sensor]]
*[[Component:_Temperature_(DS18S20)_(Environmental)|DS18S20 Temperature Sensor]]






==Downloadable macro reference==


===<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'''
''No detailed description exists yet for this component''


:[[Variable Types|BYTE]]
==Examples==




===<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>SkipROM</tt></u></span>===
Performs a bus reset and the sends the SkipROM command byte


'''Parameters'''


:''This macro has no parameters''




'''Return value'''


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




===<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|BOOL]] : Returns true if the operation is a success, else false
===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.


===<span style="font-weight: normal;"><u><tt>MatchROM</tt></u></span>===
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.
Performs a reset followed by the MatchROM code and then the 8-bit ROM code.


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


:[[Variable Types|BYTE]] ''FamilyCode''
{{fcfile|OneWire_Device_ID_LCD.fcfx|One Wire Device Scan LCD}}


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


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.


'''Return value'''
{{fcfile|OneWire_Device_ID_Serial.fcfx|One Wire Device Scan Serial}}


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


[[file:OneWireDeviceScan.jpg]]


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


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


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


:''This macro has no parameters''
A pull up resistor of between 1K and 10K is required between the data I/O pin and VCC.




'''Return value'''
===Further Examples===


:[[Variable Types|BYTE]]
The One Wire component is a key building block required by a number of other components. Some of which are included below.


*[[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]]


===<span style="font-weight: normal;"><u><tt>GetDeviceCount</tt></u></span>===
Returns the number of devices found by the last ScanBus operation.


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


:''This macro has no parameters''
[[File:OneWire.jpg]]




'''Return value'''


:[[Variable Types|BYTE]]




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


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




'''Return value'''


:[[Variable Types|BYTE]]
==Macro reference==


===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''
|}


===<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'''
===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''
|}


:[[Variable Types|BYTE]] ''Device''
::Device ID - Range: 0 - NumDevices - 1


:[[Variable Types|BYTE]] ''ByteIndex''
===GetIDByte===
::Index of the data byte. 0=FamilyCode, 1-6=Serial, 7=CRC
{| 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''
|}




'''Return value'''
===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''
|}


:[[Variable Types|BYTE]]


===MatchROM===
{| 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''
|}


===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
Sets up the 1-Wire output pin ready for communications.


'''Parameters'''
===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''
|}


:''This macro has no parameters''


===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''
|}


'''Return value'''


:''This call does not return a value''
===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''
|}




 
===TransmitByte===
==Simulation macro reference==
{| class="mtx-class-macrotable wikitable"
 
|-
''This component does not contain any simulation macros''
| 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''
|}




==Property reference==
==Property reference==
<span style="font-weight: normal;"><u>One Wire Pin</u></span>


This property is of type ''Single digital pin'' and can be referenced with the variable name ''oo_pin''.
{| class="mtx-class-macrotable wikitable"
 
|-
I/O pin used to host one wire bus.
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
 
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
<span style="font-weight: normal;"><u>Timing</u></span>
|-
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Timing''.
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | One Wire Pin
Sets the component timing model.
|-
 
| colspan="2" | I/O pin used to host one wire bus.&nbsp;
Standard is the usual 1-wire timing,
|-
 
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
Overdrive is a high speed 1-wire timing.
| width="90%" | Max Devices
 
|-
<span style="font-weight: normal;"><u>Max Devices</u></span>
| 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;
 
|-
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''BufferSize''.
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
 
| width="90%" class="mtx-class-propfolder" | Simulation
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.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | API
Default: 8 = 64 Bytes of RAM
|-
| 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