Robot Arm With Controller: Description
Robot Arm With Controller: Description
Robot Arm With Controller: Description
DESCRIPTION
One use for the CONTROLLER is to enable the five motors in the ROBOT ARM to be controlled using position feedback. This document details the use of the CONTROLLER with the ROBOT ARM. The central control element for the CONTROLLER is a Picaxe-40X microcontroller. The CONTROLLER may be incorporated into initial design of the ROBOT ARM or may be used to convert the ROBOT ARM at a later date. The CONTROLLER may also be used for mechanisms that require up to six axes of motor control with position feedback. Other devices may also be connected to the unused inputs and outputs.
Figure 1 Robot Arm Controller PCB Assembly The ROBOT ARM is a five-axis pick-and-place manipulator. Each of the axes is driven by a small DC electric motor. The axes provide the following functions: gripper, wrist, forearm, arm and shoulder.
THE PROJECT
To carry out the project, the student must: Design and build the ROBOT ARM incorporating changes required for the CONTROLLER. Alternatively, a completed ROBOT ARM may be modified to use the CONTROLLER for the next stage of development and testing. Assemble the printed circuit board, connect the wiring, motors and position feedback potentiometers. Program the Picaxe microcontroller and Figure 2 Robot Arm with Controller adjust the program parameters. IMPORTANT: This unit must be used together with the ROBOT ARM unit and component kit it does not replace it.
INVESTIGATION
This project provides a number of different aspects of the CONTROLLER for investigation. Some ideas are listed below. Investigate attaching additional input and output devices. Investigate adding more "intelligence" or different sequences to the program. Investigate different mechanical robot configurations. What differences would need to be made to the mechanics, electronics and program? Investigate other devices that could use up to six bi-directional motors with position feedback.
17 Inverell Ave., Mt. Waverley, Vic. 3149 Tel: (03) 9802 9913 Fax: (03) 9887 8158
www.scorpiotechnology.com.au
1. COMPONENTS REQUIRED
1.1. COMPONENTS SUPPLIED
This unit is designed for use in conjunction with the ROBOT ARM unit and component kit. The following components are supplied in the kit: 1.1.1. Robot Arm 6 x 50 Tooth x 0.6 Module Gear (*) 3 x 4mm dia x 33mm Knurled Steel Shaft 6 x 30/10 Tooth x 0.6 Module Gear (*) 2 x Bolt M3 x 20mm 1 x 50/10 Tooth x 0.5 Module Gear (*) 2 x Screw Self-tapping M3x10 2 x 60/10 Tooth x 0.5 Module Gear (*) 5 x 0.1uF Capacitor (monolithic or equivalent) 3 x 3mm dia x 50mm Steel Shaft 1 x 3mm ID x 100mm PVC Tube 4 x 2.5mm Flat washer (*) NOTE: Additional gears are supplied to allow for experimentation (approximately double the required quantity is supplied). 1.1.2. Controller 1 x Printed Circuit Board (PCB) 1 x Picaxe-40X (Microcontroller) 3 x L293D (Motor Driver IC) 1 x IC Socket (40 pin) 3 x IC Socket (16 pin) 1 x 4MHz Resonator - 3 Pin 1 x LED (Red) 5mm 1 x Stereo Socket - 3.5mm
9 x 0.1uF Capacitor (monolithic or equivalent) 1 x Resistor - 220 Ohms (Red-Red-Brown-Gold) 2 x Resistor - 10k Ohms (Brown-Black-Orange-Gold) 1 x Resistor - 22k Ohms (Red-Red-Orange-Gold) 1 x Capacitor - 100uF (electrolytic) 1 x 1N4004 Diode (or equivalent) 1 x Sliding Switch (small) 5 x Potentiometer 25k - Linear (B) - Splined Shaft
NOTE: This document describes the use of a Picaxe-40X. Other 40 leg Picaxe microcontrollers may be used, but changes may need to be made to the program and/or hardware. The program included with this document uses about a quarter of the available memory space in a Picaxe-40X.
The Flash memory (EEPROM - Electrically Erasable Programmable Read Only Memory) in a PICAXE allows it to be reprogrammed many times (typically at least 100,000). This means that you can develop a program and constantly check the effects of changes. A PICAXE program is created using an easy to learn version of the BASIC programming language (our preferred method) or using flowcharting software (with a limited command set). NOTE: The PICAXE is supplied containing 'bootstrap' code that enables you to download your program using the serial cable. Do not substitute the PICAXE with a blank PIC microcontroller or any other integrated circuit.
2.4.1. MOTOR OUTPUTS All of the motor outputs are digital (0V or +V). Two output legs on the Picaxe are required to drive one motor. Each of the motor outputs is directly connected to an input on an L293D motor driver IC. A total of six motors can be driven from the circuit without modification. To incorporate a seventh motor, use Analogue 7 (Leg 10) and two other outputs (Leg 15 to Leg 18). An additional L293D (or another H-bridge circuit) will be needed. A red/green pair of LEDs and resistor (optional) may be connected to each motor's terminals used to indicate which direction a motor is currently being driven. These LEDs may be useful during faultfinding. 2.4.2. POTENTIOMETER INPUTS All of the potentiometer inputs are analogue. Because the outer arms of each potentiometer are connected to 0V and +V, the voltage that appears on the wiper arm (driven by the motors), is between 0V and +V. Each of the potentiometers is associated with an analogue-to-digital converter. In the Picaxe, an analogue-to-digital converter translates an analogue voltage to a numerical value that can be used by the program. 2.4.3. OTHER INPUTS To obtain information from the outside world, switches and sensors can be added to unused input pins on the Picaxe. You should add these devices only after the basic design has been built and tested because you will need to modify the program. Some ideas for inputs include: A push-button switch (normally open) may be connected to the reset input. When the reset switch is pressed, the program starts from the beginning. A toggle switch for the program to select between two programmed sequences. Emergency stop switch to halt the ROBOT ARM when the button is pressed. Another switch could be used to detect if a "guard" or "fence" is opened. A separate button should be used to restart the ROBOT ARM. Gripper switch to indicate that an object is between the jaws. Keypad (4x4 matrix or 4x5 matrix, as per telephone/calculator keypad) to provide direct control of motors. The concept could be extended as a "teaching" pendant. 2.4.4. OTHER OUTPUTS To communicate with the outside world, additional output devices may be added to the CONTROLLER using available output pins on the Picaxe. You will need to modify the program to provide suitable output. Some possible output devices include: LED mimic panel to indicate which motor (axis) is moving. LED display - possibly a 7-segment display or a bar graph. LCD module. 2.4.5. EXTERNAL COMMUNICATIONS It is possible to connect the Picaxe to a PC using a two-way serial data link. Unfortunately, you cannot use the programming port except for using the Debug command. The Debug command may be useful to obtain real-time information, such as axis position, while debugging your software/hardware. To communicate with your PC using serial communications, you will need to use a suitable interface circuit (such as a MAX232 integrated circuit) and obtain or create suitable software for your PC. Please note that this could substantially increase the scope of your project. 7
2.6. POTENTIOMETERS
Each of the five potentiometers is used to measure the angular position of an axis. The potentiometers must be of a "linear" type; a "logarithmic" type is not suitable. The actual resistance value is not critical, since a relative voltage between the power rails (0V and +6V) is being measured. A suitable resistance range is 5k to 50k.
2.7. CAPACITORS
Capacitor C1 (100uF) smooths battery power caused by motor switching. Capacitors C2 to C9 (0.1uF) smooth the power supply close to the ICs. Capacitors C10 to C15 (0.1uF) reduce electrical motor noise that reaches the Picaxe.
2.8. POWER
Power switch SW1 is used to control power to the circuit. A red LED (light emitting diode) (L1), in series with a 220R resistor is used to indicate the presence of power on the PCB assembly. The LED intensity may change during operation. Diode D1 is used to drop the voltage to the Picaxe and to provide reverse voltage protection. 8
3. MECHANICAL CONSIDERATIONS
3.1. PLANNING
Please refer to the ROBOT ARM documentation for mechanical and assembly details that are not covered in this document. Before starting construction, plan and lay out all the components using a suitable computer program or on a sheet of paper. Look at your ROBOT ARM as a complete unit, and not just as separate parts. Use our drawings as a starting point for your design. This section describes changes to the ROBOT ARM that need to be made for it to be used with the CONTROLLER. It is recommend that the robot arm components be made from PVC, as it is relatively tough.
3.2. GRIPPER
Enlarge the hole in the gripper base to mount the gripper feedback potentiometer. The hole for mounting the potentiometer (threaded portion) should be a neat/loose fit. The hole should be about 6.5mm (1/4" diameter). Use a reamer (tapered hole enlarging tool) or round file to fit. Cut off the small protrusion on the potentiometer. Attach the potentiometer using the nut provided. Enlarge the hole in the matching gripper link and 50T gripper actuating gear for a press fit on the gripper potentiometer shaft. The hole for the splined portion of the potentiometer should be a tight fit somewhere between 5.0mm and 5.5mm diameter. You will need to determine a suitable size for this hole by drilling a 5.0mm diameter hole and then using a reamer or round file to enlarge the hole until you get a suitable fit. With the correct fit, the material in the holes should form small ridges. Figure 8 Gripper Potentiometer 9
NOTE: PVC is relatively soft/ductile and is more suitable for this application than acrylic. If required, PVC and acrylic can be softened by gently and carefully using a heat gun do not use an open flame or a burner. Screw the gear and link together. Rotate the potentiometer to its middle position. Open the jaws halfway and press the gear and gripper link onto the potentiometer shaft. This will provide a preliminary alignment of the potentiometer with the gripper axis.
3.3. WRIST
The wrist feedback potentiometer needs to be suitably mounted, refer Figure 9. Design and construct the wrist potentiometer mounting plate. Change the design of the gripper side plate #1 so that the potentiometer mounting plate can be fitted. Use a short length of PVC tube to shift the centre of the 12 tooth pinion to the centre of the gripper rotation gear. Drill a suitable sized hole in the 60 tooth gear (refer Gripper). Press the 60 tooth gear onto the potentiometer shaft. Ensure that Figure 9 Wrist Potentiometer the gear is centred on the 12 tooth pinion. Upon assembly, rotate the wrist potentiometer to its mid position and rotate the wrist so that it is in the position shown.
10
For the Forearm, Arm and Shoulder joints, change the final pinion and gear from 0.5mm module to 0.6mm module, refer Figure 10. Drill the hole in the 60 tooth x 0.5mm module gear to 2.8mm diameter. Use a 3.0mm drill bit to drill both output shaft holes in the gearcase. (The shaft should rotate freely.) Make a 10 tooth x 0.6 module pinion from a 30/10 x 0.6 module gear. File the 50 tooth x 0.6 module gear so that it sits flat when attached to the plate. The change from 0.5mm module to 0.6mm module improves the joints as follows: Minimises the final pinion gear slipping on the output shaft. Increases the strength of the final gear drive, as the teeth are larger. Decreases the accuracy required in creating hole positions for the final drive, due to the larger depth of teeth. Takes advantage of the pitch circle diameter for a 60 tooth 0.5mm module gear being the same as the 50 tooth 0.6mm module gear (60 x 0.5 = 50 x 0.6 = 30mm). This same relationship exists for a 12 tooth 0.5mm pinion and a 10 tooth 0.6mm pinion (12 x 0.5 = 10 x 0.6 = 6mm). 3.4.1. Pinion Slipping On Shaft If during testing and operation one of the 10 tooth x 0.6 module pinions slips on its shaft, then it is suggested that the pinion and 3mm shaft tied together. To do this, use a high speed drill (Dremel or equivalent) with a 0.8mm to 0.9mm diameter "jobber drill" to drill through the gear and pinion in a position away from where the gears mesh. Note that 1.0mm diameter drills are easier to obtain, but a 1mm hole will weaken the shaft too much. Pass a length of wire (paper clip or solid copper electrical wire) through the hole, then twist and cut the ends. Hint: You will need a steady hand to control the drill so that it will make a hole in the middle of the shaft. Be careful and practice on some scrap material first!
4. ASSEMBLY
4.1. MECHANICAL ASSEMBLY
NOTE: This project requires a high degree of accuracy (in some places better than 0.5mm) to ensure that gears mesh smoothly. Take care when cutting, drilling and assembling the parts. Use the following information to supplement the instructions for assembling the ROBOT ARM. Before starting assembly, solder a 0.1uF capacitor across the terminals of each motor. The purpose of the capacitor is to reduce interference generated by the motor reaching the CONTROLLER and external equipment. If you wish to mount the LED motor direction indicators on the motors, twist and solder a red LED, a green LED and a 220R resistor (not supplied) between the motor terminals. Connect the LEDs in opposite directions, flat on red LED to "+" terminal, flat on green LED away from "+" terminal. The LEDs will then indicate direction of motor rotation. Figure 11 Components on Solder suitable lengths of wire to the motor terminals. If using Motor Terminals multi-core alarm cable, allow a sufficient length of wire for each potentiometer. Assemble the gearcases. Refer to the ROBOT ARM document. Note that a 3mm output shaft needs to be fitted to the output shaft on the shoulder, arm and forearm gearcases. Construct the ROBOT ARM beginning with the gripper and then towards the base. The five two-way switches supplied with the ROBOT ARM are not required. (NOTE: The switches could be used as inputs to the Picaxe to select different routines.)
12
4.3. WIRING
For wiring details, refer Figure 4 and Figure 13. Use 6-core alarm cable or different coloured wires to assist during faultfinding. When soldering wires, strip a short piece of insulation from the end of the wire, twist the strands and "tin" them with solder. Pass the wiring from the motors and potentiometers, through the ROBOT ARM to the PCB. If required, use mating connectors to allow the ROBOT ARM CONTROLLER to be disconnected from the ROBOT ARM. Connect the motors and potentiometers as follows (suggested wire colours): Pin 1 = Motor (white) Pin 2 = Motor (blue) Pin 3 = +6V to Potentiometer (red) Pin 4 = Spare (green) Pin 5 = 0V to Potentiometer (black) Pin 6 = Potentiometer Arm (yellow) Figure 13 Wiring Diagram Connect the switch and battery holder (+ve = red, -ve = black). NOTE: The "spare" connection to pin 4 on each connector location allows an additional input or output device, such as a switch or LED, to be connected for each axis using the same length of alarm cable. Connect the track on the PCB to a spare input or output pin on the Picaxe. You will need to modify your program to use the additional device(s). 4.3.1. POTENTIOMETER WIRING Connect wires to each of the potentiometers as shown in Figure 14. (For the gripper, swap the red and black wires.) Figure 14 Potentiometer Wiring 4.3.2. MOTOR WIRING Connect wires to the motors: white to "+" and blue to "-".
13
5. ELECTRICAL TESTING
Before applying power, inspect soldering for short circuits and poor "wetting" of component leads or pads. Insert four 1.5Volt AA batteries into the battery holder. Move the power switch to "on". Check that the LED illuminates. This shows that power is available. If the LED does not illuminate: Check that the battery voltage is above 5.5 volts. (If low, replace the batteries.) Check that the batteries are properly inserted in the battery holder. Check that the LED is the right way around. Check the wiring against the wiring diagram. Move the power switch to "off". Check the orientation of the ICs - the end with leg 1 is identified with a notch or dimple at one end. Line up the legs of each IC with its IC socket holes and press down firmly. Do not use the letters/numbers on the IC to identify leg numbers. NOTE: It may be necessary to bend the IC legs slightly to line them up with the socket holes. CAUTION: ICs will be damaged if they are installed in the wrong direction or if power supply (battery) connections are reversed. Move the power switch to "on". Check that the LED illuminates. This checks that power is available. At this stage nothing will appear to be working.
14
5.4.1. PROGRAM OVERVIEW NOTE: For programming language details, from the PICAXE "Programming Editor" help menu, open "PICAXE Manual 2 - BASIC Commands". The program (refer Figure 16 and Figure 18) contains various sections, as follows: Set up variables for axis positions ("symbol" commands). Adjust these values during testing. Initialisation ("let dirs", "let dirsc", "let pins" and "let pinsc" commands) The main loop consists of a pair of lookup tables and a counter (first lookup table is to select the axis to move, second one defines the axis position and the counter is used to select which pair of values is used). The axis position is an integer in the range 1-255. A "branch" statement that directs the program to jump to the relevant axis that needs to be moved. A loop of code for each axis, consisting of two motor outputs and potentiometer input. When the loop reaches the desired Figure 16 Simplified Program Flow Chart position, the program selects the next axis to be moved. 5.4.2. MOTORS AND POSITION FEEDBACK POTENTIOMETERS The spare motor and its feedback potentiometer may be connected without any circuit modifications. The motor and potentiometer should be the same as those used in this project. The voltage present on the spare analogue input must be between 0V and +V. A potentiometer or a variable resistance, such as an LDR (Light Dependant Resistor), should be suitable. Refer to other Picaxe documentation for circuit details. A pair of commands needs to be used to control the motors, as shown in Table 3.
15
Axis Name Shoulder Arm Forearm Wrist Gripper Spare Motor Spare Analogue Input
Motor Reverse Commands pins = %00000100 pinsc = 0 pins = %00000001 pinsc = 0 pins = 0 pinsc = %01000000 pins = 0 pinsc = %00010000 pins = %00010000 pinsc = 0 pins = %00100000 pinsc = 0 -
Motor Forward Commands pins = %00001000 pinsc = 0 pins = %00000010 pinsc = 0 pins = 0 pinsc = %10000000 pins = 0 pinsc = %00100000 pins = %00100000 pinsc = 0 pins = %10000000 pinsc = 0 -
Table 3 Motors and Position Feedback Potentiometers To stop all motors, use the following pair of commands: "pins = 0" and "pinsc = 0".
5.4.3. ADDITIONAL DIGITAL INPUTS AND OUTPUTS Legs C0, C1, C2, C3 may be defined as either inputs or outputs. Input 0, 1, 2, 3, 4, 5, 6, 7 (use the "pins" command) Input C0, C1, C2, C3 (use the "pinsc" command) Up to four additional digital outputs may be connected. Output C0, C1, C2, C3 (change the value of the "dirsc" in the initialisation section and use the "pinsc" command)
16
6. FUNCTIONAL TEST
NOTE: The functional test can only be performed after the program is loaded into the PICAXE. Move the power switch "on". The ROBOT ARM should go through a sequence of motions. If the ROBOT ARM does not perform the required sequence, check each axis individually. Create a temporary version of the program. In the "loopa:" section, delete all data from both lookup tables except for three values. Change the first parameter pair to one extent of motion, the second to the opposite extent of motion, and the last pair to "xx". Download the program to the PICAXE and run the program. (Fewer or additional data points may be used.) As required, swap the motor wires and adjust the potentiometer positions by rotating the potentiometer body or changing the data values. NOTE: The L293D's may become warm with continuous use.
7. FURTHER DEVELOPMENT
We encourage you to change the program after you have determined that our program works with your CONTROLLER. Develop another sequence of actions for your ROBOT ARM to perform. Use a switch to select which routine is used. Add a switch input to move your ROBOT ARM to a "home" position. Add a switch input to "pause" the sequence to simulate an emergency stop situation. Add a microswitch (or two) to detect that an object is present in the gripper. Add a switch to select between "manual" and "program" modes. Use the 5 switches supplied with the ROBOT ARM to select which axis to move. Congratulations on successfully building and customising your own ROBOT ARM under the direction of the CONTROLLER!
HAVE FUN!
17
8. THE PROGRAM
'Robot Arm Controller '(C)2009 PVA Tecwrite - Peter Aleksejevs 'Define constants used to define axes in the lookup tables. symbol sx = 0 'shoulder symbol ax = 1 'arm symbol fx = 2 'forearm symbol wx = 3 'wrist symbol gx = 5 'gripper symbol bx = 6 'spare motor symbol cx = 7 'spare ADC input symbol yy = 8 'end of data - wait until switch cleared on input not implemented symbol xx = 9 'end of data marker = reset counter 'Define positions of axis preset positions: i=initial, 1="left", 2=mid, 3="right". 'All positions values are 0 to 255, as measured by the axis potentiometer. 'Define position 128 at centre of motion - i.e. for shoulder when arm is pointing straight out. symbol si = 100 'shoulder initial symbol s1 = 100 'shoulder left symbol s2 = 128 'shoulder mid symbol s3 = 156 'shoulder right symbol ai = 100 'arm initial symbol a1 = 100 'arm left symbol a2 = 128 'arm mid symbol a3 = 156 'arm right symbol fi = 145 'forearm initial symbol f1 = 156 'forearm down symbol f2 = 128 'forearm mid symbol f3 = 100 'forearm up symbol ri = 138 'wrist initial symbol r1 = 100 'wrist left (w1 is a variable) symbol r2 = 128 'wrist mid (w2 is a variable) symbol r3 = 148 'wrist right (w3 is a variable) symbol gi = 135 'gripper initial symbol g1 = 114 'gripper closed symbol g2 = 130 'gripper mid symbol g3 = 140 'gripper open 'Define slow down distances. To disable, change value to 0. Suitable values are in parentheses. symbol ds = 0 '(8) shoulder deceleration position. symbol da = 0 '(6) arm slow down distance. symbol df = 0 '(6) forearm slow down distance. symbol dr = 0 '(6) wrist slow down distance. symbol dg = 0 '(5) gripper slow down distance. symbol pon = 25 'PWM on time for slow down in milliseconds symbol pof = 2 'PWM off time for slow down in milliseconds (also add delay in routine) 'variables symbol counter = b1 'Selects which axis & postion value pair is currently used symbol axis = b2 'Specifies current axis symbol position = b3 'Specifies desired position of current axis symbol analog = b4 'Read in value from current axis potentiometer symbol temp = b5 'Temporary variable (used for deceleration calculation) 'The following line needs to be changed if using switches on port C. let dirsc = %11111111 'Set all C port pins as outputs. Unused pins can be inputs or outputs. let pins = 0 let pinsc = 0 counter = 0 loopa: ' 'add code to check switch inputs here! i.e. "Pause" switch/button. ' 'Add/remove comments (') at start of lines as required. 'SINGLE AXIS TEST SEQUENCE (change "sx" and position values as required) 'lookup counter,( sx, sx,xx),axis 'lookup counter,( 50,200,xx),position 'MULTIPLE AXIS TEST SEQUENCE 'lookup counter,(sx,sx,ax,ax,fx,fx,wx,wx,gx,gx,xx),axis 'lookup counter,(s1,s3,a1,a3,f1,f3,r1,r3,g1,g3,xx),position 'PICK AND PLACE SEQUENCE lookup counter,(sx,ax,fx,wx,gx,gx,fx,wx,ax,sx,fx,gx,fx,wx,fx,wx,wx,sx,ax,fx,gx,fx,sx,ax,fx,gx,fx,sx,ax,fx,g x,fx,sx,ax,fx,gx,fx,sx,ax,fx,gx,fx,xx),axis lookup counter,(si,ai,fi,r1,gi,g3,f2,r2,a1,s1,f1,g1,f2,r1,f3,r3,r2,s2,a2,f1,g3,f2,s3,a3,f1,g1,f2,s1,a1,f1,g 3,f2,s2,a2,f1,g1,f2,s3,a3,f1,g3,f2,xx),position branch axis,(loop0,loop1,loop2,loop3,loop4,loop5,loop6,loop7,loop8,loop9) goto loopa 'The program should never get to this line of code 'shoulder loop0: readadc 0,analog temp = position - 3 'position error (low)
18
if analog < temp then rev0 temp = position + 3 if analog > temp then for0 counter = counter + 1 let pins = 0 let pinsc = 0 goto loopa rev0: let pins = %00000100 temp = position - analog if temp > ds then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa for0: let pins = %00001000 temp = analog - position if temp > ds then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa 'arm loop1: readadc 1,analog temp = position - 3 if analog < temp then rev1 temp = position + 3 if analog > temp then fow1 counter = counter + 1 let pins = 0 let pinsc = 0 goto loopa rev1: let pins = %00000001 temp = position - analog if temp > da then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa fow1: let pins = %00000010 temp = analog - position if temp > da then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa 'forearm loop2: readadc 2,analog temp = position - 3 if analog < temp then rev2 temp = position + 3 if analog > temp then fow2 counter = counter + 1 let pins = 0 let pinsc = 0 goto loopa rev2: let pinsc = %01000000 temp = position - analog if temp > df then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa fow2: let pinsc = %10000000 temp = analog - position if temp > df then loopa pause pon let pins = 0 let pinsc = 0
19
pause pof goto loopa 'wrist loop3: readadc 3,analog temp = position - 3 if analog < temp then rev3 temp = position + 3 if analog > temp then fow3 counter = counter + 1 let pins = 0 let pinsc = 0 goto loopa rev3: let pinsc = %00010000 temp = position - analog if temp > dr then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa fow3: let pinsc = %00100000 temp = analog - position if temp > dr then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa loop4: goto loopa 'Analogue input 4 does not exist in hardware! 'gripper loop5: readadc 5,analog temp = position - 3 if analog < temp then rev5 temp = position + 3 if analog > temp then for5 counter = counter + 1 let pins = 0 let pinsc = 0 goto loopa rev5: let pins = %00010000 temp = position - analog if temp > dg then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa for5: let pins = %00100000 temp = analog - position if temp > dg then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa 'NOTE: Analogue input 6 is available for use as motor feedback or for general purpose use. loop6: readadc 6,analog temp = position - 3 if analog < temp then rev6 temp = position + 3 if analog > temp then for6 counter = counter + 1 let pins = 0 let pinsc = 0 goto loopa rev6: pins = %01000000 let pinsc = 0 temp = position - analog if temp > da then loopa pause pon let pins = 0 let pinsc = 0
20
pause pof goto loopa for6: pins = %00100000 let pinsc = 0 temp = analog - position if temp > da then loopa pause pon let pins = 0 let pinsc = 0 pause pof goto loopa loop7: 'NOTE: Analogue input 7 is available for general purpose use. ' readadc 7,analog goto loopa loop8: 'need to add code here to wait for switch release. counter = 0 goto loopa loop9: 'NOTE: Resets counter to restart cycle, 'xx' must be last value in lookup table counter = 0 goto loopa
21