« Close

Datasheets and User Guides

App Notes

Software & Driver

 

4.12 - AsynchConfig

Requires firmware V1.1 or higher. This function writes to the asynch registers and sets the direction of the D lines (input/output) as needed.

Execution time for this function is 60 milliseconds or less (typically 48 milliseconds in Windows).

The actual 1-bit time is about 1.833 plus a “full” delay (µs).

The actual 1/2-bit time is about 1.0 plus a “half” delay (µs). full/half delay = 0.833 + 0.833C + 0.667BC + 0.5ABC (µs)


Table 4.12-1. Common baud rates

Rate Full A,B,C Half A,B,C
1 55,153,232 114,255,34
10 63,111,28 34,123,23
100 51,191,2 33,97,3
300 71,23,4 84,39,1
600 183,3,6 236,7,1
1000 33,29,2 123,8,1
1200 23,17,4 14,54,1
2400 21,37,1 44,3,3
4800 10,18,2 1,87,1
7200 134,2,1 6,9,2
9600 200,1,1 48,2,1
10000 63,3,1 46,2,1
19200 96,1,1 22,2,1
38400 3,5,2 9,2,1
57600 3,3,2 11,1,1
100000 3,3,1 1,2,1
115200 9,1,1 2,1,1 or 1,1,1

When using data rates over 38.4 kbps, the following conditions need to be considered:

  • When reading the first byte, the start bit is first tested about 11.5 µs after the start of the tx stop bit.
  • When reading bytes after the first, the start bit is first tested about “full” + 11 us after the previous bit 8 read, which occurs near the middle of bit 8.

When enabled, STB does the following to aid in debugging asynchronous reads:

  • STB is set about 6 µs after the start of the last tx stop bit, or about “full” + 6 us after the previous bit 8 read.
  • STB is cleared about 0-2 us after the RX start bit is detected.
  • STB is set after about “half”.
  • STB is cleared after about “full”.
  • Bit 0 is read about 1 µs later.
  • STB is set about 1 µs after the bit 0 read.
  • STB is cleared after about “full”.
  • Bit 1 is read about 1 µs later.
  • STB is set about 1 µs after the bit 1 read.
  • STB is cleared after about “full”.
  • This continues for all 8 data bits and the stop bit, after which STB remains low.

Declaration:

long AsynchConfig (    long *idnum,
                       long demo,
                       long timeoutMult,
                       long configA,
                       long configB,
                       long configTE,
                       long fullA,
                       long fullB,
                       long fullC,
                       long halfA,
                       long halfB,
                       long halfC )

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.
Inputs:
  • *idnum – Local ID, serial number, or -1 for first found.
  • demo – Send 0 for normal operation, >0 for demo mode. Demo mode allows this function to be called without a LabJack.
  • timeoutMult – If enabled, read timeout is about 100 milliseconds times this value (0-255).
  • configA – If >0, D8 is set to output-high and D9 is set to input.
  • configB – If >0, D10 is set to output-high and D11 is set to input.
  • configTE – If >0, D12 is set to output-low.
  • fullA/B/C – Time constants for a “full” delay (1-255).
  • halfA/B/C – Time constants for a “half” delay (1-255).

Outputs:

  • *idnum – Returns the local ID or –1 if no LabJack is found.