engi 4933: electro-mechanical systems term project final ...chandima/project/final report.pdf ·...
TRANSCRIPT
ENGI 4933: Electro-Mechanical Systems
Term Project Final Report
Crane Safety Systems
Chandima Perera – 200458685
Brianne Luff – 200336451
Jeremy Brown – 200540086
Xiangyu Sun – 200355584
Summary
As required by ENGI 4933 Electro-Mechanical Systems a term project of a mechantronic
nature was completed. Each group was to choose a completely arbitrary area for which the
mechantronic system could be applied. Our group, Crane Safety Systems, chose to create an
electronic safety system to be applied to today’s cranes whose booms are supported at one end
which will ensure the safe loading and operation of the cranes.
The following report gives an overview of the entire project development from the initial
project proposal to future improvements of the prototype system. As well, technical data
including system drawings and program coding will be included for review.
Based on the completion of the project objectives that were outlined within the initial
project proposal the project and system prototype are ultimately a success.
Table of Contents
Introduction .................................................................................................................................................. 1
Project Justification ....................................................................................................................................... 2
Identified Problem .................................................................................................................................... 2
Proposed Solution ..................................................................................................................................... 2
Benefits of This System ............................................................................................................................ 3
Specifications and Design ............................................................................................................................. 4
Objectives of System Design .................................................................................................................... 4
Objectives of Model Design ..................................................................................................................... 5
Prototype Design .......................................................................................................................................... 7
Overview of Prototype .............................................................................................................................. 7
Crane Load Failsafe System - Electronics ................................................................................................ 7
Crane Load Failsafe System - Programming ............................................................................................ 9
Prototype Model Crane Design ................................................................................................................. 9
Difficulties Encountered.............................................................................................................................. 11
Electrical Difficulties .............................................................................................................................. 11
Programming Difficulties ....................................................................................................................... 12
Model Construction ................................................................................................................................ 13
Future Improvements ................................................................................................................................. 14
Conclusion ................................................................................................................................................... 15
Appendix ..................................................................................................................................................... 16
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 1 of 33
Introduction
The following report is an overview of the Crane Load Failsafe System. The success of
this system involved the synergistic integration of geared DC motors, a potentiometer, a load
cell, and microcontroller technology. The cooperative interaction between these components
makes our project “mechatronic” in nature. This mechatronic quality of our Crane Load Failsafe
System is the most important aspect for the required Electromechanical Systems 4933 term
project.
The Crane Load Failsafe System is a preventive of boom failure due to unsafe crane
loadings. This system reduces human error in maximum load crane operations. A load cell
measures the weight of the loading; our system then calculates the maximum boom angle of the
crane that corresponds to that load. The system will then cause the boom to stop or limit
operation if the crane operator tries to go beyond its maximum safety position angle. This safety
position angle is a position at which the moment created by the load is not too large for the crane.
Therefore, accidents due to crane loading failure will be diminished and the safety of the crane,
its vicinity and crane operators will be at a higher level. The complete system overview is
explained in greater detail in the following report.
This report also entails specifications and design objectives of the system’s
instrumentation, programming and the physical crane prototype. The difficulties encountered
associated with all of these constituents, are discussed in great detail; this allows a basis for
discussion of future system improvements. A system justification is also outlined. This
justification summarizes the problems that the Crane Load Failsafe System solves and proves
why it will have an essential impact on crane safety.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 2 of 33
Project Justification
Identified Problem
Improper lifting techniques can lead to boom failure due to overloading if the wrong
boom angle is used. Therefore, lifting properties of certain types of modern cranes pose a safety
hazard if guidelines are not adhered to. Each individual crane has a corresponding load chart.
Each load chart describes the maximum crane loading for the various boom angle positions, and
vice versa. To find the maximum boom angle, with respect to the corresponding crane loading,
one has to consider the moment that is created by the weight of the load with respect to the
distance from the boom, or the moment arm. The maximum load decreases as the boom angle
decreases, in other words, as the crane is lowered or extended the weight of the load that the
crane is able to carry decreases. The moment created by the weight cannot be too large for the
crane or failure will occur. If the load chart guidelines are not followed or ignored the safety of
the crane is at risk and the result can be fatal.
According to the official website for reporting crane related accidents, 314 crane
accidents were reported in 2006 alone. 108 of these accidents were fatal. During the years of
1984 to 1994, studies reported 22 deaths in the US alone due to crane overloading. Therefore,
crane overloading causes a big threat to crane safety. A safe working environment should be
prioritized and that is the reason our team, Crane Safety Systems decided to create the Crane
Load Failsafe System.
Proposed Solution
To reduce the risk of safety issues posed by the overloading of today’s modern cranes we
have proposed to create a safety system that ensures the safe operation of these modern cranes.
This System, the Crane Load Failsafe System, would guarantee that the crane load chart is
followed and the guidelines provided by this chart are adhered to. This means that the moment
created by the crane load with respect to the boom angle never exceeds its maximum value and
the crane will only operate in positions where there is no threat of a safety hazard. The Crane
Load Failsafe System will restrict the boom movement or stop the crane completely when lifting
maximum loads.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 3 of 33
This restriction will guarantee that no unnecessary crane accidents arise due to excessive
loads. These crane overloading accidents could easily be prevented with a precautionary
warning, such as a limit on the boom angle with respect to the load being handled. We found that
even professional crane operators could misjudge or overestimate the weight that a crane could
lift. Therefore, extra precautions need to be implemented which is what the Crane Load Failsafe
System strives to do.
Benefits of This System
The Crane Load Failsafe System has many beneficial aspects that would have potential in
the crane safety industry. The system reduces the risk of safety hazards that an overloaded crane
generates. It also prevents crane accidents that occur due to overloading. The prevention of these
accidents would ensure the safety of the crane operators and the people in the crane operating
vicinity. Therefore, our system could possibly save lives.
This system would also reduce the risk of collateral damage. It would protect the crane
itself, therefore, benefiting the owner of the crane or the crane operating companies by saving
them money. This system would also protect assets surrounding the crane’s operational area and
avoid property damages caused by crane operating accidents.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 4 of 33
Specifications and Design
Objectives of System Design
As stated in the problem identification, the main reason for utilizing such a safety
systems is due to the added complexity of loading a crane with boom is supported at a single
point and that can vary in angle. This type of crane has varying maximum loads corresponding to
different boom angles. The reason for this characteristic is due to the increasing moment at the
pivot point as the boom is lowered. This increasing moment creates higher tension forces in the
boom line and greater moment forces that the boom and crane base will have to resist. Typically
in this type of crane the maximum load for corresponding boom angles will decrease as the boom
is lowered. To know the maximum load for corresponding boom angles crane operators will
follow a load chart specific to each type of crane such as the load chart below. The graph
represents load vs. boom angle and displays two distinct load lines, red for the main line and blue
for the auxiliary line.
To implement a system that would ensure the safe loading of the crane according to a
load chart it was decided that our system should either inhibit certain operations of the crane that
would in effect overload the crane or at least give some sort of warning. Certain scenarios could
occur in which the overloading of the crane would be possible. First would be the attempt to lift
a load from the surface that exceeded the maximum load at that boom angle. The second
scenario would occur if a crane had already lifted a load that was under the maximum load for
that boom angle and then attempted to lower the boom to the angle where the load that is already
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 5 of 33
on the line exceeded the maximum load for the new boom angle. It was decided that to ensure
the safest operation of the crane halting the operation of the crane during the overload scenarios
would be best. This was the chosen option due to the fact that there should be no scenario in
which the overloading of a crane would be acceptable. To inhibiting the operation of the crane
would require controlling both the function of the main line, which lifts and lowers the load, and
as well the boom line which controls the raising and lowering of the crane’s boom. In order for
the system to know when to halt operation of the crane it would need to calculate and determine
maximum loads for particular boom angles. For these calculations to be performed boom angle
and load values would have to be gathered and implemented into the system. In the end, the final
system design should be created in such a way that if the crane on which it was implemented was
operating within proper ranges the system should have no effect on its operation.
Objectives of Model Design
The primary objective of the model design was to replicate the function of modern day
lifting cranes. Although it was essential to replicate specific aspects of the cranes, there were
characteristics that we felt were not necessary for demonstration purposes of the safety system.
For example: It was not necessary for the model to lift the weights of real cranes; to effectively
demonstrate the safety system functionality we were able to create the model with a low lifting
weight capability by scaling down the maximum load limits in our input programming.
The following details the main design goals of the physical model:
REQUREMENT JUSTIFICATION
Boom angle measurement device Accurately measure boom angle in real
time
Load weighing device Accurately measure load weight in real
time
0⁰-90⁰ boom angle range To reveal the functionality of the safety
system at any angle
High torque, low speed cable motors High torque requirements at low boom
angles
Relatively low speed of lifting action
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 6 of 33
Sound, stable structure (ie. minimal
vibrations throughout, static base frame,
and smooth load lifting/lowering)
To reduce the effects of “vibrational
noise” which may cause error in load
weight measurements
To allow for reliable data inputs for
safety system programming
Use of pulleys and lubricated pivot point To reduce the effects of friction
Less fatigue on main hoist and load
cables
Accommodate mounting of electrical
components
Aesthetically pleasing and more compact
to have all components on one platform.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 7 of 33
Prototype Design
Overview of Prototype
To demonstrate a working prototype our team decided to integrate the Crane Load
Failsafe System with a constructed model crane allowing for complete functionality of the
system to be demonstrated. During the fabrication of the prototype the project was split between
construction of the electronic system, including computer programming, and construction of the
model crane. The electronic portion effectively represents what we have called the Crane Load
Failsafe System. When both systems were finally complete they were integrated together. The
integration in effect demonstrated the safety system being installed on a crane which is more of a
real life installation scenario than if the electronic system had been built right into the model
crane.
Crane Load Failsafe System - Electronics
To satisfy the system specifications set out in the beginning various types of electronics
were required to create the system. The primary control of the system was accomplished using a
PIC 16F877 board. A schematic of the electronic system can be viewed below.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 8 of 33
As represented in the drawing the two geared DC motors are the outputs of the system.
One motor drives the winch attached to the boom and the other motor is attached to the main line
winch. Geared DC motors, opposed to stepper motors, were used due to the requirement of high
torque for the raising of the models boom and main line and precision in movement was not a
concern. As well, the system only requires motors that will quickly turn on or off.
The two inputs to the system that were required in out system specifications are a
miniature load cell and a rotational style potentiometer. The load cell provided a representation
of the load on the line and the rotational potentiometer was used to measure boom angle. The
load cell used in the prototype is a Sensotec 31, 0-10lb load cell. A load cell of this range
allowed us to more accurately measure loads that would be applied to the model for testing
opposed to using a load cell of a high load capacity. Due to the load cell design being based off
of a Wheatstone bridge design the output was in the mille volt range. Connecting that output of
the load cell to an instrumentation amplifier provided an increased signal between 0-5V which
could then be read by the PIC board. The rotational style potentiometer was able to give a
reading of the boom angle by having the potentiometer attached to the pivot pin of the boom in
such a way that when the boom rotated so did the shaft of the potentiometer. The signal from the
potentiometer was then directly sent back to the PIC board.
To control the operation of the motors two double pole double throw (DPDT) switches
were used each with three positions, though two single pole double throw switches could have
been used. Center position was the off position for both motors while the other two positions of
each switch were for the forward and reverse motion of the main line and boom motors. Since
the switches are connected directly to the PIC as inputs this meant that the motors would only
operate if the programming of the PIC board allowed for them to operate. This arrangement gave
the level of control that was required by the system. If the PIC determined that from the load cell
and potentiometer inputs that the crane was at maximum load then the PIC would halt the raising
of the main line and the lowering of the boom, but lowering of the line and reversal of the boom
could be accomplished. The programming of the PIC will be discussed in the following section
to give a more comprehensive description of the operation of the system.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 9 of 33
Crane Load Failsafe System - Programming
The main purpose of programming for our smart crane is to stop the operation when it’s
overloaded at diverse boom angles. There are two inputs which are a load cell and a
potentiometer to convert analog force and boom angles to digital numbers. These inputs data
flow into PIC and are stored into different parameters. Two two-way switches control lifting the
load and changing the boom angle of crane respectively. Both of them are connected with PIC as
well. An arbitrary equation is programmed in PIC based on the relationship between loads and
boom angles. The boom angles are the key variables in the equation. Several if sentences are
used to determine when the operation of the crane is going to be halted if the result of the
calculation based on a linear load equation is located in the overloaded area. The linear load
equation for the model was created based on the loads the crane could lift at the highest and
lowest boom angles. The chart can be viewed in Appendix X. As soon as it’s overloaded, the PIC
sends a command to cease two motors which lifts the load and adjusts the boom angles
respectively. The whole program is an endless loop so it is able to refresh the data from two
inputs in very little time.
Prototype Model Crane Design
Overall, the model crane end product met all design specifications. Even in the
preliminary testing stages, the model proved to be of sound structure and maintained a high level
of stability in all combinations of load weights and boom angles.
Throughout the model fabrication process, a drawing was used as a reference to ensure
all clearances and appropriate component dimensions were met. This drawing continuously
evolved with the physical model as it was being built, and was updated frequently. The general
process was to convert all individual components from a 2D to 3D format as they went from
concept to fabrication. Then all components were assembled in the final 3D drawing for
clearance checks. Once all dimensions were checked, the physical assembly took place with
minimal errors. The following shows the first and final model drawings. Please note that all final
dimensional drawings can be found in Appendix VI – VII.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 10 of 33
Figure 1: Initial Drawing
Figure 2: Final Drawing
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 11 of 33
Difficulties Encountered
Electrical Difficulties
While completing the electrical component of the project many difficulties were
encountered, but all were eventually overcome therefore resulting in a system which operates in
a very similar manner to the original concept. The main difficulties encountered with the
electrical components were the acquisition of the instrumentation specifically the load cell and
the instrumentation amplifier as well as the stability of the instrumentation signals generated
some difficulties. The instrumentation was eventually acquired through different contacts in the
Technical Services Department and the signal stability issue was resolved through averaging
input values in the programming code. In addition the original purpose of the double pole double
switches were to have the reverse motion of the motors hardwired to the power source, but due
to the motor output design on the PIC board this was not feasible. As a result all switch signals
were sent as inputs to the PIC and the forward and reverse motion of the motors is controlled by
the PIC. The final rather significant problem encountered during the prototype arose from the
geared DC motors. Due to the very high torque produced by the motors they have high
acceleration/deceleration and tended to be very jerky while they were turned off or on. During
the lifting of a load the high upward acceleration caused the load cell to initially read a load
value that was higher then the weight of the actual load. To reduce the acceleration of the motors
the duty cycle in the programming was adjusted to give a proper balance of torque and velocity
while not over compensating.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 12 of 33
Programming Difficulties
There were a few problems that arose during the programming. The first problem was
how to control the motors by using PIC. The basic structure of program is based on lab 2, but our
project had one more motor as an input. After an additional code was programmed for the second
motor, the second motor wasn’t running as fast as it should be because we didn’t write any
control program for the second output port. The second problem was to find the point that should
stop the crane when it’s in danger. After the data of load cell output to the hyper terminal, the
numbers were so unstable that it always had about 10% of inaccuracy. One method was to
convert the original numbers to the exact weight of load and boom angles that are actually used
in the calculation. The weight of the load was from 0 to 1 kg, and it was from 0 to 90 degrees for
the boom angle. The boom angle inaccuracy was fixed after the conversion; however, the load
cell input numbers were still swaying around 5%. The second method was take an average of the
input values over seven iterations which added additional stability of the input values. Because
the inputs from the load cell were integer numbers, the computer ignored any figures after the
decimal point. The uncertainty was reduced to a semi reasonable point. There were many small
problems also following along the program design. One PIC was burnt because of an unclear
reason, and the wires took off several times from the ports or broke into half, which caused many
troubles during the test.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 13 of 33
Model Construction
A number of difficulties were encountered in creating the crane model. The most
prominent being the Plexiglas machining. Because of the sensitive nature of the Plexiglas
material, it tended to melt and deform when machined at high speeds. In order to compensate for
this it was machined at lower cutting speeds and with the use of cooling fluid.
Although the 3D model proved useful when assembling the final model, one clearance
was overseen and required adjustment upon final assembly. As shown in Figure 3, the lower
most edge of the boom interfered with the mounting bracket at approximately a 30⁰ boom angle.
This was easily corrected by manually filing down the profile of the edge and reassembling the
boom.
During the initial design stages, there were two main concerns. One was on the proper
location of the lower load lifting pulley, and the other was on which method to measure the
boom angle. The decision to was to mount the pulley within the boom (as to ensure a permanent
contact with the load lifting cable), and upon the advice of Mr. Tom Pike we installed a
potentiometer as the angle measurement device.
Figure 3: Clearence Issue
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 14 of 33
Future Improvements
If given further time and resources, the following additions would be made:
Stable Signal Input:
A more stable load cell and instrumentation amplifier would give a more consistent and
stable input of data to better analyze the real-time boom angle and weight.
Manual Override:
If implemented correctly, a manual override of the CLFS would allow for temporary
“special case” lifting applications (ie. Lifting with various crane attachments).
Audio and Visual Warning System:
This would allow the crane operator to be aware when he/she is approaching near
maximum load weights so they may adjust the boom angle accordingly.
Real-Time Display:
The implementation of a real-time display of the boom angle and load weight would
make the operator aware of the current position and load. This would be tied into the afore
mentioned warning system and installed in an area where the states could be easily seen by the
operator.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 15 of 33
Conclusion
To conclude, the project was an overall success. The crane safety system was designed
and programmed to limit the movement of a crane while lifting maximum load weights (relative
to the crane boom angle), and a physical model crane was built which successfully demonstrated
the use and functionality of the safety system.
We learned a great deal about system development in many fields; from the basic concept
design stages to the implementation of final testing. We gained a valuable learning experience in
computer programming, standard electo-mechanical instrumentation hardware (PIC controllers
and associated board components), model drafting/ prototyping procedures, and manufacturing
processes. In addition, we further developed our technical and professional skills through the
creation of formal reports and presentations.
We believe that with additional research and access to more precise equipment, this
system has potential for use as an effective failsafe system in the lifting-crane industry.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 16 of 33
Appendix
I. Picture of System Prototype
II. Electrical Drawing - (Rev 01)
III. Electrical Drawing - (Rev 00)
IV. Model Drawing 3D
V. Model Drawing 2D
VI. Model Drawing 2D - Front
VII. Model Drawing 2D - Right
VIII. Model Drawing 2D - Top
IX. System Flowchart
X. Model Crane Load Chart
XI. Programming Code
XII. Spec Sheet – Load Cell
XIII. Picture of PIC 16F877 Board
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 17 of 33
I Picture of System Prototype
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 18 of 33
II Electrical Drawing - (Rev 01)
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 19 of 33
III Electrical Drawing - (Rev 00)
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 20 of 33
IV Model Drawing 3D
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 21 of 33
V Model Drawing 2D
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 22 of 33
VI Model Drawing 2D – Front
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 23 of 33
VII Model Drawing 2D – Right
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 24 of 33
VII Model Drawing 2D – Top
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 25 of 33
Load Cell Boom Angle
PIC16F877
No
The forward motion
is halted
Both motors run
without limitations
Main Line
Hoist Switch
Switcher
Boom Hoist
Switch
Input values are
used to evaluate
the maximum
load equation
Boom
Motor
Main Line
Motor
Main Line
Motor
Boom
Motor
Yes
IX System Flowchart
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 26 of 33
X Model Crane Load Chart
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 27 of 33
XI Programming Code
#include<16F877.H> //Using 16f877 PIC
#device adc=10; //Set ADC to 10 bit
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOPUT //Configuration Fuses
#use delay (clock=20000000) //Set clock delay
#org 0x1F00,0x1FFF{} //Reserve Memory for Bootloader
#use rs232(baud=9600,xmit=PIN_c6,rcv=PIN_C7,PARITY=N,BITS=8) //Use RS-232
#USE FIXED_IO(D_outputs=PIN_D1, PIN_D2) //Set pin D1 for motor 1 output, Set
pin D2 for motor 2 output
#byte PORTB = 6 //Port B is "File Address 06H" in "Bank 0"
#define ALL_OUT 0x00 //Constant to set data direction register to output
#define ALL_IN 0xff //Constant to set data direction register to input
#include<STDLIB.H> //Using STDLIB library
int16 duty1 =0; //Set 16 bit interger parameter 'duty1' as 0
int16 duty2 =0; //Set 16 bit interger parameter 'duty2' as 0
int16 count =0; //Set 16 bit interger parameter 'count' as 0
int16 holdload =0; //Set 16 bit interger parameter 'holdload' as 0
int16 holdloadavg =0; //Set 16 bit interger parameter 'holdloadavg' as 0
int16 holdboom=0; //Set 16 bit interger parameter 'holdboom' as 0
int16 holdboomavg=0; //Set 16 bit interger parameter 'holdboomavg' as 0
int16 boom; //Set 16 bit interger parameter 'boom'
int16 load; //Set 16 bit interger parameter 'load' as 0
void main() {
set_tris_b(0x01); //Set bit 0 of Port B to input, bits 1-7 to output
set_tris_b(0x02); //Set bit 1 of Port B to input, bits 1-7 to output
PORTB = 0; //Clear all bits of Port B
setup_ccp1(CCP_PWM); //Set up PWM on CCP1.
setup_ccp2(CCP_PWM); //Set up PWM on CCP2.
setup_timer_2(T2_DIV_BY_4,254,10); //Set up Timer2 for 4901Hz PWM
Period.
setup_adc_ports(all_analog); //Set all pins on ports A and E to
analog.
setup_adc(ADC_CLOCK_DIV_8); //Set ADC conversion speed for 4 Mhz
Clock.
set_adc_channel(0); //Set ADC channel to 0 (pin 2).
while(true){ //Do the while loop when it's true
count = count + 1; //Set a counter
holdloadavg = holdloadavg + load; //Iterating 'holdloadavg' with 'load'
holdboomavg = holdboomavg + boom; //Iterating 'holdboomavg' with 'boom'
if (count > 6){ //If count>6 do
holdload = (holdloadavg/7); //Counting the average of
'holdloadavg'
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 28 of 33
holdboom = (holdboomavg/7); //Counting the average of
'holdboomavg'
count = 0; //Set count to be 0
holdloadavg = 0; //Set 'holdloadavg' to be 0
holdboomavg=0; //Set 'holdboomavg' to be 0
}
set_adc_channel(0); //Set ADC channel to 0 (pin 2).
delay_ms(5); //Delay 5ms
boom = read_adc(); //Input the value from a pot to 'boom'
boom = (0.237*(boom-580)); //Outputing boom angle from 0 to 90 in
the hyperterminal.
set_adc_channel(1); //Set ADC channel to 0 (pin 2).
delay_ms(1); //Delay 1ms
load = read_adc(); //Input the value from load cell to 'load'
load = (load*2.286); //Convert adc value to kilogram and input to
'load'
printf("Load = %4Lu Boom = %4Lu\r",holdload, holdboom);
//Send adc result to serial port
if (input(PIN_B0)){ //if B0 is 1
if (boom<77){ //and boom less than 77
set_pwm1_duty(1000); //PWM duty cycle for motor 1.
Output_high(PIN_D1); //Setting direction for motor 1.
}
else if (boom>=77){ //If boom more than 77 then duty
cycle is 0 and motor 1 is off
set_pwm1_duty(0); //PWM duty cycle for motor 1.
}
}
if (input(PIN_B1)){ //If B1 is 1
if (holdload > ((10*holdboom)+300)){ //and the holdload is
more than (10*holdboom)+300
set_pwm1_duty(0); //stop motor 1
}
else if (holdload < ((10*holdboom)+300)){ //the holdload is
less than (10*holdboom)+300
set_pwm1_duty(500); //PWM duty cycle for motor 1.
Output_low(PIN_D1); //Setting direction for motor 1.
}
}
else if ((!input(PIN_B0)) && (!input(PIN_B1))){ // If B0 and B1 are low
then duty cycle is 0 and motor1 is off.
set_pwm1_duty(0); //PWM duty cycle for motor 1.
}
if (input(PIN_B2)){ //If B2 is 1
if (holdload > ((10*holdboom)+300)){ //and holdload is more
than (10*holdboom)+300
set_pwm2_duty(0); //motor2 is off
}
else if (holdload < ((10*holdboom)+300)){ //If holdload is less
than (10*holdboom)+300
set_pwm2_duty(600); //PWM duty cycle for motor 2.
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 29 of 33
Output_high(PIN_D2); //Setting direction for motor 2.
}
}
if (input(PIN_B3)){
set_pwm2_duty(525); //PWM duty cycle for motor 2.
Output_low(PIN_D2); //Setting direction for motor 2.
}
else if ((!input(PIN_B2))&&(!input(PIN_B3))){ // If B2 and B3 are low
then duty cycle is 0 and motor2 is off.
set_pwm2_duty(0); //PWM duty cycle for motor 2.
}
}
}
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 30 of 33
XII Spec Sheet – Load Cell
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 31 of 33
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 32 of 33
ENGI 4933 Electro-Mechanical Systems Crane Safety Systems
ENGI 4933 Electro-Mechanical Systems Page 33 of 33
XIII Picture of PIC 16F877 Board