📄 data.doc
字号:
The 8051 Data Collection Unit(0) Introduction This reference details the implementation and operation of the datacollection software included in this package, and its required hardwareconfiguration.(1) Microprocessor-Based Data Collection The original purpose of this software was to carry out a set of fluid flowtests on fluid meters in parellel. Two of these units could be controlled froma PC over a RS-485 serial link. Each unit could test up to 6 meters at a time. Each meter has inside it a magnet which rotated in response to the fluidflowing through it. At a given flow rate, this magnet will rotate a constantamount for each unit of fluid volume passing through the meter. This constantwill be approximately, but not exactly, the same for different flow rates and isan inherent characteristics of the meter's construction. The magnet internal to the meter is divided into a fixed number of sectorsof alternating magnetic field. As the magnet rotates, it can be used togenerate an square electrical waveform which is ideally suited for measurementby a microprocessor. The microprocessor-based data collection unit will mark off a set numberof square waves (corresponding to one full rotation of the magnet), measureits width, and collect the information for successive measurements. It willuse this information to determine the number of complete rotations of themeter's magnet and to estimate the number of fractional rotations, thusobtaining a highly accurate measurement of the meter's behavior. For future reference, the term NUTATION is also used to mean one fullrotation of the meter's internal magnet. The system is set up in such a way that each unit will receive a signal atthe start of a test and a signal at the end of the test. The function of thesesignals is to delimit a test and mark off a fixed volume of fluid. The remaining part of this reference will refer to this specificconfiguration, but it should be noted that this software is completely generic.It can be used to measure and perform statistical processing on any set of upto 6 square wave inputs using a 7th falling edge input to mark the start and endof a test. (a) Hardware Interface Data collection is done using an Intel 8051FA microprocessor runningdedicated stand-alone software. Each microprocessor is connected to 6 pulseinputs, to a sensor signal input, and to a RS-485 serial communicationsconnection. The pulse inputs enable the microprocessor to perform measurementson each of the 6 sources it is monitoring, as explained above. The sensorinput is responsible for signalling to microprocessor when to start and stopthe measurement and counting. Finally, the communications link enables themicrprocessor to communicate with the master PC so that its data can betransferred to the central controller. The inputs and outputs are set up as listed below: Function Location Pulse input 0 T2EX: Timer 2 External Pulse input 1 CEX0: Counter External 0 Pulse input 2 CEX1: Counter External 1 Pulse input 3 CEX2: Counter External 2 Pulse input 4 CEX3: Counter External 3 Pulse input 5 CEX4: Counter External 4 Sensor input INT0: External Interrupt 0 Serial Communications RxD: Receive input TxD: Transmit output T0: RS-485 transmit enable (b) Internal Software Architecture This is a multi-tasking software architecture. Several independent taskswill be running simultaneously on the one 8051FA chip. They communicate witheach other and with the outside world using the 8051 multitasking library.Because of the large number of processes and the limit on stack space, severalcompromises were made when integrating this library with the rest of the datacollection software. The microprocessor is responsible for monitoring 6 counters, and performingstatistical operations for each counter concurrently as it is collecting thedata. A processing loop is set up for each counter and is synchronized by thecounter input. A process is set up to monitor a test, and is synchronized to the sensorinput. When the first signal is receives, this process will Spawn the 6counter processes (and also 2 timer processes). When it receives the secondsignal, it will disable the counter inputs (and clocks) and thus stop theprocesses it spawned. Finally, the microprocessor will monitor the serial communications link,waiting for commands from the master PC. These commands serve three purposes:(a) the enable/disable the master test process, (b) the signal themicroprocessor to transfer its data over the serial communications link, and(c) for diagnostic purposes to test the microprocessor's status and properfunctioning. (c) Data Collection Method The data collection method used measures the times for full meter nutationsduring a test between the two sensor signals Suppose these events take place, as illustrated in the time-line below: *---------------------------------------------------------------------------* | N = Meter Nutation | | S = Sensor Signal | | | | S S | | N N N N N N N N N N N | | *-----------------------------------------* | | | | | | F | w0 | w1 | w2 | w3 | w4 | L | | | | | *-----------------------------------------* | | ^ ^ ^ ^ | | | | <--- N full nutations ---> | | | | S B C T | | | | Events: S = First Sensor Time, | | B = First Meter Nutation Time, | | C = Last Meter Nutation Time, | | T = Last Sensor Time | | | | First Partial Pulse Width: F = B - S | | Last Partial Pulse Width: L = T - C | | Average Pulse Width: <w> = (C - B)/N (= (C - B)/5 in this example) | | | | Estimated First Partial: F/<w> | | Estimated Last Partial: L/<w> | | Estimated Total Nutations: N + F/<w> + L/<w> | | which actually comes out to: (T - S)/<w> = N (T - S) / (C - B) | *---------------------------------------------------------------------------*Then the tester will only be actively counting BETWEEN events S and T. Thedata collection method will calculate the nutation widths w0, w1, w2, w3, w4(thus counting 5 full nutations in this example); and F and L -- the first andlast partial nutations. It will then ESTIMATE what fraction of full nutationsF and L represent by dividing F and L respectively by the average value of thew's. To ensure that a steady flow condition is valid, we also measure the VARIANCEof the pulse widths, which is defined here as: Variance = Standard-Deviation of w's / Average of w's x 100%Typical values in the actual test system this software was used for could varybetween 2% and 3% for high flow rates, down to 0.5% for low flow rates. A highvariance (say, above 5%) invalidates the extrapolation method we use, which ispremised on a constant flow rate. High variances can happen for two reasons: (1) Fluid flow is not in a steady state at the test boundaries. This can occur if the underlying system is still in a transient state as a test starts. (2) The unit undergoing test itself is not operating reliably. (d) Counter Processing To be able to deal with 6 counters with one microprocessor requires somespecial measures be taken. On average, for our actual test conditions (20nutations per second received from each of the 6 inputs) the 8051FA will spend30% of its time during the high flow test doing actual statistical calcultions.However, the demand on the processor can vary between 5% and 200% depending onwhen the 6 inputs delimit full nutations relative to one another. The maximumload will occur when the majority of the 6 inputs have full nutations close toone another in time. What we do is the following. When an input has signalled one full nutation,the time of this event is saved in a protected location. A completelyindependent process, called the Scheduler, started at the beginning of the test,will periodically remove one AND ONLY ONE of these saved items, passing it onto the corresponding statistical processing routine. This simple, buteffective, strategy will keep the processor active at about a constant 30% rate(for the test conditions indicated above). (e) Communications The details of serial commuications will be described in more detail inthe section dealing with the MicroNet. The underlying protocol used for thissystem is: 9 data bits, 1 stop bit, no parity, and 9600 baud (9600,N,9,1).The 9th data bit is used for networking purposes to distinguish commands fromdata. The centrally located PC will always send commands with the 9th bit high,and the microprocesors will always send data, with the 9th bit low. Thisprotocol will help protect the network from inadvertent access by two or moreprocessors at once. (f) Command Reference As a slave unit to the central PC, each microprocessor will respond to aset of commands. These commands are described in brief below and will bedetailed in the section on the MicroNet. STATUS: A diagnostic command that queries the current state of the data collection unit. It will respond to the PC that it is in one of the following modes: ACTIVE: In active command mode, ready to start a new test. WAITING: In test mode, waiting on the first sensor. TESTING: In test mode, collecting data, waiting on the second sensor. TEST: A command telling the microprocessor to pass into the waiting mode. It is ignored unless the microprocessor is active. ABORT: A command that forces the processor back into the active mode and cancels the current test.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -