Professional Documents
Culture Documents
MICROCONTROLLER BASED
BY
CERTIFICATE
ACKNOWLEDGEMENTS
A SUCCESS.
THANK YOU VERY MUCH,
• 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
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 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
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
2.BL2100 Subsystems.
5.BL2100 Pinouts.
1. BL2100 Models
2. Serial communication configurations
3. System specifications
CHAPTER 1
INTRODUCTION
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 ‘ρ ’.
A correct installation ensures that a change of radiation at the detector is caused
by a chance of material density in the pipe.
1.4 ADVANTAGES
• Online measurement.
• Non-contact measurement.
• Measurement of large volumes of samples.
• Withstands for harsh environment.
CHAPTER 2
RADIATION
2.1 INTRODUCTION
1Ci = 37 GBq
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
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.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 :
SYSTEM DESCRIPTION
SOURCECs LEAD
137 EHT- LV
500vdc p.s
Detector Assembly
EHT
BL2100 LCD
…….
; ;;; Micro- Rabbit
…….
;;;
…….
; .;;; Signal from 2000
Controlle
.; ;;;.
……. Detector Micropro
Display
… .;;; r
…. cessor
A to D
Pre-Amplifier D to A 4 to 20mA
Ionization
chamber Block diagram of
Micro controller based
Radiometric Density gauge
SOURCE
HOLDER
3.2 DESCRIPTION
• 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.
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:
NOTE:For a 10V input ,9-10V output is expected.Unity gain amplifier inverts the
input signal.
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.
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:
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 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.]
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:
( 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.
FUNCTIONS SWITCH : One pole 4 way rotator switch to select one of the
Following:
HIGH ALARM : The DPM indicates the high alarm set point.
3.2.7 SPECIFICATIONS:
4.1 INTRODUCTION
The BL2100 is a highperformance, Cprogrammable singleboard
computer that offers builtin 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 wallmounted.
4.2 BL2100 DESCRIPTION
The BL2100 is an advanced singleboard computer that incorporates the
powerful Rabbit 2000 microprocessor, flash memory, static RAM, digital
I/O ports, A/D converter inputs, D/A converter outputs, RS232/RS485
serial ports, and a 10BaseT 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 highcurrent
digital outputs provide sinking and sourcing outputs.
• 15 analog channels: eleven 12bit A/D converter inputs, four 12bit
D/A converter 010 V outputs (selected models).
• One RJ45 Ethernet port compliant with IEEE 802.3 standard for
10BaseT Ethernet protocol (selected models).
• Two Ethernet status LEDs (selected models).
• Four serial ports (2 RS232 or 1 RS232 with RTS/CTS, 1 RS485,
and 1 CMOScompatible programming port).
• Batterybacked realtime 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
Microprocessor Rabbit 2000 running at 22.1 MHz
Static RAM 128K
Flash Memory 256K
RJ45 Ethernet Connector, Filter
Yes No
Capacitors, and LEDs
A/D Converter Inputs
Yes No Yes No
(10 V to + 10 V)
D/A Converter Outputs
Yes No Yes No
(0 V to +10 V)
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 Rabbitbased subsystems designed into the
BL2100.
4.4.1 DIGITAL I/O
DIGITAL INPUTS
The BL2100 has 24 digital inputs, IN00IN23, each of which is protected
over a range of 36 V to +36 V. The inputs are factoryconfigured 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 surfacemounted 0 Ω resistor as shown in
Figure 9.
If the inputs are pulled up to +K2, the voltage range over which
NOTE
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.
IN16IN23 can be factoryconfigured as outputs for users who prefer to
have 16 inputs and 24 outputs.
DIGITAL OUTPUTS
The BL2100 has 16 digital outputs, OUT00OUT15, 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, lowside drivers, or as an Hbridge 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.
OUT00OUT07 are powered by to +K1, and OUT08OUT15 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, screwterminal header J4, and pin 12, screwterminal 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 RS232 serial ports, which can be configured as one
RS232 serial channel (with RTS/CTS) or as two RS232 (3wire)
channels using the serMode software function call. Table 3.2 summarizes
the options.
Serial Port
Mode
B C D
The BL2100 also has one RS485 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 RS232 communication, and
Serial Port D is used for RS485 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.
RS232
The BL2100 RS232 serial communication is supported by an RS232
transceiver. This transceiver provides the voltage output, slew rate, and
input voltage immunity required to meet the RS232 serial communication
protocol. Basically, the chip translates the Rabbit 2000's CMOS/TTL
signals to RS232 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 RS232 transceiver also provides the proper line
loading for reliable communication.
RS232 can be used effectively at the BL2100's maximum baud rate for
distances of up to 15 m.
RS485
The BL2100 has one RS485 serial channel, which is connected to the
Rabbit 2000 Serial Port D through an RS485 transceiver. The halfduplex
communication uses the Rabbit 2000's PB6 pin to control the transmit
enable on the communication line.
The BL2100 can be used in an RS485 multidrop network. Connect the
485+ to 485+ and 485 to 485 using single twistedpair wires
(nonstranded, tinned) as shown in Figure. Note that a common ground is
Recommended.
The RabbitCore module on the BL2100 has a 10pin 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 startupmode 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
connectorthe 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
RJ45 jack in Figure 14) are always absolute, and the RJ45 connector will
work properly with offtheshelf Ethernet cables.
RJ45 pinouts are sometimes numbered opposite to the way shown in
Figure 14.
Two LEDs are placed next to the RJ45 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.
The factory default is for the 0 Ω resistor "jumper" at R29 to be installed.
In highnoise 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 14channel 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.
The opamp 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.
Figure shows the 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 powersupply voltage, +RAW, up to 15 V, and drops to 2 mA per
channel for a powersupply 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.
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 (010 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 opamps for the buffered A/D
converter inputs.
The 2.048 V reference voltage is also used to generate the 2.5 V reference
for DREF used in the digital output circuit.
4.4.6 MEMORY
SRAM
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 Ω
surfacemounted 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 coresident 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.
Dynamic C Premier, an integrated development environment that includes
an editor, a C compiler, and a debugger. Library functions provide an easy
touse interface for the BL2100. Software drivers for TCP/IP, I/O, and
serial communication are included with Dynamic C Premier.
4.7 DISPLAY UNIT
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);
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);
capability of being configured in software as either sinking or sourcing
your application to initially set OUT00OUT15 to be OFF for the type of
circuit that you have, either sinking or sourcing.
outputMode is a 16bit parameter where each bit corresponds to one of the
following high current outputs.
Bit 15 = highcurrent output channel OUT15
Bit 14 = highcurrent output channel OUT14
Bit 13 = highcurrent output channel OUT13
Bit 12 = highcurrent output channel OUT12
Bit 11 = highcurrent output channel OUT11
Bit 10 = highcurrent output channel OUT10
Bit 9 = highcurrent output channel OUT09
Bit 8 = highcurrent output channel OUT08
Bit 7 = highcurrent output channel OUT07
Bit 6 = highcurrent output channel OUT06
Bit 5 = highcurrent output channel OUT05
Bit 4 = highcurrent output channel OUT04
Bit 3 = highcurrent output channel OUT03
Bit 2 = highcurrent output channel OUT02
Bit 1 = highcurrent output channel OUT01
Bit 0 = highcurrent output channel OUT00
The highcurrent 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 OUT15OUT12 =
Sinking
// Outputs OUT11OUT08 =
Sourcing
// Outputs OUT07OUT04 =
Sourcing
// Outputs OUT03OUT01 =
Sinking
// Output OUT00 = Sourcing
int digIn(int channel);
Reads the state of an input channel.
A runtime 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 (023)
RETURN VALUE
The state of the input (0 or 1).
4.8.3 Serial Communication
communications support. The RS232.LIB library provides a set of circularbuffer
with userdefined 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.
Serial Port
Mode
B C D
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 (010) 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 (03).
rawcount is a data value corresponding to the voltage desired on the output
channel (04095).
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
1turn the LCD screen on
0turn 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 bytealigned.
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.
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.
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
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
5.1 INTRODUCTION
microprocessor for use in small and mediumscale controllers. The first
product is the Rabbit 2000 microprocessor. The Rabbit 2000 designers
microprocessors, but it is a vast improvement.
The Rabbit has been designed in close cooperation with ZWorld, Inc., a
products are supported by an innovative Clanguage development system
(Dynamic C). ZWorld 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 8bit bus. This is because
the Z80derived instruction set is very compact and the design of the
memory interface allows maximum utilization of the memory bandwidth.
The Rabbit races through instructions.
simplified for Rabbit users. Incircuit emulators are not needed and will
accomplished by connecting a simple interface cable from a PC serial port
to the Rabbitbased target system.
5.2 FEATURES AND SPECIFICATIONS
• 100pin 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.
• 1megabyte code space allows C programs with up to 50,000+
lines of code. The extended Z80style instruction set is Cfriendly,
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 highorder
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 tristate 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 builtin clock doubler allows ½frequency
crystals to be used to reduce radiated emissions.
• The Rabbit may be coldbooted 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 high1/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 8bit slave port
has six 8bit 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 builtin batterybackable 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 builtin 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 lowcost
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 speedat 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 floatingpoint 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 8bit bus at 25 MHz and using Borland C is about 10 times
slower.
• There is a builtin watchdog timer.
• The standard 10pin programming port eliminates the need for in
circuit emulators. A very simple 10 pin connector can be used to
download and debug software using ZWorld's Dynamic C and a
simple connection to a PC serial port. The incremental cost of the
programming port is extremely small.
Figure 11 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 10pin programming interface replaces incircuit
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
controllers based on the Rabbit microprocessor. The Rabbit 2000 and the
Rabbit 3000 are highperformance 8bit 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.
executed and debugged interactively at the sourcecode or machinecode
level. Pulldown menus and keyboard shortcuts for most commands make
Dynamic C easy to use.
language code. C and assembly language may be mixed together.
commands, watch expressions, breakpoints and other advanced debugging
involving the target's program variables or functions. Watch expressions
running its program.
Dynamic C provides extensions to the C language (such as shared and
protected variables, costatements and cofunctions) that support realworld
preemptive multitasking.
Dynamic C comes with many function libraries, all in source code. These
libraries support realtime programming, machine level I/O, and provide
standard string and math functions.
Speed
compiled and linked and downloaded onthefly. 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
system is present and that a program starts with a clean slate, whereas
embedded systems may have batterybacked memory and may retain data
through power cycles. ZWorld 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 standalone
assembly code.
• Dynamic C has shared and protected keywords that help protect
data shared between different contexts or stored in batterybacked
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
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
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 batterybacked 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.1 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
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);
Parameters:
delaysec
The number of seconds to wait.
Return value
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
read_rtc(). Starting with DC 7.30, read_rtc_32kHz() is deprecated
read_rtc().
Return value
Time in seconds since January 1, 1980 (if RTC set correctly).
Library
RTCLOCK.LIB
6.4.5 COSTATE:
// body of costatement
}
}
}
6.4.6 CONTROL STATEMENTS
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
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.
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
C Functions
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.
returned. This can be used to store non-volatile data is so desired (if the RAM
is batterybacked), 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
purposes only. Using FS2 increases flexibility, with its capacity to use
#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
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 .
CONCLUSION
REFERENCES