« Close

Datasheets and User Guides

App Notes

Software & Driver

 

4.4 - EDigitalIn

Easy function. This is a simplified version of DigitalIO that reads the state of one digital input. Also configures the requested pin to input and leaves it that way.

Execution time for this function is 20 milliseconds or less (typically 16 milliseconds in Windows).

Note that this is a simplified version of the lower level function DigitalIO, which operates on all 20 digital lines. The DLL (ljackuw) attempts to keep track of the current direction and output state of all lines, so that this easy function can operate on a single line without changing the others. When the DLL is first loaded, though, it does not know the direction and state of the lines and assumes all directions are input and output states are low.

Declaration:

long EDigitalIn (    long *idnum,
                     long demo,
                     long channel,
                     long readD,
                     long *state )

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.
  • channel – Line to read. 0-3 for IO or 0-15 for D.
  • readD – If >0, a D line is read as opposed to an IO line.

Outputs:

  • *idnum – Returns the local ID or –1 if no LabJack is found.
  • *state – The selected line is TRUE/Set if >0. FALSE/Clear if 0.

LabJackPython Example

  
>>> import u12
>>> d = u12.U12()
>>> d.eDigitalIn(channel=0, readD=0)
{'state': 1, 'idnum': 12}
  

2 comments

If I wanted to read from two eDigitalIn lines at the same time, is this possible?

I want to read from channel 0 then a short time later, read from channel 1 then channel 2 and so on

Can I read from these channels all at the same time?

This is what I have so far:

import u12

d = u12.U12()

enter = d.eDigitalIn(channel=0, readD=1)

exit = d.eDigitalIn(channel=1, readD=1)

if (enter['state'] == 1)

#do something to signal entering area

if (exit['state'] == 1)

#do something to signal exited area

EDigitalIn is an easy way to read 1 digital input at a time, as you have shown.  If you prefer to read multiple inputs in a single call, check out DigitalIO (or AISample, AOUpdate, Counter).  See the end of Section 4.0 for discussion of the binary packed digital I/O parameters.