0% found this document useful (0 votes)
170 views21 pages

Batch Weighing Machine

The document describes a microprocessor-based batch weighing system that uses three load cells and an ADC to measure weight. It provides system details like memory organization, I/O organization, components used, and a flow chart of the algorithm. The system displays the total weight on a seven segment display and sounds an alarm if the weight exceeds 99kg.

Uploaded by

Priyansh Mehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views21 pages

Batch Weighing Machine

The document describes a microprocessor-based batch weighing system that uses three load cells and an ADC to measure weight. It provides system details like memory organization, I/O organization, components used, and a flow chart of the algorithm. The system displays the total weight on a seven segment display and sounds an alarm if the weight exceeds 99kg.

Uploaded by

Priyansh Mehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Batch No: 57

Microprocessor Programming and


Interfacing
Design assignment

Batch Weighing System

by

Shravan Kumar V 2003A7PS205


Pinakini G 2003A7PS207
Ekta Mittal 2003A7PS208
Uday Kiran Medisetty 2003A7PS212

An assignment submitted in
partial fulfilment of the requirement of the course
ES C263: MICROPROCESSOR PROGRAMMING AND
INTERFACING

BIRLA INSTITUTE OF TECHNOLOGY AND


SCIENCE
PILANI, RAJASTHAN-333031

15th April , 2005

1
Contents:

Page No.
Problem Statement 3
Assumptions 4
System Description 4
Memory Organization 8
I/O Organization 9
Flow Chart 10
Calculations 12
Limitations 14
Conclusion 14
Code 15

2
Problem Statement:

A microprocessor system is to be designed as a batch


weighing machine. The system is interfaced to three load cells
by means of an 8 bit A/D converter.

The conditioned output of the load cells is given by the


equation
V o u t = .25 x weight (Kgs)

The system monitors the output of the load cells and finds out
the total weight by taking the sum of the three values that
are sensed by each load cell. This value is displayed on a
seven-segment display. When this value exceeds 99Kg, an
output port, which is connected to a relay, is switched on to
sound an alarm. Design the necessary hardware and software
for implementing the above mentioned task.

3
Assumptions:
The following are the assumptions made regarding the
system:

Each load cell gives voltage output of the range 0-10 Volts.

If the load cells of different rating are to be used then the


voltage range is scaled down.

System Description:
The weight is sensed by the three load cells. The voltage
output of the load cells is scaled to 10 volt range if necessary.

When the start switch is pressed,


the analog voltage value is converted to its digital equivalent
by means of an A/D converter. This value is then multiplied
by the conversion factor which is dependant on the relation
between output voltage and the weight and on the scaling
factor. The calculated weight is then compared with the
limiting value of the weight which is 99 Kg. If the weight is
below this limiting value, it is displayed in the seven segment
display. If not, an alarm is sounded and the system waits for
the user to reset the system using the reset switch.

4
Basic System Layout:

Memory 8086

Load AD
Cell 570 8
2
Load AD 5
Cell 570 5
8
2
Load AD Display
5
Cell 570 8
4
2
5
ALARM
5
Power
Supply

5
The following is the list of components used in the system:

Chip
Quantity Chip Purpose
Number
Central Processing
8086 1 Microprocessor
Unit
Read Write Memory to
6116 2 RAM house Data segment
and Stack segment
Read Only Erasable
2716 2 EPROM Programmable memory
to house the code
To Select PPI (8255)
74139 1 2:4 Decoder
Decode the memory/IO
74138 1 3:8 Decoder
and read/write signals
Programmable
Provides I/O port for
8255 2 Peripheral
the other devices
Interface
Seven
Display the output
FND 507 4 Segment
values
Display
Analog to Converts the analog
AD 570 3 Digital voltage to its digital
Converter equivalent
BCD to 7- Converts a BCD value
7447 1 Segment to value required by 7
converter Segment Display
8 bit buffer
74LS245 2 bidirectional Buffering Data bus
buffers
8 bit buffer
Buffering the Control
74LS244 1 unidirectional
Lines
buffer
Latching the address
74LS373 3 8 bit latches bus

Programmable The Counter for the


8254 1
Interval Timer Alarm

Apart from the above chips, these components are also


interfaced
1. Two switches
2. One LED
3. Alarm device
4. Four PNP transistors and
5. Logic gates and resistors
6. One 8284 ( Clock Generator for 8086)
7. 1Hz Clock Generator for 8254

6
Start Switch :
When the object whose weight is to be measured has been
placed on the load cell arrangement, the user has to press
this start switch which asks the system to measure the
current weight. This switch is to be pressed whenever the
weight has to be measured.

Reset Switch:
In the case where the weight has exceeded 99 kg, the sound
alarm device is activated. It is sounded for a period of 30
secs and LED is turned on asking the user to press reset
switch. The whole system is restored and reinitialized.

Test LED:
This is used to indicate the system is currently processing the
weight. The LED glows from the time the start switch is
pressed. It is turned off when the value has been displayed.
This indicates the system is waiting for the next operation.
After the Programmable Interval Timer stops the Alarm, the
Test LED glows asking the user to press the RESET switch to
reset the whole system.

7
Memory Organization:
The system uses 4KB of RAM and 4KB of ROM. Both consist of
two chips of 2KB size each. They are organized into odd and
even bank to facilitate both byte and word size data transfers.

Random Access Memory:

Starting Address: 00000h


Ending Address: 00fffh

The data segment starts at the address of 00010h and is of


size 1KB. The stack segment starts at the address 00810h and
is of 1008 bytes.

Read Only Memory:

Starting Address: ff000h


Ending Address: fffffh

The code begins at the address ff000h.


The first address the processor sends out when it is switched
on is ffff0h. At this location, there is a jump instruction which
takes the program control to the beginning of the code.

8
I/O Organization:
Two 8255(Programmable Peripheral Interface) are used to
communicate with other input and output devices. It is
organized in the following manner.

8255(1):

Port
Port Mode Input/Output Connected to
Address
A 80h 0 Input ADC-1
B 82h 0 Input ADC-2
PC0-Test Led
PC1-Alarm
C lower 84h 0 Output
PC2-SOC1
PC3-SOC2
PC4-Reset
PC5-EOC1
C upper 84h 0 Input
PC6-EOC2
PC7-Start
Control
86h
Register

8255(2):

Port
Port Mode Input/Output Connected to
Address
A 90h 0 Input ADC-3
B 92h 0 Output 7447
PC0-SOC3
PC1-To 7 Segment
C lower 94h 0 Output Decoder(2)
PC2-Gate(8254)
PC3- --
PC4-EOC3
PC5-Out (8254)
C upper 94h 0 Input
PC6- --
PC7- --
Control
96h
Register

9
Flow Chart of the Algorithm Used:

Start

Initialize
Segments
and Devices

Is Switch
Open?

Yes

Make Test
LED Glow

Convert Analog Value to


Digital Value and store
It in memory

Multiply with the


Multiplier to
get the weight

Turn off LED

10
Yes No
Weight >99?

Display the weight


Start the on the Seven
Alarm segment display

Load Counter
in 8254
End

Is Out
pin High?

Yes

Turn on LED

Reset
No Switch Yes
Open?

11
Calculations:

Memory and Address Map:

DEVICE A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
6116
SRAM
From 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00000h
To 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
00FFFh
2716
EPROM
From 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
FF000h
To 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
FFFFFh

8255 PPI:

Here we connect the A0 and A1 of 8255 to the A1 and A2 of


the 8086 address bus respectively and also we connected the
CS(bar) of 8255 to the output of decoder 74139 for selecting
the chip. We assume that 8255(1) and 8255(2) have been
interfaced at the port addresses 80H to 86H and 90H to 96H
respectively at only even addresses.

Address lines A4 and A5 are used by the 2:4 decoder to


select the corresponding 8255 chip.

8255 (1):

A7 A6 A5 A4 A3 A2 A1 A0
Port A 80h 1 0 0 0 0 0 0 0
Port B 82h 1 0 0 0 0 0 1 0
Port C 84h 1 0 0 0 0 1 0 0
Control 86h 1 0 0 0 0 1 1 0
Register

12
8255 (2):

A7 A6 A5 A4 A3 A2 A1 A0
Port A 90h 1 0 0 1 0 0 0 0
Port B 92h 1 0 0 1 0 0 1 0
Port C 94h 1 0 0 1 0 1 0 0
Control 96h 1 0 0 1 0 1 1 0
Register

For Load Cell:


The Load Cell consists of four 350 ohm
resistors connected in a bridge configuration. A stable 10.00 V
excitation voltage is applied at the top of the bridge. With the
load on the cell, it would produce a small differential voltage
of about 2mv per volt of excitation, so with 10.00 V
excitation, the maximum differential-output voltage is 20mv.
With the help of an inverting amplifier with a
gain of 500, we can produce a output voltage of 10 V from a
input voltage of [Link] output from the amplifier is used
as the input to the analog to digital converter.

The load cell which we use can measure a maximum of 40kgs.


So, we can measure a maximum of 120kgs with the help of
three load cells. The voltage output of 10V from one load cell
correspond a weight of 40kgs.

The conversion factor or the multiplier is calculated as


follows:

Multiplier = 0.0390625 x 4 x Voltage rating of the load cell


10

Where 0.0390625 is the least voltage that can be


differentiated by the A/D converter. Under the assumptions
stated above, the multiplier value comes to be 0.157 which is
the least weight that can be measured.

Weight on Voltage Voltage Decimal


one Load output of input to ADC value of
Cell load cell output of
ADC
00kg 0mv 0v 00
20kg 10mv 5v 127
40kg 20mv 10v 255

13
Limitations:
The main limitations of the system are:

The system does not automatically check for the new


weights. Human intervention is necessary whenever a
weight is to be measured.
The system provides an accuracy of up to two decimal
digits only.
The least weight that can be measured is dependant on
the rating of the load cell. Less rated load cells enables
to measure weights more accurately.
If the load on the load cell exceeds, then the load cell
may be permanently damaged. So care should be taken
that load shouldn t exceed the maximum value.

Conclusion:
The batch weighing system has been implemented as a 8086
based system. The system has been designed in a flexible
manner.

14
Code:

;
; Batch Weighing Machine
;
;The code is situated in the location ff000h.

mov ax,0010h
mov ds,ax ;initialize data segment register

mov ax,0810h
mov ss,ax ;initialize stack segment register

mov ax,157
mov [0010h],ax ;initialize the multiplier value

restart:

mov ax,0
mov [0040h],ax
mov [0042h],ax ;initializing default values for the
;display procedure

mov al,9ah
out 86h,al ;initialize 8255(1)
mov al,98h
out 96h,al ;initialize 8255(2)

mov al,00h
out 84h,al ;initialize alarm, testing led, adc(1)
and adc(2)
mov al,00h
out 94h,al ;initialize adc(3)

trigger:
call display
mov ah,10h
in al,84h
and ah,al
jnz restart
mov ah,80h
and ah,al
jz trigger

mov al,01h
out 86h,al
;making test led to glow

15
mov al,05h
out 86h,al ;activate soc of adc(1)

mov al,07h
out 86h,al ;activate soc of adc(2)

mov al,01h
out 96h,al ;activate soc of adc(3)

mov cx,2
repe nop ;delay for 2 microsecond

mov al,04h
out 86h,al ;deactivate soc of adc(1)

mov al,06h
out 86h,al ;deactivate soc of adc(2)

mov al,00h
out 96h,al ;deactivate soc of adc(3)

;check for eoc signal from each adc

mov ah,20h
mov bx,0020h

waitforeoc1: ;check for eoc signal from adc(1)


in al,84h
and ah,al
jz waitforeoc1

in al,80h ;read port A of 8255(1)


mov [bx],al ;store the value in memory

mov ah,40h

waitforeoc2: ;check for eoc signal from adc(1)


in al,84h
and ah,al
jz waitforeoc2

in al,82h ;read port B of 8255(1)


mov [bx+1],al ;store the value in memory

mov ah,10h

waitforeoc3: ;check for eoc signal from adc(1)


in al,94h
and ah,al
jz waitforeoc3

16
in al,90h ;read port A of 8255(2)
mov [bx+2],al ;store the value in memory

;calculating weights

mov ax,[0010h] ;moving the multiplier value from


;memory
mov ch,0
mov cl,[bx] ;moving the first voltage value from
;memory
mul cx ;multiply the multiplier and the
;voltage output
mov cx,1000
div cx ;dividing by 1000 to get the weight
mov [0030h],ax
mov [0032h],dx ;moving the result back to memory

mov ax,[0010h] ;moving the multiplier value from


;memory
mov ch,0
mov cl,[bx+1] ;moving the first voltage value from
;memory
mul cx ;multiply the multiplier and the
;voltage output
mov cx,1000
div cx ;dividing by 1000 to get the weight

mov [0034h],ax
mov [0036h],dx ;moving the result back to memory

mov ax,[0010h] ;moving the multiplier value from


;memory
mov ch,0
mov cl,[bx+2] ;moving the first voltage value from
;memory
mul cx ;multiply the multiplier and the
;voltage output
mov cx,1000
div cx ;dividing by 1000 to get the weight
mov [0038h],ax
mov [0040h],dx ;moving the result back to memory

mov bx,[0030h]
add bx,[0034h]
add bx,[0038h] ;adding all the 3 quotient values

mov ax,[0032h]
add ax,[0036h]
17
add ax,[0040h] ;adding all the remainder values

mov dx,0
mov cx,1000
div cx ;dividing the remainder by 1000
add bx,ax ;adding the quotient to the overall
;quotient
;Now Overall Quotient is in bx and
;overall remainder is in dx

mov cx,bx
cmp cx,0063h ;comparing with 99
jbe calculate

mov al,00h
out 86h,al ;turning off the test led

mov al,03h
out 86h,al ;sounding the alarm using the bsr
;mode

mov al,10h
out a0h,al ;initialize timer IC

mov al,30
out a0h,al ;sending the counter

mov al,05h
out 86h,al ;sending high to the gate

counterstop:

mov ah,20h
in al,94h
and al,ah
jnz counterstop

mov al,01h
out 86h,al ;turning on the test led

waitingforreset:
in al,84h
mov ch,10h
and ch,al
jz waitingforreset
jmp restart

18
calculate:

;dx had the remainder and bx has the quotient


;extracting the digits of quotient

mov ax,bx
mov bh,0ah ;moving decimal value 10 into bh
div bh ;dividing by 10 is sufficient as the
;quotient is less than 99

;unit digit in ah & tens digit in al

mov [0040h],al ;0040h contains the tens digit


mov [0041h],ah ;0041h contains the unit digit

mov ax,dx
mov bh,0ah ;moving decimal value 10 into bh

div bh
mov ah,00h
div bh

mov [0042h],al ;moving the first decimal digit into


;memory
mov [0043h],ah ;moving the second decimal digit
;into memory

mov al,00h
out 86h,al ;turning off the test led
jmp trigger

.exit

display proc near

;starting the display process


refresh:
mov al,04h
out 96h,al

;display the first digit

mov al,[0040h] ;moving the first digit to al


add al,80h
out 92h,al ;moving the first digit into the port
;B of 8255(2) which is connected to
;7447
19
mov cx,2
repe nop ;delay for 2microsecond

;display the second digit

mov al,[0041h] ;moving the second digit to al


add al,40h
out 92h,al ;moving the first digit into the port
;B of 8255(2) which is connected to
;7447

mov cx,2
repe nop ;delay for 2microsecond

;display the first decimal digit

mov al,[0042h] ;moving the first decimal digit to al


add al,20h
out 92h,al ;moving the first digit into the port
;B of 8255(2) which is connected to
;7447

mov cx,2
repe nop ;delay for 2microsecond

;display the second decimal digit

mov al,[0043h] ;moving the first decimal digit to al


add al,10h
out 92h, al ;moving the first digit into the port
;B of 8255(2) which is connected to
;7447
mov cx,2
repe nop ;delay for 2microsecond

display endp

20
This document was created with Win2PDF available at [Link]
The unregistered version of Win2PDF is for evaluation or non-commercial use only.

You might also like