| Online Development Notebook > Index > ODN > USBm DLL Programming > Device Commands > Reset1Wire |
Reset1Wire
VERSION 1.30+ of the firmware, VERSION 36+ of the DLL
Description:
This is a USBm.dll 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, data )
The USBm_Reset1Wire function syntax has these parts:
| Part | Description |
| device | A zero-based index to address the appropriate USB device. |
| data | The bit that will be affected. |
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 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, "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 data As Byte)_ As Integer |
VB Example
| USBm_Reset1Wire 3, 1 |
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).
| Hardware: U401 USB Interface U421 USB Interface |
| Programming: USBm DLL Programming Download Files |
| Application Notes: U4x1 Application Notes Misc Applications and Information FAQ |