DAQ/Basic/Analog input and output using PCI 1711/English

From Script | Spoken-Tutorial
Jump to: navigation, search

Title of script: Analog input and output using PCI 1711 and Scilab in Linux

Author: Rakhi

Keywords: Analog input, output, Scilab, PCI 1711


Visual Clue
Narration
Show Slide 1 Hello and welcome to the Spoken Tutorial on Analog input and output using PCI 1711 and Scilab in Linux.
Show Slide 2 The objectives of this tutorial are:


How to use PCI 1711 and Scilab Xcos in Linux

Point 2 in Slide 2 To acquire an analog input and display it
Point 3 in Slide 2 To generate an analog output and measure it
Show Slide 3 The pre-requisites for this tutorial are:


Knowledge of Scilab - Xcos

Point 2 in Slide 3 Basic knowledge of Linux shell commands and
Point 3 in Slide 3 Your PC is configured as per the Spoken tutorial on Installation and Configuration of PC/Laptop to use DAQ with Scilab
Show Slide 4 The hardware used for this tutorial are:


Advantech PCI 1711 DAQ with cable

Point 2 in Slide 4 ADAM module 3968 SCSI 68P Terminal Board
Point 3 in Slide 4 A variable voltage supply 0-5V and
Point 4 in Slide 4 A multimeter
Point 5 in Slide 4 Note that you need a PC with a PCI slot on the motherboard to practise this tutorial.
Show Slide 5 To begin with, let us connect the hardware
Point 2 in Slide 5 To do this, shut down your PC
Pont 3 in Slide 5 Remove the side cover of the CPU
Point 4 in Slide 5 Insert the PCI 1711 card into the PCI slot
Show Slide 6 Here is how it will look like after inserting the card into the PCI slot
Show Slide 7 Here is a much closer picture.


You can close the side cover now

Show Slide 7 Connect the cable and the Terminal board as shown in this picture
Show Slide 8 Set 5 V in the voltage supply

Switch off the supply

Point 2 in Slide 8 Connect the positive terminal of the supply to pin number 68 in the terminal board
Point 3 in Slide 8 And the negative terminal to pin number 60
Point 4 in Slide 8 Now we have connected an analog input to channel 0 of the DAQ card

Switch ON your PC

Point 5 in Slide 8 It is better to have a printout of the pinout details of the PCI card connector ready while practising this tutorial.
Open firefox and go to the URL:


http://buy.advantech.com/PCI-bus-Cards/PCI-bus-Cards/model-PCI-1711-BE.htm

Click on Datasheet and save the file.

You can download the same from the Advantech website
Show Slide 9 Let us now check if the card has been detected by the PC as a COMEDI device
Point 2 in Slide 9 I am using Kernel 2.6.32-31
Open the terminal and type:


dmesg | grep comedi

Press Enter

We can see that the PCI card has been recognised as device comedi0



Point 3 in Slide 9 If your kernel version is older than 2.6.30, you have to first load the COMEDI module for the DAQ card
Open the terminal and type:


modprobe adv_pci1710

This can de done by the command modprobe
Open the terminal and type:


dmesg | grep comedi

Press Enter

Now check if the card is detected as a COMEDI device using the dmesg command explained before


If it is not detected, then you should check your installation

Point 4 in Slide 9 I would like to remind you that your PC must be configured with all the software as per the Spoken tutorial on DAQ installation.


If not, kindly go through the prerequisites of this tutorial.

Point 5 in Slide 9 Now let us use Scilab to read the analog input.
Open Scilab.

Click on Toolboxes and then click on hart_0.4.3.

Open Scilab and load the HART toolbox
Open Xcos.

Click on Hart from the Pallette browser.

Click on Comedi

Open Xcos and go to the Hart comedi palette
Let us create a new Xcos diagram to acquire an analog input
Choose hart_comedi_datain block from Hart comedi palette.

Place it on the new Xcos diagram.

Place a hart_comedi_datain block from the comedi palette
Choose AFFICH_m block from Sinks palette and CLOCK_c from Sources palette.

Place them on the new Xcos diagram.

Place an AFFICH_m block from the Sinks palette and a CLOCK_c block from the Sources palette
Xcos window Connect them as shown
Right click on the comedi block and select Block help


Close Block help

The hart comedi datain block (shown as COMEDI A/D) represents the comedi device.


It is used in the analog data-in mode.


You can read more about the blocks from block help

Right click on comedi block.

Click on block parameters.

Right click on the comedi block to set the parameters


Click on block parameters.

Enter 0 in the field Channel We have connected analog input to channel 0.


So the channel is 0

Enter comedi0 in the field Device The device is recognised as comedi0.


So the device field has to be comedi0.


If there are more than one such devices connected, then they will be detected as comedi1, comedi2 etc.


If so, modify the device field accordingly.

Enter 0 in the fields Range and Aref

Press OK

Give 0 for the fields Range and Aref
Double click on Clock block.

Set Period as 1

Set Init time as 0

Click OK

You can set the clock period to say 1s and Initial time as 0



Go to the menu bar and click on Simulation .

Choose Setup.

Set Final integration time as 1000

Set Real time scaling to 1

Click OK

Set the simulation parameters by going to the Setup tab under simualtion.


Set Final integration time to 1000s and real time scaling to 1


Save this Xcos diagram

Switch ON the voltage supply and start the simulation.

You can see 5 being displayed in the Affich block

Vary the voltage supply You can vary the supply voltage and see the corresponding variation in the display.
Show Slide 10 Note that you should not give voltage input more than 10V to the PCI card
Point 2 in Slide 10 You can connect the input to a different channel and repeat this experiment.
Show Slide 11 Let us now learn to output an analog voltage through Scilab
Point 1 in Slide 11 Let us output 5 V on analog output channel 0 of the device
Point 2 in Slide 11 Note that you can only output 0 to 5V in this device
Open a new Xcos window Let us create a new Xcos diagram for this.
Choose hart_comedi_dataout block from Hart comedi palette.

Place it on the new Xcos diagram.

Place the block hart_comedi_dataout (shown as COMEDI D/A) from the hart comedi palette.



Choose CONST_m block and CLOCK_c from Sources palette.

Place them on the new Xcos diagram.

Place a constant block and Clock block from Sources.


Connect them as shown.

Right click on comedi block.


Click on block parameters.

Right click on the comedi block to set the parameters


Click on block parameters.

Enter 0 in the field Channel The channel is 0
Enter comedi0 in the field Device The device field has to be comedi0
Enter 0 in the fields Range and Aref

Press OK

Give 0 for the fields Range and Aref
Double click on Constant block.

Set constant as 5.

Click OK

Set 5 in the constant block
Double click on Clock block.

Set Period as 1.

Set Init time as 0.

Click OK

You can set the clock period to say 1s and Initial time as 0



Go to the menu bar and click on Simulation .

Choose Setup.

Set Final integration time as 1000

Set Real time scaling to 1

Click OK

Set Final integration time to 1000s and real time scaling to 1


Save this Xcos diagram

Press the Play button to start simulation Start the simulation
Point 3 in Slide 11 Check the output voltage using a multimeter.
Point 4 in Slide 11 Place the positive probe on pin number 58 and negative probe on pin number 57
Go to Xcos diagram.

Vary the constant value in the constant block

You can vary the constant values and see the corresponding variation in the multimeter readings
Point 5 in Slide 11 You can also repeat this experiment for channel 1
Point 1 in Slide 11 So in this tutorial, we have learnt how to :


acquire an analog input and display it in Scilab and

Point 2 in Slide 12 Generate an analog output using Scilab and measure it
Show Slide 13 Spoken tutorial is a part of Talk to a Teacher project.



Point 2 in slide 13 This is supported by National Mission on Education

through ICT, MHRD, Govt of India.

Point 3 in slide 13 More information on this mission is available at :

http://spoken-tutorial.org/NMEICT-Intro

Hope you found this tutorial useful.


This is Rakhi for IIT Bombay signing off. Thanks for joining.

Contributors and Content Editors

Manivel