Component: One Wire (Comms: Interface)

From Flowcode Help
Revision as of 20:35, 16 November 2021 by Wiki bot (talk | contribs)
Jump to navigationJump to search
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.

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.

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.

Downloadable macro reference

Fc9-comp-macro.png ReceiveByte
Receives a byte from the one wire bus a bit at a time 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png TransmitByte
Transmit a byte to the one wire bus a bit at a time 
Fc9-u8-icon.png - BYTE Command
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SkipROM
Performs a bus reset and the sends the SkipROM command byte 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png 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 
[[File:]] - Return


Fc9-comp-macro.png MatchROM
Performs a reset followed by the MatchROM code and then the 8-bit ROM code. 
Fc9-u8-icon.png - BYTE FamilyCode
 
Fc9-u8-icon.png - BYTE SerialNumber
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ScanBus
Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png GetDeviceCount
Returns the number of devices found by the last ScanBus operation. 
Fc9-u8-icon.png - BYTE Return


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


Fc9-comp-macro.png Initialise
Sets up the 1-Wire output pin ready for communications. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SetAnalogInput
Sets the state of a single analogue input. 
Fc9-u16-icon.png - UINT Address
Coil Address 
Fc9-u16-icon.png - UINT Value
Analogue Value range 0 - 65535 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Starts up the UART to allow communications and initialises the states of the various Modbus Coils, Inputs and Registers to 0. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Initialises the MIDI component and sets up the UART. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png CommsBaud
Sets the Baud rate of the alt communications channel 
Fc9-u8-icon.png - BYTE Baud
Range: 0-7 : 0=1200 / 7=115200 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png LCDOptions
Controls some of the LCD options 
Fc9-u8-icon.png - BYTE Foreground
Range: 0-1 
Fc9-u8-icon.png - BYTE Background
Range: 0-1 
Fc9-u8-icon.png - BYTE Transparent
Range: 0-1 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png LCDVerbose
Controls the Verbose mode. When enabled the LCD automatically displays an account of the incoming API commands and parameters. When switched off the LCD is free for the user to control as required. 
Fc9-u8-icon.png - BYTE Mode
Range: 0-1 : 0=Off or User Mode / 1=API Verbose Mode 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReadDigitalInput
Reads a single digital input. 
Fc9-u8-icon.png - BYTE Channel
 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png PWMConfig
Sets the PWM configuration. Channel = 0 - 1 : 0 = EN_AB, A, B / 1 = EN_CD, C, D Period = 0 - 65535 Scaler = 0 - 3 : 0=1:1 1=1:8 2=1:64 3=1:256 
Fc9-u8-icon.png - BYTE Channel
Range 0-1 
Fc9-u16-icon.png - UINT Period
Range: 0-65535 
Fc9-u8-icon.png - BYTE Scaler
Range: 0-3 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png PWMEnable
Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD 
Fc9-u8-icon.png - BYTE EnableMask
Range 0-63 or 0b00000 to 0b111111 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png PWMDuty
Sets a single PWM channel duty. Channel = 0 - 5 : 0=EN_AB, 1=A, 2=B, 3=C, 4=D, 5=EN_CD Duty = 0 - 65535 
Fc9-u8-icon.png - BYTE Channel
Range 0-5 
Fc9-u16-icon.png - UINT Duty
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png LCDCursor
Sets the cursor position for the MIAC display 
Fc9-u8-icon.png - BYTE X
Range: 0-21 
Fc9-u8-icon.png - BYTE Y
Range: 0-4 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png WriteTran
Allows a single transistor output to be switched on or off. 
Fc9-u8-icon.png - BYTE Channel
Range 1-4 
Fc9-u8-icon.png - BYTE Value
0 = Off, 1 = On 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png LCDClear
Clears the MIAC display 
Fc9-void-icon.png - VOID Return



Property reference

Fc9-prop-icon.png Properties
Fc9-type-5-icon.png One Wire Pin
I/O pin used to host one wire bus. 
Fc9-type-21-icon.png 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 
Fc9-type-21-icon.png 6us Nops
 
Fc9-type-21-icon.png 9us Nops
 
Fc9-type-21-icon.png 10us Nops
 
Fc9-type-21-icon.png Nop Fiddle
 
Fc9-conn-icon.png Connections
Fc9-conn-icon.png Simulations
Fc9-type-16-icon.png API
Lists all the current injector components available on the user's panel