Communication with multiple serial devices on the T7 | LabJack
 

Communication with multiple serial devices on the T7

7 posts / 0 new
Last post
jhenise
jhenise44's picture
Communication with multiple serial devices on the T7

I just acquired some combo CO2/T/RH sensors that provide data through simple asynchronous serial com.

It looks like RX and TX for asynchronous serial com can be set up on any digital pins of the T7.

How would I communicate with two sensors though? is it possible to set up more then one TX and RX channel on the T7?

Is that possible?

 

 

 

 

LabJack Support
labjack support's picture
The asynch feature can only

The asynch feature can only be enabled on one pair of pins at a time.  What that really means is that only one RX pin can read data at a time.  When you enable the asynch feature on a pair of pins, a buffer is set up and the RX pin sits and reads any data that comes in and stores it in the buffer.  This is useful for devices that spontaneously send out data and if you need to read all that data all the time.  Most serial devices, however, are command-response.  You send a command that requests a reading, and the device responds with the reading.  For these you can easily do multiple, where you just keep re-doing the configuration whenever you want to talk over different pins.

https://labjack.com/support/datasheets/t-series/digital-io/asynchronous-...

 

jhenise
jhenise44's picture
Thanks for the reply.

Thanks for the reply.

My CO2 sensors have both types of mode: MODE 1 the sensor will just power up and send data twice per second. MODE 2 the sensor will send data after being polled with a command. 

So you are saying that MODE2 would be best for using two sensors?  I just configure asynchronous comm on the digital pins for RX and TX to sensor #1, poll it and after receiving the response, configure asynchronous comm on the digital pins for RX and TX to sensor #2, poll it, and repeat. Correct?   

How fast to you think I can do this routine? I would imaging 1-2 readings per sensor per second should be easy? The T7 will be connected to teh computer over WiFi.

ALSO I am using the native SBUS support on the T7 to read two of your 1050 temp/RH sensors through DAQFactory. Both of the 1050's are hooked up to FIO0 as the data line, FIO1 as the clock, FIO2 as 3.3V power, and then FI06 to enable sensor 1, and FI07 to enable sensor 2. I activate sensor 1, take a reading, wait a second activate sensor 2, wait a second, repeat... that works great.

I am using a LJTick-DigitalOut5V on the VS,GND,FIO4,FIO5 terminal block for a PWM application using CLOCK0 on FIO4.

So it sounds like I can still use any four remaining digital pins for the two TX,RX lines to my CO2 sensors, correct? or is there s problem using SBUS at teh same time?

LabJack Support
labjack support's picture
So you are saying that MODE2

So you are saying that MODE2 would be best for using two sensors?  I just configure asynchronous comm on the digital pins for RX and TX to sensor #1, poll it and after receiving the response, configure asynchronous comm on the digital pins for RX and TX to sensor #2, poll it, and repeat. Correct?

Correct.

 

How fast to you think I can do this routine? I would imaging 1-2 readings per sensor per second should be easy? The T7 will be connected to teh computer over WiFi.

A couple readings per second per sensor should be no problem.  The WiFi overhead will be roughly 7 ms, and then just add the time to send/receieve x number of bits at your bit rate:

https://labjack.com/support/datasheets/t-series/appendix-a-1

 

So it sounds like I can still use any four remaining digital pins for the two TX,RX lines to my CO2 sensors, correct? or is there s problem using SBUS at teh same time?

No problem.

 

jhenise
jhenise44's picture
getting stuck on how to do

getting stuck on how to do teh actual RX and TX...
 

From within a DAQFactory script I configure the "port" as such:

      global string identifier = "any"        

LJM_eWriteName(identifier, "ASYNCH_TX_DIONUM", 21)               

LJM_eWriteName(identifier, "ASYNCH_RX_DIONUM", 20)               

LJM_eWriteName(identifier, "ASYNCH_BAUD", 9600)                  

LJM_eWriteName(identifier, "ASYNCH_RX_BUFFER_SIZE_BYTES", 1000)  

LJM_eWriteName(identifier, "ASYNCH_NUM_DATA_BITS", 8)           

LJM_eWriteName(identifier, "ASYNCH_NUM_STOP_BITS", 1)             

LJM_eWriteName(identifier, "ASYNCH_PARITY", 0)                   

LJM_eWriteName(identifier, "ASYNCH_ENABLE", 1)   

 

For transmit this may be correct to transmit the character "A" but I have no idea if I am using the middle function correctly or if it can be used from within a DAQ factory script...

LJM_eWriteName(identifier, "ASYNCH_NUM_BYTES_TX", 1)              

LJM_eWriteNameByteArray(identifier, "ASYNCH_DATA_TX", 1, "A")          

LJM_eWriteName(identifier, "ASYNCH_TX_GO", 1)               

 

Similar with receive, I get the first part to find the number of bytes in the Lab Jack buffer, and think I an utilizing it correctly by setting it equal to a DAQ Factory variable but have no idea how to use the second fuction to read the buffer and get the data...

 

global byte_number = 0

byte_number = LJM_eReadName(identifier, "ASYNCH_NUM_BYTES_RX")    //The number of data bytes that have been received.

LJM_eReadNameByteArray(identifier, "ASYNCH_DATA_RX", byte_number, ?????

Any info would be greatly appreciated!

LabJack Support
labjack support's picture
You do need LJM

You do need LJM_eWriteNameByteArray and LJM_eReadNameByteArray. According to this DAQFactory forum post, AzeoTech is working on adding these functions. It sounds like you could contact them directly to get the beta.

jhenise
jhenise44's picture
yes LJM_eWriteNameByteArray

yes LJM_eWriteNameByteArray and LJM_eReadNameByteArray were the functions that I was getting stuck on from within DAQFactory.

I have contacted them about how to use them / or a release that supports them... I will post the solution here when I figure it out!