entertainment robot fun dog2

Upload: madonnite3781

Post on 02-Jun-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Entertainment Robot Fun Dog2

    1/78

    PSZ 19:16 (Pind. 1/97)

    UNIVERSITI TEKNOLOGI MALAYSIA

    BORANG PENGESAHAN STATUS TESIS

    JUDUL: ENTERTAINMENT ROBOT FUN DOG

    SESI PENGAJIAN: 2007/2008

    Saya SAW LEAN JUN

    (HURUF BESAR)

    mengaku membenarkan tesis (PSM/Sarjana/Doktor Falsafah)* ini disimpan di Perpustakaan

    Universiti Teknologi Malaysia dengan syarat-syarat kegunaan seperti berikut:

    1. Tesis adalah hakmilik Universiti Teknologi Malaysia.

    2. Perpustakaan Universiti Teknologi Malaysia dibenarkan membuat salinan untuk tujuan

    pengajian sahaja.

    3. Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara

    institusi pengajian tinggi.

    4. **Sila tandakan ( 4 )

    Disahkan oleh

    (TANDATANGAN PENULIS) (TANDATANGAN PENYELIA)

    Alamat Tetap:292 TAMAN DAMAI

    06400 POKOK SENA

    KEDAH Nama Penyelia

    Tarikh: 7 MAY 2008 Tarikh: 7 MAY 2008

    CATATAN: * Potong yang tidak berkenaan.

    ** Jika tesis ini SULIT atau TERHAD, sila lampirkan surat daripada pihak

    berkuasa/organisasi berkenaan dengan menyatakan sekali sebab dan

    tempoh tesis ini perlu dikelaskan sebagai SULIT atau TERHAD. Tesis dimaksudkan sebagai tesis bagi Ijazah Doktor Falsafah dan Sarjana secara

    penyelidikan, atau disertasi bagi pengajian secara kerja kursus dan penyelidikan,

    atau Laporan Projek Sarjana Muda (PSM).

    SULIT (Mengandungi maklumat yang berdarjah keselamatan atau

    kepentingan Malaysia seperti yang termaktub di dalam

    AKTA RAHSIA RASMI 1972)

    TERHAD (Mengandungi maklumat TERHAD yang telah ditentukanoleh organisasi/badan di mana penyelidikan dijalankan)

    TIDAK TERHAD

    ASSOC. PROF. DR. MOHAMAD NOH BIN AHMAD

  • 8/10/2019 Entertainment Robot Fun Dog2

    2/78

  • 8/10/2019 Entertainment Robot Fun Dog2

    3/78

    ENTERTAINMENT ROBOT

    FUN DOG

    SAW LEAN JUN

    Project Report Submitted as Partial Fulfillment

    Of the Requirement for theDegree in Bachelor of Electrical Engineering

    FACULTY OF ELECTRICAL ENGINEERING

    UNIVERSITI TEKNOLOGI MALAYSIA

    MAY 2008

  • 8/10/2019 Entertainment Robot Fun Dog2

    4/78

    i

    DECLARATION

    I declare that this work as the product of my own effort with the exception of expertscited from other works of which the sources were duly noted

    Signature : .Authors Name : SAW LEAN JUN

    Date : 7 MAY 2008

  • 8/10/2019 Entertainment Robot Fun Dog2

    5/78

    ii

    DEDICATION

    Specially to my beloved

    parents, siblings and friends

    for their external support, encouragement

    and inspiration throughout

    my journey of education.

  • 8/10/2019 Entertainment Robot Fun Dog2

    6/78

    iii

    ACKNOWLEDGEMENT

    Primarily, I would like to express my deepest gratitude to my project supervisor,

    Assoc. Prof Dr. Mohamad Noh Bin Ahmad for the guidance and enthusiasm given

    throughout the progress of this project. It would be have difficult to complete the project

    without his guidance.

    My appreciation also goes to my family who has been so tolerant and supports

    me throughout my academic years. Thanks for their encouragement, love, understanding

    and eternally moral supports that they had given to me.

    I would also like to thank our FKE lab assistant, for their co-operations and helps

    in this project.

    On the other hand, my great appreciation dedicated to my friends SEM members

    batch 2004 and those who involve directly or indirectly with this project. Thank you for

    giving me a technical advice and idea to enhance my project. I also give the greatest

    thanks and honors for those that had supported me so far.

  • 8/10/2019 Entertainment Robot Fun Dog2

    7/78

    iv

    ABSTRACT

    Entertainment robot had been a very common topic and interesting engineering

    field today. Many research had been conducted by university to understand the

    technology and the building of robots that would entertain the humans. This project

    involves the development of a 4-legged autonomous quadruped pet robot. There are a

    number of obvious advantages that robot pets have over the pets real. They do not need

    exercising or large yards in which to be kept and also the owner programs the pet robot

    to what behavior they like. The primary inspiration to this project is the Sony AIBO

    companion robot dog. The aim of this project is to design and build an autonomous

    quadruped biologically inspired robot, Fun Dog. It will be programmed to run and walk

    by itself without any external aid from human. The robot will be able to perform some

    basic movement of a dog such as sitting down, squatting down, standing up and nodding

    the head. Furthermore, the robotwill also be able to posses some like making noises and

    barking like the real puppy. Lastly, the robot has the ability of obstacle avoidance where

    it will try to avoid collision for objects that comes on its way.

  • 8/10/2019 Entertainment Robot Fun Dog2

    8/78

    v

    ABSTRAK

    Mencipta robot yang memimikkan bentuk dan kelakuan haiwan dalam bidang

    kejuruteraan telah menjadi salah satu objektif yang sangat digemari oleh ramai ahli

    saintis. Penyelidikan pada pergerakan haiwan ini merupaka satu topic yang agak umum

    dalam bidang memimik kelakuan haiwan. Ramai penyelidik daripada universiti terkenal

    telah pun membuat kajian dalam bidang penyelidikan tersebut. Dalam projek ini,

    penyelidikan adalah mengenai pergerakan robot berkaki empat dimana robot tersebut

    akan memimik pergerakan dan kelakuan seekor anjing. Ilham utama dalam mencipta

    robot ini adalah daripada robot SONY yang bernama AIBO. Tujuan utama projek iniuntuk membina satu robot autonomi yang berkaki empat dimana akan memimik

    perlakuan anjing dengan nama Fun Dog. Ia akan diprogram untuk berjalan secara sendiri

    tanpa dikawal oleh alatan luaran. Ia juga berupaya untuk memimik perlakuan anjing

    seperti duduk, berdiri dan mengangguk kepala. Tambahan pula, robot anjing ini akan

    berupaya memaparkan pelbagai emosi dengan pertunjukkan LED. Robot ini juga

    diprogram untuk berbunyi seperti anjing yang sebenar. Akhirnya, robot ini berupaya

    untuk mengelak diri daripada berlaku perlanggaran semasa bergerak.

  • 8/10/2019 Entertainment Robot Fun Dog2

    9/78

    vi

    TABLE OF CONTENT

    CHAPTER TITLE PAGE

    DECLARATION i

    DEDICATION ii

    ACKNOWLEDGEMENTS iii

    ABSTRACT iv

    ABSTRAK v

    TABLE OF CONTENT vi

    LIST OF FIGURES ix

    LIST OF TABLESxi

    LIST OF ABBREVIATIONS xii

    LIST OF APPENDICES xiii

    CHAPTER 1 INTRODUCTION

    1.1 Background of project 1

    1.2 Objective of Project 2

    1.3 Scope of Project 3

    1.4 Summary of Works 3

    1.5 Outline of Thesis 4

    CHAPTER 2 LITERATURE REVIEW

    2.1 The Aibo Robot 5

    2.2 Sega idog Robot Puppy 7

    2.3 The RoboScience RS-01 Robot Dog 8

  • 8/10/2019 Entertainment Robot Fun Dog2

    10/78

    vii

    2.4 I-Cybie 9

    2.5 Puppy Robot II 10

    2.6 Summary 10

    CHAPTER 3 METHODOLOGY

    3.1 Components Selection 11

    3.2 Servo Motor 11

    3.3 Infrared Sensor 12

    3.4 Power Supply 13

    3.5 Comparator (LM324) 143.6 Chipcorder Voice IC 14

    3.7 Microcontroller 15

    3.8 Algorithm and Programming in MPLAB IDE 16

    3.9 Summary 17

    CHAPTER 4 MECHANICAL STRUCTURE DESIGN

    4.1 General Robot Structure 18

    4.2 Leg Design of Robot 19

    4.3 Head Design of Robot 20

    4.4 Summary 20

    CHAPTER 5 ELECTRONIC CIRCUIT DESIGN

    5.1 General Introduction of Circuitry System 21

    5.2 Main Circuitry System 22

    5.2.1 Microcontroller Unit (MCU) 24

    5.2.2 Voltage Regulator Circuitry 24

    5.3 ChipCorder Circuitry 25

    5.4 Infra Red Sensor Circuitry 27

    5.5 Bootloader Circuitry 28

    5.6 Summary 28

  • 8/10/2019 Entertainment Robot Fun Dog2

    11/78

    viii

    CHAPTER 6 ACHIEVEMENT AND EXPERIMENTAL RESULT

    6.1 Galloping gaits 29

    6.1.1 Forward Motion 30

    6.1.2 Turning Right and Left Motion 30

    6.2 Physical Movement Abilities 31

    6.3 Obstacle Avoidance Mode 32

    6.4 Voice Ability - Barking and Making Noises 33

    6.5 Emotion Display 34

    6.6 Summary 34

    CHAPTER 7 CONCLUSION AND FUTURE WORK

    7.1 Conclusion 35

    7.2 Future Work 36

    REFERENCES 37

    APPENDIX A 38

  • 8/10/2019 Entertainment Robot Fun Dog2

    12/78

    ix

    LIST OF FIGURES

    FIGURE TITLE PAGE

    2.1 Front view for Aibo ERS7. 7

    2.2 Rear view for Aibo ERS7. 7

    2.3 The Sega idog Robot Puppy 82.4 The hardware of the RoboScience RS-01 Robot Dog 9

    2.5 The hardware of I-Cybie Robot by Tiger Electronics 9

    2.6 The hardware of Puppy Robot II 10

    3.1 The servomotor hardware of Futaba 3003 12

    3.2 The hardware of IR sensor 13

    3.3 Lithium Polymer rechargeable battery by the Poly-Quest. 13

    3.4 LM 324 14

    3.5 ISD2560 Chipcorder voice IC 14

    3.6 Microcontroller PIC18F452 15

    3.7 The pin diagram of PIC18F452 16

    3.8 The program data flowchart. 17

    4.1 The initial prototype of Fun Dog. 19

    4.2 Double screws are connects both the links together on

    Fun Dogs front leg. 19

  • 8/10/2019 Entertainment Robot Fun Dog2

    13/78

    x

    4.3 The head design of Fun Dog. 20

    5.1 The Fun Dogmain circuitry design in PCB. 22

    5.2 The schematic of main circuitry Fun Dog 23

    5.3 The Voltage Regulator Circuitry 26

    5.4 The ISD2560 ChipCorder circuitry 26

    5.5 The schematic of IR sensor circuitry. 27

    5.6 The schematic of boat loader circuitry. 28

    6.1 The real dog (left) and Fun Dog(right) in squatting

    down position. 31

    6.2 The real dog (left) and Fun Dog(right) in sitting position. 336.3 The real dog (left) and Fun Dog(right) in standing position. 33

    6.4 IR sensors placement in left, right, and centre position. 33

    7.1 The marketable robotics pet (from left) Sony AIBO,

    Sega Idog, Tekno-Robot and Fun Dog. 36

  • 8/10/2019 Entertainment Robot Fun Dog2

    14/78

    xi

    LIST OF TABLES

    TABLE TITLE PAGE

    1.1 Gantt chart of the project schedule for semester 1 3

    1.2 Gantt chart of the project schedule for semester 2 4

    5.1 Alternate functionality in pins 26

  • 8/10/2019 Entertainment Robot Fun Dog2

    15/78

    xii

    LIST OF ABBREVIATIONS

    CD - Compact Disc

    DC - Direct Current

    IC - Integrated Circuit

    PCB - Printed Circuit Board

    PWM - Pulse width Modulation

    MCU - Microcontroller Unit

    RX - Receive

    TX - Transmit

    IR - Infra red

    I/O - Input and Output

    ICSP - In-Circuit Serial Programming

  • 8/10/2019 Entertainment Robot Fun Dog2

    16/78

    xiii

    LIST OF APPENDIX

    APPENDIX TITLE PAGE

    A Source Code for Fun Dog 38

  • 8/10/2019 Entertainment Robot Fun Dog2

    17/78

    xiv

  • 8/10/2019 Entertainment Robot Fun Dog2

    18/78

    xv

  • 8/10/2019 Entertainment Robot Fun Dog2

    19/78

    1

    CHAPTER 1

    INTRODUCTION

    1.1 Background of Project

    Today, robot pets still remain as clumsy battery-powered animal looks alike

    objects. The best one commercially available is the Sony Aibo. They are either cheap

    and lousy, or very expensive. Robot pet is not widely accepted as a replacement for real

    one. Psychologically, people still prefer a real animals then robots. Furthermore, a robot

    dog was indeed a very long way from being self-aware. Another limiting factor is that,

    robot pets are not being able to deal with outdoors.

    But bear in mind that the whole idea of a true artificial pet is that it is a pet for

    people who can not have or do not want to have a real one for reason such as constraints

    in living area. In addition, robot pets can perform computing tasks such as recording and

    playing back sound and video, playing games, and many others. These all have justified

    the existence of robot pets.

  • 8/10/2019 Entertainment Robot Fun Dog2

    20/78

    2

    Furthermore, robots now used for entertainment attempting to provide

    accompany to human beings. The most popular of these entertainment robots is the Aibo,

    launched by Sony in 1999. This robot pet, resembling a dog, was created by the Digital

    Creature Laboratory for Sony in Japan after six years of research lead by Doctor

    Toshitada Doi [Jerome, 2004]. It basically fulfils the most current constraints arising

    when consider autonomous robots. It can be active without being linked to a computer

    and it does not need a permanent plug to a power supply other than its battery.

    Additionally, many researches about artificial intelligence and robotics have

    been done with legged robots. Nevertheless, legged robots today divided into differentcategories based on the number of legs a robot have. There are called biped, quadruped,

    hexapod for robots with two legs, four legs and six legs respectively. But, for the most

    common today are biped and quadruped robots. Besides, the degrees of freedom (DOF)

    of each leg and the total number of legs a robot have determined the mobility and

    capability of the robot. It can move through one dimensional, two dimensional or three

    dimensional paths.

    1.2 Objectives of Project

    The main objective of this project is to design and fabricate fully autonomous

    with smooth movement pet robot. Moreover, the robotalso able to perform some basic

    movement like a real dog such as sitting down, standing up, squatting down and nodding

    the head. Besides, it will be programmed and featured with the ability of barking and

    making noises. Lastly, the robot has ability as a robot petto entertain humans.

  • 8/10/2019 Entertainment Robot Fun Dog2

    21/78

    3

    1.3 Scope of Project

    It is very essential to set a project scope as it helps to draw a guideline to make

    sure the project is conducted within its intended objective. This is to ensure that the

    project is direction achieve its proposed objectives.

    For this project, the scopeis confined on four major target scopes. First, the Fun

    Dog must be able to emulate a basic movement of a real dog such as standing up, sitting

    down, squatting down and nodding the head. Secondly, it must be able to perform the

    walking and running locomotion similar to a canine. Thirdly, it will be programmed with

    ability to bark and making noises like other real puppies. Lastly, the Fun Dogwill be

    ability of obstacles avoidance.

    1.4 Summary of Works

    Implementation and works of this project are summarized into Gantt charts as

    shown in Table 1.1 and Table 1.2 for efficiency done this project.

    Table 1.1: Gantt chart of the project schedule for semester 1

    Weeks 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

    Idea and Concept

    Literature Review

    Project Proposal

    Hardware Design

    Material Purchasing

    Presentation

    Report Writing

    Activities

  • 8/10/2019 Entertainment Robot Fun Dog2

    22/78

    4

    Table 1.2: Gantt chart of the project schedule for semester 2

    Weeks 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18

    Structure Fabrication

    Circuit Design

    Programming

    Test and Fine Tuning

    Presentation /demo

    Thesis writingDraft submission

    Thesis submission

    1.5 Outline of Thesis

    The remaining content of this thesis is organized as follows. Chapter 2 will

    discusses on theory and literature reviews that have been done for robot pets.

    Continuous, mechanical design of the robot from the main chassis construction, the

    actuators, the leg design and an attachment of the head will be discussed in Chapter 3.

    Moreover, methodology for selection components of this project well discusses in

    Chapter 4. In Chapter 5, it well covers circuitry design and software development for

    main circuitry system, voice ability circuitry, Infra Red sensor circuitry and also

    software used for programming purpose. In addition, the experimental results and

    discussions will be presented in chapter 6. Lastly, Chapter 7 discusses the conclusion of

    this project and proposes the future works that can be done to improve the current results.

    Activities

  • 8/10/2019 Entertainment Robot Fun Dog2

    23/78

    5

    CHAPTER 2

    LITERATURE REVIEW

    2.1 The Aibo Robot

    Aibo is an entertainment robot designed by Sony. This four-legged robot has the

    shape of a dog and is used to entertain people. It is also used in research to test theories

    about the outcomes of complex interactions between agents.

    The Aibo is a complex machine composed of a wide range of sensors and

    effectors. It has the capacity to feel, hear and view its surrounding environment. The

    feeling is achieved using two kinds of sensors; electrostatic and pressure. There is one

    electrostatic sensor on the head and three on the back. They light up when they perceive

    a contact. The pressure sensors are under the paws and the chin. It allows Aibo to detect

    if the four paws are on the ground or if something is under the chin, out of range of the

    camera. Then, an acceleration, temperature and vibration sensors give Aibo a more

    accurate rendering of the environment. Acceleration is measured to prevent the robot

    from falling down due to acceleration when moving or to detect if the robot is abruptly

  • 8/10/2019 Entertainment Robot Fun Dog2

    24/78

    6

    stopped, for instance when encountering an obstacle or being grabbed by the user. While,

    vibration sensors analyze linear velocity, displacement and proximity with used in

    measuring acceleration.

    The robot can see through a camera located in its nose. It has three resolutions

    208x160, 104x80 and 52x40 for a horizontal angle of view is 56.9 degrees and a vertical

    one of 45.2 degrees. Two distance sensors placed in its nose and its chest, with operating

    distances from 10cm to about 90cm to help gather information about the presence of

    obstacles. Two microphones located on its head would function as ears achieving the

    dogs hearing. The sound is recorded in stereo at 16.000Hz in 16bits linear pulse codemodulation.

    Additionally, to interact with the surrounding environment, whether it is the

    human user or simply the ball or the Aibone, Aibo uses several effectors for movement

    and communication. The movement is performed using four legs with three joints in

    each to elevate, rotate and bend. The neck is also composed of three joints to tilt, pan

    and nod. The tail has two joints to tilt and pan. The mouth has one joint to be opened and

    closed. The ears also move when flicking up and down.

    As well as, Aibo uses three types of effectors to communicate whereas visual,

    audible and wireless. A wide range of LEDs with several colours are located on the

    forehead of the robot. Also, the electrostatic sensors light up to express feelings. The

    sound is display by a miniature speaker on the chest playing polyphonic sounds. The

    wireless connection is an IEEE 802.11b wireless Ethernet interface with a range to up to

    three hundred feet. Overall of detail in hardware designing of Aibo ERS7 will show in

    Figure 2.1 and Figure 2.2.

  • 8/10/2019 Entertainment Robot Fun Dog2

    25/78

    7

    Figure 2.1: Front view for Aibo ERS7.

    \

    Figure 2.2: Rear view for Aibo ERS7.

    2.2 Sega idog Robot Puppy

    The Sega unleashed its newest creation in Tokyo. It is a robotic dog called idog

    that can compose, play and dance to music. Owners can program idog with an audio

  • 8/10/2019 Entertainment Robot Fun Dog2

    26/78

    8

    input jack at the base of its left hind leg (it's friendly with Apples iPod, for instance).

    The idog has a number of switches located on its nose and other parts of its body that

    can cause the robot dog react to movement and to light up and express its emotions. In

    Figure 2.3 shows that hardware of the Sega idog Robot Puppy made in Japan.

    Figure 2.3: The Sega idog Robot

    2.3 The RoboScience RS-01 Robot Dog

    In Figure 2.4, it could show the RoboScience RS-01 is a domestic quadruped

    robot. The RS-01s brain is a miniature PC running the standard Windows operating

    system (OS). The RS-01 uses 802.11b wireless networking (WI-Fi) to link to its owners

    PC or home network, allowing it to be permanently on line, giving it the versatility and

    functionally that consumer want from future domestic robots.

    RS-01 has a wide range of senses that allow it to interact safely with the world.

    Its senses allow it to balance, understand its location and give it hearing and sight. The

    RS-01 can run in two operating modes. In autonomous mode, the RS-01 will think and

    act for itself without the need for human intervention. It can overcome obstacles and

  • 8/10/2019 Entertainment Robot Fun Dog2

    27/78

    9

    navigating around a house or office on its own. In Explorer or avatar mode, the owner

    can take control of the Robot dog via voice command or remotely from their PC. An on

    board camera allows the owner to log into the robot via the net and drive it around its

    environment, seeing through its eyes, hearing through its ears and so on.

    Figure 2.4: The hardware of the RoboScience RS-01 Robot Dog

    2.4 I-Cybie

    Tiger Electronics in Figure 2.5 released its I-Cybie robot. This robot dog can

    detect obstacles, recognize edges, sense movement, determine where sounds are coming

    from, detect light changes and identify when he is being petted or stroked. Each robot

    has 16 computer controlled motors, allowing a range of movements. Owners can teach

    the dog 8 voice commands, games and tricks.

    Figure 2.5: The hardware of I-Cybie robot.

  • 8/10/2019 Entertainment Robot Fun Dog2

    28/78

    10

    2.5 Puppy Robot II

    The robot is designed based on intersection between robotics, computational

    neuroscience, nonlinear dynamical systems, and adaptive algorithms model of a canine

    animal as shown in Figure 2.6. The physical dimension is 150mm long, 145mm wide

    and approximately 180mm high. The robot has 6 standard digital servomotors in the legs

    and head. Batteries and a micro controller are also implemented in the robot body, which

    results in a body weight of 1.5 kg.

    Figure 2.6: The hardware of Puppy Robot II

    2.6 Summary

    Today, there are many relevant and similar projects that can be search across the

    internet and reference books motivated by the autonomous quadruped pet robottechnology. Therefore, in this chapter discussed overall of autonomous quadruped pet

    robot which is relevant to the project title such as Sony Aibo robot, Sega idog,

    RoboScience RS-01, I-Cybie robot, and Puppy Robot II.

  • 8/10/2019 Entertainment Robot Fun Dog2

    29/78

    11

    CHAPTER 3

    METHODOLOGY

    3.1 Components Selection

    This section explains the process of selecting material and other components

    needed for the construction of the robot, including servo motor, infrared sensor, power

    supply, Chipcorder voice IC and microcontroller PIC18F452. The selection was made

    based on a few criteria such as functionality, cost, overall size and weight.

    3.2 Servo Motor

    In the market, there are many types of motors available that can be used to build

    robots. The kind of servo motor is look which has a feedback mechanism to sense it is

  • 8/10/2019 Entertainment Robot Fun Dog2

    30/78

    12

    position. The control input to a servo motor tells it to be in a certain position, and logic

    built into the servo motor will position it. Each type of motor has its own strength and

    weaknesses. Physically, servos have limit stops to restrict their range of motion.

    The type of servomotor chosen as the main actuators for Fun Dogis the Futaba

    3003 in Figure 3.1 due to its flexibility to rotate to specific desired angles of degree. The

    Futaba 3003size is 1.59 x 0.78 x 1.42 in (40.4 x 19.8 x 36 mm)and has a 180-degree

    range. It has a speed with 0.23 sec / 60 deg and the weight of 37.2 g. The servomotor has

    three wires connected where the black is ground, red is the motor's voltage, and white is

    the control line.

    Figure 3.1: The servomotor hardware of Futaba 3003.

    3.3 Infrared Sensor (IR Sensor)

    The IR sensors are employed for the obstacle sensing and avoidance ability in

    Fun Dog. The basic principle of IR sensor is based on an IR emitter and an IR receiver.

    When the IR receiver receives infrared, it will generate voltage at its pin. The generated

    voltage is in the range from 0V to 5V depends on the intensity of infrared it received.

    Thus, two IR sensors will be attached at the bottom shoulder level of Fun Dogand one

    IR sensors will be attached in head level of robot to detect object and prevent any

    collision from happening. The range between the robot and the obstacle can be fine-

    tuning by adjusting the IR sensors. With these IR sensors Fun Dogwill be able to walk

  • 8/10/2019 Entertainment Robot Fun Dog2

    31/78

    13

    and run while preventing collision against obstacle from happening. Figure 3.2 shows

    the IR sensors used in Fun Dog.

    Figure 3.2: The hardware of IR sensor.

    3.4 Power Supply

    Most robots today use batteries as their power supplies. Although much progress

    has been achieved in electronics field where the entire computer can be fit into silicon

    chips in the form of microprocessor, there is not much progress in batteries development.

    There are numerous types of batteries namely, zinc, alkaline, nickel-cadmium, nickel

    metal hydride, lithium, lithium ion and lead-acid.

    The power supply unit is the most critical unit in an electronic project. All the

    servomotors, microcontroller and ISD2560 Chipcorder require for 6V, 5V and 9V

    respectively. Separate sources of power supply must be provided to supply to all the

    three components. Thus, A Lithium Polymer rechargeable battery in Figure3.3 will be

    used to power Fun Dog. The battery is quite small, light and has longer life spend and

    can be recharge to many cycles before it wears out.

    Figure 3.3: Lithium Polymer rechargeable battery by the Poly-Quest.

  • 8/10/2019 Entertainment Robot Fun Dog2

    32/78

    14

    3.5 Comparator (LM324)

    The LM324 is consists of four independent, high gain, internally frequency

    compensated operational amplifiers which were designed specifically to operate from a

    single power supply over a wide voltage range. Operation from split power supplies is

    also possible so long as the difference between the two supplies is 3 volts to 32 volts

    voltage. Application areas include transducer amplifier, DC gain blocks and all the

    conventional OP amp circuits which now can be easily implemented in single power

    supply systems. Figure 3.4 shows the LM324 used in IR sensor circuitry.

    3.6 Chipcorder Voice IC

    The robot will be implemented with voice synthesizing ability that includes

    talking, singing, barking and making noises like any puppies. Therefore, ISD2560

    Chipcorder IC in Figure 3.5 will be chosen as voice ability. It is a single chip

    record/playback 2500 series with 60 seconds duration of recording and messages play

    back. This CMOS device includes an on-chip oscillator, microphone preamplifier, anti-aliasing filter, smoothing filter, and speaker amplifier. The record or playback subsystem

    can be configured with an electrets microphone and a piezo speaker, several passive

    components, two push buttons and a power source.

    Figure 3.4: LM324.

    Figure 3.5: ISD2560 Chipcorder voice IC.

  • 8/10/2019 Entertainment Robot Fun Dog2

    33/78

    15

    3.7 Microcontroller

    Microcontroller is gaining popularity among robot builders compare to

    microprocessor because of its size, cost and the performance of the microcontroller

    which is way better compare to a microprocessor. A microcontroller is the combination

    of a microprocessor, memory, input and output ports and some of the special functions

    like timer, analogue to digital converter, mathematics processor and PWM generator in

    one chip. Due to its popularity and wide use, there are countless of microcontroller in the

    market which range from 8 bit, 16 bit to the more advanced 32 bit. However, the PIC

    microcontroller solutions feature a powerful architecture, flexible memory technologies,comprehensive easy-to-use development tools, comprehensive application notes and

    complete technical documentation.

    The PIC18F452 microcontroller from Microchip will be used to store programs

    and as brain of robot. It has 32K bytes flash on chip program memory and 1536 bytes on

    chip RAM. Only need single supply 5V in circuit serial programming via two pins and

    could reached 100,000 erase/write cycle enhanced flash program memory typical. The

    microcontroller will synchronized all the servo motors at the desired position and phase

    to achieve different gaiting style for Fun Dog. Figure 3.6 shows the PIC18F452

    microcontroller chip and Figure 3.7 shows pin diagram of PIC18F452.

    Figure 3.6: Microcontroller PIC18F452

  • 8/10/2019 Entertainment Robot Fun Dog2

    34/78

    16

    3.8 Algorithm and Programming in MPLAB IDE

    In the software implementation there are many considerations have been taken

    during the process selection of software to program the robot. Nevertheless, MPLAB

    IDE is used to program microcontroller in assembly language. Moreover, basic C

    language is used for user interface purpose and for monitoring the all function for the

    robot.

    An algorithm has to be developed to make the microcontroller to read the input

    and respond accordingly. Therefore, the algorithm is established and represented by a

    flowchart in Figure 3.8. That all steps will translate into assembly language and

    compiled using MPLAB, the PIC18F452 software development tool. Therefore, the

    Microchip MPLAB IDE is the main compiler and editor for the PIC18F452

    microcontroller. It is free software that can be downloaded from the internet. Then, the

    Microchip MCC-18 compiler will be needed for the programming of using the C

    language together with the PIC18F452 microcontroller family. This compiler helps to

    Figure 3.7: The pin diagram of PIC18F452

  • 8/10/2019 Entertainment Robot Fun Dog2

    35/78

    17

    compile the C-language into machine code before programming the microcontroller.

    Apart from this, the PIC18F452 family devices can be programmed using either the

    high-voltage In-Circuit Serial Programming (ICSP.) method or the low-voltage ICSP

    method. Both methods can be done ICSP method is slightly different than the high-

    voltage method and these differences are noted where applicable. Moreover, the

    ICPROG is software created for the microcontroller reprogramming cause of this

    software allow user to burn data via serial communication from the PC to the

    microcontroller loading the HEX file to the PIC microcontroller.

    Figure 3.8: The program data flowchart.

    3.9 Summary

    Generally, building an autonomous robot required knowledge from various

    aspects, discipline and studies thus a systematic approach is crucial in the development

    process. This chapter describes the components selection and all of that will be

    integrated together to build up the robot.

  • 8/10/2019 Entertainment Robot Fun Dog2

    36/78

    18

    CHAPTER 4

    MECHANICAL STRUCTURE DESIGN

    4.1 General Robot Structure

    The main chassis of Fun Dogis made of aluminium where size of the aluminium

    is measured and cut according to the desired size when the servo motors are attached to

    the chassis. The chassis construction is build to be as firm and as rigid as possible to

    prepare a solid platform for the Fun Dog.Figure 4.1 shows the initial prototype of Fun

    Dog. The initial prototype of Fun Dog had been constructed with weight around 800g

    without batteries. The body length and height is both 180mm and 100mm respectively.

    Nonetheless, a final design of robot was the enhanced prototype of the initial design.

    The main modification of the initial design is enlarged width dimension for stability

    purpose.

  • 8/10/2019 Entertainment Robot Fun Dog2

    37/78

    19

    Figure 4.1: The initial prototype of Fun Dog.

    4.2 Leg Design of Robot

    During the design phase of the robot, there are a few problem occurred. One of

    the major constraints is the weight. Due to the overall light and petite size of Fun Dog,

    the weight that can be supported by the robot is limited. Too heavy and bulky structure

    will result in difficulties in the galloping gaits. Therefore, a suitable mechanism design is

    vital where the overall weight should be as soon as possible.

    Figure 4.2:Double screws are connects both the links together on Fun Dogs front leg.

  • 8/10/2019 Entertainment Robot Fun Dog2

    38/78

    20

    4.3 Head Design of Robot

    In Fun Dogs head design had problems occurred due to consider the limit

    weight, size and cost. Besides, it also need considering in good look likes the robot. As a

    result, a final decision was made it with used soaps cover as Fun Dogs head.

    Additionally, the soaps cover will be attached LEDs and IR sensor to look like nice Fun

    Dog.

    4.4 Summary

    In the process of mechanical structure design in this chapter will covered initial

    prototype, the leg design and the attachment of the head of Fun Dog. All of mechanism

    design will be integrated together to build up the robot structure.

    .

    Figure 4.3: The head design of Fun Dog.

  • 8/10/2019 Entertainment Robot Fun Dog2

    39/78

    21

    CHAPTER 5

    ELECTRONIC CIRCUIT DESIGN

    5.1 General Introduction of Circuitry System

    The electronic design can be a difficult task if the practice is not conducted in a

    systematic order. The process basically commenced off by selecting and determining the

    correct components and electronic devices follow by designing the circuitry. The

    process does not stop here as the circuit needs to be tested part by part before proceeding

    to the software development. The initial circuit is built on donut board for testing its

    functionally and possibility before it is had wired on the PCB.

  • 8/10/2019 Entertainment Robot Fun Dog2

    40/78

    22

    5.2 Main Circuitry System

    The entire circuit design process took about a few weeks from the design stage to

    the fabrication of the PCB, soldering of the component and finally troubleshooting.

    Along the process of testing the circuit, there might be times where necessary

    modification and additional components added to the circuit in order to make the circuit

    more stable and reliable.

    In main circuitry, themicrocontroller basically interfaces with a few componentsand devices such as the servo motors, IR sensors, emotion LED lights and boot loader.

    Figure 5.1 shows the clocking circuitry for the PIC and other interfacing circuits where

    relevant parts are assigned to specific components and devices as mention above. While,

    the schematic diagram of the main circuitry is shown in Figure 5.2.

    Figure 5.1: The Fun Dogmain circuitry design in PCB.

  • 8/10/2019 Entertainment Robot Fun Dog2

    41/78

    Figure 5.2: The schematic of main circuitry Fun Dog

  • 8/10/2019 Entertainment Robot Fun Dog2

    42/78

  • 8/10/2019 Entertainment Robot Fun Dog2

    43/78

    25

    In main circuitry, the LM7805 and LM7806 voltage regulators were used in the

    circuit to procedure a voltage output of 5V and 6V, respectively from an approximately

    12V Lithium Polymer battery supply. The 5V output is for the supply of MCU whereas

    the 6V supply for the servo motors. Figure 5.3 shows the voltage regulator circuitry will

    used in main circuitry.

    Figure 5.3: The Voltage Regulator Circuitry

    5.3 ChipCorder Circuitry

    The ISD2560 IC is mainly used for recording and playing back audio signals

    using non-volatile analog memories. They feature high quality of sound recording,

    simple design and long storage time. Integrated circuits applied, like most of ISD

    devices, enable easy way to create various functions without any additional control

    circuits.

    Figure 5.4 shows the ISD2560 ChipCorder circuitry has contain a push button

    operational mode is used primarily in very low cost applications and is designed to

    minimize external circuitry and components, thereby reducing system cost. In order to

  • 8/10/2019 Entertainment Robot Fun Dog2

    44/78

    26

    configure the device in push button operational mode, the two most significant address

    bits must be HIGH and the push button mode pin must also be HIGH. A device in this

    mode always powers down at the end of each playback or record cycle after CE goes

    HIGH. When this operational mode is implemented, three of the pins on the device have

    alternate functionality as described in Table 5.1.

    Table 5.1: Alternate functionality in pins

    Pin name Alternate functionality in push button mode

    CE Start/Pause push button( LOW pulse-activated)

    PD Stop/Reset push button (HIGH pulse-activated)

    EOM Active HIGH Run indicator

    Figure 5.4: The ISD2560 ChipCorder circuitry

  • 8/10/2019 Entertainment Robot Fun Dog2

    45/78

    27

    5.4 Infra Red Sensor Circuitry

    More concerns on the working principle of infrared sensor and the output from it

    will be application in IR sensor circuitry. IR is the typical light source used as a sensor

    in robot to sense opaque object. The basic principle of IR sensor is based on an IR

    emitter and an IR receiver. Usually, IR emitter and IR receiver will be attached side by

    side and point to a reflective surface. When the IR receiver receives infrared, it will

    generate voltage at its pin. The generated voltage is in the range from 0V to 5V depends

    on the intensity of infrared it received. The voltage will drop to zero if there is noinfrared received. Therefore, comparator able to compare both input voltage and

    generate either 0V or 5V where can connect it to microcontroller. Figure 5.5 shows the

    schematic of IR sensor circuitry.

    Figure 5.5: The schematic of IR sensor circuitry.

  • 8/10/2019 Entertainment Robot Fun Dog2

    46/78

    28

    5.5 Bootloader Circuitry

    Bootloader is an easy way to program code in hex file to a PIC microcontroller.

    The interfacing pin between the microcontroller and the boatloader is two separate

    TX/RX pin built in the PIC itself. With small program memory space and the capability

    to self program, PIC microcontroller may perform bootloading. The microcontroller

    could be attached with the circuit board on Fun Dog while load a program to test. It is a

    small, handy and portable device that needed less than 2 minutes for reprogramming the

    microcontroller. There is not need for expensive programmer and no need to pull the

    chip out of the circuit board just necessitate is serial port on PC or Laptop, a serial cable,microcontroller with bootloader firmware and circuitry. In Figure 5.6 shows the

    schematic of bootloader circuitry will be connected to PIC microcontroller.

    Figure 5.6: The schematic of bootloader circuitry.

    5.6 Summary

    The circuitry design in this chapter focus on main circuitry included the MCU,

    ChipCorder circuitry, IR sensor circuitry and boolloader circuitry. All of that circuit will

    be integrated together to build up as Fun Dogcircuitry system.

  • 8/10/2019 Entertainment Robot Fun Dog2

    47/78

    29

    CHAPTER 6

    ACHIEVEMENT AND EXPERIMENTAL RESULT

    6.1 Galloping gaits

    Gaiting method is the basic pattern in which the robot can moves its legs. The

    study of the behavior of the canine locomotion is crucial where their gaiting style can be

    imitated while designing Fun Dog. The gaits of the dog are commonly divided into two

    main groups; symmetric and asymmetric. With symmetric gaits such as the walk, trot,

    and pace, the movement of the limbs on one side of the dog's body repeats the motion of

    the limbs on the opposite side with the intervals between feet falls being nearly evenly

    spaced. Meanwhile, with asymmetric gaits such as the gallop, the limb movements of

    one side do not repeat those of the other and the intervals between foot falls are

    unevenly spaced. As a result, there are two main gaits that Fun Dog will emulate from

    the canine locomotion which consists of both the symmetric and asymmetric gaits such

    as the walking gaits and the running gaits respectively.

  • 8/10/2019 Entertainment Robot Fun Dog2

    48/78

    30

    6.1.1 Forward Motion

    In the forward galloping mode, both front and behind legs of Fun dog was

    programmed to be moving simultaneously. The gait was emulated based on the analysis

    of a galloping dog video. Formerly, Fun Dog begins to gallop the frequency of the gaits

    remains almost constant while the robot dog increases its speed by increasing the gaits

    length.

    6.1.2 Turning Right and Left Motion

    The direction of Fun Dogis importantly needed as turning enable the robot dog

    to gallop around when necessary in order to avoid knocking object. In the turning right

    motion, the movement on both right legs is moving more dominantly then turns left side.

    The turning right motion is performed by moving both the right legs (front and behind)

    before activating the left legs (front and behind) few milliseconds later.

    The same concept applies to the turning left motion where both the left legs

    (front and behind) are activated a few milliseconds before the right side are activated.

    The time between activating one of side to the others are obtained through experimental

    result. The best interval was recorded down and the value is critical as different intervals

    might result in different turning angle.

    Lastly, Fun Dogwas programmed to be galloping in three motions consisting of

    the forward motion, turning left and turning right motion. The turning left and right

    motion are used to change Fun Dogs directions whenever necessary to prevent itself

  • 8/10/2019 Entertainment Robot Fun Dog2

    49/78

    31

    from knocking into the side wall. All the three motions are captured in video clips

    whereas can be seen in the attached CD at the end of the thesis.

    6.2 Physical Movement Abilities

    The biologically inspired technology had encouraged Fun Dog to adapt andperform some basic movement of a canine. In this context, the standing, sitting,

    squatting down, nodding the head, lifting the hand and knocking down are the few

    physical movements that Fun Dogare managed to perform successfully. The movement

    are designed and programmed with the aim to emulate a real puppys action as similar as

    possible. Nevertheless, the actions mention in above can be seen in a more convincing

    video clips attached in the CD. In Figure 6.1, Figure 6.2 and Figure 6.3 show some basic

    movements of real puppy together with its mechanical counterpart, Fun Dog.

    Figure 6.1: The real dog (left) and Fun Dog(right) in squatting down position.

  • 8/10/2019 Entertainment Robot Fun Dog2

    50/78

    32

    Figure 6.2: The real dog (left) and Fun Dog(right) in sitting position.

    Figure 6.3: The real dog (left) and Fun Dog(right) in standing position.

    6.3 Obstacle Avoidance Mode

    In this mode, Fun Dog is using three IR sensors as a feedback reading to the

    microcontroller. Before adding the obstacle avoidance ability, Fun Dog structure is built

    to be as rigid and as stable as possible in order to be dynamically steady in the galloping

    gaits.

    The microcontroller is used to obtain input signal from the IR sensor attach at the

    in front part of Fun Dog. Two sensors were attached on the bottom shoulder level of Fun

  • 8/10/2019 Entertainment Robot Fun Dog2

    51/78

  • 8/10/2019 Entertainment Robot Fun Dog2

    52/78

    34

    6.5 Emotion Display

    The emotion of Fun Dogcan be mainly classified into two categories which are

    the happy and depressed moment. For instance, LED lights are used to display the

    emotion where the green LED will signified the happy moment whereas the red LED

    will signified the depressed moment. The barking mode, singing mode, and playful

    mode are categorized in the happy moment of Fun Dog, whereas the depressed moment

    are namely the angry mode, scared mode and finally the whimpering mode. This has all

    together contributed to serves simple modes of action and expressions.

    6.6 Summary

    Fun Dog had been considered successfully designed and built according to its

    initial proposed scope. The achievement of Fun Dog can mainly be summarized into

    three major parts. Firstly, the accomplishment of this project is purely the obstacle

    avoidance mode where Fun Dog is capable in galloping while avoiding collision with

    object. Secondly, Fun Dog is capable in performing some physical movement closely

    imitating a canine. The robot dog is also capable in voice synthesizing ability and

    displaying its emotion by indicating with the emotion LED light.

  • 8/10/2019 Entertainment Robot Fun Dog2

    53/78

    35

    CHAPTER 7

    CONCLUSION AND FUTURE WORK

    7.1 Conclusion

    This project has been able to achieve its overall goal, designing and building a

    biologically inspired quadruped robot that greatly imitated the physical appearance of a

    canine. The conceptual design of Fun Dogis based on a few theories of physics inspired

    by animal behavior, locomotion and implemented using the microcontroller, sensor,

    servo motors, voice synthesizing IC and other components.

    Fun Doghad been constructed according to schedule. The overall achievements

    of this project are generally summarized as follows:

    1) Fun Dogis capable in galloping is an enclosure while avoiding collision with the

    side wall.

    2) Performs physical movement action like a real puppy.

    3)

    Able to do barking and make noises.

    4)

    Displaying emotion of either happy or depressed moment.

  • 8/10/2019 Entertainment Robot Fun Dog2

    54/78

    36

    7.2 Future Work

    Many leading companion such as Sony, Toyota, Honda and Omron are investing

    tens of millions of euros annually in the development of personal robots. Thus, the

    development of biologically inspired technology is crucial. Conversely, it might still be

    a distant reality in our country as compare to other advance country like Japan.

    Proposing the idea of Fun Dogmight sure be the best solution in this problem,

    but it will be a foundation for the future development in this field in our country. In

    Malaysia, robotics pets research is still in a born stage and there are rooms to expandand improve. Hopefully with the research on this project so far will help to improve the

    current success of Fun Dog.

    In future development, Fun Dogmay be upgraded with other ability such as

    sight, smell, hearing and sensing. Other vision and Artificial Intelligence technology can

    be introduced to the current work to make Fun Dog more intelligent and more fun to

    play as human companion as entertainment pet robot. Hopefully with all the new

    abilities and technology Fun Dogwill be able to sit side by side with other marketable

    robotics pet. In Figure 7.1 shows the marketable robotics pet Sony AIBO, Sega Idog,

    Tekno-Robot and Fun Dog.

    Figure 7.1: The marketable robotics pet (from left) Sony AIBO, Sega Idog, Tekno-Robot

    and Fun Dog.

  • 8/10/2019 Entertainment Robot Fun Dog2

    55/78

    37

    REFERENCE

    1.

    R. C. Arkin(1998), Behavior-Based Robotics. MIT Press.

    2.

    Brooks, R. A. "A Robust Layered Control System for a Robot Pet", IEEE Journal

    of Robotics and Automation, Vol. 2, No. 1, March 1986.

    3. Alexander, R. McN (1984), The Gaits of Bipedal and Quadrupled Animals.,

    International Journal of Robotics Research.

    4.

    MacDonald, W.S. (1994), Design and Implementation of a Multilegged

    Walking Robot.

    5. Huosheng Hu and Dongbing Gu (2000), A Multi-Agent System for Cooperative

    Quadruped Walking Robots.6.

    Yoseph Bar-Cohen (2002), Biologically Inspired Robots as Artificial

    Inspectors.

    7.

    Doctor Toshitada Doi Jerome (2004), Digital Creature Laboratory for Sony in

    Japan.

    8. http://www.tzi.de/4legged/bin/view/Website/WebHome

    9. http://www.microchip.com

    10.

    http://www.robotmatrix.org

    11.

    http://www.sony.net/Products/aibo/

    12.

    http://www.Futaba.com

    13.http://www.cytron.com.my

    14.http://www.itrc.org/reports/sensors/sensorch4.pdf

  • 8/10/2019 Entertainment Robot Fun Dog2

    56/78

    38

    APPENDIX A

    /********************************************************************/

    /** AUTHOR : SAW LEAN JUN **/

    /** IC NO : 850605-02-5181 **//** APPLICATION : PSM_FUN DOG **/

    /** SEMESTER : 2007/2008 II **/

    /********************************************************************/

    // PIC18F452 BLOCK DIAGRAM

    // ____ ___________// MCLR|1 40|RB7 FRONT_RIGHT_SV

    // RA0 |2 39|RB6 BEHIND_RIGHT_SV

    // RA1 |3 38|RB5 BEHIND_LEFT_SV

    // RA2 |4 37|RB4 FRONT_LEFT_SV

    // RA3 |5 36|RB3 HEAD_SERVO MOTOR// RA4 |6 35|RB2// RA5 |7 34|RB1

    //ACTION_MODE RE0 |8 33|RB0

    //SENSOR_MODE RE1 |9 32|VDD

    // RE2 |10 31|VSS

    // VDD |11 30|RD7 EXTRA_SENSOR

    // VSS |12 29|RD6 CENTER_SENSOR

    // CLK1 |13 28|RD5 RIGHT_SENSOR

    // CLK0 |14 27|RD4 LEFT_SENSOR//HEAD4_LED RC0 |15 26|RC7 RX

    //HEAD3_LED RC1 |16 25|RC6 TX//HEAD2_LED RC2 |17 24|RC5

    //HEAD1_LED RC3 |18 23|RC4

    //ANGRY_LED RD0 |19 22|RD3 BOARD2_LED

    //BEHIND_LED RD1 |20__________21|RD2 BOARD1_LED

    #include

    #include #include

    #include

  • 8/10/2019 Entertainment Robot Fun Dog2

    57/78

    39

    void timer_isr(void);

    int i;unsigned int var;

    unsigned int value1;unsigned int value2;

    unsigned int V_TMR0=0;unsigned int SERVO1=20; //RB7-Front Right Servo Motor

    unsigned int SERVO2=20; //RB6-Behind Right Servo Motor

    unsigned int SERVO3=20; //RB5-Behind Left Servo Motor

    unsigned int SERVO4=20; //RB4-Front Left Servo Motor

    unsigned int SERVO5=34; //RB3-Head Servo Motor

    #pragma config OSC = HS

    #pragma config OSCS = OFF

    #pragma config PWRT = ON#pragma config BOR = OFF

    #pragma config WDT = OFF

    #pragma config CCP2MUX = ON

    #pragma config STVR = OFF#pragma config LVP = OFF

    #pragma config DEBUG = OFF#pragma interruptlow timer_isr

    void try(void);

    void action (void);

    void gimmick (void);void greeting (void);void barking (void);

    void playful (void);

    void angry (void);

    void scaring (void);

    void singing (void);

    void goodbye (void);

    void nodding (void);

    void nodding_long (void);void nodding_fast (void);

    void play_led (void);void run_led (void);

    void emotion_led (void);

    void eyes_blink (void);

    void angry_led (void);

    void angry_blink (void);

    void all_led_blink (void);

    void on_led (void);void off_led (void);

    void sensor(void);

    void check (void);

  • 8/10/2019 Entertainment Robot Fun Dog2

    58/78

    40

    void gallop_far_left (void);

    void gallop_left (void);void gallop_far_right (void);

    void gallop_right (void);void gallop (void);

    void stop (void);void down (void);

    void sit (void);

    void stand2 (void);

    void stand4 (void);

    void timer_isr (void)

    { INTCONbits.TMR0IF=0;

    TMR0H = 0xFF; //write low byte to Timer0

    TMR0L = 0x06; //write high byte to Timer0V_TMR0++;

    if (V_TMR0==400)

    { V_TMR0=0;LATBbits.LATB7=1;

    LATBbits.LATB6=1;LATBbits.LATB5=1;

    LATBbits.LATB4=1;

    LATBbits.LATB3=1;}

    else

    { if (V_TMR0==SERVO1){LATBbits.LATB7=0;}if (V_TMR0==SERVO2)

    {LATBbits.LATB6=0;}

    if (V_TMR0==SERVO3)

    {LATBbits.LATB5=0;}

    if (V_TMR0==SERVO4)

    {LATBbits.LATB4=0;}

    if (V_TMR0==SERVO5)

    {LATBbits.LATB3=0;} }}

    void main (void)

    {

    OpenADC(ADC_0ANA_0REF,ADC_INT_OFF);

    TRISA = 0x00; // 0000 0000

    TRISB = 0x01; // 0000 0001

    TRISC = 0x00; // 0000 0000

    TRISD = 0x70; // 0111 0000TRISE = 0x03; // 0000 0011

    //Interrupt Configuration

  • 8/10/2019 Entertainment Robot Fun Dog2

    59/78

    41

    RCONbits.IPEN = 1;

    INTCONbits.GIEH = 1;INTCONbits.GIEL = 1;

    PIE1bits.TMR1IE = 1;IPR1bits.TMR1IP = 0;

    //Set Timer0 0.1ms

    OpenTimer0(TIMER_INT_ON&T0_SOURCE_INT&T0_16BIT&T0_PS_1_1);

    WriteTimer0(65286);

    LATBbits.LATB1=0; //OFF LED

    LATBbits.LATB2=0; //OFF LEDLATCbits.LATC0=0; //OFF LED

    LATCbits.LATC1=0; //OFF LED

    LATCbits.LATC2=0; //OFF LED

    LATCbits.LATC3=0; //OFF LEDLATCbits.LATC4=0; //OFF LED

    LATCbits.LATC5=0; //OFF LED

    LATDbits.LATD0=0; //OFF LED

    LATDbits.LATD2=0; //OFF LEDLATDbits.LATD3=0; //OFF LED

    {try();}}

    //=================== MODE SELECTION =======================//

    void try (void)

    { while(1){ if(!PORTEbits.RE0)

    { action (); }

    else if (!PORTEbits.RE1)

    { sensor (); }

    }

    }

    //=================== FUN DOG MOTION =======================//

    void action (void){ gimmick ();

    play_led ();greeting ();

    eyes_blink ();

    barking ();

    run_led ();

    playful ();

    eyes_blink ();

    run_led ();angry ();

    angry_blink ();

    angry_blink ();

  • 8/10/2019 Entertainment Robot Fun Dog2

    60/78

    42

    scaring ();

    all_led_blink ();run_led ();

    all_led_blink ();play_led ();

    all_led_blink ();for ( i=0; i

  • 8/10/2019 Entertainment Robot Fun Dog2

    61/78

  • 8/10/2019 Entertainment Robot Fun Dog2

    62/78

    44

    Delay10KTCYx(20);

    SERVO4=23;

    for ( i=0; i

  • 8/10/2019 Entertainment Robot Fun Dog2

    63/78

    45

    for ( i=0; i

  • 8/10/2019 Entertainment Robot Fun Dog2

    64/78

  • 8/10/2019 Entertainment Robot Fun Dog2

    65/78

    47

    SERVO5=34;

    Delay10KTCYx(125);SERVO5=29;

    Delay10KTCYx(80);SERVO5=34;

    Delay10KTCYx(125);SERVO5=29;

    Delay10KTCYx(80);

    SERVO5=34;

    for (i=0;i

  • 8/10/2019 Entertainment Robot Fun Dog2

    66/78

    48

    for (i=0;i

  • 8/10/2019 Entertainment Robot Fun Dog2

    67/78

    49

    Delay10KTCYx(20);

    SERVO5=30;Delay10KTCYx(20);

    SERVO5=31;Delay10KTCYx(20);

    SERVO5=32;Delay10KTCYx(20);

    SERVO5=33;

    Delay10KTCYx(20);

    SERVO5=34;

    Delay10KTCYx(20);SERVO1=20;

    SERVO2=26;

    SERVO3=14;

    SERVO4=16;Delay10KTCYx(20);

    SERVO1=20;

    SERVO2=26;

    SERVO3=14;SERVO4=20;

    }

    void nodding (void)

    { LATCbits.LATC3=1;

    LATCbits.LATC2=1;

    LATCbits.LATC2=1;LATCbits.LATC0=1;LATDbits.LATD1=1;

    SERVO5=35;

    Delay10KTCYx(140);

    LATCbits.LATC3=0;

    LATCbits.LATC2=0;

    LATCbits.LATC1=0;

    LATCbits.LATC0=0;

    LATDbits.LATD1=0;SERVO5=29;

    Delay10KTCYx(70);}

    void nodding_long (void)

    { LATCbits.LATC3=1;

    LATCbits.LATC2=1;

    LATCbits.LATC1=1;

    LATCbits.LATC0=1;LATDbits.LATD1=1;

    SERVO5=35;

    Delay10KTCYx(155);

  • 8/10/2019 Entertainment Robot Fun Dog2

    68/78

    50

    Delay10KTCYx(45);

    LATCbits.LATC3=0;LATCbits.LATC2=0;

    LATCbits.LATC1=0;LATCbits.LATC0=0;

    LATDbits.LATD1=0;SERVO5=29;

    Delay10KTCYx(85);

    }

    void nodding_fast (void){ LATCbits.LATC3=1;

    LATCbits.LATC2=1;

    LATCbits.LATC1=1;

    LATCbits.LATC0=1;LATDbits.LATD1=1;

    SERVO5=34;

    Delay10KTCYx(85);

    LATCbits.LATC3=0;LATCbits.LATC2=1;

    LATCbits.LATC1=1;LATCbits.LATC0=0;

    LATDbits.LATD1=1;

    SERVO5=29;

    Delay10KTCYx(55);

    }

    //==================== LED EXPRESSION =======================//

    void emotion_led (void)

    { LATCbits.LATC3=0;

    LATCbits.LATC2=0;

    LATCbits.LATC1=0;

    LATCbits.LATC0=0;

    LATDbits.LATD1=0;

    LATDbits.LATD3=1;LATCbits.LATC3=0;

    LATCbits.LATC2=1;

    LATCbits.LATC1=1;

    LATCbits.LATC0=0;

    LATDbits.LATD1=1;

    Delay10KTCYx(15);

    LATDbits.LATD3=0;

    LATCbits.LATC3=0;

    LATCbits.LATC2=1;

  • 8/10/2019 Entertainment Robot Fun Dog2

    69/78

  • 8/10/2019 Entertainment Robot Fun Dog2

    70/78

    52

    LATDbits.LATD1=1;

    Delay10KTCYx(5);

    LATCbits.LATC3=0;LATCbits.LATC2=1;

    LATCbits.LATC1=1;LATCbits.LATC0=0;

    LATDbits.LATD1=1;

    Delay10KTCYx(10);

    LATCbits.LATC3=0;LATCbits.LATC2=1;

    LATCbits.LATC1=0;

    LATCbits.LATC0=1;

    LATDbits.LATD1=1;Delay10KTCYx(15);

    LATCbits.LATC0=0;

    }

    void all_led_blink (void)

    { LATCbits.LATC3=1;LATCbits.LATC2=1;

    LATCbits.LATC1=1;

    LATCbits.LATC0=1;

    LATDbits.LATD1=1;

    Delay10KTCYx(150);LATCbits.LATC3=0;LATCbits.LATC2=0;

    LATCbits.LATC1=0;

    LATCbits.LATC0=0;

    LATDbits.LATD1=0;

    Delay10KTCYx(50);

    }

    void angry_led (void){ LATCbits.LATC3=0;

    LATCbits.LATC2=0;LATCbits.LATC1=0;

    LATCbits.LATC0=0;

    LATDbits.LATD1=0;

    LATDbits.LATD0=1;

    }

    void angry_blink (void){ LATCbits.LATC3=0;

    LATCbits.LATC2=0;

    LATCbits.LATC1=0;

  • 8/10/2019 Entertainment Robot Fun Dog2

    71/78

    53

    LATCbits.LATC0=0;

    LATDbits.LATD1=0;for (i=0;i

  • 8/10/2019 Entertainment Robot Fun Dog2

    72/78

    54

    Delay10KTCYx(30);

    LATCbits.LATC1=1;LATCbits.LATC0=1;

    Delay10KTCYx(5);LATCbits.LATC3=0;

    LATCbits.LATC2=0;LATCbits.LATC1=0;

    LATCbits.LATC0=1;

    Delay10KTCYx(30);

    LATCbits.LATC0=0;

    }

    void run_led (void)

    { LATCbits.LATC3=1;

    LATCbits.LATC2=1;LATCbits.LATC1=1;

    LATCbits.LATC0=1;

    LATDbits.LATD1=1;

    Delay10KTCYx(200);LATCbits.LATC3=0;

    LATCbits.LATC2=0;LATCbits.LATC1=0;

    LATCbits.LATC0=0;

    LATDbits.LATD1=1;

    Delay10KTCYx(50);

    LATCbits.LATC3=1;Delay10KTCYx(35);LATCbits.LATC2=1;

    Delay10KTCYx(35);

    LATCbits.LATC1=1;

    Delay10KTCYx(35);

    LATCbits.LATC0=1;

    Delay10KTCYx(35);

    LATCbits.LATC3=0;

    LATCbits.LATC2=0;LATCbits.LATC1=0;

    LATCbits.LATC0=0;LATDbits.LATD1=1;

    Delay10KTCYx(50);

    LATCbits.LATC3=1;

    LATCbits.LATC2=1;

    LATCbits.LATC1=1;

    LATCbits.LATC0=1;

    LATDbits.LATD1=1;}

    void eyes_blink (void)

  • 8/10/2019 Entertainment Robot Fun Dog2

    73/78

    55

    { for(i=0;i

  • 8/10/2019 Entertainment Robot Fun Dog2

    74/78

  • 8/10/2019 Entertainment Robot Fun Dog2

    75/78

    57

    SERVO4=18;

    Delay10KTCYx(85);SERVO2=18;

    SERVO3=23;Delay10KTCYx(20);

    SERVO1=16;SERVO4=24;

    Delay10KTCYx(85);

    }

    void gallop (void){ while(1)

    for(i=0;i

  • 8/10/2019 Entertainment Robot Fun Dog2

    76/78

    58

    SERVO3=19;

    Delay10KTCYx(20);SERVO1=21;

    SERVO4=19;SERVO2=22;

    SERVO3=18;Delay10KTCYx(20);

    SERVO1=22;

    SERVO4=18;

    SERVO2=23;

    SERVO3=17;Delay10KTCYx(20);

    SERVO1=23;

    SERVO4=17;

    SERVO2=24;SERVO3=16;

    Delay10KTCYx(20);

    SERVO1=24;

    SERVO4=16;SERVO2=25;

    SERVO3=15;

    }

    void sit (void)

    { SERVO1=20;SERVO2=20;SERVO3=20;

    SERVO4=20;

    Delay10KTCYx(20);

    SERVO1=20;

    SERVO2=21;

    SERVO3=19;

    SERVO4=20;

    Delay10KTCYx(20);SERVO1=19;

    SERVO2=21;SERVO3=19;

    SERVO4=21;

    Delay10KTCYx(20);

    SERVO1=19;

    SERVO2=22;

    SERVO3=18;

    SERVO4=21;Delay10KTCYx(20);

    SERVO1=18;

    SERVO2=23;

  • 8/10/2019 Entertainment Robot Fun Dog2

    77/78

  • 8/10/2019 Entertainment Robot Fun Dog2

    78/78

    60

    Delay10KTCYx(20);

    SERVO1=22;SERVO2=22;

    SERVO3=18;SERVO4=18;

    Delay10KTCYx(20);SERVO1=21;

    SERVO2=21;

    SERVO3=19;

    SERVO4=19;

    Delay10KTCYx(20);SERVO1=20;

    SERVO2=20;

    SERVO3=20;

    SERVO4=20;}