Thursday, December 14, 2017
Home » Flowstone Workshop » Flowstone Workshop 3

Flowstone Workshop 3

Flowstone-Header

Programming Data Acquisition Devices: Signal Conditioning Explained

FLOWSTONE WORKSHOP 3-1Welcome to the third of our FlowStone workshops where we give a beginners guide to programming robotics using the FlowStone programming language. This issue we are going to cover Data Acquisition boards or DAQ’s as they are better known.

Data acquisition devices form the basis of most robotics systems getting signals in and out of a system from external hardware (switches, knobs, sensors etc.). These signals come in several guises, from analogue and digital, to pulse width or timing signals. There are literally hundreds of DAQ boards available to use with FlowStone, so we have selected a few examples from different manufacturers to highlight the differences.

The term ‘Data Acquisition’ covers a multitude of IO possibilities and there are many subtle differences in how the signals are conditioned on each device. The basic idea being that you connect an electrical signal to the board and it translates this into some form of computer data, like a number or a state (true or false). In order to do this, certain electrical characteristics have to be fulfilled and this is where it can get confusing.

SIGNAL TYPES AND LEVELS 

The signal types for DAQ boards usually comes down to analogue or digital, but in order to get your data processed correctly, there is usually some form of signal conditioning necessary and, this is usually hidden deep in a data sheet somewhere.

For Example:

A Digital Input: 0 or 1 but what signal level represents a 0 or a 1, what is the maximum voltage? If the voltage goes over will it nuke the board etc.

So here is a rough guide to signal conditioning for DAQ’s:

INPUTS—DIGITAL INPUTS 

Inside FlowStone Digital Inputs are represented as Bool (Boolean ie. true or false), and on the DAQ board this will be a DC voltage, usually referred to as TTL or CMOS, together with a max voltage figure (eg. 5V TTL).

TL is usually 5V and CMOS is usually 3.3V, however this not always the case so you will need to check the data sheets. It could be 3.3V, 5V, 12V, or 24V for either!

So let’s say you have a simple switch, switching a signal from a 12V battery, and the input is 5V TTL. Usually there is an absolute max voltage say 5.5V which if exceeded will damage the board. Also the OFF state is usually around 50% of the ON state, so in this case anything < 2.5V will be read as a 0, and anything >2.5V will be read as a 1, again this can vary!

So it’s pretty clear that if we connected the 12V signal into our 5V board, there would be smoke! This is where signal conditioning comes in; we need to drop our 12V signal to 5V somehow?

FLOWSTONE WORKSHOP 3-2
The basic idea being that you connect an electrical signal to the board and it translates this into some form of computer data, like a number or a state (true or false). In order to do this, certain electrical characteristics have to be fulfilled

The solution is to use a Potential Divider. This is two external resistors connected in series, where the 12V signal connected to one end, and the 5V signal is tapped from the junction, then the other end is then connected to ground. This simple circuit works perfectly with DAQ devices as the current required by the TTL or CMOS inputs is so low it becomes negligible in the math.

FLOWSTONE WORKSHOP 3-3
Potential Divider

Using Ohms Law you can calculate the resistor values as follows: Vout = R2 . Vin R1+R2 So in our example for ease of math we could use a total resistance of 12K ohms, R1 = 7K and R2 = 5K So Vout = 5000 . 12 = 5.00 V 12000 In reality the resistor values might be slightly different as they come in odd values like 4.7K and 7.2K, which is okay as long as the absolute max voltage isn’t exceeded: Vout = 4700 .12 = 4.73 V 11900

ANALOGUE INPUTS 

Analogue signals are usually fed into a device called an Analogue to Digital Converter or A/D for short; this converts a varying voltage into a Number inside FlowStone. A/D converters also suffer from the same voltage restrictions as the digital inputs, and usually provide a stabilized reference voltage to help with the signal conditioning. Again a Potential Divider can be used to drop a higher voltage to the reference voltage. Frequently A/D converters use a reference like 3.3V, so you will need to check in the data sheets what it is for any given board.

However there are also other considerations when providing signal conditioning for A/D converters. There is Dynamic Range (what it the biggest number that can be represented), is it polar or bi-polar ( is it just positive signals (0-3.3V)or positive and negative (+3.3 to -3.3), and finally the sampling rate (what is the maximum frequency you can read? 1hz, 100hz, 1Khz etc.).

REFERENCE VOLTAGE 

This is usually a stabilized and very accurate voltage to be used as the A/D reference. This is usually the max voltage the A/D can read.

DYNAMIC RANGE

Dynamic Range is the difference between the largest and smallest signals.

Usually described in ‘Bits’ (8 bit, 10bit, 16bit, 24bit etc.) this is the maximum number or limit of the signal resolution. You can calculate the actual max number using: 2 to the power of the bits or 2^b where b= bits. So 2^8 = 256, 2^10 = 1024, 2^16 = 65536, 2^24 = 1677216

So here you can see that the dynamic range is very important if you want a lot of resolution.

PROGRAMMING DATA ACQUISITION DEVICES 

To illustrate this imagine a vibration sensor on the Space Shuttle, when it launches the vibration will be huge, but in Space everything is calm. Let’s say Launch = 90% of the full signal and in Space the signals are only 1%. So if you want to detect any minor vibrations in space you will need a large Dynamic Range to read both large and small signals. Say you used an 8 bit A/D converter, that would give you only 256 steps between the largest and smallest signal, so in Space the reading would be only max 3 steps, a very poor resolution. If we then used a 16bit A/D (65536 steps) this would give you 655 steps at the low end to read the signals. Now imagine a 24 bit converter (1677216 steps) the low end signal would have 167,000 steps!

SAMPLING RATE 

This is how many times a second the signals are read and this dictates the maximum frequency of an input signal.

This is defined by the ‘Nyquist Rate’ and states that the minimum sampling rate must be 2x the required bandwidth. Or the other way round the maximum frequency you can read is ½ the sampling rate.

So if you want to read an analogue signal at 1000Hz you will need to sample at a minimum of 2000Hz in a digital system. Another good example is CD music, the sampling rate is 44.1Khz so the maximum audio frequency is 22050Hz.

ANTI ALIASING 

Aliasing is an erroneous reading produced by the A/D by sending signals of too higher frequency to an A/D converter, basically above the Nyquist Rate. This is similar to looking at the propeller of a plane spinning, at some speeds the propeller appears to be stationary or moving slowly when in fact it is spinning really fast. In our case of an A/D converter, imagine sampling at 1000Hz and then connecting a sine wave signal at 2000Hz. Depending on the phase of the signal you could read all zeros or all ones or if it drifts slightly you could see a low frequency wave. The long and short of it is that if your analogue signals can go higher in frequency than ½ the sampling rate then you should add an anti aliasing filter to limit the bandwidth!

TIMER INPUTS 

Timer inputs are used for accurate timing when the signals used are too fast for the PC. A timer will typically have a start and a stop trigger and the timing will be done on the DAQ board itself. Once captured only the result is passed into FlowStone allowing very accurate timing with little overhead on the PC.

OUTPUTS 

The outputs are also sensitive to how they are connected, the main issue being the load current. All outputs have a max load current value, and if exceeded again you can nuke the board so care is necessary.

FLOWSTONE WORKSHOP 3-5
Phidgets 888

CMOS outputs – are usually very low current and used to connect to other CMOS devices say < 1mA TTL output – can also be connected to other TTL devices but can sometimes deliver a little more current say 10mA (usually enough for an LED) Buffered outputs – are usually buffered to deliver much higher currents often enough for a relay say 100mA+ Relay outputs – these are already buffered and have a relay connected to isolate the output altogether; again relays have max ratings so take care.

DIGITAL OUTPUTS 

These usually go from zero to the supply voltage say 5V and are controlled via a Bool output inside FlowStone.

PWM OUTPUTS 

PWM (pulse width modulation) outputs are pulses of signal where the value is the width of the pulse. This is in fact how servos and motor controllers work and this was covered in our previous Workshops. In the DAQ case it is usually used for some form of motor controller where PWM is required to control the speed. In FlowStone a single number representing the pulse width is output, and the DAQ board does the rest making it far more accurate and produces a smaller load on the PC.

ANALOGUE OUTPUTS 

Analogue Outputs come from a Digital to Analogue converter or D/A, and deliver an analogue voltage from a Float input inside FlowStone. Again there is usually a Ref voltage out to give you the maximum voltage of the D/A.

FLOWSTONE WORKSHOP 3-4
FlowBoard DAQ

PROGRAMMING DAQ’S 

So we now have an idea how to condition the signals correctly for our DAQ, so let’s look at the programming inside FlowStone the graphical programming language. The benefit of using a language like FlowStone is that you can use your PC to display the values of the inputs live and also make fast decisions based on the signals and feed them back to the outputs or record them to disk etc. You can even add a fully custom user interface (GUI) and make an EXE out of your program to sell or distribute it!

So we now have an idea how to condition the signals correctly for our DAQ, so let’s look at the programming inside FlowStone the graphical programming language. The benefit of using a language like FlowStone is that you can use your PC to display the values of the inputs live and also make fast decisions based on the signals and feed them back to the outputs or record them to disk etc. You can even add a fully custom user interface (GUI) and make an EXE out of your program to sell or distribute it!

FLOWBOARD DAQ 

The FlowBoard DAQ is available from DSPRobotics and is a universal DAQ board with 16 Digital ins, 16 Digital Outs, and 8 Analogue (10 bit) ins. Plus optional Cell phone SMS sending and receiving! The great thing about this DAQ is that you can add optional boards to provide most of the signal conditioning, like an external 8ch Relay board, or an LED board, or an Opto Isolated input board. There is a pre-programmed module inside FlowStone so it’s plug and play.

FLOWSTONE WORKSHOP 3-6
Measurement Computing 1208FS

PHIDGET 888 

There are several Phidgets DAQ’s to choose from that are supported inside FlowStone, the 888 is one of the most popular with 8 analogue (10 bit) ins, 8 digital ins and 8 digital outs. Another great thing about the Phidgets line is the amount of external pre-wired sensors you can connect directly to the board with confidence that the signal conditioning is already done!

Inside FlowStone there is a pre-made module so there is no programming necessary, you can even specify an IP address if you are using this over a network or on another PC!

MEASUREMENT COMPUTING 1208-FS & MC-1608-FS 

Measurement Computing makes several hi-quality DAQ devices, currently the 1208-FS & 1608-FS are supported in FlowStone. These differ slightly to other DAQ’s as the I/O configuration is programmable. Both boards have 16 configurable digital I/O pins, counters/timers, 8 analog inputs and some analogue outputs; the main difference between the 1208 & 1608 is the dynamic range 12 bit or 16bit.

To program the I/O configuration you need to supply a string to the I/O input of the component. This should be a comma separated list of any combination of the following:

SE – single ended analog inputs

D – differential analog inputs

AI – set bank A of digital I/O to be inputs

BI – set bank B of digital I/O to be inputs

AO – set bank A of digital I/O to be outputs

BO – set bank B of digital I/O to be outputs

Etc.

LABJACK U3 HV & LV 

FLOWSTONE WORKSHOP 3-7The LabJack U3 is a very versatile DAQ device that is also programmable. This DAQ has 16 flexible I/O pins and 4 fixed analog inputs, and these are again programmed through a control String.

To set the I/O you need to supply a comma separated string or a newline separated list of strings in a Text component to the I/O input. Each entry defines the format for a particular I/O pin. The entry starts with two characters to determine the type and direction: “DI”, “DO” or “AI” for digital in, out and analog in respectively.

In the case of analog, it defaults to single ended, but you can set the negative channel with a minus symbol followed by “SE”,”SP”,”VR” (single ended, special (0-3.6v or -10/+20v), internal voltage ref) or the number of the pin you want to have as the negative channel.

FLOWSTONE WORKSHOP 3-8STARTING POINT SYSTEMS UCHAMELEON 

The uChameleon is what it says, a bit of a Chameleon as it can also be configured to your needs. This DAQ has18 general purpose I/O’s, 8 Analog inputs, 4 Analog outputs, 4 Timer channels, 1 SPI 3-wire serial port, and 1 UART serial port. The configuration is software programmable and is programmed through a virtual com port in FlowStone. We have made a little test application that you can play with to see how to set it up and get the data in and out.

EXAMPLES 

As always there are working examples of all of these DAQ devices on the DSPRobotics forum under FlowStone Examples. In order to view them you will need to download the FlowStone FREE software.

Links

DSP Robotics, www.dsprobotics.com

Leave a Reply

Your email address will not be published. Required fields are marked *