Labjack-Digitimer control | LabJack
 

Labjack-Digitimer control

5 posts / 0 new
Last post
Wally
adamczykfizjo's picture
Labjack-Digitimer control

Hi everyone,

I am struggling with the communication between labjack and electrnic device that trigger electrical shocks (Digitimer, DS8R). If I connect Labjack by DB15 (EIO1 pin) to Digitimer (BNC socket) I can easily trigger the shock by python comand:

import u3

lj = u3.U3()
address = 6701 #this is the address of EI01
lj.writeRegister(address,0xFF00)

j.writeRegister(address,65280+255) #give a shock

My problem is that I want to repeat the same procedure BUT with triggering shock by the screw (e.g. FIO0) NOT DB15 terminal.

I guess I need a new address, but if I changed the address in to code to e.g. "6700" it does not work. Which command I should used?

 

Thank you

Wacu

 

LabJack Support
labjack support's picture
Address 6700 is FIO states

Address 6700 is FIO states which sets all 8 FIO states. The line's direction needs to be an output to set the state. So for FIO0, see if performing this call beforehand helps:

# Address 6750 is FIO Directions. Upper byte is the mask.
# Setting FIO0 to output.
lj.writeRegister(6750, 0x0101)

To set only one line, use DIO State starting at address 6000. 6000 = FIO0, 6001 = FIO1, .FIO2 = 6002, etc.. When writing the state, it will also set the direction to an output.

If you have an U3-LV, digital lines FIO0-FI03 will be available. If using a U3-HV, digital lines FIO0-FIO3 are unavailable since they are dedicated analog input lines (AIN0-AIN3).

Just in case, you may want to also run a call like below before your digital I/O operations to make sure the FIO lines are configured as digital I/O instead of analog inputs:

# Address 50590 is FIOAnalog. Bitmask (1=Analog, 0=digital).
# Setting all FIO lines to digital I/O
lj.writeRegister(50590, 0x00)

Wally
adamczykfizjo's picture
Dear Labjack,

Dear Labjack,

Now I am struggling with another problem, and kindly ask you for little help.

I would like to send a trigger to all of EIO pins localized at DB15, the point is that each of EIO pins (from EIO0 to EIO7) is connected to one of 8 electrodes and I just need to activate one of them.

My basic code is:

 

I am struggling with the communication between labjack and electrnic device that trigger electrical shocks (Digitimer, DS8R). If I connect Labjack by DB15 (EIO1 pin) to Digitimer (BNC socket) I can easily trigger the shock by python comand:

import u3

lj = u3.U3()
address = 6701 #this is the address of EI01
lj.writeRegister(address,0xFF00)
j.writeRegister(address,65280+255) #give a shock

How I can send a trigger to other EIO pins?

I would be glad for any help... 

 

LabJack Support
labjack support's picture
Address 6701 is EIO states.

Address 6701 is EIO states. It sets all EIO lines, where of the value, bits 0 to 7 are the states (1 = high, 0 = low), and bits 8-15 are the write mask (1 = update, 0 = do not update).

Your current code is first setting all EIOs to low, then sets all EIOs high (65535 = b1111111111111111). If you want to set all lines, but only have one line high for the EIOs, then something like this (just the writeRegister calls):

address = 6701  # This is the address of EI0 States

lj.writeRegister(address, 0xFF00)  # Set all EIOs low

write_mask = 255 << 8  # Update all EIOs. Upper 8 bits. Value = 65280.
eio_bit = 1 << 2  # Update EIO2. Value = 4.
lj.writeRegister(address, write_mask + eio_bit)  # EIO2 high, other EIOs are low.

# Other EIO bits. Lower 8 bits.
#eio_bit = 1  # EIO0. Value = 1.
#eio_bit = 1 << 1  # EIO1. Value = 2.
#eio_bit = 1 << 3  # EIO3. Value = 8.
#etc.

Alternatively, you can use addresses 6008-6015 which is part of the DIO state registers. Those addresses are for EIO0-EIO7. These addresses only set one line. For example:

address = 6701  # This is the address of EI0 States
lj.writeRegister(address, 0xFF00)  # Set all EIOs low

address = 6008  # This is the address of DIO8 (EIO0)
lj.writeRegister(address, 1)  # Set EIO0 to high

#address = 6009  # This is the address of DIO9 (EIO1)
#lj.writeRegister(address, 1)  # Set EIO1 to high
#lj.writeRegister(address, 0)  # Set EIO1 to low

For the Modbus map, go here:

https://labjack.com/support/software/api/modbus/ud-modbus

 

 

Wally
adamczykfizjo's picture
Dear Labjack Support,

Dear Labjack Support,

Second solution works great!

Thank you.