Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

FreePascal-adc-control

Control program for the adc written in Free Pascal

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

ADC control program (free pascal)

From eevblog forum: DIY high resolution multi-slope converter (with permission of Ulrich Harms)

Changelog:

Catch exceptions

Original copy in branch: Kleinstein_2021-07-28

Free pascal: https://www.freepascal.org/download.html

Synapse TCP/IP and serial library (Synaser): http://synapse.ararat.cz/doku.php/download

Manual

Commands are sent as 1 byte ASCII:

0..7 Selection of MUX channel for measurement (Input1..8 on U7 DG408)

 0 -> Pin 7 on connector J2

 1 -> Pin 5 on connector J2

 2 -> Pin 3 on connector J2

 3 -> Pin 1 on connector J2

 4 -> temperature diode

 5 -> Pin 9 on connector J2 - connected to frontend

 6 -> 7V Ref without buffer

 7 -> 0V (GNDS)

A..E reading mode:

 A -> 2 readings AZ (S 0) - needs scalefactor correction: let it run for some time (m_sf #readings), switch to function L (console output: update scalefactor from ref reading), then back to mode A

 B -> INL test difference 2 run-up modes 1. run-up Q, 2. selected (S S)

 C -> 3 readings (S 0 7)

 D -> 4 readings (S S2 (channel 2) 0 7 - 2 channels + ref)

 E -> 2 readings (S S2 (channel 2) - difference to channel 2)

F..M functions:

 F -> reset integration time to 1 PLC (possibly side effect)

 G -> integration capacitor DA test (not implemented in control program)

 I -> infinite run-up (for test - only continue with reset?)

 K -> old version slope measurement (stops if necessary)

 L -> slope measurement K1 and K2

 M -> double integration time (2, 4, 8, ... PLC)

P..W run-up versions:

 P -> fast 35+3*x/8/8

 Q -> normal case 78+6*x/12/12

 R -> short fix 86+6*x/8/8

 S -> 4 step mode

 T -> dummy 4 step mode (integrator MUX U5 4053 always off)

 U -> 4 step with 0

 V -> long fix 66+6*x/18/18

 W -> slow 168+12*x/18/18

X -> exit control program (no changes in adc)

Raw data format received from ADC:

0xFF sync

1 byte selection mode / type of data, for sync generally> 128

16 bit run-up counts

16 bit cycles for pos ref, step size is 4

16 bit cycles for neg ref, step size is 4

16 bit aux ADC reading (average voltage at the integrator output)

16 bit residual ADC reading after conversion

16 bit residual ADC reading before conversion

possibly more data records (without sync and mode) one after the other, depending on the number of conversions in the cycle

The factors K1 and K2 are used to calculate the result.

K1 is the ratio of the negative reference and the sum (- Vref- / (Vref+ + Vref-)).

K2 gives the scale factor for the µC internal ADC.

The two quantities are measured by sending the command "L" to the ADC.

The appropriate calibration measurements are then made.

The values ​​also end up in the file, but are not yet directly adopted for the measurement - they need to be manually set in the program.

The notation as 1 / ... and 4 / ... and comes from the fact that the outputs from the program just correspond to the ... values.

At the console the 5th value is the voltage in mV, the 6th value is the raw value of the µC internal ADC.

This value is influenced by the trimmer and should be around the middle of the range, i.e. around 300-700, and not come to the limit.

That the values ​​fluctuate is normal, these are just the different measured values ​​corresponding to the lower 6-8 bits.

The trimmer isn't particularly sensitive - the range for the ADC should be around 2-4 revolutions.

The setting should be suitable for the calibration measurement to work.

To see directly what the trimmer is doing, you can look at the signal at the output of the NE5534, that should shift.

Normally the conversions are 20 ms = 1 PLC @ 50Hz mains (not particularly precise - something could possibly be adjusted).

The time can be doubled using the "M" command (i.e. 2, 4, 8 PLC) and set back to 1 with "F".

The outputs on the screen are mean values ​​over more conversions (e.g. 20 one channel constant at the top of the program).

In the file, the values ​​are generally 1 PLC and due to the auto zero mode 1 value approximately every 40.4 ms (mode B, longer with 3 or 4 values in mode C/D).