ersion 1.4, oct 24 1997 - nikhef.nl · tation sp eci c features will b e pro vided b y the soft w...

22

Upload: lekhue

Post on 08-Feb-2019

214 views

Category:

Documents


0 download

TRANSCRIPT

Crystal-CAN

a CAN-bus nodefor monitoring multiple distributed

analog signals

(prototypes for B-�eld and Temperature monitoring in ATLAS)

Software Manual

NIKHEF, Amsterdam �

Version 1.4, Oct 24 1997

�Note prepared by Henk Boterenbrood (email: [email protected])

1

Contents

1 Introduction 3

2 Hardware 32.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.1.1 Controller Module . . . . . . . . . . . . . . . . . . . . . . 32.1.2 Sensor Module . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2 System Con�guration . . . . . . . . . . . . . . . . . . . . . . . . 52.3 B-�eld Sensor Module . . . . . . . . . . . . . . . . . . . . . . . . 62.4 Temperature Sensor Module . . . . . . . . . . . . . . . . . . . . . 7

3 Software 93.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.3 Device Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.4 CS5525 Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.5 Crystal-CAN CS5525 Operation . . . . . . . . . . . . . . . . . . 11

3.5.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . 113.5.2 Conditions of Operation . . . . . . . . . . . . . . . . . . . 123.5.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3.6 B-�eld Sensor Controller Software . . . . . . . . . . . . . . . . . 133.7 Temperature Sensor Controller Software . . . . . . . . . . . . . . 13

A Command/Reply Format 15

B Crystal-CAN Device, Message and Error Identi�ers 18

C CS5525 Message Parameter Identi�ers 20

D Controller Performance 21

2

1 Introduction

One of the requirements of the future ATLAS detector monitoring and controlsystem is that it should be able to measure magnetic �elds and temperaturesinside/around di�erent parts of the detector, notably the MUON detector ([1],ch.11). This document is about hardware and software that was developed forjust that purpose.

However, the concept presented here can fairly easily be extended to coverany application where (slow) analog channels have to be monitored remotely.

To measure the B-�eld inside the detector it is foreseen that in the order ofone- to twothousand B-�eld sensors will be needed distributed throughout thevolume of the detector.

Temperature measurements inside the detector (e.g. temperature distribu-tion along the muon chambers) will probably require in the order of thousandsof sensors, scattered throughout a wide volume.

To be able to read out and control all these sensors a distributed controlsystem is essential. This can be achieved by using a robust industrial �eld-bus(serial bus) and cheap but powerful microcontrollers for local intelligence andprocessing capacity.

This document brie y describes the electronics developed and the systems forwhich it was developed; it then continues to describe the software that controlsthe modules and the way to operate the modules from a user's point of view.

2 Hardware

2.1 Modules

The hardware is made up of 2 module types: the Controller Module and theSensor Module.

The Controller Module hardware is the same in all applications; implemen-tation speci�c features will be provided by the software running on the module.

The Sensor Module is built around the same ADC in all applications, but thesignal conditioning electronics around it depend on the application (the type ofsensors to be read out).

2.1.1 Controller Module

The Controller Module is based on a commercially available universal micro-controller module (MicroKey 20CN592, [3]) designed around the Philips80C592 8-bit microcontroller [2] running at a clock frequency of 16 MHz.

The microcontroller has an integrated CAN controller and the on-boardCAN transceiver (Philips 82C250) provides an ISO/DIS-11898 standard CAN-bus interface.

The module o�ers 48 kByte of user application ROM ( ash) and 63.5 kByteof RAM. This amount of memory is enough to build quite large applications.User application code can be downloaded through a serial port (standard) oroptionally via the CAN-bus (a future option which could be very useful once

3

the modules are integrated into an experiment); these features are provided bythe onboard �rmware delivered with the module.

The Controller Module also contains a multiplexer chip to enable connec-tions to several Sensor Modules. One Controller Module may control up toabout 16 Sensor Modules (NB: up to 8 in the current hardware/software im-plementation); a digital multiplexer-chip is used to switch the controller's serialinterface I/O port to any of the connected Sensor Modules.

2.1.2 Sensor Module

Main part of the Sensor Module is the ADC which digitizes the analogue quan-tities to be measured: the CRYSTAL CS5525 16-bit ADC [4].

The CS5525 ADC contains an instrumentation ampli�er, a programmablegain ampli�er, a digital �lter and calibration circuitry; it also has 4 output latchpins, which e.g. can be used to control an external analog multiplexer to directlyselect any of up to 16 analogue inputs.

The CS5525 can perform conversions with rates of 3.76, 7.5, 15, 30, 60, 123,169 and 202 Hz with voltage input ranges of 25 mV, 55 mV, 100 mV, 1 V and5 V, unipolar as well as bipolar (all con�gurable).

The CS5525 is controlled through a three-wire serial interface (compatiblewith SPITM and MicroWireTM standards). The interface signal lines areconnected to I/O ports of a Controller Module's microcontroller, which runssoftware implementing the protocol across these lines (see [5]).

Table 1 shows the ADC conversion data coding as a function of the inputvoltage, for a bipolar measurement.

Input ConversionVoltage Data

> V-1.5LSB 0x7FFF

0x7FFFV-1.5LSB ....

0x7FFE

0x0000-0.5LSB ....

0xFFFF

0x8001-V+0.5LSB ....

0x8000

< V+0.5LSB 0x8000

Table 1: Bipolar input voltage to CS5525 16-bit conversion data coding.(V=voltage between full scale and ground in selected input voltage range,LSB=voltage corresponding to the Least Signi�cant Bit in ADC conversion)

The Sensor Module has a simple serial interface and can in principle becontrolled by any kind of microcontroller. The Controller Module used here cantherefore easily be replaced by some other controller should cost or requirementsjustify this.

4

CRYSTAL CS5525 ADC

Sensor 1

Sensor 2

Sensor 2n

n

selection

Analog Mux

analog in

SensorModule # 2

CRYSTAL CS5525 ADC

Sensor 1

Sensor 2

Sensor 2n

n

selection

Analog Mux

analog in

SensorModule # 1

20CN592Micro Module

CANcontroller

CAN-bus

SDISCLK

SDODigital Mux

4

selection

SCLK,SDI,SDO

SCLK,SDI,SDO

Controller Module

3

3

3

1

2

16

CRYSTAL CS5525 ADC

Sensor 1

Sensor 2

Sensor 2n

n

selection

Analog Mux

analog in

SensorModule # 16

Figure 1: Schematic of a Controller plus connected Sensor Modules.

2.2 System Con�guration

Figure 1 shows a schematic of a general con�guration of a Controller Moduleand a number of Sensor Modules. Typically the Sensor Modules are locateda variable but relatively small distance away from the Controller Module con-nected by a cable, carrying the control signals and power. The individual sensorseither are part of the Sensor Module or are connected to the Sensor Module bya cable.

The Controller Module is connected to the outside world through a CAN�eld-bus. The CAN-bus can extend several hundred meters with its {in thisapplication{ foreseen 125 kBit/s transfer rate1 and can connect up to about64 Controller Modules, thus providing the distributed control capability.

Figure 2 shows a possible con�guration of an entire remote control and mon-itoring system in ATLAS; it is a hierarchical system: the Controller Modulesmonitor the sensors, the Bus-to-CAN interfaces possibly may possess some in-telligence and monitor the Controller Modules on 'their' CAN-bus and the HostController monitors the various CAN-networks through the system-bus inter-faces and may provide a local (graphical) user interface; the whole system isremotely monitored and controlled by the central experiment control system.

1The maximum possible CAN-bus rate depends on the total length of the bus and can beup to 1 MBit/s with 40 m bus length (see [6]).

5

CAN-bus

Host Controller/User Interface

Sensors (fig. 1)

Controller+

Bus- to- CANinterface

Sys

tem

Bu

s(e

.g. V

ME

, PC

I)

CAN-bus

MainControlSystem

Sensors (fig. 1)

Controller+

Sensors (fig. 1)

Controller+

Sensors (fig. 1)

Controller+

Sensors (fig. 1)

Controller+

Sensors (fig. 1)

Controller+

Sensors (fig. 1)

Controller+

Sensors (fig. 1)

Controller+

Control System Crate

ATLAS Detector

Bus- to- CANinterface

User

Figure 2: A monitoring and control system con�guration for ATLAS.

2.3 B-�eld Sensor Module

A schematic of the B-�eld Sensor Module is shown in �gure 3; it consists of 6 Hallelements, a reference element, a temperature sensor and the CS5525 ADC, mul-tiplexer and some additional electronics (not shown here). ADC, multiplexer,sensors and additional electronics form one single compact module.

There are a total of 8 analogue quantities to measure; these are selectedusing 3 of the 4 output latch pins the CS5525 provides.

CRYSTAL CS5525 ADC

Hall sensor 1

Hall sensor 2Hall sensor 3Hall sensor 4Hall sensor 5Hall sensor 6Calibration inputTemperature sensor

D0D1D2

selection

Analog Mux

analog in

B-field Sensor Module

SDI

SCLK

SDO

01

7

Figure 3: The B-�eld Sensor Module.

Summary of speci�cations:

� (to be de�ned)

6

2.4 Temperature Sensor Module

A schematic of the Temperature Sensor Module is shown in �gure 4. It consistsof a small box containing the ADC, multiplexer, reference resistors for the cali-bration inputs, some additional electronics (not shown here) and 30 connectorsfor the NTC temperature sensors, which can be spatially distributed around themodule (distances between NTCs and box are typically up to several meters).

There are a total of 32 analogue quantities to measure. The 4 output latchpins the CS5525 provides are not su�cient to make a selection; an extra (unused)CS5525 pin (CPD = Charge Pump Drive, [4]) is used in the selection.

CRYSTAL CS5525 ADC

Temp sensor 1

Temp sensor 2

Temp sensor 3

0o C referenceselection

Analog Mux

analog in

Temperature Sensor Module

SDI

SCLK

SDO Temp sensor 30

01

29

100o C reference3031

Temp sensor 4

D0D1D2D3

CPD

Figure 4: The Temperature Sensor Module.

The input voltage to the ADC on the module as a function of the tempera-ture of the NTC temperature sensor is a non-linear function, requiring a look-uptable. Table 2 shows a look-up table for the NTC temperature sensor (Thermo-metrics NTC type DC95-F-503-W, 5 kOhm); �gure 5 shows the same look-uptable in a graph; the voltage values were calculated for the Temperature SensorModule from the NTC's manufacturer provided temperature-to-resistance table.

From table 2 an ADC-count-to-temperature look-up table has been gen-erated (using curve-�tting) containing all 32768 positive ADC-values (15 bitrange) providing a direct conversion from ADC-value to a temperature between00 and 1000C (provided a proper calibration has been performed).

This look-up table is available as an ASCII-�le to be read in by the host ap-plication, which has to apply the ADC-to-temperature conversion on the ADC-values it receives from the Controller Modules.

Summary of speci�cations:

� Number of T-sensors: 1 to 30

� Measuring range: 00 to 1000C

� Error in measurement: ca. 0.10C (calibration precision) + NTC-sigma (tobe used in DATCHA: 0.20C; also available: 0.050C)

� Linearity: ADC-count to temperature conversion in the form of a look-uptable.

7

Temp VADC Temp VADC[0C] [mV] [0C] [mV]

0 0.000 50 85.510

5 14.859 55 88.421

10 28.274 60 90.828

15 40.104 65 92.823

20 50.344 70 94.478

25 59.078 75 95.856

30 66.445 80 97.002

35 72.614 85 97.958

40 77.738 90 98.761

45 81.991 95 99.434

100 100.000

Table 2: ADC input voltage vs. NTC temperature.

Figure 5: ADC input voltage as a function of NTC temperature.

� Resolution: ranging from ca. 1 m0C@50C to 2 m0C@300C to 25m0C@1000C

� Drift: 1 m0C/0C (with periodical calibration, otherwise 5 m0C/0C)

8

3 Software

3.1 Introduction

The software implementing the local CS5525 ADC control application is basedon applications written for another 80C592-based microcontroller module (de-veloped by NIKHEF). For a description of this module and the applicationsdeveloped for it see [6]. For the application described in this note the NIKHEFGPCAN module was replaced by the MicroKey 20CN592 module, becauseit provides more ROM/RAM memory and new application code can be down-loaded easily, but functionally the two modules are very similar (software forone will run on the other, possibly after remapping some I/O ports).

The initially developed software is a general piece of software whose mainfeature is to be able to control and monitor up to 8 CRYSTAL CS5525 ADCs,each with up to 32 multiplexed analogue inputs. We'll call it Crystal-CANfor short.

Application-speci�c features for either the B-�eld Sensor Module or Temper-ature Sensor Module will be added to the software as found necessary duringthe development of the hardware and while gaining experience in using thehardware.

Application-speci�c features are described in sections 3.6 and 3.7.

All software has been written in C using IAR Systems ICC8051 Develop-ment Kit for the 8051 microcontroller family (which the 80C592 microcontrollerbelongs to); it consists of an ANSI-C cross-compiler, assembler, linker and li-brarian, all running on a PC under MS-DOS.

3.2 Devices

The software was designed in a device-oriented (or 'object-oriented', if you will)manner: a CAN-node can be viewed as a collection of devices, each devicebeing of a certain device-type ('class'), capable of handling certain commands(processing certain received messages) and sending certain messages or replies;matching the object-oriented approach is the fact that there are commandsthat can be given to any or to several device-types although the exact actionperformed by a device depends on its device-type (e.g. a 'status' request canbe handled by almost any device, although the format of the 'status' returneddepends on the type of the device).

Table 3 list the devices available in the Crystal-CAN Controller and theirmapping to 80C592 I/O pins or 20CN592 I/O memory space.

The PAR IO device is connected to the hex-switches that de�ne the Con-troller's CAN-node identi�er at start-up. The DIG IO devices can be used tocontrol LEDs to enable implementation of visual clues to the Controller's stateand actions.

CS5525 is the CRYSTAL CS5525 16-bit ADC device.

3.3 Device Messages

A description of the protocol used in the CAN-messages and descriptions ofthe commands/replies for the various devices can be found in [6], except those

9

Device1 Number 87C592/20CN592 I/0 Mapping

NODE 1 |

CAN 1 CRX0, CRX1, CTX0 (P1.6), CTX1 (P1.7)

RS2322 1 RXD (P3.0), TXD (P3.1)

PAR IO3 1 CS1 I/O space

DIG IO 4 P1.2, P1.3, P1.4, P3.2

CS5525 8 SD0 (P3.3), SDI (P3.4), SCLK (P3.5)CS5525 selection by port P4 (P4.0, 1 and 2)

Table 3: I/O devices available to the Crystal-CAN application and their map-ping to 20CN592 I/O ports and pins.

for the CS5525 device, which is the new device type in this application; itsavailable commands/replies are described in the next section and the appendix.

(NB: Periodic actions for the DIG IO and PAR IO devices have beenremoved in Crystal-CAN),

3.4 CS5525 Messages

Table 4 lists the available commands and gives a short description of each com-mand. The commands typically re ect the capabilities of the CS5525 ADC asdescribed in [4].

The tables in Appendix A give the format and description of the parametersfor each command (In) and corresponding reply (Out) (if any; if there is noreply the word 'Out' is in italics); '|' means the byte(s) is (are) not present.

If in these tables a parameter consists of more than 1 byte the MSB (MostSigni�cant Byte) will occupy the �rst designated byte in the CAN-message bytearray.

1Device identi�ers are listed in Appendix B.24800 baud, 8 bits, no parity, 1 stop bit3Read-only of on-board hex switches (to establish the node's CAN-identi�ers).

10

Command1 Description

READ start an analog-to-digital conversion ofthe requested analogue input and re-turn the data when done

READ PERIODIC2 set up a periodic conversion for all nanalogue inputs with the requested fre-quency; send results

READ LOCAL return the locally stored analog-to-digital conversion result

READ PERIODIC LOCAL2 set up a periodic conversion for all nanalogue inputs with the requested fre-quency; store results in local memory

CANCEL PERIODIC cancel periodic actions for all con-nected CS5525s

READ REG read one of O�set, Gain, Con�gurationor Conversion Data Register

READ REG LOCAL read locally stored O�set, Gain orCon�guration Register contents

WRITE REG write one of O�set, Gain or Con�gura-tion Register

STATUS get some status words describing thestate of the ADC

SET WORDRATE set the conversion word rate

SET GAIN RANGE set the conversion gain range

PUMP DISABLE disable/enable the charge pump

UNIPOLAR set measurement mode to unipolar orbipolar

CALIBRATE perform one of the calibrations

SERIAL INIT initialize the serial port interface

POWER SAVE set the ADC into power-save mode

RESET reset the ADC's serial interface andthe ADC itself(, perform calibrations,etc...3)

Table 4: CS5525 commands.

3.5 Crystal-CAN CS5525 Operation

3.5.1 Initialization

At power-up the Controller waits for at least 700 ms for the CS5525's oscillatorto become stable, then checks for the correct initial values in the CS5525'sregisters. (This, of course, the Controller does for all connected CS5525s).

The results of these actions can be checked e.g. by requesting a CS5525'sstatus (see STATUS).

The CS5525's settings after reset or power-up are the CS5525's defaults:

� O�set = 0

1Command (message) identi�ers are listed in Appendix B.2Periodic actions are performed only when enabled 'NODE-wide' as well.3Number and type of RESET actions is application-speci�c.

11

� Gain = 1.0

� Conversion word rate = 15.02 Hz

� Bipolar measurement mode

� Analog input range = 100 mV

The next step (to be initiated by the user or remote host, or added tothe Controller software as an implementation-speci�c feature) should be a cal-ibration: a system o�set calibration where the CS5525's input is connectedto a ground reference signal, followed by a system gain calibration where theCS5525's input is connected to a signal at the positive full scale point. It is bestto perform calibrations at a low conversion word rate.

3.5.2 Conditions of Operation

When a READ PERIODIC or READ PERIODIC LOCAL operation isenabled the only commands that can be given to the CS5525 areREAD LOCAL,READ REG LOCAL, STATUS and CANCEL PERIODIC; other com-mands result in anERRORmessage with error identi�er ILLEGAL MESSAGE ID.Before any of the other commands can be given a CANCEL PERIODIChas to be given �rst; this is necessary to prevent interference between periodicand user requested CS5525 operations. A periodic action starts only when theNODE device has been given the ENABLE PERIODIC command (see [6]).

When an analogue input is selected a certain signal settling time has to betaken into account: about 40 ms for the T-sensor inputs and about 8 ms forthe B-sensor inputs; when performing a READ (ADC conversion) the softwarewaits for a �xed period of 50 ms to let the signal settle which is su�cient for bothtypes of sensors; when performing periodic conversions the software switchesto the next analog input immediately after the completion of a conversion;it is up to the user to prevent that the frequency of periodic actions resultsin a period shorter than the required signal settling time (so the theoreticalREAD PERIODIC( LOCAL) frequency should not exceed 25 Hz for T-sensors and 125 Hz for B-sensors).

The frequency of a READ PERIODIC( LOCAL) operation is the re-quested frequency of AD-conversions; since there are n analogue inputs, everyindividual input will be sampled at a rate of 1/n-th of the requested frequency;however if the CS5525's conversion wordrate has been set to a lower frequencythen the requested frequency, then the CS5525's conversion wordrate will be theresulting rate.

A �xed time-out of about 400 ms is set for any CS5525 analog-to-digitalconversion which is adequate for even the lowest conversion rate (3.76 Hz).

ForREAD orREAD PERIODIC a time-out results in an ERRORmes-sage with error identi�er TIMEOUT (see Appendix B); it also results in can-cellation of further READ PERIODIC( LOCAL) periodic actions for theCS5525 that timed out (until again enabled by a message from the outside).

Only for READ is the Controller in a busy-wait state while in a time-outperiod (but still able to receive and queue CAN-messages !)

12

3.5.3 Example

A typical example of a host application setting up and monitoring a Crystal-CAN Controller involves the following steps:

/* Initialization step: */

for every 'CS5525' device

{

- execute RESET;

- read and check STATUS;

if required:

- set GAIN and OFFSET registers or perform calibration(s);

- set conversion word rate, input range, etc.;

- set up a READ_PERIODIC_LOCAL action with the required frequency;

}

/* Start the periodic sampling operations */

- set ENABLE_PERIODIC on this 'NODE' device;

/* Monitoring: */

while(1)

/* Repeat the following with a low enough frequency,

not to overload the CAN-bus and not to read values

more often than they are refreshed by the Controller;

(at the same time be able to handle possible ERROR messages

from CS5525, CAN or NODE devices, synchronous and asynchronous!)

(N = number of analogue inputs per CS5525)

*/

for every 'CS5525' device

for( input=0; input<N; ++input )

- READ_LOCAL input;

3.6 B-�eld Sensor Controller Software

(No details about B-�eld controller software speci�cs yet...)

3.7 Temperature Sensor Controller Software

At startup or reset of the controller and after a bf RESET command to a CS5525the controller software does the following:

� The default values for conversion word rate (15.02 Hz) and input voltagerange (100 mV) are used.

� A so-called 'system o�set' calibration is performed with input 31 selected(00C reference) followed by a so-called 'system gain' calibration with in-put 30 selected (1000C reference).

� A READ PERIODIC LOCAL action is set with a frequency of 10 Hz(meaning that every temperature sensor is read out once every 3.2 seconds;the sensor data the user reads from the controller therefore is not olderthan 3.2 seconds maximum).

At controller reset or startup the above actions are performed for everyconnected CS5525.

The user still has to do the following before he can start monitoring thetemperatures:

13

� if he wants to reset the CS5525s explicitly using the RESET commandhe must �rst issue one CANCEL PERIODIC command to disable theautomatically set periodic actions for all connected CS5525s (otherwisethe controller will reject the RESET command as illegal),

� check the statuses of the CS5525s (after every power-up, reset or CS5525RESET) using the STATUS command,

� possibly check the current O�set and Gain Register values, using theREAD REG LOCAL command, for problems in calibrating and possi-bly log the values for keeping track of trends in the o�set and gain values,

� enable all preset periodic sampling actions by issuing anENABLE PERIODICcommand to the NODE device,

� read in the ADC-to-temperature conversion table.

Still to be de�ned perhaps: an (automatic) periodic re-calibration, e.g.every hour.

References

[1] ATLAS Muon Spectrometer Technical Design Report,Version 1.1, CERN/LHCC 97-22, 5 June 1997.(http://atlasinfo.cern.ch/Atlas/GROUPS/MUON/TDR/Web/TDR.html)

[2] 80C51-Based 8-Bit Microcontrollers,Data Handbook IC20, Philips Semiconductors, 1995.

[3] 20CN592 80C592 based micro module with on board CAN bus controller,User's Manual Rev1.3, Micro-key B.V., 1996.

[4] CS5525/CS5526 16-bit/20/bit multi-range ADC with 4-bit latch, data sheets,Crystal Semiconductor Corporation, Sept 1996.(http://www.crystal.com/prod/dap.htm#im)

[5] Interfacing the CS5526 to the 80C51 Microcontroller, Application Note(AN74), Crystal Semiconductor Corporation, Sept 1996.(http://www.crystal.com/prod/dap.htm#im)

[6] H. Boterenbrood,GPCAN a general purpose CAN-bus nodeHardware Overview and Applications,version 2.0, NIKHEF, Aug 14 1997.

14

A Command/Reply Format

READ/READ LOCAL

Msg Byte Out In

1 ADC's sub input [0,n-1] idem

2+3 16-bits conversion data |

4 ags (bit 0: Overrange Flag,bit 1: Oscillation Detect, bit7-2: 111100)

|

READ PERIODIC

Msg Byte Out In

1 ADC's sub input [0,n-1] frequency*10 [Hz](0.1<=f<=25.5)

2+3 16-bits conversion data |

4 ags (bit 0: Overrange Flag,bit 1: Oscillation Detect, bit7-2: 111100)

|

READ PERIODIC LOCAL

Msg Byte Out In

1 | frequency*10 [Hz](0.1<=f<=25.5)

CANCEL PERIODIC

Msg Byte Out In

1 | |

READ REG/READ REG LOCAL

Msg Byte Out In

1 register ID (see table 5) idem

2+3+4 24-bits register content |

WRITE REG

Msg Byte Out In

1 | register ID (see table 5)

2+3+4 | 24-bits register content

15

STATUS

Msg Byte Out In

1 initialization error status: |bit 0: Reset Valid bit not set(0x000040)bit 1: Reset Valid bit not resetafter readingbit 2: O�set Register not zerobit 3: Gain Register not0x800000bit 4: Calibration failed

2 Conversion status: |bit 0: periodic conversionenabledbit 1: periodic conversionstored locallybit 2: conversion in progress

3 periodic action freq*10 [Hz] |

SET WORDRATE

Msg Byte Out In

1 | word rate ID (see table 6)

SET GAIN RANGE

Msg Byte Out In

1 | gain rate ID (see table 7)

PUMP DISABLE

Msg Byte Out In

1 | 0: Charge Pump enabled> 0: Charge Pump disabled

UNIPOLAR

Msg Byte Out In

1 | 0: Bipolar Measurement mode> 0: Unipolar Measurementmode

16

CALIBRATE

Msg Byte Out In

1 ADC's sub input [0,n-1]1 idem

2 calibration function ID (ta-ble 8)

idem

3+4+5 24-bits register content: |O�set, Gain or O�set+GainReg2

|

SERIAL INIT

Msg Byte Out In

1 | |

POWER SAVE

Msg Byte Out In

1 | |

RESET

Msg Byte Out In

1 | |

1ADC input selection only relevant for 'system' calibrations.2When O�set and Gain Registers are calibrated 2 replies are generated.

17

B Crystal-CANDevice, Message and Error Iden-ti�ers

A device identi�er is coded in the upper 5 bits of a byte, the lower 3 bits selecta subdevice of the type (if more than one is present). The message identi�er iscoded in one byte.

/* ------------------------------------------------------------------------ */

/* Device identifiers (first databyte in CAN-message) */

#define DEVICETYPE_MASK 0xf8

#define SUBDEVICE_MASK 0x07

/* Device types */

#define NODE 0x00

#define CAN 0x08

#define RS232 0x10

#define PAR_IO 0x18

#define DIG_IO 0x20

#define CS5525 0x50

/* ------------------------------------------------------------------------ */

/* Messages identifiers (second databyte in CAN-message) */

/* General messages */

#define RESET 0x00

#define STATUS 0x40

#define CANCEL_PERIODIC 0x60

#define ERROR 0x50

/* READ/WRITE messages */

#define READ 0x20

#define READ_PERIODIC 0x21

#define WRITE 0x30

/* NODE messages */

#define ARE_YOU_THERE 0x01

#define ENABLE_MESSAGES 0x02

#define DISABLE_MESSAGES 0x03

#define ENABLE_PERIODIC 0x04

#define DISABLE_PERIODIC 0x05

#define ENABLE_ACK 0x06

#define DISABLE_ACK 0x07

#define ACKNOWLEDGE 0x08

#define DEBUG_ON 0x09

#define DEBUG_OFF 0x0A

/* Specific CAN-controller messages */

#define CAN_INIT 0x10

#define CAN_RESET_ERRORS 0x11

#define CAN_SET_BITRATE 0x12

/* Specific CS5525 messages */

#define READ_REG 0x90

#define WRITE_REG 0x91

#define SET_WORDRATE 0x92

#define SET_GAIN_RANGE 0x93

#define PUMP_DISABLE 0x94

#define UNIPOLAR 0x95

#define CALIBRATE 0x96

#define SERIAL_INIT 0x97

18

#define POWER_SAVE 0x98

#define READ_LOCAL 0x99

#define READ_PERIODIC_LOCAL 0x9a

#define READ_REG_LOCAL 0x9b

/* ------------------------------------------------------------------------ */

/* Error identifiers (third databyte in CAN-message) */

/* (fourth databyte in CAN-message contains an extra parameter

to possibly further clarify the error) */

#define ILLEGAL_DEVICE_TYPE 0x01

#define UNIMPLEMENTED_MESSAGE_ID 0x02

#define ILLEGAL_MESSAGE_ID 0x03

#define ILLEGAL_SUBDEVICE 0x04

#define PAR_OUT_OF_RANGE 0x05

#define MISSING_DEVICE_TYPE 0x06

#define MISSING_MESSAGE_ID 0x07

#define TIMEOUT 0x08

#define CAN_ERROR 0x11

#define CAN_OVERRUN 0x12

#define CAN_BUFFULL 0x13

/* ------------------------------------------------------------------------ */

19

C CS5525 Message Parameter Identi�ers

The following tables show the mapping of various identi�ers to CS5525 param-eters, as used in the CS5525 messages described in a previous chapter.

Id Register

0 O�set Register

1 Gain Register

2 Con�guration Register

3 Conversion Data Register

Table 5: Identi�ers for CS5525 registers.

Id ConversionWord Rate

[Hz]

0 3.76

1 7.51

2 15.021

3 30.06

4 60.01

5 123.18

6 168.90

7 202.27

Table 6: Identi�ers for CS5525 conversion word rates.

Id GainRange

0 25 mV

1 55 mV

2 100 mV1

3 1 V

4 5 V

5,6,7 IGC

Table 7: Identi�ers for CS5525 gain ranges. (IGC : Internal Gain Calibration,required during gain self-calibration).

1default at start-up.

20

Id Calibration Function

0 O�set self-calibration

1 Gain self-calibration

2 O�set system-calibration

3 Gain system-calibration

4,5,6,7 O�set self-calibfollowed by Gain self-calib

Table 8: Identi�ers for CS5525 calibration functions.

D Controller Performance

This section discusses some of the boundary conditions and limitations thatthe CAN-bus, microcontroller and the software set on the performance of theController.

Using the current hardware and software (written in C, optimized for read-ability not speed...) with the 16 MHz 80C592 microcontroller some processingtimes have been measured and are given below (approximately, because timesdepend somewhat on the type of memory the parameters of the subroutines arelocated):

� reading a byte from the CS5525: 35 �s

� writing a byte to the CS5525: 42 �s

� reading a CS5525 register: 210 �s

� writing a CS5525 register: 300 �s

� a CS5525 'Reset System' action including checking Con�g, Gain and O�setRegisters for default contents: 1760 �s

� processor activity involved in sending a CAN-message with 2 databytes:350 �s

� processor activity involved in sending a CAN-message with 8 databytes:600 �s

The conversion time of the CS5525 determines the speed of the conversionfor most of the conversion word rates; the processing overhead involves a fewregister reads and is in the order of 1 ms.

A Crystal-CAN T-sensor Controller with 8 sensor modules has 8*32=256analogue channels to monitor. This will set a limit on the monitoring perfor-mance of the system, per channel.

If reading a locally stored converted analogue value (using theREAD LOCALcommand) and preparing the reply takes the Controller about 1 ms (ca. 400 �sfor processing the received CAN-message and ca. 400 �s for preparing the re-ply CAN-message) it could produce {provided the CAN-bus has the capacityto transport messages at this rate{ samples of 256 analogue channels with a

21

maximum rate of about 4 Hz per channel. Frequency F of periodic read-out perCS5525 (with 32 channels) should then comply to:

F < 128Hz

If, because on grounds of noise �ltering requirements, the conversion wordrate is set to e.g. 15 Hz the maximum achievable 'refresh' rate can only be0.5 Hz per analog channel. Frequency F of periodic read-out per CS5525 (with32 channels) should then comply to:

F < 15Hz

Another boundary condition is formed by the CAN-bus capacity, becauseanalogue-to-digital conversion results in this application is only meaningful whenthe results can be sent out via the CAN-bus to some host controller/application.

We will use a bus rate of 125 kBit/s; from [6] (table 21) can be seen that persecond a maximum of 1315 READ PERIODIC messages (these are CAN-frames with 6 data bytes) could be sent at this bus rate.

Each of the 256 analogue quantities could thus be read out with a maximumfrequency of about 5.1 Hz if the Controller would be the only CAN-node (as-suming that at the same time the Controller is able to read out 256 channelsat this rate...); if there are N nodes in the CAN-bus network the maximumpossible read-out frequency will be 5.1/N Hz per channel.

When we use the command/reply combinationREAD LOCAL, there is anextra (command) message to be sent across the CAN-bus (with 3 data bytes),resulting in a maximum possible read-out frequency of about 2.9/N Hz perchannel.

When we set frequency F of periodic read-out for all analog inputs on Nnodes we can take the above into consideration, because there is no need to re-fresh the converted analogue quantities more often than can be monitored by thehost system without saturating the CAN-bus. E.g. forREAD PERIODIC LOCALthis leads to the following requirement:

F

32<

2:9

N) F <

92:8

NHz

And, last but not least, the protocol for the periodic read-out commandssets the following limit:

F <= 25:5Hz

Frequency F should only be chosen such that it complies to all four require-ments above; some of the values are examples and have to be recalculated if theconditions in which the system operates change.

22