+ All Categories
Home > Documents > BuildingRealtimeAnalysis (1)

BuildingRealtimeAnalysis (1)

Date post: 01-Jun-2018
Category:
Upload: shashwat-pathak
View: 215 times
Download: 0 times
Share this document with a friend
43
g.tec  medical engineering GmbH Sierningstrasse 14, A-4521 Schiedlberg Austria - Europe Tel.: (43)-7251-22240-0 Fax: (43)-7251-22240-39 [email protected] , http://www.gtec.at  Copyright g.tec medical engineering GmbH Building a Simulink model for real-time analysis V1.12.01
Transcript
Page 1: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 1/43

g.tec – medical engineering GmbH

Sierningstrasse 14, A-4521 Schiedlberg

Austria - Europe

Tel.: (43)-7251-22240-0

Fax: (43)-7251-22240-39

[email protected], http://www.gtec.at 

Copyright g.tec medical engineering GmbH 

Building a Simulink model for real-time analysis

V1.12.01

Page 2: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 2/43

Content:

Introduction to g.USBamp ....................................................................................... 2 g.USBamp Highspeed Block ................................................................................... 3 

Running g.USBamp Highspeed ............................................................................... 6 

Creating a Simulink Model for Biosignal Acquisition ............................................ 9 

Biosignal Acquisition and Visualization ............................................................... 16 

Viewing Data with g.BSanalyze ............................................................................. 20 

MATLAB Plot Function ........................................................................................... 21 

Synchronization of Multiple g.USBamps .............................................................. 22 

Impedance Check ................................................................................................... 30 

Calibration ............................................................................................................... 33 

Other Examples ...................................................................................................... 36 

MATLAB API ........................................................................................................... 37 

Data Acquisition ..................................................................................................... 40 

Page 3: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 3/43

Building a Simulink model for real-time analysis v 1.12.01 2 

Introduction to g.USBamp 

g®.USBamp is a multimodal biosignal amplifier for any type of electrophysiological signals like EEG,

ECG, EOG, EMG, ECoG, ... and external sensors. It has an integrated 24-bit ADC and a floating pointDSP and can be connected directly to the PC via USB. The device is characterized by excellent signalquality and a very low noise level. Multiple units (16 channels each) can be stacked to build multi-channel systems. A programming API is included and drivers for MATLAB are also available. CE-certified medical device.g.USBamp comes with 16 analog input channels, one trigger channel which is scanned with theanalog inputs, 2 digital inputs and 2 digital outputs.

g.USBamp has 4 potential separated groups with 4 input channels each. Each group has its ownreference and ground inputs.

Highlights 

  CE and FDA certified medical device for use in humans according to medical normative EN

60601-1 (IEC 60601-1)

  EEG, ECoG, ECG, EMG and EOG recording via USB

  16 analog inputs with 24 Bit and a sampling frequency of up to 4800 Hz per channel

  Digital filtering of the biosignal data (DC - 2.4 kHz)

  Over-sampling to achieve a high signal to noise ratio

  Simultaneous sample and hold for all channels

  Direct connection of electrodes with standard safety connectors or system connectors for a

very fast electrode application

  can be used for recordings directly on the brain (ECoG) or heart (CF-System)

  on-line signal analysis under Simulink

  can be combined with g.BSanalyze for off-line biosignal analysis under MATLAB

Page 4: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 4/43

Building a Simulink model for real-time analysis v 1.12.01 3 

g.USBamp Highspeed Block

The g.USBamp Highspeed block provides a graphical interface to theg.USBamp hardware which can be used under Simulink to specify theamplifier properties and to acquire the data.

Description  The g.USBamp block output signal provides the biosignal data. The dataformat is single (float32) and it is scaled in µV. If all analog input channels (16)and the trigger signal (1) are acquired the line width is 17. Use a Demux blockto de-multiplex the channels. 

Dialog Box

Page 5: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 5/43

Building a Simulink model for real-time analysis v 1.12.01 4 

Specify AMPLIFIER SETTINGS

Common ground check the editor box to connect a specific group to common ground

Common reference check the editor box to connect a specific group to common reference

Serial number enter the serial number of the amplifier

CHANNEL selection check the analog input channels that should be acquired

Sampling rate (Hz) specify the sampling frequency of the g.USBamp in Hz

Frame length specify the buffering block size

Options

Counter show a counter on channel 16 which is incremented with every blocktransmitted to the PC

Trigger scan the digital trigger channel with the analog inputs. The trigger channel isshown as channel 17 if 16 analog channels are used.

Slave set the amplifier to slave mode if multiple units are used

Shortcut enable the shortcut input

Mode

Measure amplify the inputs and send the data to the PC

Test signal apply internal test signal to all inputsNOTE: The test signal works for sampling rates equal or below 600 Hz

 Analog output generate a Square-, Sawtooth-, Sine- or Noise-signal as test signal

 Amplitude specify the amplitude of the test signal (max: 245 mV)

Offset specify the offset of the test signal

Frequency specify the frequency of the test signal

Specify CHANNEL SETTINGS

Bipolar perform a bipolar derivation between 2 input channels

Bandpass perform a digital bandpass filtering of the input channels

Notch perform a bandstop filtering to suppress the power line frequency of 50 Hz or60 Hz

Load Load an amplifier configurationSave Save the amplifier configuration

Page 6: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 6/43

Building a Simulink model for real-time analysis v 1.12.01 5 

Perform the following steps:

1. Select the channels in the listbox that should be edited. Use the Strg key or the Shift key toselect multiple input channels.

2. Select the Bandpass filter HP: 0.5 / LP: 30 and press the apply button to assign the

bandpass to the specific channel. The selection is shown in the listbox.

3. Select the 50 Hz Notch filter to suppress the power line interference at 50 Hz and then press

the apply button

4. To perform a bipolar derivation between channels 1 and 2 select the first channel in thelistbox. Then select channel 2 under Bipolar  and press the apply button. The settings appearin the listbox. This configuration subtracts channel 2 from channel 1 and the bipolar derivationwill be visible on channel 1.

NOTE: Select 0 under Bipolar  and assign it to the channel if no bipolar derivation should beperformed

5. Use the Save … button to store the configuration for the g.USBamp. The Load … buttonallows to import configurations.

6. Press OK to close the window

Page 7: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 7/43

Building a Simulink model for real-time analysis v 1.12.01 6 

Running g.USBamp Highspeed

To test the g.USBamp Highspeed configuration on your system please perform the following example:

1. Start the MATLAB command window. See your MATLAB documentation if you are not sure

how to do this.

2. Open the Simulink model by typing gUSBampdemo1 into the MATLAB command window. This

command starts up Simulink and creates the following window:

The Simulink model contains a g.USBamp block which reads in the data from the amplifierover USB.

3. Switch g.USBamp on and connect it to one free USB port. The power LED on g.USBampmust be on.

4. Connect a sine wave generator to channel 1 of g.USBamp. The sine wave should have an

amplitude of  100 µV. This can be done e.g. with g.SIGgen.

Page 8: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 8/43

Building a Simulink model for real-time analysis v 1.12.01 7 

5. Double click on the g.USBamp block

6. Load the configuration file gUSBampdemo1.cfg . The following window appears:

7. Select the correct Serial number  of the connected amplifier and press the OK button

8. Start the model by pressing the Start button in the Simulink model

Page 9: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 9/43

Building a Simulink model for real-time analysis v 1.12.01 8 

9. To view the signals double click on the Scope block. Click with the right mouse button into thefirst channel and select Autoscale to zoom into the axis.

Note that g.USBamp Highspeed reads in all biosignal data in µV

Channel 1 shows a  100 V signal with a frequency of 10 Hz provided by g.SIGgen.

10. Stop the model with the Stop button and close it

Page 10: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 10/43

Building a Simulink model for real-time analysis v 1.12.01 9 

Creating a Simulink Model for Biosignal Acquisition

1. To create a new Simulink model click on the Simulink icon in the MATLAB window

or enter simulink into the MATLAB command window.

The Simulink Library Browser  opens:

The Simulink Library Browser gives access to all Simulink based blocksets.

2. Scroll down to g.USBamp to show the biosignal data acquisition block.

Page 11: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 11/43

Building a Simulink model for real-time analysis v 1.12.01 10 

3. Press the Create a new model icon in the Simulink Library Browser

to open an empty Simulink model: 

4. Click on the gUSBamp block in the Simulink Library Browser  and drag it into the newSimulink model

5. Open the Signal Management path under Signal Processing Blockset in the SimulinkLibrary Browser  and copy the Unbuffer  block into the new model

6. From the Sinks directory under Simulink copy the Scope block

7. From the Signal Routing directory under Simulink copy the Demux block

8. From Sinks under Simulink copy the To File block

9. From Signal Attributes under Simulink copy the Data Type Conversion block

Page 12: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 12/43

Building a Simulink model for real-time analysis v 1.12.01 11 

Now your model should look like this: 

Page 13: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 13/43

Building a Simulink model for real-time analysis v 1.12.01 12 

10. Double click on the gUSBamp block, load the configuration gUSBampdemo2.cfg  and enter

the serial number of your amplifier.

11. Double click on the Demux block and enter 16 

12. Double click the Scope block and select the Parameters icon:

Page 14: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 14/43

Building a Simulink model for real-time analysis v 1.12.01 13 

13. Set the Number of axes to 16 to visualize 16 analog input channels. Set the Time range to

5 seconds and the Tick labels to none. The Sampling Decimation should be 1.

14. Double click on the To File block and enter the filename test.mat to store the data into

variable y 

Page 15: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 15/43

Building a Simulink model for real-time analysis v 1.12.01 14 

15. Double click on the Data Type Conversion block and change the Output data type mode to

double because g.USBamp is acquiring the data as float32.

16. After configuring each block perform the connections as shown below:

Page 16: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 16/43

Building a Simulink model for real-time analysis v 1.12.01 15 

17. Click on the Simulation menu and select Configuration Parameters 

18. Set the Stop time to inf and the Type under Solver options to Fixed-step. The Fixed-

step size must be set to 1/256 because g.USBamp samples the data with 256 Hz.

19. Confirm the settings and close the window with OK 

20. Switch g.USBamp on and connect it to one free USB port. The power LED on g.USBampmust be on.

21. Start the model

Page 17: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 17/43

Building a Simulink model for real-time analysis v 1.12.01 16 

Biosignal Acquisition and Visualization

This section shows the configuration of g.USBamp Highspeed for the acquisition of an ECG channel.

1. Start the MATLAB command window.

2. Open the Simulink model by typing gUSBampdemo3 into the MATLAB command window. This

command starts up Simulink and creates the following window:

Page 18: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 18/43

Building a Simulink model for real-time analysis v 1.12.01 17 

3. Double click on the gUSBamp block and select only channel CH01. Assign a Bandpass filter

with a HP of 0.1 Hz and a LP of 100 Hz. The sampling frequency should be 1200 Hz. 

Note: The settings can also be loaded from the configuration file gUSBampdemo3.cfg 

4. Double click on the To File bock and enter Filename test.mat. The data is stored into the

variable y.

Page 19: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 19/43

Building a Simulink model for real-time analysis v 1.12.01 18 

5. Double click on the Scope block and open the ‘Scope’ parameters window. Enter under

Decimation 4 to downsample the values for the visualization.

6. Switch g.USBamp on and connect it to one free USB port. The power LED on g.USBampmust be on.

7. Connect your ECG electrodes to channel 1

8. Press the Start icon

Page 20: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 20/43

Page 21: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 21/43

Building a Simulink model for real-time analysis v 1.12.01 20 

Viewing Data with g.BSanalyze

1. Start the biosignal processing toolbox g.BSanalyze and load the biosignal data file ekg.mat 

or the file test.mat which was recorded in the previous section into the Data Editor with the 

Load data function from the File menu

2. Enter the sampling frequency 1200 Hz

The Data Editor shows the ECG channel. Use the sliders to scroll through the data-set.

Page 22: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 22/43

Building a Simulink model for real-time analysis v 1.12.01 21 

MATLAB Plot Function

You can use the MATLAB plotting functions for the visualization of acquired data. After running

gMOBIlabdemo3.mdl  and logging data to the harddisk perform the following steps:

1. Change to the directory where test.mat is stored and enter load test.mat in your

MATLAB command line. Instead of test.mat the file ekg.mat can also be used.

2. Type whos to investigate the variable y. The first row is a time vector and the second raw the

acquired ECG data.

3. Enter plot(y(1,:),y(2:end,:))to create the following window: 

Page 23: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 23/43

Building a Simulink model for real-time analysis v 1.12.01 22 

Synchronization of Multiple g.USBamps

g.USBamp Highspeed can be used to acquire data from two g.USBamps. Perform the following steps:

1. Start the Simulink model gUSBampSync from the MATLAB command line to open the

following model:

2. Double click on g.USBamp and load the configuration file gUSBampSyncMaster.cfg

Page 24: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 24/43

Building a Simulink model for real-time analysis v 1.12.01 23 

3. Enter the Serial number  of the MASTER device and connect the synchronization cable to theoutput SYNC OUT on the rear side of the device.

Page 25: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 25/43

Building a Simulink model for real-time analysis v 1.12.01 24 

4. Right click on g.USBamp and select Block Properties… 

Page 26: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 26/43

Building a Simulink model for real-time analysis v 1.12.01 25 

5. Assign 2 to Priority field and press OK 

Note: There must be only one device configured for master in your model.  

Page 27: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 27/43

Building a Simulink model for real-time analysis v 1.12.01 26 

6. Double click on g.USBamp1, load the configuration file gUSBampSyncSlave.cfg

and enter the Serial Number  of the SLAVE device. Additionally check the Slave box underOptions. Connect the synchronization cable to the SYNC IN connector on the rear side of theamplifier.

Page 28: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 28/43

Building a Simulink model for real-time analysis v 1.12.01 27 

7. Right click on g.USBamp1 and select Block Properties… 

Page 29: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 29/43

Building a Simulink model for real-time analysis v 1.12.01 28 

8. Assign 1 to Priority field and press OK

Note: If there are multiple slave devices in your model you have to set all slave devicespriority to 1. 

Page 30: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 30/43

Building a Simulink model for real-time analysis v 1.12.01 29 

9. Switch on both amplifiers and connect the MASTER to the USB port. Then connect theSLAVE to the USB port.

10. Press the Start icon

Start the Simulink model gUSBampdemo5 from the MATLAB command line to open another example

of g.USBamp synchronization (4 amplifiers).

Page 31: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 31/43

Building a Simulink model for real-time analysis v 1.12.01 30 

Impedance Check

g.USBamp has a build-in impedance check unit. To measure the electrode impedances perform thefollowing steps:

1. Start the Simulink model gUSBampdemo4 from the MATLAB command line to open the modelbelow:

2. Double click on g.USBamp and load the configuration file gUSBampdemo4.cfg . Enter the

Serial Number  of your amplifier.

3. Double Click Impedance Check block. The following window will appear:

The system creates a panel for each amplifier in the current model. The channels are labeled1 to 16 and the references R1 to R4. If the corresponding toggle button is pressed theelectrode impedance is measured. You can use Select all to select all electrodes or Selectnone to deselect all electrodes.If Auto select is checked the system will enable the electrodes selected in the configurationwindow of the amplifier.

Page 32: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 32/43

Building a Simulink model for real-time analysis v 1.12.01 31 

4. Press Start to start the measurement. The label of the currently measured electrode isdisplayed red. Impedance values are displayed next to the corresponding channel labels.Different colors indicate ranges of the impedance values:

green Impedance < 5 kΩ 

yellow Impedance in 5 to 7 kΩ 

red Impedance in 7 to 100 kΩ 

blue Electrode not connected

5. The system starts measuring the electrode impedance of channel 1 until channel 16. At theend the impedances of the reference electrodes are additionally measured. All impedances

are measured against the common ground potential (all grounds of groups A to D areconnected).

The impedance is measured for 1 second for each channel with a 20 Hz signal. Theimpedance is shown in kΩ. For a good EEG recording the values should be below 5 kΩ(green).

6. To stop the impedance measurement press Stop.

Page 33: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 33/43

Building a Simulink model for real-time analysis v 1.12.01 32 

If you want to add the Impedance measurement facility to your model type simulink to the

MATLAB command line and select the g.USBamp library. Drag the Impedance Check block intoyour model:

:

Note: Any sensor or device has to be disconnected from the amplifier while impedance ofelectrodes is measured.

Page 34: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 34/43

Building a Simulink model for real-time analysis v 1.12.01 33 

Calibration

g.USBamp has a build-in calibration unit. Perform the following steps:

1. Start the Simulink model gUSBampdemo4 from the MATLAB command line to open the model

below:

2. Double click on g.USBamp and load the configuration file gUSBampdemo4.cfg . Enter the

Serial Number  of your amplifier.

Page 35: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 35/43

Building a Simulink model for real-time analysis v 1.12.01 34 

3. Double Click Calibration block. The following window will appear:

4. Press Start to perform the calibration and to get the Offset and Scaling values for eachchannel.

5. Inspect the Offset and Scaling values. If you want to perform some changes use the editorboxes.

6. Press the Save button to store the calibration.

Page 36: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 36/43

Building a Simulink model for real-time analysis v 1.12.01 35 

If you want to add the Calibration facility to your model type simulink to the MATLAB command

line and select the g.USBamp library. Drag the Calibration block into your model:

Page 37: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 37/43

Building a Simulink model for real-time analysis v 1.12.01 36 

Other Examples

g.USBamp Highspeed provides other useful examples. Click on the Start button under MATLAB andgo to the Blocksets folder, select gUSBamp Highspeed to run one of the following applications:

gUSBampHS starts a Simulink model with the driver block

Online ECG, Respiration starts a Simulink model which calculates the heart-rate, heart-rate

variability and respiration rate

Brain Computer Interface starts a Simulink model which performs brain computer interface

experiments

Page 38: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 38/43

Building a Simulink model for real-time analysis v 1.12.01 37 

MATLAB API

To test the g.USBamp API configuration on your system please perform the following

example:

1.  Start the MATLAB command window. See your MATLAB documentation if you are not

sure how to do this.

2.  Type h=daqhwinfo into the MATLAB command line. This command searches for all

installed data acquisition devices on your PC.

h=daqhwinfo

h =

ToolboxName: 'Data Acquisition Toolbox'

ToolboxVersion: '2.8 (R14SP3+)'

MATLABVersion: '7.1 (R14SP3)'

InstalledAdaptors: {4x1 cell}

3.  InstalledAdaptors contains the adaptor names of the installed data acquisition devices

h.InstalledAdaptors

ans =

'guadaq'

'nidaq''parallel'

'winsound'

guadaq represents the g.USBamp data acquisition adaptor.

4.  If the guadaq adaptor is not found on your system register the g.USBamp adaptor with

daqregister('guadaq')

ans =

'guadaq.dll' successfully registered.

This command writes the adaptor into the registry and therefore it is not necessary to

 perform the command the next time.

Page 39: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 39/43

Building a Simulink model for real-time analysis v 1.12.01 38 

5.  Check how many g.USBamps are connected to your PCdaqhwinfo('guadaq')

ans =

AdaptorDllName: 'C:\MATLAB7\gtec\gUSBampAPI\,… Lib\guadaq.dll'

AdaptorDllVersion: '1.2'

AdaptorName: 'guadaq'

BoardNames: {'g.USBamp'}

InstalledBoardIds: {'1'}

ObjectConstructorName: {'analoginput('guadaq',1)' '' ,… 

'digitalio('guadaq',1)'}  

InstalledBoardIds returns the Ids of the installed g.USBamps. In this case one

amplifier with Id 1 is connected. AdaptorDllVersion is the version number of the

g.USBamp adaptor. Daqhwinfo registers the g.USBamp with this Id into your system.

The next time when the g.USBamp with this serial number is connected to your system,the Id will be the same.

6.  Configure g.USBamp to acquire 1 channel in calibration mode. Therefore an analog input

object with the adaptor guadaq of device 1 must be created.

ai = analoginput('guadaq',1); 

Add the first channel

addchannel (ai,1) 

and set g.USBamp to calibration mode

set(ai,'Mode','Calibration');  

Page 40: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 40/43

Building a Simulink model for real-time analysis v 1.12.01 39 

7.  Start the Data Acquisition Oscilloscope

softscope(ai); 

8.  Press the Trigger button to start g.USBamp. The data window displays a calibration

signal in form of a sine wave.

9.  Use the Vertical Scale and Horizontal Scale buttons to adjust the scope settings

10. Press the Stop button and close the window.

Page 41: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 41/43

Building a Simulink model for real-time analysis v 1.12.01 40 

Data Acquisition

A data acquisition session consists of the following steps:

1.  Create a device object –  a device object is created by using the analoginput function.Device objects are used to access the g.USBamp device.

2.  Add channels –  after the g.USBamp device object is created, analog input channels must

 be added. The channel number defines which analog input should be acquired.

3.  Configure properties –  use the set function to assign g.USBamp properties like samplerate, filter settings,… 

4.  Acquire data –  use the start function to start the biosignal data acquisition

5.  Clean up –  use the delete function to remove the device object from memory and the 

clear function to remove it from MATLAB workspace

Example: Data Acquisition of 16 channels

This example demonstrates the steps for acquiring data with g.USBamp. Run this example by

typing gUSBampAPIDemo1 into the MATLAB command line.

1.  Create device object –  create an analog input object for g.USBamp.

The connected g.USBamps are found with the following command:

daqhwinfo('guadaq')

ans =

AdaptorDllName: 'C:\MATLAB7\gtec\gUSBampAPI\Lib\guadaq.dll'

AdaptorDllVersion: '1.2'

AdaptorName: 'guadaq'

BoardNames: {'g.USBamp'}

InstalledBoardIds: {'1'}

ObjectConstructorName: {'analoginput('guadaq',1)' '' ,… 

'digitalio('guadaq',1)'}

Create the analog input object of g.USBamp with Id 1: 

ai = analoginput('guadaq',1);

2.  Add channels –  add 16 channels to the analog input object ai 

addchannel(ai,1:16);  

3.  Configure property values –  set the sampling frequency of g.USBamp to 256 Hz and

acquire data for 2 second

set(ai,'SampleRate',256,'SamplesPerTrigger',512);

Page 42: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 42/43

Building a Simulink model for real-time analysis v 1.12.01 41 

4.  Acquire data –  Start ai, wait for 512 samples and extract the data with getdata. Before

starting connect a sine wave generator to the first channel of g.USBamp.

start(ai);

while strcmp(ai.running, 'On')==1

end

data = getdata(ai,ai.SamplesAvailable);

5.  Plot the first channel and last second of the acquired data and label the figure.

plot(data(256:end,1));

xlabel('Samples');

ylabel('Signal [Volts]');

6.  Clean up –  remove the data acquisition object from memory and MATLAB workspace

delete(ai)

clear ai 

Page 43: BuildingRealtimeAnalysis (1)

8/9/2019 BuildingRealtimeAnalysis (1)

http://slidepdf.com/reader/full/buildingrealtimeanalysis-1 43/43


Recommended