AUTOMATED MANUFACTURING IN REMOTE AREAS USING
MICRO-CONTROLLERS
BY
PUNIT ANAND
GRADUATE STUDENT
FACULTY OF BUSINESS ADMINISTRATION
McMASTER UNIVERSITY
HAMILTON, ONTARIO, CANADA
E-MAIL: [email protected]
AND
ANAND M. SHARAN
PROFESSOR
MECHANICAL ENGINEERING
MEMORIAL UNIVERSITY OF NEWFOUNDLAND,
ST JOHN’SNEWFOUNDLAND, CANADA A1B 3X5
E-MAIL: [email protected]
1
ABSTRACT
 To achieve economical production, automation using microcontrollers have been used.
 This is carried out by mounting a frame for weaving a pattern
on the end effector of an X-Y robot. The robot operates in
conjunction with a sewing machine.
 The energy for driving these dc motor powered machines is
obtained using photo-voltaic panels.
 The co-ordinated motions for the robot and sewing machine
are obtained by programming a controller in mikrobasic
language.
KEYWORDS: Robots in manufacturing, Microcontroller based
manufacturing, Robot and machines having co-ordinated
motions.
2
1. INTRODUCTION
In vast areas of the world, economical manufacturing in rural areas
has become a necessity as the cities are becoming over-crowded.
This requires introduction of high-tech industries to be located in
such areas. Quite often, such places require introduction of low cost
machines due to the shortage of capital in these areas.
For an example, stitching / weaving type of industries require very
small amount of power but are labour intensive.
To reduce the cost – automation and mechanization is needed even
here because hand-made products of matching quality are difficult
to be produced economically in large quantities since the probability
of error is there in every piece made.
Secondly, if we introduce robots, they can make many more variety
of products than earlier generation of machines like existing lathes
and milling machines with human operators .
3
This paper deals with programming a microcontroller to make a
pattern using a sewing machine. The microcontroller is used to
provide motions to an X-Y or Cartesian robot as well as to a sewing
machine as shown in Fig. 1.
FIG. 1 MOTION TO EMBROIDERY FRAME BEING PROVIDED BY X-Y MOTION
ROBOT
2. ILLUSTRATION OF
MANUFACTURING
DEVICES
FOR
AUTOMATED
Fig 2 shows an arrangement where on a fabric, a geometrical
shape has to be weaved (made).
FIG. 2 BATTERY BEING CHARGED BY A SOLAR PANEL
4
To have co-ordinated motion in the X, Y and Z directions, one
uses micro-controller shown in Fig. 3.
FIG. 3 USE OF MICRO-CONTROLLER TO PROVIDE MOTION CONTROL
Here two Pulse Width Modulated (PWM) signals are generated and
sent to two respective H-Bridges (Fig. 4) corresponding to X and Y
motions. The third motion, that of the needle along the Z direction,
is given by motor 3.
FIG. 4 THREE DC MOTORS CONTROLLED BY MICRO-CONTROLLER THROUGH
H BRIDGES
5
These H Bridges are switching devices which open the high current
gates using MOSFETs. The signals generated by micro-controllers
in Fig. 3 can drive the two dc motors shown in Figs 1, and 2 using
these H Bridges.
3. PROGRAMMING A MICRO-CONTROLLER
A computer program written in MikroBasic was used to drive
the motors in Fig. 5.
6
The program was written for making embroidery of circular shape
as shown in Fig. 5.
This figure shows a circle whose equation was obtained using a
Fourier series.
The Fourier coefficients were obtained using Fast Fourier
Transform subroutine in MATLAB software
These coefficients were stored in the memory of the controller.
The pattern to be weaved was carried out in a sequential manner
where a vertical line of variable length (1) was stitched followed by a
very small horizontal line of fixed length(2) and then, again a
vertical line(3) and so on.
7
Clearly, the end points of the vertical line were computed using
Fourier coefficients on line.
The associated computer program was written by referring to [9].
The chip used was Pic 18F45K22 which was mounted on an Easy Pic
V7 Development Board. The experimental set up is shown in Fig. 7.
Using these principles, one can introduce automation in
rural and remote areas where one can manufacture other parts or
products at reduced cost and of far better quality than what is being
done presently.
8
4 CONCLUSIONS
 In this paper, a methodology was presented to introduce
automation in rural and remote areas.
 By the introduction of micro-processors, these automated
machines can be manufactured in rural areas, as well as
such machines can be used to manufacture products.
 By introduction of automation, people will find
employment in villages and it will reverse the migration
to cities for better life.
5 ACKNOWLEDGEMENTS
 The author is thankful to Dr M. J. Hinchey, for his generous
help in building hardware for controller.
 The author is also indebted to Dr. T. Iqbal for valuable
assistance in course of this research.
9
6 REFERENCES
1.
2.
3.
4.
5.
6.
7.
8.
9.
Ostwald , P.F., Amstead, B. H., and Begeman, M. L., “Manufacturing Processes” , 7th
Edition, John Wiley and Sons, Toronto, Canada , pp 450-466.
Sharan, A.M. , and Prateek, M. , 2006, “ Automation of Minimum Torque Based
Accurate Solar Tracking Systems Using Microprocessors “ 86, Sept – Oct. , pp . 415 - 437
Journal of Indian Institute of Science
Craig, J.,J.,” Introduction to Robotics, and Control”, 3rd Edition, Prentice Hall, New
Jersey, USA, pp 62-92.
Klafter, R. A., Chmielewski, T.A., and Negin, M, “Robotic Engineering: An Integrated
Approach”, 1989 Edition. Prentice Hall, New Jersey, USA, pp 58-70.
Guru, B.,S., and Hiziroglu, H.,R., “Electric Machinery and Transformers “,Third Edition,
BJS Publishers, New York, USA, pp 201-244 ; 421-428
Sewing Machines, http://en.wikipedia.org/wiki/Sewing_machine
MOSFET, http://en.wikipedia.org/wiki/MOSFET
Fourier Analysis of Time Series,
http://people.uncw.edu/hermanr/signals/Notes/Signals.htm
Mazidi, M.,A., Mazidi, J., G., and McKinlay, R., D.,” The 8051 Microcontroller and
Embedded Systems “, 2nd Edition, Prentice Hallm , New Jersey, USA, pp 153-178.
PROGRAM
'-----------------------------------------------------------------------------'
FULL CIRCLE FILLUP
'-----------------------------------------------------------------------------'PIK 18F45K22 on Easy Pic V7 Development Board; mikroBasic Pro for PIC
V6.0.0
' External 8 MHZ Oscillator
' Config Parameters
' Oscillator Frequency = 8 MHZ
' Oscillator Selection = HS Oscillator (medium power 4 -16 MHZ)
' 4X PLL Enable = Disabled
' Fail - Safe Clock Monitor Enabled
' Internal / External Oscillator Switchover = Enabled
' Power-up Timer = Enabled
' Brown-Out Reset = "Brown - Out Reset enabled in Hardware only (SBOREN is
disabled)
' Brown out Reset Voltage = "VBOR set to 1.90 V nominal"
' Watch Dog Timer = Disabled
' Watchdog Timer Postscale = 1:32768
' CCP2 MUX bit = CCP2 input/output is multiplexed with RC1
' PORTB A/D = Enabled
10
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
P3A/CCP3 Mux bit = P3A/CCP3 input/output is multiplexed with RB5
HFINTOSC Fast Start-up = Enabled
Timer3 Clock input mux = T3CK1 is on RC0
ECCP2 B Output mux = P2B is on RD2
MCLR PIN = MCLR pin enabled, RE3 input pin disabled
Stack Full/ UnderFlow Reset = Enabled
Low Voltage Program = Disabled
Extended Instruction Set = Disabled
Background Debug = Disabled
Code Protection Block 0 = Block 0 not Code Protected
Code Protection Block 1 = Block 1 not Code Protected
Code Protection Block 2 = Block 2 not Code Protected
Code Protection Block 3 = Block 3 not Code Protected
Boot Block Code Protection = Disabled
Data EEPROM Code Protection = Disabled
Write Protection Block 0 = Disabled
Write Protection Block 1 = Disabled
Write Protection Block 2 = Disabled
Write Protection Block 3 = Disabled
Configuration Register Write Protection = Disabled
Boot Block Write Protection = Disabled
Data EEPROM Write Protection = Disabled
Table Read Protection Block 0 = Disabled
Table Read Protection Block 1 = Disabled
Table Read Protection Block 2 = Disabled
Table Read Protection Block 3 = Disabled
Boot Block Table Read Protection = Disabled
program MotorControl
' Global Declarations section
' PWM at 80% duty cycle is required to move by 1 resolution in +ve dir &
' PWM at 20% duty cycle is required to move by 1 resolution in -ve dir
' Number of PWM waves required to move the motor by a minimum X,Y
Resolution
const motor_res_x as longint = 100
const motor_res_y as longint = 100
' minimum resolution in mm
const res_x_mm as float = 1.0
const res_y_mm as float = 1.0
'PIC18F45K22 running at 8 MHZ
' PWM Timer to be at 500 HZ
' Timer0 is running at (8 Mhz/4) * (1/256), i.e 7812.5 HZ
' Therefore Timer0 multiple is 7812.5 / 500 = 15.625
const frequencymult as float =15.625
'const frequencymult as float =4000
11
const timerscale as float =1.0
const Constword as word = 0xFFFF
' global variables that always contain position vectors of the frame
dim xpos as float
dim ypos as float
'counter
dim cnt as word
'--------------Timer Interrupt handling--------------'This program uses TMR0L as a counter and when the register overflows it
'interrupts. This interrupt is used to generate PWM
'sub procedure Timer0_Interrupt iv 0x000008 ics ICS_AUTO
'sub procedure interrupt_low
sub procedure interrupt
'IF INTCON.TMR0IF =1 Then
TMR0H=0
TMR0L=0
'TMR set to initial value of 0
'INTCON.=0x20
'Interrupt control register only TMR0 overflow interrupt
enabled
'INTCON.GIE=1
'INTCON.PEIE=1
'INTCON.TMR0IE=1
'INTCON.INT0IE=0
'INTCON.RBIE=0
INTCON.TMR0IF=0
'INTCON.INT0IF=0
'INTCON.RBIF=0
cnt = cnt +1
'end if
end sub
' Counter incremented
sub function AbsoluteValueFloat(dim abspara as float) as float
IF abspara <0
THEN
result = -abspara
else
result = abspara
end if
end sub
'--------------MoveX_pos--------------'This subroutine moves the frame so that the needle is at xnew coordinate
'The exact number of PWM pulses are provided to the X motor to position
the
' frame exactly below the needle. Position xnew in mm;
12
' PWM1 is used for generating pulse. For PIC18F45K22 its RC2 (port c 3rd
bit)
' which for 40pin DIP is pin #17
sub Procedure MoveX_pos(dim xnew as float)
'local declaration
dim xmove, xtemp as float
dim pwm_time as word
dim cnt_limit as word
dim cnt_start as word
'dim xtimerhi, xtimerlo as byte
'Delta movement computation
xtemp = xnew - xpos
xmove = xtemp / res_x_mm
' compute the # of PWM required to reach X position
'pwm_time = integer((AbsoluteValueFloat(xmove) * motor_res_x)/timerscale)
pwm_time = integer((AbsoluteValueFloat(xmove) * motor_res_x *
frequencymult)/timerscale)
cnt_limit =1
' By default it is set to cnt_limit setup
IF pwm_time > Constword then
cnt_limit = 1+ (pwm_time div Constword)
cnt_start = pwm_time - Constword*(cnt_limit-1)
else
cnt_limit =1
cnt_start = Constword - pwm_time
end if
cnt =0
'Duty cycle set on the choice of direction
IF xmove >0 THEN
PWM1_Set_Duty (204) 'function takes only values in byte, 204 is 80% duty
cycle
'INTCON = 0xA0 'Interrupt control register Global interrupt & TMR0
overflow enab
else
PWM1_Set_Duty (51) 'function takes only values in byte, 51 is 20% duty
cycle
'INTCON = 0xA0 'Interrupt control register Global interrupt & TMR0
overflow enab
end if
'TMR0L Loaded
'T0CON.7=0
'xtimerhi = Hi(cnt_start)
'xtimerlo = Lo(cnt_start)
'TMR0H = xtimerhi
13
'TMR0L = xtimerlo
'T0CON.7=0
TMR0H = Hi(cnt_start)
TMR0L = Lo(cnt_start)
T0CON.TMR0ON =1
' loop until timer overflow interrupt
do
loop until cnt = cnt_limit
'delay_ms(500)
PWM1_Set_Duty (127)
'PWM1_Stop()
cnt=0
xpos = xnew ' New xposition
T0CON.TMR0ON =0
end sub
'--------------MoveX_pos_delta--------------' Move the motor by the smallest possible amoount in positive x direction
sub Procedure MoveX_pos_delta
dim posdelta as float
posdelta = xpos + res_x_mm
MoveX_pos(posdelta)
'MoveX_pos(xpos + res_x_mm)
end sub
'--------------MoveX_neg_delta--------------' Move the motor by the smallest possible amoount in positive x direction
sub Procedure MoveX_neg_delta
dim negdelta as float
negdelta = xpos - res_x_mm
MoveX_pos(negdelta)
'MoveX_pos(xpos - res_x_mm)
end sub
'--------------MoveY_pos--------------'This subroutine moves the frame so that the needle is at ynew coordinate
'The exact number of PWM pulses are provided to the Y motor to position
the
' frame exactly below the needle. Position ynew in mm;
' PWM2 is used for generating pulse. For PIC18F45K22 its RC1 (port c 2nd
bit)
' which for 40pin DIP is pin #16
sub Procedure MoveY_pos(dim ynew as float)
14
'local declaration
dim ytemp, ymove as float
dim pwm_time_y as word
dim cnt_limit_y as word
dim cnt_start_y as word
' xmove
'Delta movement computation
ytemp = ynew - ypos
'Motor direction control to be determined by xmove
ymove = ytemp / res_y_mm
' compute the # of PWM required to reach X position
'pwm_time = integer((AbsoluteValueFloat(ymove) * motor_res_y)/timerscale)
pwm_time_y = integer((AbsoluteValueFloat(ymove) * motor_res_y *
frequencymult)/timerscale)
cnt_limit_y =1
' By default it is set to cnt_limit setup
IF pwm_time_y >Constword then
cnt_limit_y = 1+ (pwm_time_y div Constword)
cnt_start_y = pwm_time_y - Constword*(cnt_limit_y-1)
else
cnt_limit_y =1
cnt_start_y = Constword - pwm_time_y
end if
cnt =0
TMR0H = Hi(cnt_start_y)
TMR0L = Lo(cnt_start_y)
T0CON.TMR0ON =1
'PWM2_Init(488)
'PWM2_Start()
IF ymove >0 THEN
PWM2_Set_Duty (204) 'function takes only values in byte, 204 is 80% duty
cycle
'INTCON = 0xA0 'Interrupt control register Global interrupt & TMR0
overflow enab
else
PWM2_Set_Duty (51) 'function takes only values in byte, 51 is 20% duty
cycle
'INTCON = 0xA0 'Interrupt control register Global interrupt & TMR0
overflow enab
end if
' TMR0H & TMR0L Loaded
' Loop until timer overflows
do
15
loop until cnt
= cnt_limit_y
'delay_ms(500)
PWM2_Set_Duty (127)
'PWM2_Stop()
cnt=0
ypos = ynew
T0CON.TMR0ON =0
end sub
'--------------MoveY_pos_delta--------------' Move the motor by the smallest possible amount in positive y direction
sub Procedure MoveY_pos_delta
dim posdelta as float
posdelta = ypos + res_y_mm
MoveY_pos(posdelta)
end sub
'--------------MoveY_neg_delta--------------' Move the motor by the smallest possible amount in negative y direction
sub Procedure MoveY_neg_delta
dim negdelta as float
negdelta = ypos - res_y_mm
MoveY_pos(negdelta)
end sub
' 6th bit of Port C RC5, 24th pin of 40 DPI is 1
sub procedure NeedleOn()
PORTC.5 = 1
'RC5 or the 6th bit 1 for needle motor to switch on
end sub
sub procedure NeedleOff()
PORTC.5 = 0
'RC5 or the 6th bit 0 for needle motor to switch off
end sub
'----------WEAVE OPERATION UP TO DOWN ------------' yup and ydown as integer
sub procedure WeaveYUpDown(dim yp,yn as float)
' Local Declaration
dim forcounter, PDtemp as integer
'PORTC = 0 ' PORT C =0
'TRISC = 0 ' Set Port C as output
PDtemp = integer((yp - yn) / res_y_mm ) + 1
16
'Move the needle to Yup position
IF ypos = yp then
else
MoveY_pos (yp)
end if
'switch on the needle
'NeedleOn()
' Y to be moved by the y resolution
For forcounter = 1 to PDtemp step 1
MoveY_neg_delta()
next forcounter
'switch off the needle
'NeedleOff()
end sub
'----------WEAVE OPERATION DOWN TO UP ------------' yup and ydown as integer
sub procedure WeaveYDownUP(dim yplus,yminus as float)
' Local Declaration
dim forcounter, DPtemp as integer
'PORTC = 0 ' PORT C =0
'TRISC = 0 ' Set Port C as output
DPtemp = integer((yplus - yminus) /
res_y_mm) + 1
'Move the needle to Ydown position
IF ypos = yminus then
else
MoveY_pos (yminus)
end if
' Switch on the needle
'NeedleOn()
For forcounter = 1 to DPtemp step 1
MoveY_pos_delta()
next forcounter
' Switch off the needle
'NeedleOff()
end sub
'In order to weave a circle, fourier series is employed.
'--------------------------Fourier Part begins--------------------------'
sub function GetYup(dim i,N as integer) as float
dim A0,A1,A2 as float
dim B0,B1,B2 as float
dim compT0,compT1,compT2,compT3,compT4 as float
17
A0 = 7.0554
A1 = -0.5140
A2 = 0.0013
B0 = 0.0
B1 = 0.0294
B2 = 0.0010
'get y location
'i dont know how to do arrays in basic, so doing individually
compT0
compT1
compT2
compT3
compT4
=
=
=
=
=
A0/2
A1*cos(2*PI*i/N)
B1*sin(2*PI*i/N)
A2*cos(2*PI*2*i/N)
B2*sin(2*PI*2*i/N)
IF i=0 THEN
result = compT0
else
result = compT0+compT1+compT2+compT3+compT4
end if
end sub
sub function GetYdown(dim i,N as integer) as float
dim ymin, ytmp as float
ymin = 3.0
ytmp = GetYup(i,N)
result = (2*ymin) - ytmp
end sub
'--------------------------Fourier Part ends--------------------------'
main:
'
Main program
' assume that you have to start weaving at X initial position
dim N,i,j as integer
dim yup as float
dim ydown as float
dim xinitial as float
yup =0.0
ydown =0.0
xinitial = 10.0
N = 144
' initial values
xpos=0.0
ypos=0.0
cnt =0
'Configuring AN PINS as Digital I/O
'ANSEL =0
ANSELC = 0
TRISC = 0 ' Set Port C as output
PORTC = 0 ' PORT C =0
18
'Selecting Frequency to be 31.25KHZ Internal source
' OSCOCN2 Register Oscillator Control Register 2
' PLLRDY; SOSCRUN; Unimplemented; MFIOSEL; SOSCGO;PRISD;MFIOFS;LFIOFS
'OSCCON2 =%01000101
'OSCTUNE Register
'INTSRC; PLLEN; TUN <5:0>
'OSCTUNE =%00100000
'OSCCON Register
'IDLEN; IRCF <2:0>, OSTC; HFINTOSC; SCS <1:0>
'OSCCON =%00000010
'T0CON Timer0 Control Register 8 bits are TMR0ON, T08BIT, T0CS, T0SE, PSA,
' TOPS <2:0>, 16 bit timer with 1:16 prescale vale
' TMR0ON, T08BIT, TOPS (100) (1/4 * 1/256) 1:1024 frequency value
'T0CON.TMR0ON =0 'Timer Stopped
'T0CON.T08BIT =0 '16 Bit Timer Mode
'T0CON.T0CS =0
'Use System Clock to Increment Timer
'T0CON.T0SE =0
'T0CON.PSA =0
'Use Prescaler to Timer0
'T0CON.TOPS2 =1 'Use 1:256 prescaler
'T0CON.TOPS1 =1
'T0CON.TOPS0 =1
T0CON = %00000111
'T0CON = %00001000
TMR0H=0
TMR0L=0
'TMR set to initial value of 0
'Intcon Register 8 bits are GIE/GIEH; PEIE/GIEL; TMR01E; INT01E; RBIE;
TMR01F;
' INT01F; RBIF
RCON.IPEN=0
'RCON.IPEN=1
'INTCON2.TMR0IP=1
INTCON.GIE=1
INTCON.PEIE=1
INTCON.TMR0IE=1
INTCON.INT0IE=0
INTCON.RBIE=0
INTCON.TMR0IF=0
INTCON.INT0IF=0
INTCON.RBIF=0
'INTCON=0xA0 enable interrupt TMR0
'TxCon Timer 1/3/5
'TMRxCS<1:0>; TxCKPS<1:0>; TxSOSCEN; TxSYNC;TxRD16;TMRxON
'TMRxCS =00 instruction cycyle (1/4); TxCKPS<1:0>=11 (1/8)
19
'T1CON=%00110101
'T3CON=%00110101
'TxCON, Timer 2/4/6
'Unimplemented; TxOutps postcaler <3:0> ; TMRxON; TXCKPS (prescaler)
PR2 = %11111001
T2CON = %00000111
CCPR1L = %01111100
CCP1CON = %00111100
' With this LF Stable Oscillator at 31.25 KHZ is chosen as the primary
clock
' driving Timer0, Timer2 at prescale value of 1/64;
' PWM will be generated at frequency 488.28 Hz
'PWM1_Init(488)
'PWM2_Init(488)
'PWM1_Init(500)
'PWM2_Init(500)
PWM1_Start()
PWM2_Start()
PWM1_Set_Duty (127)
PWM2_Set_Duty (127)
MoveX_pos (xinitial)
j=0
PORTC = 0 ' PORT C =0
TRISC = 0 ' Set Port C as output
NeedleOn()
for i = 0 to N step 2
IF i =0 then
yup = GetYup(i,N)
else
yup = GetYup(j,N)
end if
ydown = GetYdown(i,N)
WeaveYUpDown(yup,ydown)
'WeaveYUpDown(yup,6.0-yup)
j = i+1
'delay_ms(1000)
MoveX_pos_delta
'delay_ms(1000)
yup = GetYup(j,N)
ydown = GetYdown(i,N)
WeaveYDownUp(yup,ydown)
'WeaveYDownUp(yup,6.0 - yup)
MoveX_pos_delta
next i
PWM1_Stop()
PWM2_Stop()
20
NeedleOff()
end.
21
Download

Fig. 4 - Faculty of Engineering and Applied Science