You are on page 1of 164

ROBOCON 2008

Workshop
Facilitator: Ober Choo Sui Hong
Cytron Technologies Sdn Bhd
Prepared by Ober Choo
www.cytron.com.my 2
Presentation Outline
Day 1
Preparation
Connector
Power
Motor
Sensor
AR40B
Introduction
Packing list
Board Layout
Power Supply
Driving Motors (tires)
Encoder
Driving Relays
Digital Inputs
Analog Inputs
General Purpose Output
Programmer
Prepared by Ober Choo
www.cytron.com.my 3
Presentation Outline
Day 2
C Programming
C template
Compile and download program
AR40B description
Using AR40B (programming)
Brushless motor (Linix and Vexta)
Brush motor (MD10A and MD30A)
Prepared by Ober Choo
www.cytron.com.my 4
Presentation Outline
Day 3
Using AR40B (programming)
Relays (MD10A and MD30A)
Rotary encoder
Digital Inputs (RGB, FX301, Limit switch)
Analog Inputs (Distance sensor, Ultrasonic)
Constructing a Robocon robot
Assembly robot base, body and mechanism
Sensor position and calibration
Writing program for line following
Prepared by Ober Choo
www.cytron.com.my 5
Presentation Outline
Day 4
Test Run
Line following
Extra Mechanism
Modes selecting
Improvements
Prepared by Ober Choo
www.cytron.com.my 6
Presentation Outline
Day 5
ROBOCON discussion
Game rules and strategies discussion
Robot maintenance and troubleshooting
Test run and training
Motivation
Q & A
Prepared by Ober Choo
www.cytron.com.my 7
ROBOCON Msia and ABU
ROBOCON is an annual robotic competition in J apan for many yearsago, organized by NHK
J apan. Only few country is invited to participate, Indonesia andThailand have joined before
year 2002.
In 2002, ABU decided to organize ROBOCON and invite all countries of ABU to participate.
There will be two level of competition, Domestic and Asia Pacific.
Host country may send two representative teams.
Every year have different theme and rules based on the country culture and organizing
committee.
2002(Reach to Mount Fuji, Malaysia MMU, ABU Vietnam (at J apan).
2003(Takraw Space Conqueror), Malaysia UTM, ABU Thailand (at Thailand).
2004(Reunion of Separated Lover), Malaysia UTM, ABU Vietnam (at Korea).
2005(Climb the Great Wall, Light the Holy Fire), Malaysia - UTM, ABU - J apan (at China).
ROBOCON 2006(Building the worlds Tallest Twin Tower), Malaysia MMU, ABU
Vietnam (at Malaysia).
ROBOCON 2007(Halong Bay Discovery), Malaysia UTM, ABU China (at Vietnam).
ROBOCON 2008 (Govinda), at India
ROBOCON 2002
Theme: REACH FOR THE TOP OF MT FUJ I
Venue: Tokyo, J apan
Dat e: 31st August 2002
ROBOCON 2003
Theme: TAKRAW- SPACE CONQUEROR
Venue: Bangkok, Thai l and
Dat e: 24t h August 2003
ROBOCON 2004
Theme: THE REUNI ON OF SEPERATED LOVER
Venue: Seoul , Kor ea
Dat e: 11t h Sept ember 2004
ROBOCON 2005
Theme: CLI MB THE GREAT WALL, LI GHT
THE HOLY FI RE
Venue: Bei j i ng, Chi na
Dat e: 27t h August 2005
ROBOCON 2006
Theme: BUI LDI NG THE WORLD TALLEST TWI N
TOWER
Venue: Kual a Lumpur , Mal aysi a
Dat e: 11t h Sept ember 2006
ROBOCON 2007
Theme: HALONG BAY DI SCOVERY
Venue: Hanoi , Vi et nam
Dat e: 26t h August 2007
ROBOCON 2008
Theme: Govi nda
Venue: Pune, I ndi a
Dat e: 31
st
August 2008
Total Development
Process (ROBOCON)
Prepared by Ober Choo
www.cytron.com.my 16
Understand Rules, discuss strategies
Auto Machine (MCU) Manual Machine (MCU or logic)
Divide group
Weekly update, debugging,
target and meeting
Stabilizing and training
Register and form a team
Workshop (learn technical knowledge)
Construct Robots, Write Program
Preparation for Competition
Controller, Sensor, Mechanism,
Motor, Wheel, Battery
Funding
Team work
Motivation
Dedication
Strategies
Information
Hardware Preparation
Collect and Prepare all
hardware
Prepared by Ober Choo
www.cytron.com.my 18
Hardware and materials
AR40B + PIC
PS40B + PIC
Vexta brushless motor + Connector
Brush motor + Connector
MDX0A
Battery + Connector + Charged
Rotary Encoder + Connector
FX301 + Connector, Limit Switch + Connector
Prepared by Ober Choo
www.cytron.com.my 19
Vexta control pin
Prepared by Ober Choo
www.cytron.com.my 20
MDX0A control pin
Prepared by Ober Choo
www.cytron.com.my 21
FX301 control pin
Prepared by Ober Choo
www.cytron.com.my 22
Encoder control pin
Auto and Manual
Robot
Prepared by Ober Choo
www.cytron.com.my 24
Auto Robots
One operation to start.
Need a controller to
operate automatically.
Must fit in 1000mm x
1000mm zone.
Combination of
controller, software and
mechanism.
Prepared by Ober Choo
www.cytron.com.my 25
Manual Robot
Operated by human.
Controller box is either
logic or microcontroller.
Must fit in 1000mm x
1000mm zone.
Operator and mechanism
are the most important
element.
Prepared by Ober Choo
www.cytron.com.my 26
Robots Basic Elements
Controller
Sensor
Motor
Battery
Mechanism
Prepared by Ober Choo
www.cytron.com.my 27
Line Following Robot
Motors and wheels (Leg)
Sensors (Eye)
Controller
(Brain)
Mechanism
Battery
Prepared by Ober Choo
www.cytron.com.my 28
Controller
Control a robot. Mostly automatic robot, manual robot may
have controller to control simple routine work.
Controller boards: (not limited to)
Handy Board
Basic Stamp
CytronsAR40B
Computer Embedded PC, PC or Laptop
Microcontroller: (not limited to)
PIC from Microchip
6811 from Motorola
AVR, AT89C2051 from Atmel
Must be light weight, low powered, easy to develop, easy
to learn and easy to get (availability).
Prepared by Ober Choo
www.cytron.com.my 29
Controller
Prepared by Ober Choo
www.cytron.com.my 30
Simple factors
A system will need at least a minimum hardware to work.
In this case, it involved electronics interface.
There are 4 important points to take care:
Voltage
Maximum or Minimum of operating
Analog or Digital
Current
Maximum or Minimum of operating (motor)
Polarity
Positive and Negative
Short circuit
Clearance of your circuit
It seem simple, but these are the famous factors for those circuit that cannot
works
PIC Microcontroller
The Brain of AR40B
Prepared by Ober Choo
www.cytron.com.my 32
PIC MCU from Microchip
PIC is designed by Microchip
More than 100 types of PIC MCU, dsPIC,
EEPROMs, battery charger, radio component.
Provide total solution in term of hardware,
software and tools.
Development tools include:
MPLAB IDE
Programmer
C compiler
Debugger
App Notes
.
Why PIC MCU?
Peripheral Interface Controller
Prepared by Ober Choo
www.cytron.com.my 34
Why PIC MCU?
Low cost, from RM15-RM60.
Easy to get, you can order from Cytron, Farnell, RS and even
electronics store.
Less instructions.
PDIP Packaging.
MPLAB, WinPIC, C compiler, Assembler and many software
is distributed as freeware.
Plenty of free project and sources code from Internet.
Easy to load program.
large program memory space.
Low cost programmer, Bootloader and Startup Kit are
available in market.
Prepared by Ober Choo
www.cytron.com.my 35
PIC16F877A
40 pins package (PDIP).
35 instructions.
External clock is required, maximum crystal speed is 20MHz,
Time for 1 instruction =200ns (Crystal=20MHz)
8,092 14bit FLASHprogram memory, can be reprogrammed for
more than 1,000 times.
You can write 8092 lines of assembly codes.
368 8bit data memory or registers (File registers).
Interrupt capability.
33 GPIO.
Other peripherals: 8 channel 10bit ADC, USART/I2C/SPI, 16
bits & 8 bits timers/counter, PWM, Compare and Capture.
Features: ICSP-In Circuit Serial Programming.
Note: Refer to Data Sheet
Prepared by Ober Choo
www.cytron.com.my 36
PIC16F877A
PIC16F87XA datasheet pg.5
Prepared by Ober Choo
www.cytron.com.my 37
PIC16F877As Peripherals
Different PICshave different on-board
peripherals
PIC16F877A common peripherals are:
Digital I/O pins.
Analog to Digital Converters (ADC) (10bit).
Serial communications: UART (RS-232), SPI, I
2
C.
Pulse Width Modulation (PWM) (10bit).
Timers and counters (8 and 16bit).
Watchdog timers, Brown out detect.
Prepared by Ober Choo
www.cytron.com.my 38
16F877A Pins
Diagram
Prepared by Ober Choo
www.cytron.com.my 39
Ports (Digital I/O)
40 pins 16F877A has 5 Ports with 33 digital I/O pins.
Every port has 2 control registers
TRISxsets whether each pin is an input or output.
PORTxsets their output bit levels or hold input status.
Most pins have 25mA source/sink (directly drives LEDs)
What is source/sink?
WARNING: Other peripherals SHARE pins!
Example: Port A share digital I/O with Analog input
Applications:
Inputs: Digital sensor, push button (keyboard)
Outputs: LED, Buzzer, motor driver, LCD.
Note: Refer to Data Sheet
Prepared by Ober Choo
www.cytron.com.my 40
TRISx and PORTx
Prepared by Ober Choo
www.cytron.com.my 41
16F877As ADCs
Prepared by Ober Choo
www.cytron.com.my 42
ADCs
Analog Digital Converter (ADC).
Store Analog voltage in digital value.
ADC can operate during sleep mode. (internal RC clock)
10bit
What does 10bit means?
Can generate an interrupt on ADC conversion done.
Page 126.
Applications:
Audio volume control, temperature sensor, position sensor, ECG signal
Prepared by Ober Choo
www.cytron.com.my 43
16F877As CCP
Prepared by Ober Choo
www.cytron.com.my 44
CCP Modules
Capture/Compare/PWM (CCP).
10bit PWM (Pulse Width Modulation) width within 8bit PWM
period (frequency).
Some time PWM is used to give external speed for DC
brushless motor.
Normally is used to control speed of DC motor.
Applications:
DAC (Digital to Analog Converter)
Control speed of motor using PWM
Generate frequency pulse for stepper motor.
Prepared by Ober Choo
www.cytron.com.my 45
PWM on PIC
Registers involved:
PR2 register: PWM period
CCPR1L and CCP1CON<5:4>:
10-bit duty cycle
Basic operation:
Start of period
Timer TMR2 cleared
CCP1 pin set to high
10-bit duty cycle latched to
CCPR1H
When TMR2 =CCPR1H
Clear CCP1 (duty cycle over)
When TMR2 =PR2
New period starts
Prepared by Ober Choo
www.cytron.com.my 46
CCP1CON Register
Prepared by Ober Choo
www.cytron.com.my 47
16F877As Timer
Prepared by Ober Choo
www.cytron.com.my 48
Timers
Available in all PICs.
May generate interrupts on timer overflow.
Some 8bit, some 16bit, some have prescalers.
Can use external pins as clock in/clock out
(Counting encoder motor feedback).
Warning: some peripherals share Timer resources
PWM share Timer 2 in 16F877A.
Applications:
Encoder feedback from motor.
Prepared by Ober Choo
www.cytron.com.my 49
PIC16F877A Interrupt
Batteries
Prepared by Ober Choo
www.cytron.com.my 51
Batteries
There are various type of battery available in the
market.
Depending on the application, we try to balance
up the weight and current needed.
The higher current capacities, the heavier battery.
Prepared by Ober Choo
www.cytron.com.my 52
Sealed Lead Acid
Following are some examples of SLA:
12V 12Ah
12V 7Ah
6V 4Ah
We can simply charge SLA with ordinary power supply
Prepared by Ober Choo
www.cytron.com.my 53
Sealed Lead Acid
SLA batteries provide high current capacity, is the best
for high current application.
It also have low self discharge rate(5% per month),
therefore it is best for long storage device such as UPS.
No memory effect.
Drawbacks: Heavy, charge cycle is around 300 times.
Suitable for high current application if weight is not a
problem: power window and starter motor.
Prepared by Ober Choo
www.cytron.com.my 54
Lithium ion Polymer (LiPo)
Prepared by Ober Choo
www.cytron.com.my 55
Lithium ion Polymer (LiPo)
Each pack is 11.1V.
Come with different capacity (800mAh, 1800mAh)
No memory effect.
Advantages:
Lighter than NiMH
higher current capacities
Higher discharging rate
Drawbacks:
require special charger
Hazardous (will exploded if in-correct charging)
Suitable for high current application.
Prepared by Ober Choo
www.cytron.com.my 56
Precautions
Never connect both terminal of battery together. It
will spoil the battery.
Be careful when using or charging LiPobattery.
Lets see video of Lipoovercharge.
Q & A
Batteries
Programming
MPLAB
PICC Lite
MICROCHIP MPLAB IDE
Installation of MPLAB IDE
PICC Lite
Prepared by Ober Choo
www.cytron.com.my 61
What is MPLAB IDE?
MPLAB is a Integrated Development
Environment which combines the source code
editor, assembler/compiler, linker, simulator
and debugger for PIC microcontroller.
We use MPLAB IDE to write the source code
and assemble/compile it into the machine
code (hex file).
Prepared by Ober Choo
www.cytron.com.my 62
How to use MPLAB IDE?
1. Install and run the MPLAB IDE, you can see the
screen as below.
Prepared by Ober Choo
www.cytron.com.my 63
How to use MPLAB IDE?
1. Since we are using PICC Lite, please refer to
another file for PICC Lite
PICC Lite
MPLAB IDE & PICC Lite
Any Question???
If no, we will proceed with
Assembly Language and real
programming
AR40B
Autonomous Robot
Controller
Prepared by Ober Choo
www.cytron.com.my 66
AR40B
Enhanced version of AR40A.
Utilize all 33 I/O pins of PIC.
Industrial grade PCB with heavy copper material.
On board USB programmer.
ZIF (Zero Insert Force) socket for ease of changing PIC.
Fully compatible for 40 pins PIC such as PIC16F877A or PIC18F452.
8 relays output with maximum current allowed up to 10 Amp to control
4 motors in 2 directions.
External port for 30 Amp motor driver (MD30A).
Able to drive Oriental AXH series and LINIX series of brushless motor.
Up to 8 digital inputs and 3 analog inputs which can be connected to
various kinds of sensors and switches.
3 input push button.
15mm x 25mmexpandable zone is prepared for additional circuit and
advance application.
Prepared by Ober Choo
www.cytron.com.my 67
AR40B
Prepared by Ober Choo
www.cytron.com.my 68
AR40B
Going through AR40B Instruction Manual
Power
Driving motors
Relays
Rotary Encoder
Digital Inputs
Analog Inputs
Programmer
Prepared by Ober Choo
www.cytron.com.my 69
AR40Bs
Pin Assignments
Practical +
Assignments
Using AR40B
Prepared by Ober Choo
www.cytron.com.my 71
Assignments
Before we can operate AR40B, we must
ensure it is properly connected and
powered up.
Connect necessary components to
operate AR40B.
Try to connect power for motor, connect
a brushed motor, try to operate motor
with relay.
Prepared by Ober Choo
www.cytron.com.my 72
Demonstrations
Instruction manual of AR40B
Write an LED blinking program.
Modify the source code from template
file inside CD.
Compile it and load it.
Test it.
Loading Program
On Board Programmer
Programming of Robots
components
Controlling Brushless Motor
Controlling Brush Motor
Assignments
Motors
Main driver for robot
mechanism
Prepared by Ober Choo
www.cytron.com.my 76
AR40B - Two methods (Tires)
Either Brush motor + MDX0A
Or Brushless Motor (Vextaor Linix)
Prepared by Ober Choo
www.cytron.com.my 77
Motors
DC brush, DC brushless, Servo, Stepper.
Prepared by Ober Choo
www.cytron.com.my 78
Using Brushless Motor
Prepared by Ober Choo
www.cytron.com.my 79
Vexta Brushless Motor
Simple interface(logic 0V or 5V), speed output,
driver protection, variable speedand variable gear
ratio.
Each set included motor, gear, driver and manual.
3 types of power, 50W, 30Wand 15W.
Around RM1+++.00 each set.
Weight: 50W=1.8kg, 30W=1.0kg, 15W=0.5kg
Maximum speed of motor = 3000 rpm
24V
Prepared by Ober Choo
www.cytron.com.my 80
Oriental DC Brushless Motor
Motor Driver
Motor
Gear Head
Prepared by Ober Choo
www.cytron.com.my 81
Oriental DC Brushless Motor
Motor Drivers
pins
Prepared by Ober Choo
www.cytron.com.my 82
DC brushless Control
START, RUN, CWand INT.VR are the 4 driver
inputs that we normally control.
It can be control with direct connection to PIC
output pins (logic-5V or 0V) or switches(manual
machine).
Note: No pull-up resistor is required.
Prepared by Ober Choo
www.cytron.com.my 83
DC Brushless Inputs
Prepared by Ober Choo
www.cytron.com.my 84
DC Brushless with Switches
Prepared by Ober Choo
www.cytron.com.my 85
DC Brushless with uC
Prepared by Ober Choo
www.cytron.com.my 86
DC Brushless Outputs
There are 2 outputs from DC Brushless Driver
which can be connected to PIC for feedback
(close loop control).
Alarm Output (Pin 1) and Speed Output (Pin 2).
Output drain Pull-up resistor is required.
Note: Be careful with pull-up resistor, it should
be > 5K.
Prepared by Ober Choo
www.cytron.com.my 87
DC Brushless
Outputs Connection
5V
5K-10K
Alarm Output
Speed Output
Motor Driver
Counter or
Digital Inputs
Microcontroller
Prepared by Ober Choo
www.cytron.com.my 88
DC Brushless
Motor Speed (Internal)
There are 2 options for motor speed, internal variable
resistor voltageor external voltage.
If internal speed is required, the INT.VR (Pin 8) must be
pulled low.
Prepared by Ober Choo
www.cytron.com.my 89
DC Brushless
Motor Speed (External)
External speed maybe applied if the INT. VR
is high (5V).
The are 2 ways, either by connecting a external
variable resistor or connect an external DC
power supply.
Prepared by Ober Choo
www.cytron.com.my 90
DC Brushless
Motor Speed (External)
Prepared by Ober Choo
www.cytron.com.my 91
DC Brushless
Motor Speed (External)
Prepared by Ober Choo
www.cytron.com.my 92
DC Brushless
Motor Speed (External)
It could also be PWM (Pulse Width Modulation)
with a simple resistor.
1K
uC
Motor
Driver
VRM (Pin 5)
PWM
+
22uF
-
Prepared by Ober Choo
www.cytron.com.my 93
DC Brushless
Gear and Torque
Prepared by Ober Choo
www.cytron.com.my 94
DC Brushless
Driver Protection
1. Overload
2. Overvoltage15% > 24V = 27.6V
3. Out-of-Phase, disconnection of cable.
4. Undervoltage25% < 24V = 18V.
5. Overspeed> 3,500 rpm
LED will be blinking when Protection is activated and motor will be stopped.
Prepared by Ober Choo
www.cytron.com.my 95
DC Brushed Motor
Prepared by Ober Choo
www.cytron.com.my 96
Using MDX0A
with Brush motor
Prepared by Ober Choo
www.cytron.com.my 97
MD10A
Gnd
PWM
CW
RUN
12V
battery
Motor
Prepared by Ober Choo
www.cytron.com.my 98
MD30A
Prepared by Ober Choo
www.cytron.com.my 99
MD30A
Prepared by Ober Choo
www.cytron.com.my 100
Using MDX0A
with Brush motor
The program is a bit different between brush
motor and brushless motor.
Lets look at the example.
Prepared by Ober Choo
www.cytron.com.my 101
AR40B
Controlling Driving Motors
Group 1 Switch 1 to activate left motor, switch 2 to
activate right motor, switch 3 to stop both motor.
Group 2 Switch 1 to activate left motor with
minimum speed, switch 2 to increase speed, switch 3
to decrease speed
Group 3 Switch 1 to activate 2 motors, switch 2 to
change direction (forward), switch 3 to change
direction (backward)
Group 4 Switch 1 to activate 2 motors, switch 2 to
change direction (turn left), switch 3 to change
direction (turn right).
Day 2 - Completed
We continue tomorrow morning
sharp at 9.00 am
Day 3
Relays
Rotary Encoder
Digital Inputs
Analog Inputs
Prepared by Ober Choo
www.cytron.com.my 104
Driving brush
motors for mechanism
Relays
MD10A
MD30A
Prepared by Ober Choo
www.cytron.com.my 105
Relays
Allow high current application, can be a switch.
Various combination (poles and throws), various
activation voltage (5V, 6V, 9V, 12V, 24V),
various size, various price..
Can be applied on logic circuit (without uC,
manual controller box).
Control motor direction, but not speed.
Prepared by Ober Choo
www.cytron.com.my 106
Relays
Single Pole Double Throw
Single Pole Single Throw
Prepared by Ober Choo
www.cytron.com.my 107
Relays
Bottom view
Double Pole Double Throw Single Pole, Double Throw
DPDT SPDT
Prepared by Ober Choo
www.cytron.com.my 108
How to control
motor with Relays
1 SPDT relay could only control 1 motor for ON
or OFF.
How about bi-directional control of motor?
Must use at least 2 SPDT relays.
Prepared by Ober Choo
www.cytron.com.my 109
Schematic of
Relays Control Motor
Q & A
Motors
Prepared by Ober Choo
www.cytron.com.my 111
Assignments
Brushless motor activation with switch
Brushless motor activation from sensor
Brushless motor speed change with switch
Brushless motor direction with switch
DC brush motor with switch
DC brush motor with sensor
Using MDX0A
Encoder
Rotary encoder
Prepared by Ober Choo
www.cytron.com.my 113
Rotary Encoder
Prepared by Ober Choo
www.cytron.com.my 114
Rotary Encoder
Simple interface(3 pins), 5V to24V, 500 pulse per
rotation, open drain output (must pull-upand can be
any voltage).
5V to 24V
Gnd
Signal
Prepared by Ober Choo
www.cytron.com.my 115
Rotary Encoder
AR40B provide option to use internal encoder from
DC brushless driver or external rotary encoder.
Connected to RA4 and RC0 of PIC.
Use counter (timer0 and timer1) to accumulate the
pulse.
Calculate robot distance.
Prepared by Ober Choo
www.cytron.com.my 116
Rotary Encoder
Connecting rotary encoder to AR40B.
Please move the jumper to EXx.
Prepared by Ober Choo
www.cytron.com.my 117
AR40B - Assignment
Group 1 & 2 Switch 1 to activate robot, stop
robot when encoder 2 reach 500 pulse (equal to
1 rotation)
Group 3 & 4 Switch 1 to activate robot,
activate MOTOR1 if encoder 1 reach 750 pulse
Extra Using encoder from Vextabrushless
motor
Making interrupt for encoder
Digital Inputs
limit switch, photoelectric
sensor, fiber optic sensor, RGB
Prepared by Ober Choo
www.cytron.com.my 119
Sensor
Use to sense environment of robot and as input for controller to make
decision.
Switches
Limit switch
Push button
Detect object with touch
Example: wall, gift(2004), pole(2005), block (2006), island (2007)..
Proximity sensor
CX-422 from SUNX
FX-301 from SUNX
Detect object with a distance without touching
Can be used to detect color, line tracking, and also object.
There are other type of sensor, for example: camera.
However we must consider the ease to operate, ease to interface and
availability.
Prepared by Ober Choo
www.cytron.com.my 120
Limit switch
Normally Close
Normally Open
Common
Prepared by Ober Choo
www.cytron.com.my 121
Photoelectric and
fiber optic Sensors
Prepared by Ober Choo
www.cytron.com.my 122
SUNX CX-422 Infrared Sensor
Simple interface(3 pins), 12V to 24V, 80cm
distance, open drain output (must pull-upand can be
any voltage).
Is only logic level, therefore no filter required.
Prepared by Ober Choo
www.cytron.com.my 123
SUNX CX-422
Photoelectric Sensor
Can be changed to active highor active lowoperation.
Adjustable sensing distance.
Prepared by Ober Choo
www.cytron.com.my 124
FX-301
Simple interface(3 pins), 10V to30V, 2m distance, open drain
output (must pull-upand can be any voltage).
Is only logic level, therefore no filter required.
Prepared by Ober Choo
www.cytron.com.my 125
FX-301
Prepared by Ober Choo
www.cytron.com.my 126
FX-301
Calibration is very important if FX-301 is used
Basic calibration will involve mounting of sensor,
threshold setting and testing
Lets see how can we calibrate it
Prepared by Ober Choo
www.cytron.com.my 127
Keyence CZ-V21
Complex interface(8 pins), 24V, 70mm distance, open
drain output (must pull-upand can be any voltage).
Is only logic level, therefore no filter required.
Prepared by Ober Choo
www.cytron.com.my 128
AR40B - Assignment
Group 1 Switch 1 to activate MOTOR1, SEN1 to
Change direction, SEN2 to stop MOTOR1.
Group 2 Switch 1 to activate MOTOR2, SEN3 to
stop MOTOR2, SEN4 to activate MOTOR3.
Group 3 Switch 1 to activate MOTOR1 and
MOTOR2, SEN5 to change direction of MOTOR1,
SEN6 to activate MOTOR3.
Group 4 Switch 1 to activate ALL MOTOR, SEN7
to stop MOTOR1 and 2, also change direction of
MOTOR3 and 4, SEN8 to stop all MOTOR.
Prepared by Ober Choo
www.cytron.com.my 129
How about ADC?
AR40B offers 3 analog inputs
Where can it be used?
How to use it?
Prepared by Ober Choo
www.cytron.com.my 130
Using distance sensor
Sharp offer cheap and good distance sensor
There are several models
Sharp GP2D120 (4cm to 30cm)
Analog output
4.5 to 5V operating voltage
Prepared by Ober Choo
www.cytron.com.my 131
Connecting to AR40B
Important is voltage and correct pin.
Since is 5V powered, just match the pin.
AR40B Analog input
+
S
-
Prepared by Ober Choo
www.cytron.com.my 132
GP2D120
0.4V at 30cm
2.8V at 4cm
Lets Try
Convert ADC to distance (cm)
Prepared by Ober Choo
www.cytron.com.my 134
Using Ultrasonic
42kHz Ultrasonic sensor
Operates from 2.5-5.5V
Low 2mA supply current
20Hz reading rate
RS232 Serial Output - 9600bps
Analog Output - 10mV/inch
PWM Output - 147uS/inch
Small, light weight module
Prepared by Ober Choo
www.cytron.com.my 135
Connecting to AR40B
AR40B Analog input
+
S
-
Lets Try
Convert ADC to distance (inch)
Prepared by Ober Choo
www.cytron.com.my 137
AR40B - Assignment
Group 1 Switch 1 to activate robot, ADC1 to change the
speed.
Group 2 Switch 1 to activate MOTOR1,
If ADC2 >2.6V, CW
If ADC2 <2.4V, CCW
If 2.4V <ADC2<2.6V, no change
Group 3:
If ADC3 >=4.0V, stop all motor
If ADC3 <4.0V, activate MOTOR1 and MOTOR2
Group 4 Switch 1 to activate LED blink base on ADC1.
Q & A
Sensors
Day 3 - Completed
We continue tomorrow morning
sharp at 9.00 am
Day 4
Line Following Robot
Sensor calibration
Write program
Prepared by Ober Choo
www.cytron.com.my 141
Combining all components
Use AR40B to write program:
Limit switch to start Brush motor
Increased Brushless Motors speed slowly (time)
Increased Brushless Motors speed base on ADC
Change Brush Motor direction based on Limit switch
Infrared sensor to stop Brush motor
Encoder to stop Brushless motor
Counter to stop DC brushless motor
Extra: Pivot robot with limit switch status
Prepared by Ober Choo
www.cytron.com.my 142
Constructing a Robot
1. Assembly robot base, body and mechanism.
2. Sensor position and calibration
3. Robot testing and fine tuning
Prepared by Ober Choo
www.cytron.com.my 143
How to start?
1. Determine what is the task of robot (Auto or Manual?)
2. Search and collect the necessary components (Sensor,
Motor, battery,.)
3. Construct a base for robot, connect existing component to
AR40A board.
4. Reading sensor, control motor, calibrate sensor, verifying
motor speed, and trial run
5. Adjusting sensor and motor position
6. Debugging (software or hardware?)
7. Training. Training and more training.
Prepared by Ober Choo
www.cytron.com.my 144
Line following algorithm
Line following is important in ROBOCON.
Try to write a program to simulate line
following.
Prepared by Ober Choo
www.cytron.com.my 145
Line Following Robot
Motors and wheels (Leg)
Sensors (Eye)
Controller
(Brain)
Mechanism
Battery
How to integrate all the components
together ; the controller, actuator and
sensors?
Prepared by Ober Choo
www.cytron.com.my 146
Line Following Robot
Sensors
Left or Middle or Right
sensor triggered
Controller
Algorithm process the
Inputs / sensors reading
Actuators
Move direction based
on algorithm written
Prepared by Ober Choo
www.cytron.com.my 147
Line Following Robot
Flow chart for 3 line sensors
Start
Middle
Sensors?
Turn
Left
Yes
Right
Sensors?
No
Left
Sensors?
No
No
Error
End
Turn
Right
Yes
Moving
Forward
Yes
Assignment!
Write simple code for line
following!
Prepared by Ober Choo
www.cytron.com.my 149
Line Following Improvement
Averaging sensor reading
Counting cross
Apply PD control
Combining encoder
Prepared by Ober Choo
www.cytron.com.my 150
Mechanism
Require mechanical design.
You are free to design, be creative!
Pneumatic
Motor actuators
Momentum
Spring and rubbers
Reliability
Dont stop improving your design and testing.
Learn! Renovate! Improve! But dont copyfrom the others
design!
Prepared by Ober Choo
www.cytron.com.my 151
Modes
You can write program for several modes
By using push button
Write program for team A and team B
Improvements
Prepared by Ober Choo
www.cytron.com.my 153
Improvements
Simplify your mechanisms and materials
Do simple program and increase
functionality step by step (save version)
Always have group discussion to improve:
Mechanism
Program
Strategy
Training
Day 4 - Completed
We continue tomorrow morning
sharp at 9.00 am
Day 5
ROBOCON 2008 discussion
Robot Maintenance and Troubleshooting
Training
Motivation
ROBOCON 2008 Discussion
Prepared by Ober Choo
www.cytron.com.my 157
ROBOCON 2008
Game Rules must be very familiar and understand
correctly.
Read and understand FAQ
Ask organizer if you have any doubt
Game strategies
Be creative and dare to try
Example, J apan, China, Malaysia and Vietnam.
Task distribution and weekly meeting (short and serious).
Collect information (technical and strategies).
Plan budget wisely.
Training, Training and Training.
Prepared by Ober Choo
www.cytron.com.my 158
Robot Maintenance
and Troubleshooting
Prepared by Ober Choo
www.cytron.com.my 159
Robot Maintenance
and Troubleshooting
Take care your robot like your precious.
Create a check list for your robot.
Possible reasons for non working robot:
Power supply
Hardware Interfacing
Software Algorithm
Components failure (PIC, motor, relays, sensor
etc)
Prepared by Ober Choo
www.cytron.com.my 160
Test Run and Training
Prepared by Ober Choo
www.cytron.com.my 161
Motivation
Prepared by Ober Choo
www.cytron.com.my 162
Objective and Mission
Give your commitment to ROBOCON.
Dont stop improving your robots.
No excuses.
Show that we love Malaysia and do our best to
show other countries we are a strong country.
Thank You
Q & A
Please!
Problem/s cannot be solved?
Contact Cytron Technologies at:
support@cytron.com.my
Or
Log in to our forum at
www.cytron.com.my

You might also like