Serial Communication With Sensor


tamm

Recommended Posts

Hi.

I want to connect a gas sensor to DAQFactory via a U3 Labjack. The sensor has two options for connection:

1) analog

2) digital

I know how to connect using the analog signal. However, it would be interesting for me to use the digital signal instead.

In the sensor's documentation for the serial protocol, there is information on the baud rate and what to send to the sensor in order to get a response containing the current reading. But I am not sure if it is possible to do such communication with DAQFactory and the U3, and I'm a bit lost where to begin actually. As long as I understand DF, I can set pins on the U3 to high and low, but this is certainly not enough to get some serial communication with the sensor.

Any hint is appreciated!

If it helps, I can even post the protocol specifications.

Thank you!

Link to comment
Share on other sites

If you want to go digital and its a serial connection (RS232) you should skip the LabJack and just use a normal serial port.  You can buy a cheap USB-Serial converter for $20 from radio shack.  I usually don't recommend these for industrial use, but if you are doing a bench top experiment that isn't mission critical, you can use one of these cheap ones.  Anything else, including needing more than one, and you should use ones from SeaLevel or other industrial rated (and therefore more expensive, i.e. $200) ones.

 

To try and use the U3 to do serial communications is kind of like trying to dig a big hole in the ground to plant a tree with a spoon.  Yeah, you can probably do it, but its not the right tool for the job.

Link to comment
Share on other sites

The U3 does support asynchronous serial communication, so you don't have to bit-bang it:

 

http://labjack.com/support/u3/users-guide/4.3.12

 

... but using a cheap USB<=>RS232 dongle will be easier.  I would only use the U3 for the asynchronous serial communication if there is a specific reason not to use a dedicated RS232 adapter.

 

U3 via Bit-Bang:  Dig a hole with a spoon.

U3 using Asynch functions:  Dig a hole with a shovel.

RS232 adapter:  Dig a hole with a backhoe.

Link to comment
Share on other sites

Depending on the sensor there usually are advantages to using digital over analog.  If, internally, the sensor is going to digital first, then converting to analog using a D to A to give you the analog output, then you are adding error in that digital to analog transition.  By going digital the whole way you skip converting it to analog and then back to digital.  But even if the device is giving you the analog signal from the sensor and instead has an A to D converter that makes the digital, there are two reasons you should still consider digital: 1) the A to D on the sensor may be higher resolution than the LabJack, and it may be calibrated specifically for the sensor, 2) if your sensor is any distance from the LabJack you have the possibility of introducing noise to the line if using analog.  This won't occur if you go digital (thus the reason cell phones are all digital now).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.