Documentation of Radiometry
Transcript of Documentation of Radiometry
PROJECT REPORT ON
MICROCONTROLLER BASED
RADIOMETRIC DENSITY GAUGE
SUBMITTED IN PARTIAL FULLFILLMENT OF
THE REQUIREMENT FOR THE AWARD OF THE DEGREE OF
BACHELOR OF TECHNOLOGY IN ELECTRONICS AND
COMMUNICATION ENGINEERING
BY
D.SUDHEER KUMAR (05L01A0448)
U.HARISH (05L01A0418)
G.SUKUMAR (05L01A0449)
L.SREENATH REDDY (05L01A0444)
UNDER THE ESTEEMED GUIDANCE OF
I.C.S.REDDY, Technical Manager
NUCLEAR INSTRUMENTATION SECTION,
INSTRUMENTS AND SYSTEMS DIVISION,
ELECTRONICS CORPORATION OF INDIA LIMITED,
HYDERABAD.
ELECTRONICS CORPORATION OF INDIA LIMITED
A Govt. of India (Department of Atomic Energy) Enterprise
Instruments and Systems Division
ECIL (P.O.)
Hyderabad - 500 062 (AP)
Tel: 040 27122986
Fax: 040 27121611 E-mail: [email protected]
CERTIFICATE
This is to certify that students of 4 th year B.TECH (Electronics and
Communication Engineering) studying in TRR COLLEGE OF
ENGINEERING ,PATANCHERU affiliated to JAWAHARLAL NEHRU
TECHNOLOGICAL UNIVERSITY, HYDERABAD.
D.SUDHEER KUMAR (05L01A0448)
U.HARISH (05L01A0418)
G.SUKUMAR (05L01A0449)
L.SRINATH REDDY (05L01A0444)
Have carried out an industry-oriented project titled “MICRO
CONTROLLER BASED RADIOMETRIC DENSITY GAUGE” at ELECTRONICS
CORPORATION OF INDIA LIMITED (ECIL), HYDERABAD. For the partial
fulfillment of requirement for the award of the industry oriented project of BACHELOR
OF TECHNOLOGY.
The project work has been completed to our satisfaction. This is the record of
Bonafide work carried out under our supervision.
PROJECT INCHARGE PROJECT GUIDE
R.S.MURTHY I.C.S.REDDY
(Sr. DGM, I.S.D) (Technical Manager)
ACKNOWLEDGEMENTS
OUR SINCERE THANKS TO OUR COLLEGE,
PRINCIPAL AND LECTURERS
WHO HAD GIVEN US THIS OPPORTUNITY.
OUR HEART FULL THANKS TO ISD-ECIL FOR
GUIDING US AT EVERY STAGE OF
THE PROJECT WORK.
THANKS TO ALL THE PEOPLE WHO HAD
HELPED US IN MAKING THIS PROJECT
A SUCCESS.
THANK YOU VERY MUCH,
D.SUDHEER KUMAR (05L01A0448)
U.HARISH (05L01A0418)
G.SUKUMAR (05L01A0449)
L.SRINATH REDDY (05L01A0444)
COMPANY PROFILE
Electronics has been the single largest contributor to the tremendous
technical progress made in 20th century. BARC undertook the design development
and production of electronic components, instruments and systems.
This group grew in strength and diversified its activities to manufacturing
and supply of electronic equipment for the nuclear research project at Trombay.
In August 1963, the Govt. of India realizing the importance of electronics in the
process of technological development constituted the electronic committee,
familiarly known as BABA committee with late Dr. Homi Jahangir Baba as its
chairman to access the nations requirement of electronic components and
equipment and to suggest measures necessary to achieve self sufficiency in the
shortest possible time.
It was fit to undertake production on the commercial scale by converting
the electronic production division of BARC into a separate organization. This lead
to the setting up of ECIL in April 1967 as a Govt. of India enterprise, under the
development of Atomic Energy, to indigenously manufacture electronic
components, instrument and systems.
ECIL’s area of operation includes control instruments and systems, computers,
electronic components and special products for nuclear and measuring electronic
instruments and systems, defense products, color and B&W T.V, receivers,
antenna systems and consumer electronic, communication equipments. It caters to
the special requirements of nuclear and thermal power plants, telecommunication,
radio and T.V. broadcasting, police & paramilitary organization, civil aviation,
research and teaching institution in addition to consumers.
ECIL’s activities are organized into six different groups
Computer
Communication Systems
Strategic electronics
Instruments
Components and special products
Industry and consumer Electronics
ECIL lays constant emphasis on R&D, which is an essential part of any
electronic industry where the rate of obsolescence is very rapid. ECIL has a
network of four zonal offices and branches through out the country, which looks
after the sales and services function the offices, are located in CHENNAI,
MUMBAI, DELHI and KOLKATA.
ABSTRACT
The coal finds wide application in industries because of their
abundance and low cost. Coal obtained from mines consists of lot of
impurities in the form of rock. For industrial purpose, the need of high-grade
coal (with density of 1.2 to 1.5gm/cc) is essential. “Floating Technique”
obtains the high-grade coal. This technique employs washing of mine-coal in
a mixture of water and magnetite powder known as “Slurry”. Slurry has a
density of approximately 1.5gm/cc to 1.9gm/cc. The high-grade coal will
float and the coal with impurities will sink. Thus separating the high-grade
coal from the low-grade coal.
The quality of coal depends on the density of the slurry; hence
the density of the slurry should be monitored on L.C.D and the information is
sent to the control disc through the serial port and controlled continuously.
For this purpose the slurry is made to flow through a pipe to which the
“Radiometric Density Gauge” is mounted. A radioactive source and a
detector are placed on the either side of the pipe. The radiation emitted by the
source passes through the pipe and falls on the detector. The detector gets
ionized and gives an output current inversely proportional to the density of
the slurry. This signal is given to the BL2100 micro controller as analog
input.
The software used to implement this is “Dynamic C”.
OBJECTIVES OF THE PROJECT
To provide an efficient and systematic control of density of the slurry, which
indirectly helps in maintaining the quality of the coal.
To stabilize the analog voltage from the detector, which is a fast changing signal.
To display the density corresponding to the voltage and provide the controlling of
the density to maintain the slurry density at the desired value.
CONTENTS
Chapter 1 Introduction
1.1 General information
1.2 Application of Density Gauge
1.3 Principle
1.4 Advantages
Chapter 2 RADIATION
2.1 Introduction
2.2 Type of Radiation
2.3 Radiation Units
2.4 Interaction of Radiation with Matter
2.5 Safety Standards
Chapter 3 System Description
3.1 Block diagram
3.2 Description
Chapter 4 BL 2100 MICRO CONTROLLER
4.1 Description
4.2 Features
4.3 Subsystems
4.4 BL2100 Pin outs
4.5 Software
4.6 Display unit
4.7 BL 2100 Function APIs.
Chapter 5 RABBIT 2000 MICROPROCESSOR
5.1 Features & Specifications
5.2 Advantages
Chapter 6 Dynamic C
6.1 Introduction
6.2 The Nature of dynamic C
6.3 Dynamic C enhancements and differences
6.4 Functions used in Dynamic C
Chapter 7 Basic program
7.1 Flow chart for the basic program
7.2 Basic program to calculate the slurry density
Chapter 8 Contribution to the project
8.1 program1: To calculate the slurry density and display the value.
8.2 program2: To display the values and transmit using serial port
8.3 program3: To calculate the density and transmit the value to other
systems only when a request is sent
Chapter 9 Future scope
Chapter 10 Conclusion
Chapter 11 References
LIST OF FIGURES
1.Block diagram of Radiometric Density Gauge.
2.BL2100 Subsystems.
3.RJ-45 Ethernet Port Pinout.
4.Analog Reference Voltage Circuit.
5.BL2100 Pinouts.
6.Block Diagram of the Rabbit Microprocessor.
7.Flow Chart for the Basic Density Program.
LIST OF TABLES
1. BL2100 Models
2. Serial communication configurations
3. System specifications
CHAPTER 1
INTRODUCTION
1.1 GENERAL INFORMATION
The Radiometric Density Gauge is designed for continuous
measurement of the density of liquids, suspensions, slurries of poured materials.
Measurement is without physical contact and is unaffected by changes of
pressure, flow rate and viscosity.
1.2 PRINCIPLE OF OPERATION
The Radiometric Density Gauge operates on the principle that Gamma
rays absorbed as a function of density expressed mathematically.
Where,
I = Actual intensity of the gamma ray
Io = Intensity measured when no coal is present
= Total mass absorption coefficient of coal
= Density of coal
X = Thickness (distance between the source and detector)
Because the source to detector distance is fixed, ‘’ is constant. Mass
absorption coefficient’’ is constant for a given process material. Therefore,
the resultant radiation, ‘I’ is only a function of process density ‘’.
Ix =Io *exp (- X)
A correct installation ensures that a change of radiation at the detector is caused
by a chance of material density in the pipe.
1.3 THEORY OF OPERATION
The beam of Gamma rays emitted by a radioactive source, generally
Cs137 or Co60 (depending on application), passes through the slurry to an
ionization chamber (detector), which converts it into output electric current. The
strength of the current depends upon the activity of the source, on a geometric
layout and on the quantity of slurry through which the rays have passed. It will
be a function of the density of the slurry so long as the volume and geometric
disposition of the material remains constant.
The intensity of the gamma rays decreases exponentially with the
thickness and the density of the absorber. Since the diameter of the pipe in
which the slurry is passed is fixed, so the absorption of the gamma rays is
proportional to the density.
In general, an ionization chamber is used as a detector. The control of
density is done using BL2100 microcontroller, which consists of a RABBIT
2000 microprocessor, which is programmed in Dynamic C.
1.4 ADVANTAGES
Online measurement.
Non-contact measurement.
Measurement of large volumes of samples.
Withstands for harsh environment.
1.5 APPLICATIONS OF DENSITY GAUGE :
Steel Industry.
Thermal Power Station.
Coal Washeries.
Aluminum Industries and soon.
CHAPTER 2
RADIATION
2.1 INTRODUCTION
Nuclear radiation is the process by which energy is transformed from
nucleus of the atoms by releasing in the form of electromagnetic wave or other particles.
Radiation ionize/excite the medium through which it passes. This ionizing radiation is
hazardous to human health. But application of radiation and isotope technology in any
field is so beneficial for mankind that radiation is a very minor component of the risks,
what every individual is facing in day to day life so it is emphasized to treat radiation
with care rather than fear.
2.2 TYPE OF RADIATION
Alpha : +ve charged particle (two protons+ two neutrons) (AM-241)
Beta : _ve charged particle (one electron) (Sr-90, Kr-85)
Neutron : a neutral particle (Am-Be, Pu-Be)
Gamma : Electromagnetic wave (Co-60, Cs-137)
2.3 RADIATION UNITS
An International Body International Commission on Radiation Units &
Measurement (ICRU) defines radiation units.
2.3.1 ACTIVITY
Number of disintegrations per unit time1 Ci(Curie) = 3.7 x 10^10 disintegration
per second New defined unit 1 Bq(Becqurel) = 1dps.
2.3.2 QUALITY FACTOR
Gamma & Beta Radiation -- 1
Proton -- 5
Alpha -- 20
Neutron Thermal(10 Kev) -- 5
Medium(10-100 Kev) -- 10
Fast(0.1-2 Mev) -- 20
2.3.3 HALF LIFE
Half life(T1/2) of a source is defined as the period of time after which activity of
the source becomes half. It is different for different sources. Ex: Cs 137-T1/2 = 30.17
years, Co 60-T1/2 = 5.3 years.
2.3.4 K-FACTOR
Exposure from 1 mCi at 1 cm distance from the source in one hour.
Ex: Cs137- 3300 mR
1Ci = 37 GBq
2.4 INTERACTION OF RADIATION(GAMMA RAY) WITH MATTER
2.4.1 PHOTOELECTRIC EFFECT:
Interaction of radiation with a bound electron of the medium as a result of
which the entire energy is absorbed and the electron is ejected from the atom.
2.4.2 COMPTON SCATTERING:
The scattering of an incident gamma ray by an orbital electron of the medium
resulting in the transfer of a fraction of gamma energy.
2.4.3 PAIR PRODUCTION:
When the incident gamma ray energy exceeds 1.02 Mev, the gamma ray is
completely absorbed and in its place an electron-positron pair is produced
2.5 SAFETY STANDARDS:
2.5.1 STORAGE:
Proper storage and documentation of inward and outgoing radioactive material is very
important. The sources should be stored, tagged with contents and activity of the sources,
in a separate room with lock and key arrangement.
2.5.2 SOURCE HANDLING:
Time, Distance and Shielding are the major points to minimize radiation
exposure while handling sources.
2.5.3 TIME:
Radiation exposure is directly proportional to working time. A minimum time
should be taken to complete the work in the radiation field.
2.5.4 DISTANCE:
Exposure is inversely proportional to the square of the distance.
2.5.5 SHIELDING:
Shielding of the material is inversely proportional to the radiations, so shielding
of high density material is to be used to keep radiation at acceptable limits.
2.5.6 DISPOSAL :
It is advisable to plan for disposal of unused radioactive material as early as
possible. These are disposed off at Bhabha Atomic Research Center (BARC), Mumbai
with a prior permission of AERB.
CHAPTER 3
SYSTEM DESCRIPTION
3.1 BLOCK DIAGRAM:
SOURCE
HOLDER
Detector Assembly
AAAAAAAAAASassembly
LCD
Display
4 to 20mA
EHT-500vdc
LVp.s
BL2100Micro-Controller
Rabbit2000Microprocessor
EHT
…….…….
…….…….
…….
…….
A to DD to A
..;;;.;;;
;;;.;;;
;;;.;;;
;;;.;;;
LEAD
Pre-Amplifier
Ionization chamber
Signal from Detector
Block diagram of Micro controller based
Radiometric Density gauge
SOURCECs 137
3.2 DESCRIPTION
The basic system consists of the following components
Frame
Source
Electronic unit
Detector unit
Control unit
Mounting saddles
3.2.1 FRAME
Frame houses the source (Cs-137) on one side and the detector (G16) on the
other side. Source holder and detector are aligned such that the collimated narrow
beam from the source holder falls on the detector. Frame is designed to keep the
detector and the source holder almost in the center of the pipe.
3.2.2 SOURCE HOLDER:
Cesium137 or Cobolt60 source (depending on the application) is used as the
radiation source. The source is housed in a source holder with lead shielding. A
shutter is provided to keep the source either open or in closed position. There is a
provision to look the source holder in both positions. The design of Source Holder
approved has been accorded by the Division of Radiological Protection, Bhaba
Atomic Research Center, Mumbai.
3.2.3 ELECTRONIC UNIT:
The unit works on 230/110V, 50Hz, AC, Full wave bridge circuit across center
tapped secondary winding of the mains transformers is used to get the rectified
DC for 15V and +5V supplies are regulated & +24V DC un regulated. An other
Transformer is to supply 24VAC to Heater control circuit.
POWER SUPPLY:
3 terminal IC regulators are used for all supplies to provide regulated DC o/p
voltages.
A 10V reference is generated from 15 volts supply, which can be adjusted for any
deviations by potentiometer on power supply PCB. This PCB contains a source
decay compensation circuit and also main process like signal suppression. The
source decay compensation circuit consists of a linear potentiometer in feed back
circuit of a stable operational amplifier. The source decay circuit connected after
the output of the varactor bridge amplifier.
As the source decays with time varactor diode amplifier output decreases. To
maintain the amplifier output , despite a decreasing input, the source decay circuit
is designed to increase the gain of operational amplifier.
LOG-AMPLIFIER:
The log linearizer circuit compensates for non- proportional absorption of
radiation by varying amount of material. The circuit is an input signal
conditioning device that ensures output linearity related to the measured variable .
The linearizer circuit acts between the original signal amplification stage and the
following suppression circuit .In this way, only the amplified detector signal is
affected. As incoming signal is an exponential functional of the material,
linearizer acts logarithmically so that the resultant output is linear. The circuit is
log amplifier with a specific transfer function of 10log Vin/1.
NOTE:For a 10V input ,9-10V output is expected.Unity gain amplifier inverts the
input signal.
EXTRA HIGH TENSION:(EHT)
This PCB contains high voltage circuit and a high input impedance pre amplifier
circuit. High voltage supply, basically a DC-to-DC converter consists of an
oscillator whose output is rectified and filtered to obtain a stable high voltage
supply for powering the detector (Ion chamber).
EHT power supplies are characterized as being able to generate some tens of
kilovolts into capacitive loads of up to a few hundred Pico farads, typically
implying total electrical energy yields of up to about 100 mJ
.
For EHT we are using oscillator, rectifier, filter & feedback for constant high
voltage. And we are using Transformer, rectifier, filter & regulator for low
voltage power supply. Regulators 7815 is for +15V, 7915 is for –15V & 7805 is
for +5V.
3.2.4 DETECTOR UNIT:
The detector is an ionization chamber, which consist of organ gas at 20ATP.
When the radiation falls on the gas present in the ionization chamber gets ionized.
Dc voltage must be applied to collect the ions before recombination of ions takes
place. If the applied voltage is high ionization gets multiplied and large signal is
produced.
IONIZATION CHAMBER:
Ionization chamber is used to get the current, which is inversely proportional to
that of density of a liquid to be measured. The air is evacuated from the envelope
and a small amount of an inert gas, such as argon, is added.
The voltage is kept below the ionization potential of the gas. Now if radiation
penetrates through the pipe and enters the envelope, it would ionize some of the
gas atoms.
The resulting negative ions go towards the anode and positive ions towards the
cathode. In their passage, the ions collide with some of the gas atoms, causing
them to be ionized in turn. This process continues till whole of the gas atoms are
ionized. Complete ionization takes place in no time. A pulse of current then flows
through the tube. This current flowing through the resistance is the output voltage.
Pre-amplifier amplifies this output pulses from the resistance.
PRE-AMPLIFIER :
The ionization chamber reacts to the changing gamma ray intensity, out putting a
small proportional current. This current typically in the Pico ampere range is fed
to a (varactor bridge amplifier) PRE-AMPLIFIER. Amplifier feed back current
develops a usable voltage across the high-meg resistor to a given input time
constant. This constant is necessary, as over a short interval of time, radiation is a
random event and the incoming signal must be integrated to minimize these
statistical effects.
HETER CONTROL:
The heater controller unit is present in the detector unit of RDG. It is an
ionization chamber, which consist of argon gas at 20 atmos. When the radiation
falls on the gas present in the ionization gas present in the chamber gets ionized.
DC voltage must be applied to collect the ions before recombination of ions takes
place. If the applied voltage is high ionization gets multiplied and large signal is
produced. The heater controller here maintains the temperature required for the
above process with the help of the heater present in it.
Block diagram of Heater Controller
The heater control circuit consists of a triac heater driver, which is controlled by
a zero crossing switch. The circuit (except for the heater and thermistor) is located
in a separate board fixed near pre-amplifier board.’V1’ is an IC zero crossing
switch which is controlled by thermistor ‘R2’. Resistor (R1+ P1), thermistor ‘R2’
and ‘V1’ form a bridge. If the thermistor temperature is less than 65 degrees (i.e.,
thermistor resistance greater than R1 + P1), V1 supplies a pulse to the triac ‘Q1’
each time the AC voltage crosses zero. As long as the temperature at the
thermistor remains below 65 degrees C, the triac conducts and supplies power to
the heater. When the temperature exceeds 65 degrees C the output pulses of ‘V1’
are inhibited and low power is supplied to the heaters. DC powers for ‘V1’ (5.5 to
7.5V) are developed from the AC at terminals 5 of ‘V1’ by an internal power
supply. Capacitor ‘C3’ is a ripple filter for the internal supply. A safety thermostat
‘F1’ (thermal fuse) is mounted on the side of the circuit board. The safety
thermostat open the AC power line when the detector temperature exceeds 60
degrees and prevents the unit from over heating if the control circuit fails.
The heater control circuit drives 200W heat. The heater is located in a single unit
wrapped around the heater housing. The control thermistor is located on the side
of the detector package, between the installation and the heater.]
3.2.5 CONTROL UNIT:
The Control unit is BL2100 Micro Controller running on Rabbit2000
Microprocessor. The signal is received from the detector & processed the
corresponding density is displayed on LCD and digital panel meter.
(a) A/D and D/A CONVERTER:
The 4-20mA,o/p from detector is in analog form. It is converted into digital form
by using analog to digital converter (A/D). Digital form of signal is essential for
micro controller based RDG.
Digital to analog converter (D/A) is used to convert digital signal from micro
controller to analog signal for external disp
(b) Software:
The software program is developed in Dynamic C language to calculate the
density of various liquids and it is displayed on LCD and Digital panel meters.
( c ) Display Unit:
The processed and calculated data from the micro-controller is displayed on the
LCD.The display unit displays both analog meter and digital display of the
density of the liquid that is measured.
3.2.6 OPERATIONAL CONTROLS:
MAINS ON SWITCH : DPST switch is used to ON the mains supply to the
instrument. Presence of mains supply is indicated
by the pilot lamp glow.
FUNCTIONS SWITCH : One pole 4 way rotator switch to select one of the
Following:
REF : The DPM indicates the o/p of preamplifier in this
stage.
MEASURE : The DPM indicates the density of the process
material.
LOW ALARM : The DPM indicates the low alarm set point.
HIGH ALARM : The DPM indicates the high alarm set point.
3.2.7 SPECIFICATIONS:
Density Range : 1.2 gm/cc to 1.99 gm/cc
Accuracy : +/- 0.01
Response Time : 20 seconds
Radioactive source : Type CS-137 (Half life: 33yrs)
Detector : Ionization chamber LND 50417
Output Signal : 4 to 20mA DC; 600 ohms max load;
Operating temperature: 0 to 50 degrees Celsius.
CHAPTER 4
BL 2100 MICRO CONTROLLER
4.1 INTRODUCTION
The BL2100 is a high-performance, C-programmable single-board
computer that offers built-in digital and analog I/O combined with
Ethernet connectivity in a compact form factor. A Rabbit 2000TM
microprocessor operating at 22.1 MHz provides fast data processing. An
optional plastic enclosure and LCD/keypad module are available, and may
be wall-mounted.
4.2 BL2100 DESCRIPTION
The BL2100 is an advanced single-board computer that incorporates the
powerful Rabbit 2000 microprocessor, flash memory, static RAM, digital
I/O ports, A/D converter inputs, D/A converter outputs, RS-232/RS-485
serial ports, and a 10Base-T Ethernet port.
4.3 BL2100 FEATURES
Rabbit 2000TM microprocessor operating at 22.1 MHz.
128K static RAM and 256K flash memory standard, may be
increased to 512K SRAM and 512K flash memory.
40 digital I/O: 24 protected digital inputs and 16 high-current
digital outputs provide sinking and sourcing outputs.
15 analog channels: eleven 12-bit A/D converter inputs, four 12-bit
D/A converter 0-10 V outputs (selected models).
One RJ-45 Ethernet port compliant with IEEE 802.3 standard for
10Base-T Ethernet protocol (selected models).
Two Ethernet status LEDs (selected models).
Four serial ports (2 RS-232 or 1 RS-232 with RTS/CTS, 1 RS-485,
and 1 CMOS-compatible programming port).
Battery-backed real-time clock.
Watchdog supervisor.
Optional backlit 122 × 32 graphic display/keypad module.
Remote program downloading and debugging capability via
RabbitLink.
Four BL2100 models are available. Their standard features are
summarized in table 3.1
Table 3.1 BL2100 Models
Feature BL2100 BL2110 BL2120 BL2130
Microprocessor Rabbit 2000 running at 22.1 MHz
Static RAM 128K
Flash Memory 256K
RJ-45 Ethernet Connector, Filter
Capacitors, and LEDsYes No
A/D Converter Inputs
(-10 V to + 10 V)Yes No Yes No
D/A Converter Outputs
(0 V to +10 V)Yes No Yes No
Rabbit Core Module Used RCM2200 RCM2300
4.4 SUBSYSTEMS
· Digital I/O
· Serial Communication
· A/D Converter Inputs
· D/A Converter Outputs
· Analog Reference Voltage Circuit
· Memory
· External Interrupts
Figure 3.1 shows these Rabbit-based subsystems designed into the
BL2100.
4.4.1 DIGITAL I/O
DIGITAL INPUTS
The BL2100 has 24 digital inputs, IN00-IN23, each of which is protected
over a range of -36 V to +36 V. The inputs are factory-configured to be
pulled up to +5 V, but they can also be pulled up to +K2 or down to 0 V in
banks of eight by changing a surface-mounted 0 resistor as shown in
Figure 9.
Figure 3.2 BL2100 Digital Inputs [Pulled Up--Factory Default]
NOTE If the inputs are pulled up to +K2, the voltage range over which
the digital inputs are protected changes to K2 - 36 V to +36 V.
The actual switching threshold is approximately 2.40 V. Anything below
this value is a logic 0, and anything above is a logic 1.
IN16-IN23 can be factory-configured as outputs for users who prefer to
have 16 inputs and 24 outputs.
DIGITAL OUTPUTS
The BL2100 has 16 digital outputs, OUT00-OUT15, which can each sink
or source up to 200 mA. Figure 10 shows a wiring diagram for using the
digital outputs in a sinking or a souring configuration.
Figure 3.3 BL2100 Digital Outputs
All the digital outputs sink and source actively. They can be used as high-
side drivers, low-side drivers, or as an H-bridge driver. When the BL2100
is first powered up or reset, all the outputs are disabled, that is, at a high-
impedance status, until the digoutConfig software function call is made.
The digoutConfig call sets the initial state of each digital output according
to the configuration specified by the user, and enables the digital outputs
to their initial status.
OUT00-OUT07 are powered by to +K1, and OUT08-OUT15 are powered
by +K2. K1 and K2 can each be up to 36 V. They don't have to be same.
All the sinking current, which could be up to 3.2 A, is returned through the
GND pins. Be sure to use a suitably sized GND and keep the distance to
the power supply as short as possible. Since there are two GND terminals
(pin 1, screw-terminal header J4, and pin 12, screw-terminal header J11),
it is highly recommend that you split the GND returns according to the
two banks of digital outputs.
For the H bridge, which is shown in Figure 11, K1 and K2 should be the
same if two digital outputs used for the H bridge are on different banks.
4.4.2 SERIAL COMMUNICATION
The BL2100 has two RS-232 serial ports, which can be configured as one
RS-232 serial channel (with RTS/CTS) or as two RS-232 (3-wire)
channels using the serMode software function call. Table 3.2 summarizes
the options.
Table 3.2 Serial Communication Configurations
ModeSerial Port
B C D
0 RS-232, 3-wire RS-232, 3-wire RS-485
1 RS-232, 5-wire CTS/RTS RS-485
The BL2100 also has one RS-485 serial channel and one CMOS serial
channel that serves as the programming port.
All four serial ports operate in an asynchronous mode. An asynchronous
port can handle 7 or 8 data bits. A 9th bit address scheme, where an
additional bit is sent to mark the first byte of a message, is also supported.
Serial Port A, the programming port, can be operated alternately in the
clocked serial mode. In this mode, a clock line synchronously clocks the
data in or out. Either of the two communicating devices can supply the
clock. The BL2100 boards typically use all four ports in the asynchronous
serial mode. Serial Ports B and C are used for RS-232 communication, and
Serial Port D is used for RS-485 communication. The BL2100 uses an
11.0592 MHz crystal, which is doubled to 22.1184 MHz. At this
frequency, the BL2100 supports standard asynchronous baud rates up to a
maximum of 230,400 bps.
RS-232
The BL2100 RS-232 serial communication is supported by an RS-232
transceiver. This transceiver provides the voltage output, slew rate, and
input voltage immunity required to meet the RS-232 serial communication
protocol. Basically, the chip translates the Rabbit 2000's CMOS/TTL
signals to RS-232 signal levels. Note that the polarity is reversed in an RS-
232 circuit so that a +5 V output becomes approximately -10 V and 0 V is
output as +10 V. The RS-232 transceiver also provides the proper line
loading for reliable communication.
RS-232 can be used effectively at the BL2100's maximum baud rate for
distances of up to 15 m.
RS-485
The BL2100 has one RS-485 serial channel, which is connected to the
Rabbit 2000 Serial Port D through an RS-485 transceiver. The half-duplex
communication uses the Rabbit 2000's PB6 pin to control the transmit
enable on the communication line.
The BL2100 can be used in an RS-485 multidrop network. Connect the
485+ to 485+ and 485- to 485- using single twisted-pair wires
(nonstranded, tinned) as shown in Figure. Note that a common ground is
Recommended.
Figure 3.4 RS-485 Termination and Bias Resistors
PROGRAMMING PORT
The RabbitCore module on the BL2100 has a 10-pin programming header.
The programming port uses the Rabbit 2000's Serial Port A for
communication, and is used for the following operations.
Programming/debugging
Cloning
Remote program download/debug over an Ethernet connection via
the RabbitLink EG2100
The programming port is used to start the BL2100 in a mode where the
BL2100 will download a program from the port and then execute the
program. The programming port transmits information to and from a PC
while a program is being debugged.
The Rabbit 2000 startup-mode pins (SMODE0, SMODE1) are presented
to the programming port so that an externally connected device can force
the BL2100 to start up in an external bootstrap mode. The BL2100 can be
reset from the programming port via the /EXT_RSTIN line.
The Rabbit 2000 status pin is also presented to the programming port. The
status pin is an output that can be used to send a general digital signal.
ETHERNET PORT
Figure shows the pinout for the Ethernet port (J2 on the BL2100 module).
Note that there are two standards for numbering the pins on this
connector--the convention used here, and numbering in reverse to that
shown. Regardless of the numbering convention followed, the pin
positions relative to the spring tab position (located at the bottom of the
RJ-45 jack in Figure 14) are always absolute, and the RJ-45 connector will
work properly with off-the-shelf Ethernet cables.
Figure 3.5 RJ-45 Ethernet Port Pinout
RJ-45 pinouts are sometimes numbered opposite to the way shown in
Figure 14.
Two LEDs are placed next to the RJ-45 Ethernet jack, one to indicate an
Ethernet link (LNK) and one to indicate Ethernet activity (ACT).
The transformer/connector assembly ground is connected to the BL2100
module printed circuit board digital ground via a 0 resistor "jumper,"
R29, as shown in Figure.
Figure Isolation Resistor R29
The factory default is for the 0 resistor "jumper" at R29 to be installed.
In high-noise environments, remove R29 and ground the
transformer/connector assembly directly through the chassis ground. This
will be especially helpful to minimize ESD and/or EMI problems.
4.4.3 A/D CONVERTER INPUTS
The single 14-channel A/D converter used in the BL2100 has a resolution
of 12 bits (models BL2100 and BL2120 only). Eleven of the 14 channels
are available externally, and three are used internally for the reference
voltages: 4.096 V (Vref), 2.048 V (Vref/2), and Analog Ground. These
internal voltages can be used to check the functioning of the A/D
converter.
The A/D converter only measures voltages between 0 V and the applied
reference voltage. Therefore, each external input has circuitry that
provides scaling and buffering. All 11 external inputs are scaled and
buffered to provide the user with an input impedance of 1 M and a range
of -10.24 V to +10.24 V.
Figure shows the buffered A/D converter inputs.
Figure 3.6 Buffered A/D Converter Inputs
The op-amp is powered from the +V supply. The 1 M and 200 k
resistors set the gain (scale factor), which is 0.2 in this case. This results in
a dynamic input range of 0.2 × 20.48 V or 4.096 V. The center point of
this range is set by the 1.707 V reference voltage. With the reference set to
1.707 V, the center point is at 0 V and the input voltage can range from -
10.24 V to +10.24 V. To maintain the best accuracy, the input range
should be limited to -10.0 V to +10.0 V.
4.4.4 D/A CONVERTER OUTPUTS
Only the BL2100 and the BL2120 models are stuffed with D/A converters.
The D/A converter outputs are buffered and scaled to provide an output
from 0 V to +10 V.
NOTE
The D/A converter output voltage depends on the original power-
supply voltage, +RAW, so if +RAW < 13 V, the maximum D/A
converter output will be +RAW - 3 V.
Figure shows the D/A converter outputs.
Figure 3.7 D/A Converter Outputs
To stay within the maximum power dissipation of the D/A converter
circuit, the maximum D/A converter output current is 10 mA per channel
for a power-supply voltage, +RAW, up to 15 V, and drops to 2 mA per
channel for a power-supply voltage of 36 V.
Figure . Maximum D/A Converter Output
Current vs. Power-Supply Voltage
4.4.5 ANALOG REFERENCE VOLTAGE CIRCUIT
Figure shows the analog voltage reference circuit.
Figure 3.8 Analog Reference Voltages
This circuit generates the 4.096 V reference voltage, which is used by the
A/D converter and by the D/A converters. This sets the operating range of
the A/D converter and the D/A converters (0-10 V). To use the full
accuracy of the A/D converter and the D/A converters, this voltage must
be accurate to the same degree.
The reference zener diode in combination with the 300 resistor form a
shunt regulator. The 4.096 V reference voltage then feeds the A/D
converter, the D/A converters, and the voltage divider composed of the 10
k and the 14 k resistors. The voltage divider generates a second
reference voltage of 1.707 V to feed the four op-amps for the buffered
A/D converter inputs.
The 2.048 V reference voltage is also used to generate the 2.5 V reference
for D-REF used in the digital output circuit.
4.4.6 MEMORY
SRAM
The BL2100 module is designed to accept 128K to 512K of SRAM
packaged in an SOIC case. The standard BL2100 modules come with
128K of SRAM.
FLASH MEMORY
The BL2100 is also designed to accept 128K to 512K of flash memory
packaged in a TSOP case. The standard BL2100 modules comes with one
256K flash memory.
A Flash Memory Bank Select jumper configuration option based on 0
surface-mounted resistors exists at header JP2 on the RabbitCore module.
This option, used in conjunction with some configuration macros, allows
Dynamic C to compile two different co-resident programs for the upper
and lower halves of the 256K flash in such a way that both programs start
at logical address 0000. This is useful for applications that require a
resident download manager and a separate downloaded program. See
Application Note 218, Implementing a Serial Download Manager for a
256K Flash, for details.
4.4.7 EXTERNAL INTERRUPTS
The BL2100 is already configured to support external interrupts on pin 11
of screw terminal header J11. The external interrupt circuit is shown in
Figure.
Figure 3.9 Use of Rabbit 2000 External Interrupt
In addition to its primary use as an external interrupt, pin 11 of screw
terminal header J11 may also be used as a CMOS-level digital input or
output, or to generate a PWM signal.
4.5 BL2100 PINOUTS
The BL2100 pinouts are shown in Figure 3.10
Figure 3.10 BL2100 Pinouts
4.6 SOFTWARE
The BL2100 is programmed using version 7.06 or later of Z-World's
Dynamic C Premier, an integrated development environment that includes
an editor, a C compiler, and a debugger. Library functions provide an
easy-to-use interface for the BL2100. Software drivers for TCP/IP, I/O,
and serial communication are included with Dynamic C Premier.
4.7 DISPLAY UNIT
Plastic enclosure (can be wall-mounted or panel-mounted) with
LCD/keypad module that comprises a 122 × 32 LCD graphic
display, 7-key keypad, and seven LEDs. The plastic enclosure
consists of a base and a cover for an assembly made up of the
BL2100 with the LCD/keypad module plugged in.
Plastic enclosure base.
LCD/keypad module.
4.8 BL2100 FUNCTION APIS
4.8.1 Board Initialization
void brdInit (void);
Call this function at the beginning of your program. This function
initializes the system I/O ports and loads all the A/D converter and D/A
converter calibration constants from flash memory into SRAM for use by
your program. If the LCD/keypad module is installed, this function will
turn off LED DS1 to indicate that the initialization was successful.
4.8.2 Digital I/O
void digOutConfig(unsigned int outputMode);
Each of the BL2100 high-current outputs (OUT00-OUT15) has the
capability of being configured in software as either sinking or sourcing
using the digOutConfig function. Execute digOutConfig at the start of
your application to initially set OUT00-OUT15 to be OFF for the type of
circuit that you have, either sinking or sourcing.
NOTE The brdInit function must be executed before calling digOutConfig.
NOTE
You must execute the digOutConfig function to set the high-current
drivers to be either sinking or sourcing. A runtime error will occur in
digOut if digOutConfig has not executed.
NOTE
The extra digital outputs resulting from the reconfiguration of IN16-IN23
as digital outputs are sinking outputs only and cannot be configured with
digOutConfig.
PARAMETER
outputMode is a 16-bit parameter where each bit corresponds to one of the
following high current outputs.
Bit 15 = high-current output channel OUT15
Bit 14 = high-current output channel OUT14
Bit 13 = high-current output channel OUT13
Bit 12 = high-current output channel OUT12
Bit 11 = high-current output channel OUT11
Bit 10 = high-current output channel OUT10
Bit 9 = high-current output channel OUT09
Bit 8 = high-current output channel OUT08
Bit 7 = high-current output channel OUT07
Bit 6 = high-current output channel OUT06
Bit 5 = high-current output channel OUT05
Bit 4 = high-current output channel OUT04
Bit 3 = high-current output channel OUT03
Bit 2 = high-current output channel OUT02
Bit 1 = high-current output channel OUT01
Bit 0 = high-current output channel OUT00
The high-current outputs can be configured to be sinking or sourcing
outputs by setting the corresponding bit to an 0 or 1: 0 = sinking, 1 =
sourcing.
RETURN VALUE
None.
outputMode = 0x0ff1; // Outputs OUT15-OUT12 =
Sinking
// Outputs OUT11-OUT08 =
Sourcing
// Outputs OUT07-OUT04 =
Sourcing
// Outputs OUT03-OUT01 =
Sinking
// Output OUT00 = Sourcing
int digIn(int channel);
Reads the state of an input channel.
A run-time error will occur for the following conditions:
1. channel out of range.
2. brdInit was not executed before executing digIn.
PARAMETER
channel is the input channel number (0-23)
RETURN VALUE
The state of the input (0 or 1).
4.8.3 Serial Communication
Library files included with Dynamic C provide a full range of serial
communications support. The RS232.LIB library provides a set of circular-buffer-
based serial functions. The PACKET.LIB library provides packet-based serial
functions where packets can be delimited by the 9th bit, by transmission gaps, or
with user-defined special characters.
int serMode(int mode);
User interface to set up BL2100 serial communication lines. Call this
function after serXOpen().
PARAMETER
mode is the defined serial port configuration.
ModeSerial Port
B C D
0 RS-232, 3-wire RS-232, 3-wire RS-485
1 RS-232, 5-wire CTS/RTS RS-485
RETURN VALUE
0 if valid mode, 1 if not.
4.8.4 A/D Converter Inputs
int anaIn(unsigned int channel);
Reads the state of an A/D converter input channel.
PARAMETER
channel is the A/D converter input channel (0-10) to read.
RETURN VALUE
A value corresponding to the voltage on the analog input channel ( 0-
4095).
float anaInVolts(unsigned int channel);
Reads the state of an A/D converter input channel and uses the previously
set calibration constants to convert it to volts.
4.8.5 D/A Converter Outputs
void anaOut(unsigned int channel, unsigned int rawcount);
Sets the voltage of a D/A converter output channel.
PARAMETERS
channel is the D/A converter output channel (0-3).
rawcount is a data value corresponding to the voltage desired on the output
channel (0-4095).
RETURN VALUE
0 if sucessful.
-1 if rawcount is more than 4095.
4.8.6 LCD/Keypad Module Function APIs
LEDs
When power is applied to the LCD/keypad module for the first time, the
red LED (DS1) will come on, indicating that power is being applied to the
LCD/keypad module. The red LED is turned off when the brdInit function
executes.
One function is available to control the LEDs, and can be found in the
BL21XX.LIB library.
void ledOut(int led, int value);
LED on/off control. This function will only work when the LCD/keypad
module is installed on the BL2100.
PARAMETERS
led is the LED to control.
0 = LED DS1
1 = LED DS2
2 = LED DS3
3 = LED DS4
4 = LED DS5
5 = LED DS6
6 = LED DS7
value is the value used to control whether the LED is on or off (0 or 1).
0 = off
1 = on
RETURN VALUE
None.
4.8.7 LCD Display
The functions used to control the LCD display are contained in the
GRAPHIC.LIB library located in the Dynamic C DISPLAYS/GRAPHIC
library directory.
void glInit(void);
Initializes the display devices, clears the screen.
RETURN VALUE
None.
void glBackLight(int onOff);
Sets the intensity of the backlight, if circuitry is installed.
PARAMETER
: onOff reflects the low to high values (typically 0 to 255, depending on
the board design) to set the backlight intensity (0 will turn the backlight
off completely.)
RETURN VALUE
None.
void glDispOnOff(int onOff);
Sets the LCD screen on or off. Data will not be cleared from the screen.
PARAMETER
onOff turns the LCD screen on or off
1--turn the LCD screen on
0--turn the LCD screen off
RETURN VALUE
None.
void glXFontInit(fontInfo *pInfo, char pixWidth, char pixHeight,
unsigned startChar, unsigned endChar, unsigned long xmemBuffer);
Initializes the font descriptor structure, where the font is stored in xmem.
Each font character's bitmap is column major and byte-aligned.
PARAMETERS
*pInfo is a pointer to the font descriptor to be initialized.
pixWidth is the width (in pixels) of each font item.
pixHeight is the height (in pixels) of each font item.
startChar is the value of the first printable character in the font character
set.
endChar is the value of the last printable character in the font character set.
xmemBuffer is the xmem pointer to a linear array of font bitmaps.
RETURN VALUE
None.
4.8.8 Printing the string
void glPrintf(int x, int y, fontInfo *pInfo, char *fmt, ...);
Prints a formatted string (much like printf) on the LCD screen. Only the
character codes that exist in the font set are printed, all others are skipped.
For example, '\b', '\t', '\n' and '\r' (ASCII backspace, tab, new line, and
carriage return, respectively) will be printed if they exist in the font set,
but will not have any effect as control characters. Any portion of the
bitmap character that is outside the LCD display area will be clipped.
PARAMETERS
x is the x coordinate (column) of the upper left corner of the text.
y is the y coordinate (row) of the upper left corner of the text.
*pInfo is a font descriptor pointer.
*fmt is a formatted string.
... are formatted string conversion parameter(s).
EXAMPLE
glprintf(0,0, &fi12x16, "Test %d\n", count);
RETURN VALUE
None.
4.8.9 Keypad
The functions used to control the keypad are
contained in the KEYPAD.LIB library located in the
Dynamic C KEYPAD library directory.
void keyInit(void);
Initializes keypad process
RETURN VALUE
None.
void keyProcess(void);
Scans and processes keypad data for key assignment, debouncing, press
and release, and repeat.
NOTE This function is also able to process an 8 × 8 matrix keypad.
RETURN VALUE
None
char keyGet(void);
Get next keypress
RETURN VALUE
The next keypress, or 0 if none
int keyUnget(char cKey);
Push keypress on top of input queue
PARAMETER
cKey
RETURN VALUE
None.
void keypadDef();
Configures the physical layout of the keypad with the desired ASCII
return key codes.
Keypad physical mapping 1 × 7
0 4 1 5 2 6 3
['L'] ['U'] ['D'] ['R']
['-'] ['+'] ['E']
where
'E' represents the ENTER key
'+' represents
'-' represents
'D' represents Down Scroll
'U' represents Up Scroll
'R' represents Right Scroll
'L' represents Left Scroll
Example: Do the following for the above physical vs. ASCII return key
codes.
keyConfig ( 3,'R',0, 0, 0, 0, 0 );
keyConfig ( 6,'E',0, 0, 0, 0, 0 );
keyConfig ( 2,'D',0, 0, 0, 0, 0 );
keyConfig ( 4,'-',0, 0, 0, 0, 0 );
keyConfig ( 1,'U',0, 0, 0, 0, 0 );
keyConfig ( 5,'+',0, 0, 0, 0, 0 );
keyConfig ( 0,'L',0, 0, 0, 0, 0 );
Characters are returned upon keypress with no repeat.
RETURN VALUE
None.
CHAPTER 5
RABBIT 2000 MICROPROCESSOR
5.1 INTRODUCTION
Rabbit Semiconductor was formed expressly to design a a better
microprocessor for use in small and medium-scale controllers. The first
product is the Rabbit 2000 microprocessor. The Rabbit 2000 designers
have had years of experience using Z80, Z180 and HD64180
microprocessors in small controllers. The Rabbit shares a similar
architecture and a high degree of compatibility with these
microprocessors, but it is a vast improvement.
The Rabbit has been designed in close cooperation with Z-World, Inc., a
long-time manufacturer of low-cost single-board computers. Z-World's
products are supported by an innovative C-language development system
(Dynamic C). Z-World is providing the software development tools for the
Rabbit.
The Rabbit is easy to use. Hardware and software interfaces are as
uncluttered and are as foolproof as possible. The Rabbit has outstanding
computation speed for a microprocessor with an 8-bit bus. This is because
the Z80-derived instruction set is very compact and the design of the
memory interface allows maximum utilization of the memory bandwidth.
The Rabbit races through instructions.
Traditional microprocessor hardware and software development is
simplified for Rabbit users. In-circuit emulators are not needed and will
not be missed by the Rabbit developer. Software development is
accomplished by connecting a simple interface cable from a PC serial port
to the Rabbit-based target system.
5.2 FEATURES AND SPECIFICATIONS
100-pin PQFP package. Operating voltage 2.7 V to 5 V. Clock
speed to 30 MHz. All specifications are given for both industrial
and commercial temperature and voltage ranges. Rabbit
microprocessors cost under $10 in moderate quantities.
Industrial specifications are for a voltage variation of 10% and a
temperature range from -40°C to +85°C. Commercial
specifications are for a voltage variation of 5% and a temperature
range from 0°C to 70°C.
1-megabyte code space allows C programs with up to 50,000+
lines of code. The extended Z80-style instruction set is C-friendly,
with short and fast instructions for most common C operations.
Four levels of interrupt priority make a fast interrupt response
practical for critical applications. The maximum time to the first
Instruction of an interrupt routine is about 1 µs at a clock speed of
25 MHz.
Access to I/O devices is accomplished by using memory access
instructions with an I/O prefix. Access to I/O devices is thus faster
and easier compared to processors with a restricted I/O instruction
set.
The hardware design rules are simple. Up to six static memory
chips (such as RAM and flash EPROM) connect directly to the
microprocessor with no glue logic. Even larger amounts of
memory can be handled by using parallel I/O lines as high-order
address lines. The Rabbit runs with no wait states at 24 MHz with
a memory having an access time of 70 ns. There are two clocks per
memory access. Most I/O devices may be connected without glue
logic.
The memory cycle is two clocks long. A clean memory and I/O
cycle completely avoid the possibility of tri-state fights. Peripheral
I/O devices can usually be interfaced in a glueless fashion using
pins programmable as I/O chip selects, I/O read strobes or I/O
write strobe pins. A built-in clock doubler allows ½-frequency
crystals to be used to reduce radiated emissions.
The Rabbit may be cold-booted via a serial port or the parallel
access slave port. This means that flash program memory may be
soldered in unprogrammed, and can be reprogrammed at any time
without any assumption of an existing program or BIOS. A Rabbit
that is slaved to a master processor can operate entirely with
volatile RAM, depending on the master for a cold program boot.
There are 40 parallel I/O lines (shared with serial ports). Some I/O
lines are timer synchronized, which permits precisely timed edges
and pulses to be generated under combined hardware and software
control.
There are four serial ports. All four serial ports can operate
asynchronously in a variety of customary operating modes; two of
the ports can also be operated synchronously to interface with
serial I/O devices. The baud rates can be very high--1/32 the clock
speed for asynchronous operation, and 1/6 the clock speed
externally or 1/4 the clock speed internally in synchronous mode.
In asynchronous mode, the Rabbit, like the Z180, supports sending
flagged bytes to mark the start of a message frame. The flagged
bytes have 9 data bits rather than 8 data bits; the extra bit is located
after the first 8 bits, where the stop bit is normally located, and
marks the start of a message frame.
A slave port allows the Rabbit to be used as an intelligent
peripheral device slaved to a master processor. The 8-bit slave port
has six 8-bit registers, 3 for each direction of communication.
Independent strobes and interrupts are used to control the slave
port in both directions. Only a Rabbit and a RAM chip are needed
to construct a complete slave system if the clock and reset are
shared with the master processor
The built-in battery-backable time/date clock uses an external
32.768 kHz crystal. The time/date clock can also be used to
provide periodic interrupts every 488 µs. Typical battery current
consumption is 25 µA with the suggested battery circuit. An
alternative circuit provides means for substantially reducing this
current.
Numerous timers and counters (six all together) can be used to
generate interrupts, baud rate clocks, and timing for pulse
generation.
The built-in main clock oscillator uses an external crystal or more
usually a ceramic resonator. Typical resonator frequencies are in
the range of 1.8 MHz to 29.5 MHz. Since precision timing is
available from the separate 32.768 kHz oscillator, a low-cost
ceramic resonator with ½ percent error is generally satisfactory.
The clock can be doubled or divided by 8 to modify speed and
power dynamically. The I/O clock, which clocks the serial ports, is
divided separately so as not to affect baud rates and timers when
the processor clock is divided or multiplied. For ultra low power
operation, the processor clock can be driven from the separate
32.768 kHz oscillator and the main oscillator can be powered
down. This allows the processor to operate at approximately 100
µA and still execute instructions at the rate of approximately
10,000 instructions per second. This is a powerful alternative to
sleep modes of operation used by other processors. The current is
approximately 65 mA at 25 MHz and 5 V. The current is
proportional to voltage and clock speed--at 3.3 V and 7.68 MHz
the current would be 13 mA, and at 1 MHz the current is reduced
to less than 2 mA. Flash memory with automatic power down
(from AMD) should be used for operation at the lowest power.
The excellent floating-point performance is due to a tightly coded
library and powerful processing capability. For example, a 25 MHz
clock takes 14 µs for a floating add, 13 µs for a multiply, and 40 µs
for a square root. In comparison, a 386EX processor running with
an 8-bit bus at 25 MHz and using Borland C is about 10 times
slower.
There is a built-in watchdog timer.
The standard 10-pin programming port eliminates the need for in-
circuit emulators. A very simple 10 pin connector can be used to
download and debug software using Z-World's Dynamic C and a
simple connection to a PC serial port. The incremental cost of the
programming port is extremely small.
Figure 1-1 shows a block diagram of the Rabbit.
Figure 5-1. Block Diagram of the Rabbit Microprocessor
5.3 SUMMARY OF RABBIT ADVANTAGES
The glueless architecture makes it is easy to design the hardware
system.
There are a lot of serial ports and they can communicate very fast.
Precision pulse and edge generation is a standard feature.
Interrupts can have multiple priorities.
Processor speed and power consumption are under program
control.
The ultra low power mode can perform computations and execute
logical tests since the processor continues to execute, albeit at 32
kHz.
The Rabbit may be used to create an intelligent peripheral or a
slave processor. For example, protocol stacks can be off loaded to
a Rabbit slave. The master can be any processor.
The Rabbit can be cold booted so unprogrammed flash memory
can be soldered in place.
You can write serious software, be it 1,000 or 50,000 lines of C
code. The tools are there and they are low in cost.
If you know the Z80 or Z180, you know most of the Rabbit.
A simple 10-pin programming interface replaces in-circuit
emulators and PROM programmers.
The battery backable time/date clock is included.
The standard Rabbit chip is made to industrial temperature and
voltage specifications.
CHAPTER 6
DYNAMIC – C
6.1 INTRODUCTION TO DYNAMIC C
Dynamic C is an integrated development system for writing embedded
software. It is designed for use with Z-World controllers and other
controllers based on the Rabbit microprocessor. The Rabbit 2000 and the
Rabbit 3000 are high-performance 8-bit microprocessors that can handle C
language applications of approximately 50,000 C+ statements or 1 MB.
6.2 THE NATURE OF DYNAMIC C
Dynamic C integrates the following development functions:
Editing
Compiling
Linking
Loading
Debugging
into one program. In fact, compiling, linking and loading are one function.
Dynamic C has an easy-to-use built-in text editor. Programs can be
executed and debugged interactively at the source-code or machine-code
level. Pull-down menus and keyboard shortcuts for most commands make
Dynamic C easy to use.
Dynamic C also supports assembly language programming. It is not
necessary to leave C or the development system to write assembly
language code. C and assembly language may be mixed together.
Debugging under Dynamic C includes the ability to use printf
commands, watch expressions, breakpoints and other advanced debugging
features. Watch expressions can be used to compute C expressions
involving the target's program variables or functions. Watch expressions
can be evaluated while stopped at a breakpoint or while the target is
running its program.
Dynamic C provides extensions to the C language (such as shared and
protected variables, costatements and cofunctions) that support real-world
embedded system development. Dynamic C supports cooperative and
preemptive multi-tasking.
Dynamic C comes with many function libraries, all in source code. These
libraries support real-time programming, machine level I/O, and provide
standard string and math functions.
Speed
Dynamic C compiles directly to memory. Functions and libraries are
compiled and linked and downloaded on-the-fly. On a fast PC, Dynamic C
might load 30,000 bytes of code in 5 seconds at a baud rate of 115,200
bps.
6.3 DYNAMIC C ENHANCEMENTS AND DIFFERENCES
Dynamic C differs from a traditional C programming system running on a
PC or under UNIX. The reason? To be better help customers write the
most reliable embedded control software possible. It is not possible to use
standard C in an embedded environment without making adaptations.
Standard C makes many assumptions that do not apply to embedded
systems. For example, standard C implicitly assumes that an operating
system is present and that a program starts with a clean slate, whereas
embedded systems may have battery-backed memory and may retain data
through power cycles. Z-World has extended the C language in a number
of areas.
DYNAMIC C ENHANCEMENTS
Many enhancements have been added to Dynamic C. Some of these are
listed below.
Function chaining, a concept unique to Dynamic C, allows special
segments of code to be embedded within one or more functions.
When a named function chain executes, all the segments belonging
to that chain execute. Function chains allow software to perform
initialization, data recovery, or other kinds of tasks on request.
Costatements allow concurrent parallel processes to be simulated
in a single program.
Cofunctions allow cooperative processes to be simulated in a
single program.
Slice statements allow preemptive processes in a single program.
The interrupt keyword in Dynamic C allows the programmer to
write interrupt service routines in C.
Dynamic C supports embedded assembly code and stand-alone
assembly code.
Dynamic C has shared and protected keywords that help protect
data shared between different contexts or stored in battery-backed
memory.
Dynamic C has a set of features that allow the programmer to
make fullest use of extended memory. Dynamic C supports the 1
MB address space of the microprocessor. The address space is
segmented by a memory management unit (MMU). Normally,
Dynamic C takes care of memory management, but there are
instances where the programmer will want to take control of it.
Dynamic C has keywords and directives to help put code and data
in the proper place. The keyword root selects root memory
(addresses within the 64 KB physical address space). The keyword
xmem selects extended memory, which means anywhere in the
1024 KB or 1 MB code space. root and xmem are semantically
meaningful in function prototypes and more efficient code is
generated when they are used. Their use must match between the
prototype and the function definition. The directive #memmap
allows further control.
DYNAMIC C DIFFERENCES
The main differences in Dynamic C are summarized here and discussed in
detail in chapters Language and Keywords.
If a variable is explicitly initialized in a declaration (e.g., int x
= 0;), it is stored in Flash Memory (EEPROM) and cannot be
changed by an assignment statement. Starting with Dynamic C 7.x
such declaration will generate a warning that may be suppressed
using the const keyword: const int x = 0; To initialize
static variables in Static RAM (SRAM) use #GLOBAL_INIT
sections. Note that other C compilers will automatically initialize
all static variables to zero that are not explicitly initialized before
entering the main function. Dynamic C programs do not do this
because in an embedded system you may wish to preserve the data
in battery-backed RAM on reset
The default storage class is static, not auto. This avoids
numerous bugs encountered in embedded systems due to the use of
auto variables. Starting with Dynamic C 7.x, the default class can
changed to auto by the compiler directive #class auto.
The numerous include files found in typical C programs are not
used because Dynamic C has a library system that automatically
provides function prototypes and similar header information to the
compiler before the user's program is compiled. This is done via
the #use directive. This is an important topic for users who are
writing their own libraries. Those users should refer to the
Modules section of the language chapter. It is important to note
that the #use directive is a replacement for the #include
directive, and the #include directive is not supported.
When declaring pointers to functions, arguments should not be
used in the declaration. Arguments may be used when calling
functions indirectly via pointer, but the compiler will not check the
argument list in the call for correctness.
Bit fields are not supported.
Separate compilation of different parts of the program is not
supported or needed.
There are minor differences involving extern and register
keywords.
6.4 FUNCTIONS USED IN DYNAMIC C
int DelayMs(long delayms);
Description:
Millisecond time mechanism for the co statement "wait for" constructs. The
initial call to this function starts the timing. The function returns zero and
6.4.1 DelayMs:
continues to return zero until the number of milliseconds specified has
passed.
Parameters :
delayms
The number of milliseconds to wait.
Return value
1: The specified number of milliseconds has elapsed.
0: The specified number of milliseconds has not elapsed.
Library:
COSTATE.LIB
6.4.2. DelaySec:
int DelaySec(long delaysec);
Description: Second time mechanism for the co statement "wait for"
constructs. The initial call to this function starts the timing. The function
returns zero and continues to return zero until the number of seconds
specified has passed.
Parameters:
delaysec
The number of seconds to wait.
Return value
1: The specified number of seconds has elapsed.
0: The specified number of seconds has not elapsed.
Library
COSTATE.LIB
6.4.3 log
float log(float x);
Description
Computes the logarithm, base e, of real float value x.
Parameters:
x Float value .
Return value
The function returns -INF and signals a domain error when x = 0.
Library
MATH.LIB
6.4.4 read_rtc:
unsigned long read_rtc(void);
Description : Reads seconds (32 bits) directly from the Real-time Clock
(RTC). Use with caution! In most cases use long variable SEC_TIMER,
which contains the same result, unless the RTC has been changed since the
start of the program.
If you are running the processor off the 32 kHz crystal and using a
Dynamic C version prior to 7.30, use read_rtc_32kHz() instead of
read_rtc(). Starting with DC 7.30, read_rtc_32kHz() is deprecated
because it is no longer necessary. Programmers should only use
read_rtc().
Return value
Time in seconds since January 1, 1980 (if RTC set correctly).
Library
RTCLOCK.LIB
6.4.5 COSTATE:
Indicates the beginning of a costatement.
Costate [ name [ state ] ]
{
……
}
Name can be absent. If name is present, state can be always on or init_on. If
state is absent, the co statement is initially off.
Void
To multitask using Dynamic C language extensions, most application
programs will have some flavor of this simple structure:
main()
{ inti;
while(1)
{
// endless loop for multitasking framework
costate
{
// task 1 . . .
//
body of costatement
}
costate
{
// task 2 ...
// body of costatement
}
}
}
6.4.6 CONTROL STATEMENTS
Wait for (expression);
The keyword wait for indicates a special wait for statement and not a
function call. The expression is computed each time wait for is executed. If
true (non-zero), execution proceeds to the next statement, otherwise a jump is
made to the closing brace of the co statement or co function, with the
statement pointer continuing to point to the wait for statement. Any valid C
function that returns a value can be used in a wait for statement.
Yield
The yield statement makes an unconditional exit from a co statement or a co
function. Execution continues at the statement following yield the next time
the co statement or co function is encountered.
abort
The abort statement causes the co statement or co function to terminate
execution. If a co statement is always on, the next time the program reaches
it, it will restart from the top. If the co statement is not always on, it becomes
inactive and will not execute again until turned on by some other software.
A co statement can have as many C statements, including abort, yield, and
wait for statements, as needed. Co statements can be nested.
Code Placement in Memory
Code runs just as quickly in extended memory as it does in root memory, but
calls to and returns from the functions in extended memory take a few extra
machine cycles. Code placement in memory can be changed by the keywords
xmem and root, depending on the type of code:
Pure Assembly Routines
Pure assembly functions may be placed in root memory or extended memory.
Prior to Dynamic C v 7.10 pure assembly routines had to be in root memory.
C Functions
C functions may be placed in root memory or extended memory. Access to
variables in C statements is not affected by the placement of the function.
Dynamic C will automatically place C functions in extended memory as root
memory fills. Short, frequently used functions may be declared with the root
keyword to force Dynamic C to load them in root memory.
Using SRAM
The flash file system can be used with battery-backed SRAM. Internally,
RAM is treated like a flash device, except that there is no write-cycle
limitation, and access is much faster. The file system will work without the
battery backup, but would, of course, lose all data when the power went off.
Currently, the maximum size file system supported in RAM is about 200k.
This limitation holds true even on boards with a 512k RAM chip. The
limitation involves the placement of BIOS control blocks in the upper part of
the lower 256k portion of RAM.
To obtain more RAM memory, xalloc () may be used. If xalloc () is called
first thing in the program, the same memory addresses will always be
returned. This can be used to store non-volatile data is so desired (if the
RAM is battery-backed), however, it is not possible to manage this area using
the file system.
When using FS1, since only one device type is allowed at a time, the entire
file system would have to be in SRAM. This is recommended for debugging
purposes only. Using FS2 increases flexibility, with its capacity to use
multiple device types simultaneously. Since RAM is usually a scarce resource,
it can be used together with flash memory devices to obtain the best balance
of speed, performance and capacity.
The basic program to calculate the slurry density.
#class auto
fontInfo fi8x10;
void main()
{
struct tm rtc;
auto float ip,a[500],sum,avg,Ep,Wp,num,denom,val,den,dw;
int i;
brdInit();
glInit();
dispInit();
glBackLight(1);
glXFontInit(&fi8x10,8,10,32,127,Font8x10);
digOutConfig(0xffff);
avg=0.0;
sum=0.0;
//empty=4.5003;
//water=3.504;
dw=1.0;
Ep=log(4.503);
Wp=log(3.504);
//den=num*dw/denom;
denom=Ep-Wp;
for(i=0;i<=499;i++)
{
a[i]=0;
}
while(1)
{
for(i=0;i<=499;i++)
{
a[i]=anaInVolts(8);
sum=sum+a[i];
}
avg=sum/500;
val=log(avg);
num=Ep-val;
den=num*dw/denom;
tm_rd(&rtc);
glPrintf(30,0,&fi8x10,"%02d:%02d:
%02d",rtc.tm_hour,rtc.tm_min,rtc.tm_sec);
glPrintf(0,13,&fi8x10,"I/P=%.4f",avg);
glPrintf(0,23,&fi8x10,"DEN=%.4fg/cc",den);
if(den<1.2)
{
ledOut(0,1);
ledOut(2,0);
ledOut(3,0);
ledOut(4,0);
ledOut(6,0);
digOut(8,0);
digOut(9,1);
}
if((den>=1.2)&&(den<=1.8))
{
ledOut(0,0);
ledOut(2,1);
ledOut(3,1);
ledOut(4,1);
ledOut(6,0);
digOut(8,0);
digOut(9,0);
}
if(den>1.8)
{
ledOut(0,0);
ledOut(2,0);
ledOut(3,0);
ledOut(4,0);
ledOut(6,1);
digOut(8,1);
digOut(9,0);
}
avg=0.0;
sum=0.0;
num=0.0;
val=0.0;
den=0.0;
}
}
OUT PUT:
The output of the above program will be displayed on the LCD keypad. The
varying density of the slurry is continuously displayed on the screen for the
corresponding change in voltage.
CHAPTER 8
CONTRIBUTION
Participated in Developmental work of sub units i.e. EHT,
Pre-Amplifier, Power supply.
And also participated in the software development of BL
2100 Micro controller working on Rabbit 2000 Microprocessor.
Program is executed and density is measured between
1.5 to 1.9gm/cc and corresponding led is glowing.
CHAPTER 9
FUTURE SCOPE
A database can be developed from the data available through serial port
communication.
The database stores the values of density at any given instant of time .
This database can be used to generate graphs on weekly, monthly or
yearly basis.
CHAPTER 10
CONCLUSION
The hardware of “Radiometric Density Gauge” is studied and the
software is generated using Dynamic C.
The programs for calculation of density and transmission of data on serial
port are generated. The testing is performed using the BL2100 micro controller to check
the reliability of the program.
It is concluded thus, that the program is reliable and accurate. It can be
used in real time applications.
CHAPTER 11
REFERENCES
Dynamic C user's manual.
BL2100 user's manual.
Rabbit 2000 user’s manual.
Let Us C Yashwant kanethkar.