Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Jack H.Integration and automation of manufacturing systems.2001.pdf
Скачиваний:
86
Добавлен:
23.08.2013
Размер:
3.84 Mб
Скачать

page 476

scanf("%d", &value);

if(value == 1) return DIGITALIN; if(value == 2) return DIGITALOUT; return ERROR;

} else {

return ERROR;

}

}

void error_log(int code, char *string){ printf("ERROR %d: %s \n", code, string);

}

16.8 SUMMARY

A/D conversion will convert a continuous value to an integer value.

D/A conversion is easier and faster and will convert a digital value to an analog value.

Resolution limits the accuracy of A/D and D/A converters.

Sampling too slowly will alias the real signal.

Analog inputs are sensitive to noise.

The analog I/O cards are configured with a few words of memory.

BTW and BTR functions are needed to communicate with the analog I/O cards.

16.9 PRACTICE PROBLEMS

1. You need to read an analog voltage that has a range of -10V to 10V to a precision of +/-0.05V. What resolution of A/D converter is needed?

(ans.

10V – ( –10V)

 

7 bits = 128

R =

= 200

 

0.1V

 

8 bits = 256

The minimum number of bits is 8.

2.We are given a 12 bit analog input with a range of -10V to 10V. If we put in 2.735V, what will the integer value be after the A/D conversion? What is the error? What voltage can we calculate?

page 477

(ans.

N = 12

R = 4096

 

 

Vmin

 

= –10V

Vmax = 10V

Vin = 2.735V

 

=

 

 

 

 

Vin

Vmin

 

 

 

=

2608

 

 

VI

INT

 

 

R

 

 

 

----------------------------

 

 

 

 

 

 

 

 

V

 

 

V

 

 

 

 

 

 

 

 

 

 

 

 

 

VI

 

 

 

max

 

 

min

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

V

=

 

( V

 

 

V

 

 

) + V

 

 

= 2.734V

 

 

----

 

 

 

 

 

 

 

 

 

C

 

 

R

 

 

max

 

 

min

 

 

 

min

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3.We need to select a digital to analog converter for an application. The output will vary from -5V to 10V DC, and we need to be able to specify the voltage to within 50mV. What resolution will be required? How many bits will this D/A converter need? What will the accuracy be?

(ans.

A card with a voltage range from -10V to +10V will be selected to cover the entire range.

R =

10---------------------------------V – ( –10V)

= 400

minimum resolution

 

0.050V

 

 

8 bits = 256

9 bits = 512

10 bits = 1024

The A/D converter needs a minimum of 9 bits, but this number of bits is not commonly available, but 10 bits is, so that will be selected.

V

 

=

Vmax

Vmin

10V – ( –10V)

=

±0.00976V

ERROR

----------------------------

=

---------------------------------

 

 

2R

2( 1024)

 

 

 

 

 

 

4. Write a program that will input an analog voltage, do the calculation below, and output an analog voltage.

Vout = ln ( Vin)

5.Develop a program to sample analog data values and calculate the average, standard deviation, and the control limits. The general steps are listed below.

1.Read sampled inputs.

2.Randomly select values and calculate the average and store in memory. Calculate the standard deviation of the stored values.

3.Compare the inputs to the standard deviation. If it is larger than 3 deviations from the mean, halt the process.

4.If it is larger than 2 then increase a counter A, or if it is larger than 1 increase a second counter B. If it is less than 1 reset the counters.

5.If counter A is =3 or B is =5 then shut down.

6.Goto 1.

page 478

 

m

 

 

 

 

 

 

 

 

 

 

 

 

UCL = X + 3σ

 

 

 

X =

Xj

 

 

 

 

 

 

X

 

 

 

 

 

 

 

 

j = 1

 

 

 

 

 

 

 

 

 

 

 

 

LCL = X – 3σ

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X

16.10 LABORATORY - INTERFACING TO A DAQ CARD

Purpose:

To use a data aquisition card to aquire data.

Overview:

The daq card will be placed into a Linux computer and then controlled with the drive programs listed in this chapter.

Pre-Lab:

1. Visit the computer boards web site (www.computerboards.com) and review the manual for the DAS-08 ISA board.

In-Lab:

1.Complete the tutorial for the DAS-08 DAQ card.

2.Modify the tutorial program so that the analog input value from the board is read once a second and written to a database.

Submit (individually):

1. The program developed during the laboratory.