Package Sorter Jason Ron, Kelton Lightfoot EENG 383

advertisement
Package Sorter
Jason Ron, Kelton Lightfoot
EENG 383
Final Project Spring 2015
Outline
●
●
●
●
●
●
●
●
Package Sorter general description
Initial concepts
Final design
Circuit diagram
Software flow chart
Pseudo code
Timing diagram
Movie
Package Sorter General Description
●
A mechanical conveyor that sorts packages by height using a sonar sensor, stepper motor, and
2 servo motors
o Sorting
 Implemented by Sonar sensor
● Nothing
o pulse width conversion to cm >12
● Small
o 9<pulse width conversion to cm <12
● Large
o 5<pulse width conversion to cm < 6
o Movement
 Implemented by a Stepper motor
● counted steps to move convey proper distance for box size
o Removal from belt
 Servos
● rotated the servo in front of conveyor once height was measured
● rotated back to hit box off conveyer belt
Initial Concepts
● Sorting area
 IR
 Sonar
● Removal from belt
 Movable Servo
● Conveyor Belt
o Bidirectional
o stepper motor
Final Design
● Sorting area
 1 Sonar elevated above track
● Removal from belt

2 Servo motors to remove
● Conveyor Belt
 Unidirectional
 stepper motor
Final Circuit Diagram
Stepper motor Driver
Software Flow Chart
Pseudo Code: Part 1 Sonar
main program
set up timer system enable timer counter TSCR1 and fast flag clear
disable overflow set prescaler to 64 using register TCR2
set up trigger signal
enable output compare channel 6 TIOS register
set OC6 pin high
clear output capture flag using TFLG1
enable interrupts for channel 6
setup input capture
enable input capture channel 7 TIOS register
capture rising edge using TCTL3
clear c7F flag
enable interrupts for channel 7
Pseudo Code: Part 1 Sonar
Interrupt for output capture channel 6
Interrupt for Input capture channel 7
if TCTL1 &0x10 is true
set TC6 =
TC6+highcount
set next action
to go low
else
set TC6=TC6+lowcount
set next action to go high
if TCTL3 = 0x40 is true
set variable edge 1 equal to TC7
set TCTL3 to look for falling edge next
else
set variable pulse width = TC7 - edge 1
set TCTL3 to look for rising edge next
set w=(pwidth*(64/24000000) this is width in
seconds on channel PT7
( this PT7 which is hardwired to PM1 the echo pulse
signal)
now you are ready to determine it the box is small
medium or large
Pseudo Code: Part 2 Servo’s
main program
select clock SA for channel 4
set clock A prescaler (M=8)
set divider for clock SA (N=120)
set positive going pulse, channel 4, and channel 2 using PWMPOL
set pulse width for channel 4
set period for channel 4, and channel 2 to 250
enable channel 4, and channel 2
route PWM channel 4 to PT4
● and you have used the internal hardware of the HCS12 to create a PMW signal with a 20ms period that outputs
to PT4 and PT2 on H1
●
to control the second servo connected to J6 hardwire PT2 to PT5
Pseudo Code: Part 3 Stepper Motor
initialize a Void function called steppergo
function takes an int called steps as a parameter
for i=0, i<steps, i++
set PTT = PTT |0x01 to set PT0 high
delay a second
set PTT=PTT&FE to set PT\0 low
delay a second
main function
set DDRT = 0x03 to have steps pin and direction pin as output
set PTT =0x03 to initially set both pins to high
Pseudo Code: Part 3 the ∞ loop
For ever
set variable height “y” = w *(1*10^6)/58
if y is greater than 9 and less than 12
disable channel 2 PWM
set duty cycle on channel 4 = 9
call stepper go function passing in 2500 steps
set duty cycle on channel 4 = 30
enable channel 4 and channel 2 PWM
else if y is greater than 5 and less than 6
disable channel 4 PWM
set duty cycle on channel 2 = 9
call stepper go function passing in 6100 steps
set duty cycle on channel 4 = 30
enable channel 4 and channel 2 PWM
else
set duty on channel 2 and 4 to 30
Timing Diagram
Movie
https://www.youtube.com/watch?v=smobE9jdu
Lw&feature=youtu.be
Questions
● Answers
Download