Set up ⁄ reset a 1-wire bus⁄device
VERSION 1.30+ of the firmware, VERSION 36+ of the DLL
Description:
This is a function to send a 1-wire (MicroLAN) reset pulse on the selected port pin. This command also sets the port pin for subsequent 1-wire write and read commands. The port pin direction is controlled by the 1-wire commands.
Command Syntax: (USBm.dll)
USBm_Reset1Wire( device, dataarray )
The USBm_Reset1Wire function syntax has these parts:
Part | Description |
device | A zero-based index to address the appropriate USB device. |
dataarray | The bit that will be affected. Minimum size of the array is 8. |
Remarks:
This command sets the port direction for the selected pin.
Bit⁄Line Selection
Byte Value | Result | Byte Value | Result | |
00h | Use A.0 as 1-wire bus | 08h | Use B.0 as 1-wire bus | |
01h | Use A.1 as 1-wire bus | 09h | Use B.1 as 1-wire bus | |
02h | Use A.2 as 1-wire bus | 0Ah | Use B.2 as 1-wire bus | |
03h | Use A.3 as 1-wire bus | 0Bh | Use B.3 as 1-wire bus | |
04h | Use A.4 as 1-wire bus | 0Ch | Use B.4 as 1-wire bus | |
05h | Use A.5 as 1-wire bus | 0Dh | Use B.5 as 1-wire bus | |
06h | Use A.6 as 1-wire bus | 0Eh | Use B.6 as 1-wire bus | |
07h | Use A.7 as 1-wire bus | 0Fh | Use B.7 as 1-wire bus |
The port pin that is selected as a 1-wire bus is configured with an internal pull-up resistor of approximately 14k ohm. During idle bus times it is this resistor that pulls the line high. When the U4x1 transmits a low signal on the bus, it pulls the line low with an open collector device.
Multiple 1-wire buses can exist simultaneously on the U4x1. It is the Reset1Wire command that sets the port configuration for a specific line, plus sets the subsequent read⁄write commands to use that line.
After the function is called, “data” contains a value that indicates if any device returns a presence pulse. If a device was detected, data will contain 00h. If no device was detected, data will contain 01h.
The U4x1 devices support 1-wire communication with any 1-wire device. When you select an I⁄O port line of the U4x1 to use as the connection to a 1-wire device, you have changed that line from just being a digital I⁄O line to a 1-wire bus. The Reset1Wire command configures the line with a 14kohm pull up resistor, and issues a reset pulse on that line. The Reset1Wire command returns (via a pointer – see the command description) an indication of the reception of the device presense pulse.
If you select a particular line to use as the 1-wire bus, you do so with the Reset1Wire command. A Read1Wire command or a Write1Wire command will operate on the line that was last referenced by the Reset1Wire command.
What this means is that you can use all 16 lines on the U4x1 as 16 seperate 1-wire busses. Issuing the Reset1Wire command is the way to get attention of the 1-wire devices on that bus, prior to using the Read1Wire and Write1Wire commands to communicate with the 1-wire device. You can use Reset1Wire to select and communicate with one line of the U4x1, then use it again to communicate with a different line on the U4x1.
You can use all 16 lines on the U4x1 to communicate with 16 1-wire devices, one per line. But you can also have multiple 1-wire devices on each line, and address them individually by using their ROM serial numbers. The 1-wire device documentation contains the details that you need to communicate with 1-wire devices.
The internal 14kohm pull up resistor will suffice for a short bus distance, but you should consider supplementing with a 10kohm resistor external to the U4x1 device. The 10kohm resistor would be connected between the 1-wire data line and Vcc (+5V).
VB Declaration
Public Declare Function USBm_Reset1Wire _ Lib “USBm.dll” _ (ByVal device As Byte, _ ByRef dataarray As Byte)_ As Integer |
VB Example
Dim dataarray(8) as Byte dataarray(0) = 1 USBm_Reset1Wire 3, dataarray(0) |
This code fragment addresses U4x1 device #3, and issues a reset pulse on pin 1 (A.1).
C Prototype
int USBm_Reset1Wire( unsigned char device, unsigned char * data ); |
C Example
data = 1; USBm_Reset1Wire( 3, data); |
This code fragment addresses U4x1 device #3, and issues a reset pulse on pin 1 (A.1).
RobotBASIC
usbm_Reset1Wire(ne_DeviceNumber,ne_Specs)
Returns the status of any devices on the 1wire line. Returns 0 if any device reponded and 1 if none did. This function sets up the 1wire line to be used.
Raw Command Format:
Byte Number | Description |
0 | 1Dh: Reset1WireCmd |
1 | Pin – The bit that will be affected. |
2 | <not used> |
3 | <not used> |
4 | <not used> |
5 | <not used> |
6 | <not used> |
7 | <not used> |
Raw Command Format Details:
Byte 0 contains the command. Byte 1 is the port pin that is selected as a 1-wire bus is configured with an internal pull-up resistor of approximately 14k ohm. During idle bus times it is this resistor that pulls the line high. When the U4x1 transmits a low signal on the bus, it pulls the line low with an open collector device.
Bit⁄Line Selection
Byte Value | Result | Byte Value | Result | |
00h | Use A.0 as 1-wire bus | 08h | Use B.0 as 1-wire bus | |
01h | Use A.1 as 1-wire bus | 09h | Use B.1 as 1-wire bus | |
02h | Use A.2 as 1-wire bus | 0Ah | Use B.2 as 1-wire bus | |
03h | Use A.3 as 1-wire bus | 0Bh | Use B.3 as 1-wire bus | |
04h | Use A.4 as 1-wire bus | 0Ch | Use B.4 as 1-wire bus | |
05h | Use A.5 as 1-wire bus | 0Dh | Use B.5 as 1-wire bus | |
06h | Use A.6 as 1-wire bus | 0Eh | Use B.6 as 1-wire bus | |
07h | Use A.7 as 1-wire bus | 0Fh | Use B.7 as 1-wire bus |
Multiple 1-wire busses can exist simultaneously on the U4x1. It is the Reset1Wire command that sets the port configuration for a specific line, plus sets the subsequent read⁄write commands to use that line.
After the function is called, the returned byte contains a value that indicates if any device returns a presence pulse. If a device was detected, the returned byte will be 00h. If no device was detected, the byte will be 01h.
The U4x1 devices support 1-wire communication with any 1-wire device. When you select an I⁄O port line of the U4x1 to use as the connection to a 1-wire device, you have changed that line from just being a digital I⁄O line to a 1-wire bus. The Reset1Wire command configures the line with a 14kohm pull up resistor, and issues a reset pulse on that line. The Reset1Wire command returns (via a pointer – see the command description) an indication of the reception of the device presense pulse.
If you select a particular line to use as the 1-wire bus, you do so with the Reset1Wire command. A Read1Wire command or a Write1Wire command will operate on the line that was last referenced by the Reset1Wire command.
What this means is that you can use all 16 lines on the U4x1 as 16 seperate 1-wire busses. Issuing the Reset1Wire command is the way to get attention of the 1-wire devices on that bus, prior to using the Read1Wire and Write1Wire commands to communicate with the 1-wire device. You can use Reset1Wire to select and communicate with one line of the U4x1, then use it again to communicate with a different line on the U4x1.
You can use all 16 lines on the U4x1 to communicate with 16 1-wire devices, one per line. But you can also have multiple 1-wire devices on each line, and address them individually by using their ROM serial numbers. The 1-wire device documentation contains the details that you need to communicate with 1-wire devices.
The internal 14kohm pull up resistor will suffice for a short bus distance, but you should consider supplementing with a 10kohm resistor external to the U4x1 device. The 10kohm resistor would be connected between the 1-wire data line and Vcc (+5V).
Raw Command Response Format:
Byte Number | Description |
0 | 1Dh: StepperCmd |
1 | Status |
2 | <not used> |
3 | <not used> |
4 | <not used> |
5 | <not used> |
6 | <not used> |
7 | <not used> |
Raw Command Response Format Details:
Byte 0 contains the command.
Byte 1 contains the connection status.
Byte 2 through byte 7 are unused.