129
FACULDADE DE E NGENHARIA DA UNIVERSIDADE DO P ORTO Perceptual Feedback of Grasping Touch to Prosthesis Hand User Jorge Filipe Peixoto da Silva Luís Master Thesis Program in Electrical and Computer Engineering Supervisor: Andrzej Wolczowski (Doctor) Co-Supervisor: António Paulo Gomes Mendes Moreira (Doctor) June 2010

Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

FACULDADE DE ENGENHARIA DA UNIVERSIDADE DO PORTO

Perceptual Feedback of Grasping Touchto Prosthesis Hand User

Jorge Filipe Peixoto da Silva Luís

Master Thesis Program in Electrical and Computer Engineering

Supervisor: Andrzej Wolczowski (Doctor)

Co-Supervisor: António Paulo Gomes Mendes Moreira (Doctor)

June 2010

Page 2: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

c© Jorge Filipe Luís, 2010

Page 3: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects
Page 4: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects
Page 5: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Abstract

Nowadays with the technology development, new resources are available. It is up to usto use and develop new systems that allow a much better life quality. One of this fields isthe prosthetic field. Investigators around the world are developing new control and mainlyfeedback systems to human. Having this as background it was proposed the developmentof such system. This consists in perceptual feedback to human. Summarizing, havinga robotic prosthetic arm it is necessary to ’feel’ and identify objects. Some companies,like DARPA have already the state of the art control and feedback systems. These arecontrolled with myoelectric sensors that can feel the sparkling between the nerves andmuscles. Usually the feedback is based in tactors, or vibrating motors. More developedstimulations systems consist in electrical feedback, stimulating directly on the human skinthe sensory system. A European collaboration involving different universities has alreadydeveloped such a system. From a sensory system it is possible to the user to feel the objectif it was its own hand.

With all this development the global proposed system will consist in two non-invasivestimulations, and one acquisition system. The acquisition is based in force sensing resis-tors connected to microcontrollers. These sensors are spread in key locations around thehand, using voltage dividers. After, they are connected to microcontroller and then it ispossible to be seen the values in a user interface program. The stimulation is based inmechanical and electrical systems. The mechanical is based in tactors in specific places,these motors vibrate when there is a state change in the sensors, in other words when asensor ’senses’ touch, a motor will start to vibrate. These will increase their frequencyas the sensors increase their voltage. The second stimulation system is electrical and itis used to identify objects. For example, when some sensors are activated a object isidentified and so the system stimulates the nerves. This is based in an already developedsystem used in medical nerve stimulation, called TENS. Having it as background it wasproposed the development of a controlled current and frequency stimulator. This systemconsists in half H-bridge but instead of controlling a usual motor is used to control a pairof electrodes, allowing a current to flow in a muscle. The user interface is based in Mat-lab, and allows a easier way of identifying objects. The main advantage is the plotting ofthe sensors value, and so when they are activated is possible to be seen the value changingand it is graphically easily to identify objects.

i

Page 6: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

ii

Page 7: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Acknowledgments

I want to thank my family for giving me the opportunity of going abroad to a differentcountry and for all the support they have given me. I want to thank my friends i have metduring these long chapters of my life. In special to Juan Ortiz for being a truly friend inthe moments i needed the most. I also want to thank to my roommate for all the nightswithout sleeping and disturbances, Albert Gancedo thank you.

I want to thank to my supervisor in Poland, Dr. Andrzej Wolczowski for giving methe opportunity of being part of this extraordinary project. I want to thank my supervisorin Portugal, Dr. António Paulo Gomes Mendes Moreira for the coordination necessaryand for all the help in this project. A special thanks to Mateusz Cholewinski and JacekUrbanowicz for all the willingness.

Jorge Filipe Luís

iii

Page 8: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

iv

Page 9: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

“When the arm was put on, i had tears rolling down my face.It was the first time in 21 years that i had seen a hand open.”

Ray Edwards

v

Page 10: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

vi

Page 11: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Contents

1 Introduction 11.1 Basis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Acquisition System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Mechanical Stimulation . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Electrical Stimulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.5 Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 State of the Art 52.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Human Physiology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.2.1 How muscles work . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.2 Sensory system . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.3 Shadow Robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3.1 Tactile and Position sensors . . . . . . . . . . . . . . . . . . . . 72.3.2 Air muscles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.3.3 Communications and Control . . . . . . . . . . . . . . . . . . . 8

2.4 DARPA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.4.1 DEKA - Luke Arm . . . . . . . . . . . . . . . . . . . . . . . . . 92.4.2 APL - Proto 1 and Proto 2 . . . . . . . . . . . . . . . . . . . . . 11

2.5 Touch Bionics i-LIMB . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.5.1 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.5.2 Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.5.3 Sensory Feedback . . . . . . . . . . . . . . . . . . . . . . . . . 152.5.4 Future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.6 SmartHand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.6.1 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.6.2 Motor control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.6.3 Sensory Feedback . . . . . . . . . . . . . . . . . . . . . . . . . 172.6.4 Future . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3 Signal acquisition 193.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.3 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.3.1 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.3.2 Operational amplifiers . . . . . . . . . . . . . . . . . . . . . . . 21

vii

Page 12: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

viii CONTENTS

3.3.3 Multiplexer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.3.4 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3.4 System designing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.5 Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.6 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4 Mechanical stimulation 274.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.3 The math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.4 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.4.1 Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.4.2 Mosfet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.4.3 Darlington . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.4.4 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.5 System designing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.6 Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

5 Electrical stimulation 335.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.3 The math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.3.1 Boost converter . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.3.2 Current controlled circuit . . . . . . . . . . . . . . . . . . . . . . 36

5.4 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.4.1 Boost converter . . . . . . . . . . . . . . . . . . . . . . . . . . . 385.4.2 Current circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . 395.4.3 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

5.5 System designing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395.6 Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

6 Communications 436.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436.2 Communications design . . . . . . . . . . . . . . . . . . . . . . . . . . . 436.3 SMP-Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

6.3.1 Control messages . . . . . . . . . . . . . . . . . . . . . . . . . . 456.3.2 SMP-write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476.3.3 SMP-read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486.3.4 Slave receive . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

6.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

7 Control 537.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537.2 Acquisition system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

7.2.1 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537.2.2 User interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Page 13: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

CONTENTS ix

7.3 Mechanical stimulation system . . . . . . . . . . . . . . . . . . . . . . . 577.3.1 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577.3.2 Key locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

7.4 Electrical stimulation system . . . . . . . . . . . . . . . . . . . . . . . . 587.4.1 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.4.2 Key locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

7.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

8 Conclusions and Future developments 638.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638.2 Future Developments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

References 67

A Drawings 71

B Source code Acquisition System 75B.1 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75B.2 Main loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

C Source code Mechanical System 93C.1 Main Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

D Source code Electrical System 103D.1 DAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103D.2 Main loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

Page 14: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

x CONTENTS

Page 15: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

List of Figures

2.1 Comparison of the Human hand to Shadow Hand. . . . . . . . . . . . . . 72.2 QTC conduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.3 Air muscle in action. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.4 DEKA Luke Arm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.5 Power source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.6 TMR with IMES control. . . . . . . . . . . . . . . . . . . . . . . . . . . 132.7 i-Limb. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.8 SmartHand. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1 Acquisition architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . 203.2 Location of the sensors. . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.3 Test glove. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.4 Resistance vs force. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.5 Sensor diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.1 Mechanical stimulation architecture. . . . . . . . . . . . . . . . . . . . . 284.2 Darlington configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . 294.3 Motor control diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

5.1 Electrical stimulation architecture. . . . . . . . . . . . . . . . . . . . . . 345.2 Boost converter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.3 Proposed circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.4 Lower quadrant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385.5 Upper quadrant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385.6 Ne555 configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405.7 Simulation Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.8 Simulation Circuit, voltage around human skin. . . . . . . . . . . . . . . 415.9 Control circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

6.1 Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446.2 SMP-Write function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476.3 SMP-Read function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496.4 Slave receive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

7.1 Location of the sensors. . . . . . . . . . . . . . . . . . . . . . . . . . . . 547.2 User interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567.3 Location of the motor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597.4 Location of the circuits. . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

xi

Page 16: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

xii LIST OF FIGURES

A.1 Acquisition system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72A.2 Mechanical stimulation system. . . . . . . . . . . . . . . . . . . . . . . . 73A.3 Electrical stimulation system. . . . . . . . . . . . . . . . . . . . . . . . . 74

Page 17: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Abbreviations and Symbols

PWR Politechnika WroclawskaCPU Central Process UnitPWM Pulse-width modulationNPN Bipolar Transistor Negative Positive NegativePNP Bipolar Transistor Positive Negative PositiveCNS Central nervous systemQTC Quantum Tunneling CompositePSoC on-board Programmable System-on-ChipPAM Pneumatic Artificial MusclesADC Analog-to-Digital ConverterCAN Controlled Area networkDARPA Defense Advanced Research Projects AgencyFDA Food and Drug analysisAPL Applied Physics LaboratoryRIC Rehabilitation Institute of ChicagoTMR Targeted Muscle ReinnervationIMES Injectable Myoelectric SensorsUSEA Utah Slant Electrode ArrayTSR Targeted Sensory ReinnervationFSR Force Sensitive ResistorOPA Operational AmplifierTENS Transcutaneous Electrical Nerve StimulationUART Universal Asynchronous Receiver TransmitterDAC Digital to analog converterSPI Serial peripheral interface

xiii

Page 18: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

xiv Abbreviations and Symbols

Page 19: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Chapter 1

Introduction

This document describes the work developed in PWR - Politechnika Wroclawska. Itis referred what has been done, what were the approaches followed, the design circuitsalso as the future work to be developed. In this chapter it will be described what led tothe development of this project and what is the the structure of this document.

1.1 Basis

As it is known human limbs do not regenerate themselves. Having it as a backgroundit is necessary to develop intelligent systems able to replace this lost limbs. Usually thesesystems are prosthesis based in robotics. They are called bionic arms. But one of thebiggest problems is how to feedback what this arm is doing, what is it touching, whatis its space position. It is believed that one of the USA military problems is the soldiersthat come home and have lost their limbs serving their country, according to SSgt ReinaBarnett survival rates for combat wounded are higher than ever before and that meansmany more service members are coming home with severe injuries such as a lost of alimb. With this new approach it is possible to rehabilitate them whether in new militarymissions whether in normal day life.

The scope of this project is to help investigators to develop more advanced feedbacksystems. And when the objective is completed there will be greater satisfaction from theinvestigator and from the users that can actually get back their normal life, and realize thatsomeone is actually doing something for them. In a scientific field this project develop-ment can be understood as the search for the perfect super human, the perfect symbiosesbetween human machine and all of the applications that can be achieved.

“ The most important and urgent problems of the technology of today areno longer the satisfactions of the primary needs or of archetypal wishes, but

1

Page 20: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

2 Introduction

the reparation of the evils and damages by the technology of yesterday.” byDennis Gabor, Innovations: Scientific, Technological and Social, 1970.

1.2 Acquisition System

Acquisition systems assume a very important task. In order to achieve the most ef-fective system it is necessary to check previous systems already developed. It is alsonecessary to study what are the best options for the design of the system, such as sensorsand controllers. The main objective of this project is to develop a simple yet effectivenetwork of sensors. This network will be based in force sensors connected to microcon-trollers. These sensors must feel what is being touched by the prosthetic hand. Havingthis as background, it is also considered the control of the system and the development ofa new user interface.

1.3 Mechanical Stimulation

The mechanical stimulation is the most used stimulation in projects like this one. Thismethod is based in vibrating motors connected to the human body. It is a non invasivemethod because no surgery is needed. The main objective is to develop a mechanical stim-ulation with independent control of the motors. According to this, the proposed systemis based in a master microcontroller connected to different vibrating motors or stimula-tors. Having specific instructions from the master microcontroller the motors will vibrate.These will be indirectly connected to sensors, and it is possible to feedback the force, inother words, more force more vibration.

1.4 Electrical Stimulation

The electrical stimulation system is like the mechanical system, non invasive. Themethod is based in what has been already developed and used in medicine called TENS.These stimulation is called Transcutaneous Electrical Nerve Stimulation. Having a pairof electrodes attached to the human body is possible to stimulate the nerves. The mainobjective of the electrical stimulation system is to identify objects. This means, whensome object is identified the specific electric stimulator is activated. Another objective isto identify the force applied to the object, this means more force more electric stimulation.

1.5 Structure

This thesis is composed with more 7 chapters describing what has been done. Inchapter 2 is described the state of the art, what has been developed by some companies all

Page 21: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

1.5 Structure 3

around the world, is also described how muscles work in order to understand more aboutelectrical stimulations. Chapter 3 presents the first system developed, the acquisitionssystem. It is described what approaches have been made, what components chose as wellas the control. In chapter 4 is delineate the approach to the motor stimulation system.System designing, components chose, tests also as the mathematics behind are presented.In chapter 5 is described the electrical stimulation system. It is showed what has beendone, the system designing including mathematics and the tests performed. In chapter 6 isbased in the communications of all the systems. Also is described the protocol developed.Chapter 7 describes the control also as some code implementations. It is also presentedthe user interface developed. The last chapter 8 is described the conclusions of this projectalso as the future developments, what can be improved.

Page 22: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

4 Introduction

Page 23: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Chapter 2

State of the Art

In this chapter is briefly described how muscles work as an introduction to the matterof robotic artificial hand specifically prosthesis. After, it will be referred what has beenbrought up by many different researchers in the world.

2.1 Introduction

Since long time ago, human race has always tried to be one step ahead. One of manyexamples is the prosthetic field. In 424 B.C., Herodotus wrote of a Persian seer who wascondemned to death but escaped by amputating his own foot and making a wooden fillerto walk 30 miles to the next town [1].

But what is actually a prosthesis?Prosthesis is an artificial substitute of a part of the body, it can be a simple tooth

to a complete arm, or leg [2]. Against iron prosthesis from primitive times, nowadaysthese are much more lighter made of plastic, aluminum and other composite materials.These provide amputees functional devices. This is now possible with microprocessors,computer chips and robotics. In order to fully understand how this is possible is necessarya briefly background in medicine about muscles and sensory system.

2.2 Human Physiology

2.2.1 How muscles work

Muscle comes from Latin musculus, diminutive of mus ’mouse’, it is a band of fibroustissue in the body that has the ability to contract, producing movement [3]. Muscles arethe engine the body uses to move, without them it would be impossible. Most people thinkthe muscles are those which are visible, like the biceps or triceps, but it is completely

5

Page 24: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

6 State of the Art

wrong. Nowadays muscles are divided in three categories. These are smooth muscles,cardiac muscles and skeleton muscles. Smooth muscles are muscles which can contractinvoluntarily, like stomach muscles. Cardiac muscles are only in the heart, they can stretchlike smooth muscle, and contract like a skeleton muscle. Skeleton muscles come in pairsand are attached to the skeleton. One muscle is responsible to move the bone in onedirection and another to move it back the other way. The interest falls on the skeletonmuscles.

A muscle is comprised of cells called fibers. These are arranged in long cylinders andmade up of protein filaments, myofibrils. Myofibrils are made of protein myofilamentscalled actin and myosin. They are the so called thick and thin filaments. These allow mus-cles to contract. The triggering of these fibers, muscles, is an electrical impulse. Doingan analogy to electronics this is how it works. The brain is the CPU(Central ProcessingUnit). From the brain, through the spinal chord there are nerve fibers, like wires. Theneuromuscular junction is a small gap between the nerve fibers and the muscular fibers.At the neuromuscular junction the nerve fires up, producing what is called myopotentials,and causes the release of the neurotransmitter acetylcholine and stimulate the muscle tocontract [4].

2.2.2 Sensory system

The nervous system has a specific sensory system, one to each sense. Usually they aredivided in five classifications. They are touch, sight, hearing, smell and taste, accordingto Aristotle. The interest is in touch system, or somatosensory system. This system isbased on sensory receptors and afferent neurons in the skin or muscle, to even neuroneswithin the CNS(Central Nervous System). The feeling of touch is a perception. Thisresults from activation of neural receptors on the skin. The neural receptors cover all theskin. They detect stimulus, this stimulus is converted into information and it is directedto the CNS by afferent neurons [5]. Afferent neurons are composed of sensory nervefibers put together. These carry impulses from receptors to the CNS. The afferent neuronscommunicate one with each other, through what is called synapses. In the spinal cord, thesensory system includes paths from the body to the brain. Between the spinal chord andthe brain afferent neurons there is the association neurons [4]. In the brain, the primarysomatosensory system, the information is processed. Doing the same analogy as before,spread sensors on human skin, feel the touch, and transmit through wires to the CPU,which is in the brain.

Page 25: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

2.3 Shadow Robot 7

2.3 Shadow Robot

The Shadow Robot company is placed in London, United Kingdom. Currently, theyhave developed what has been said as the most advanced dextrous hand in the world.The Shadow Hand is a humanoid hand very similar to human hand in all aspects, as itis possible to be seen in figure 2.1. Shadow Hand has touch and position sensors andthe movement is provided by air muscles. It is able to reproduce 24 degrees of freedom.According to Matthew Godden, senior robotics-design engineer for Shadow company, thehand is commercially available and costs more than $100,000.

Figure 2.1: Comparison of the Human hand to Shadow Hand [6].

2.3.1 Tactile and Position sensors

The Shadow Hand uses new state of the art sensors. The position sensors are Halleffect sensor with resolution of 0.2 degrees. This data is sampled by 12 bit ADC(Analogto Digital Converter) and transmitted on the CAN(Controlled Area Network) bus. Thetactile sensors are based in QTC(Quantum Tunneling Composite). QTC is a new typeof conductive material developed by Peratech. It is made mixing metal filler particleswith some elastomeric binder, usuallty silicone rubber. Under pressure this sensor has theability to change from electrical insulator to conductive properties. What gives the QTCextremely good conductive is the fact that the metal particles have a surface normally withspikes. When pressed, all of the metal particles get closer allowing the sensor to conductas it is possible to see in figure 2.2 at page 8. Each tactile sensor of Shadow hand hasan PSoC (on-board Programmable System-on-Chip), which allows the user to activelycontrol whether the range whether the sensitivity.

Page 26: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

8 State of the Art

Figure 2.2: QTC conduction [7].

2.3.2 Air muscles

The air muscles are based in PAM(Pneumatic Artificial Muscles). They were firstdeveloped in the 1950s. The main objective was to use in artificial limbs. They areextremely similar to human muscles. Like biological muscles contract, these musclescontract when pressurized with gas. With a supply of compressed air, they contract byup to 40% of its original length [8]. They are a very powerful mechanism to providemovement. The core is an inflatable rubber tube, figure 2.3. The air muscle provides alight-weight low cost powerful actuator, easily employed in a variety of systems [9].

Figure 2.3: Air muscle in action [10].

2.3.3 Communications and Control

The Shadow Hand uses CAN standard interface bus. The microcontrollers PIC18F4580are used for control in the system. All sensor data, components, configuration and con-troller set points can be accessed over this bus [8]. Shadow company developed their ownprotocol interface.

Page 27: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

2.4 DARPA 9

2.4 DARPA

DARPA means Defense Advanced Research Projects Agency. DARPA was created inFebruary 1958 as an agency of the United States Department of Defense. They are re-sponsible for the development of technology. This was intended to use by the military. Itscreation was attributed to the launching of Sputnik by Soviet Union. In 2005, DARPA hasannounced a very ambitious program. This program is Revolutionizing Prosthetics Pro-gram. It is a two inter related program. Revolutionizing Prosthetics Program 2007 whichintends to deliver a working prosthetic arm with a neural interface by 2007, and Rev-olutionizing Prosthetics Program 2009 which will have a neurally controlled arm readyfor FDA(Food and Drug Administration) approval and clinical trials in four years [11].According to Col. Geoff Ling, DARPA’s manager of the programs, the RevolutionizingProsthetics program will create, within this decade, a fully functional upper limb thatresponds to direct neural control. It was awarded to DEKA Research and DevelopmentCorp. $18.1 million by the Revolutionizing Prosthetics Program 2007, and $30.4 millionto APL(Applied Physics Laboratory) of Johns Hopkins University by RevolutionizingProsthetics 2009 [12]. The Revolutionizing Prosthetics 2009 program is divided into two24-month phases [11]. The first end by the year 2007 and the second by the year of 2009.

2.4.1 DEKA - Luke Arm

DEKA Research and Development Corporation is a company founded in 1982 byDean Kamen. The name DEKA is derived from his name, and is worldwide known asthe inventor of Segway. By the year of 2007, DEKA introduce the world the Luke Arm,visible in figure 2.4 at page 10. The name comes from Star Wars: The empires strikesback after Luke Skywalker, who gets a artificial hand in. This prosthetic arm is state-of-the-art functional arm with usable fingers and sensory feedback [13].

“...after the initial shock of amputation wears off, usually within a year ortwo, patients stop wearing their prostheses. Even extreme levels of amputationdon’t much curb this tendency. Wearing the burdensome prosthetic is simplynot justified by the small amount of assistance it provides...” by Dean Kamen.

2.4.1.1 Specifications

The Luke Arm enables 18 degrees of freedom [15]. It is modular and was modeledbased on the weight of a female arm. The arm is powered by a lithium battery. The motorsused are electrical. It was built mostly in aluminiun because titanium is too heavy to keepthe weight limit, proposed by DARPA.

Page 28: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

10 State of the Art

Figure 2.4: DEKA Luke Arm [14].

2.4.1.2 Motor Control

With the cooperation of RIC(Rehabilitation Institute of Chicago) DEKA has a twoway of controlling the prosthesis. The first is controlled by specific controllers placed inthe soles of shoes and the second way is thought controlled. The shoes controller canbe fully customizable. For example when user pushes down his left big toe, the armmoves forwarded and when he pushes down his right big toe, the arm moves backwards,like a normal skeleton muscle. The second way control is by thought control [15]. It isonly possible to the innovative surgery developed by Dr. Todd Kuiken from RIC. It isTMR(Targeted Muscle Reinnervation). TMR is a method by which the target muscle ofan amputated patient is denervated, then reinnervated with residual nerves of the ampu-tated limb [16]. In the specific case, like arm prosthesis, this method consists in reassignthe nerves that once controlled the patient’s arm and hand to the patient’s pectoral mus-cles [17]. With this new approach the patient thinks about moving the arm, and the signalsare fired up in the chest muscles. Then these muscles contract in response to the signals,myopotentials. The contractions are sensed by myoelectric sensors, these send the signalsto an amplifier and digital signal processor, which sends command signals to the motorsof the prosthesis [11]. Finally the arm moves by thought control.

2.4.1.3 Sensory Feedback

The Luke Arm provides feedback in a non invasive way. This means no surgery isneeded. The feedback is based in two different approaches. The feedback is given bya tactor. A tactor is a vibrating motor. A tactile sensor on the fingertip of the LukeArm, connected to a microprocessor, sends a signal to the tactor, and that signal changes

Page 29: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

2.4 DARPA 11

with grip and force. When a user grabs something lightly, the tactor vibrates slowly. Asthe user’s pressure on the object increases, the frequency of the vibration increases [15].Another approach is accomplished by using tiny balloons. The shoulder socket, is fullwith this tiny balloons. These have two objectives. The first is to give much more modularand comfortable prosthesis, and second transmit the feedback sensing. When the userlifts something these balloons inflate proportional, giving at the same time a comfortableposition and heavy sensation.

2.4.1.4 Future

According to Dean Kamen before the arm can be commercialized, it needs to be ap-proved by the FDA. Current stage of the Luke arm is clinical trials. The Luke Arm sentto clinical trials is the one that uses controllers placed within the soles of shoes, and it isexpected to have a price of $100,000 US.

2.4.2 APL - Proto 1 and Proto 2

APL of John Hopkins University is a non profit, university affiliated research centerlocated in Maryland, US. The Revolutionizing Prosthetics 2009 program that is beingmanaged by APL leader by Stuart Harshbarger is divided into two 24-month phases [11].The first end by the year 2007 and the second by the year of 2009. In the first phase, APLled a team of approximately 30 organizations. Against all expectations one year before thedeadline, APL showed the world their first prosthetic arm, it was called the Proto 1 [18].Few months later the second prototype was unveiled. In 2008, DARPA gives green Lightfor Phase 2[19].

2.4.2.1 Specifications

Proto 1 has been built with eight degrees of freedom compared to the 25 degrees of theProto 2. This has almost has much dexterity as a human limb [20]. Proto 1 is a completeprosthetic system. This system is based in a virtual environment with the objective ofpatient training and clinical configuration. It has the ability to record movements andcontrol signals. Proto 2, has also a virtual environment but it goes further ahead with15 motors in the hand alone capable of extraordinary mechanical agility. Proto 1 andProto 2 use electric motors and the power comes from heavy power supply on the floor.Engineers at Vanderbilt University are working on a pneumatic actuation system, seen infigure 2.5 page 12 . The power unit provides about ten times as much power as otherprosthetic limbs, according to Michael Goldfarm, professor of Mechanical Engineeringat Vanderbilt University. It contains a special catalyst that causes hydrogen peroxide toburn, producing pure steam. The steam is used to open and close the valves. These are

Page 30: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

12 State of the Art

connected to the spring loaded joints of the prosthesis by belts. A small sealed canister ofhydrogen peroxide that easily fits in the upper arm can provide enough energy to powerthe device for 18 hours of normal activity [21].

Figure 2.5: Power source [21].

2.4.2.2 Motor Control

According to Dr. Harshbarger the degree of control is directly proportional to theinvasiveness of the method. APL team is working with four levels of neural interface. Forlow level amputation it is used simple electrodes on the limb skin, because the muscles andnerves are still there. The electrodes detect and amplify those signals. After with patternrecognition algorithms, the impulses are translated to instructions to microprocessors.A lot of noise is introduced, so it is only possible to open and close hand. The secondlevel is application of IMES(Injectable Myoelectric Sensors), for the control of the fingersindividually. These sensors are injected into the muscle tissue of the remaining limb, theyare capable of detecting and transmitting a cleaner and higher fidelity signal, and so, allowbetter motor control of the arm [20]. IMES are powered by a coil in the prosthetic limb.For more severe amputations the control is the same as the control defined in previoussection. It is based in TMR. With IMES and amplifiers it is possible to detect the musclefiring up, and control the motor. It is seen this effective control in figure 2.6 at page13. The most extreme solution is meant for people whom the TMR surgery is not evenan option. In such cases University of Utah developed an implantable device called theUSEA(Utah Slant Electrode Array). This is a 5 millimeter square grid of 100 electrodes,similar to needles. These sensors are placed in the brain’s motor cortex, more specificallyon the top of the skull. These pick up the brain’s signals and are capable of intercept theneurons firing up. With the help of complex algorithms it is translated the related signalsinto a language that can control the mechanics of the arms [20].

Page 31: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

2.4 DARPA 13

“The Rehabilitation Institute of Chicago continues to advance this applied re-search and bring the application of the Targeted Reinnervation technique tothe forefront to benefit our nation’s service men and women.” by Dr. Kuiken.

Figure 2.6: TMR with IMES control [22].

2.4.2.3 Sensory Feedback

Proto 1 has force sensors in the artificial hand that give the user a sensation of touch.According to Harshbarger Proto 2 has built in 100 sensors [20]. These will give users asense of touch, temperature, pressure, and vibration, as well as a sense of where the limbis situated in space [23]. Proto 1 and Proto 2, use the same mechanism used in the Luke’sarm, the tactor or vibrating motors. This is the best mechanism on the market today. Likeexplained in previous section it is based of a vibrating motor against the skin that vibratesmore or less intensely to feedback, force factors. According to APL other technologiesare being explored as well [23].

Page 32: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

14 State of the Art

“This work offers the possibility that an amputee may one day be able to feelwith an artificial limb as though it was his own. Sensors could be placed ina prosthetic hand to measure contact forces and temperature, while a devicecould press or thermally stimulate the reinnervated skin to provide sensoryfeedback that appropriately correlates to hand perception.” by Dr. Kuiken.

Dr. Kuiken discovered that TMR was responsible not only for muscle control but alsofor sensation, in other words, rerouted nerves sensitized the skin. But the volunteers didn’tfeel the sensation in the chest, they felt it in the phantom limb, according to DR. Kuiken.This is called TSR(Targeted Sensory Reinnervation). By placing the tactor on the chestnext to the electrodes, they created a complete feedback loop [24]. In the end, Dr. Kuikencomplex rewiring scheme and the brain simulated a real arm. In [25] is shown a patientssensory map, due to this TSR. Dr. Kuiken has been working to redefine the map of thephantom limb to determine the connection between the exact location on a prostheticfinger and the corresponding feeling perceived in the phantom limb [20]. This feedbacksystem was developed by Kinea Design and it is called Prosthetic Haptic Interface SystemProject. The system is composed of three subsystems. Fingertip sensor - this sensor isplaced on the fingertip of a prosthetic hand and senses force and accelerations. Haptictactor - vibrating motor which displays the force, texture and friction sensed by the sensor.Embedded controller system - the signals from the sensor are converted into commandsignals that allow the tactor to vibrate according to the force, texture and friction sensed.

2.4.2.4 Future

Currently some technology used in these Prosthetic arm is on its way to FDA trials,such as IMES and USEA. It is left in the air the connection of sensors directly to humansomatosensory system.

2.5 Touch Bionics i-LIMB

In 2007, Touch Bionics, a company situated in Scotland, introduced the world whatis called the i-Limb [26]. It was invented in Edinburgh, Scotland, by David Gow. i-Limbhas become the first commercially available hand. This has five individually powereddigits. These digits are simple robotic fingers. i-LIMB, figure 2.7 page 15 , is capable ofdifferent grip positions. It allows the user to balance power and precision. Extending theindex finger it is possible to type on a computer. The ut pageser can grip a key by rotatingthe thumb. These prosthetic hand has a cost of approximately $18,000 US.

Page 33: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

2.5 Touch Bionics i-LIMB 15

Figure 2.7: i-Limb [27].

2.5.1 Specifications

i-LIMB has a modular construction, this means that each digit is easily detached byremoving one screw. It has electric motors and it is powered by a battery. It takes be-tween one and four hours to charge. i-LIMB has multi position thumb, which allows tomanipulate the thumb into different positions, grips. These grips are normal predefinedpositions of the hand [28]. It has key grip - the thumb closes onto the side of the indexfinger. Power Grip - all fingers close to create a full wrap grip. Precision Grip - wherethe index finger and thumb meet. Index Point - the thumb and fingers close but the indexfinger does not. Fingers can be controlled from sensors. These sensors are from eitherFSR(Force Sensitive Resistor) or Remote Electrodes.

2.5.2 Motor Control

i-LIMB Hand, uses myoelectric principles already developed and spread in other pros-thetic hands. It is controlled using two sensors. These are myoelectric sensor, it readsnerve impulses through the skin with non invasive fittings, easily configurable. One is sit-uated in upper prosthetic and the other down. The hand uses a stall detection system. Thisis system allows to tell when is applied enough pressure. After is able to stop powering toprevent crushing the object. It is also capable of self adjusting to the shape of the objectthanks to the individually controlled fingers, or digits [29].

2.5.3 Sensory Feedback

The feedback of i-LIMB is referred as ’phantom’ feelings. Patients usually have asensation that their hand still exists despite it being amputated [28]. This is experiencedbetween 80%-100% of patients who lost a limb, by many reasons. This is explained as ifone part of the somatosensory cortex is deprived of input, the somatosensory cortex willreorganize the inputs so that the idle areas of the cortex become active [30].

Page 34: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

16 State of the Art

“You can fool the brain into changing its programming,” by Dick Nickle.

2.5.4 Future

Touch Bionics is developing a new product for patients missing individual fingers.They are also waiting for TSR and TMR techniques to become widespread. After ispossible to start the development of a new i-LIMB.

2.6 SmartHand

The SmartHand is a European Union collaborative project to produce a functionalartificial hand that looks and feels to a patient like a real hand [31]. SmartHand is thefirst device of its kind to feedback signals to the wearer, figure 2.8, allowing them to feelwhat they touch. This project counts with the participation of Tel Aviv University (Israel),ARTS Lab, Scuola Superiore Sant’Anna (Italy), Aalborg University (Denmark), TyndallInstitute (Ireland), Ossur (Iceland) and SciTech Link HB (Sweden).

Figure 2.8: SmartHand [32].

2.6.1 Specifications

The SmartHand has four electric motors and 40 sensors. It can replicate the the move-ment of a human hand. It is able to provide the user with a sensation of feeling andtouch.

2.6.2 Motor control

The control of the motors are very similar to has been written in previous sections.These are based in myoelectric sensors. An amputee thinks about moving a hand, thesesignals activate muscles that would have moved the fingers. Myolelectric signals from

Page 35: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

2.7 Conclusion 17

those muscles are recorded by electrodes applied to the forearm and then transmitted tomotors in the artificial hand [33].

2.6.3 Sensory Feedback

It is in the sensory feedback that smart hand marks its difference.

“The big difference between our system and others is the sensory feedback”by Fredrik Sebelius.

It is the first prosthetic hand to give feedback to its user, a real feeling. Accordingto Prof. Shacham-Diamand from from Tel Aviv University perfectly good nerve endingsremain at the stem of a severed limb [34]. His team connected the sensors in the handto the nerves in the arm. Now, it is possible to feel as well as to control. The sensoryinformation provided by the arm has to be fed back to the residuum remainder of theamputated arm, the only problem is to find out where [33]. It is very difficult to identifythe sensing of each finger. In this perspective, different techniques described in previoussections can be used, like TMR and TSR. Robin af Ekenstam is the project’s first humansubject.

“I am using muscles which I haven’t used for years. I grab something hard,and then I can feel it in the fingertips, which is strange, as I don’t have themanymore. It’s amazing.” by Robin af Ekenstam.

2.6.4 Future

The long term objective is developing a neural interface. The researchers are alsoplanning to equip the smart hand with artificial skin. This will give the brain even moretactile feedback. In 1 year, 2011, is possible that the Smarthand will be commerciallyavailable.

2.7 Conclusion

The prosthetic field is becoming a field of great interest. A field of excellent oppor-tunities for investigators and for market success. With what technology offers is possibleto build similar prosthesis as human limbs. All around the world, efforts are being madeand it is possible to see what has already been done whether in electronics whether inmedicine. DARPA and the revolutionizing program have made extraordinary develop-ments in prosthetic control, using pattern recognition algorithms, but it is definitely theSmarthand the most interesting program, because it has already shown a human machineinterface, allowing to the user to feel the prosthetic hand. Human feels not with help of

Page 36: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

18 State of the Art

tactors but electrical stimulation directly on the nerves. It is believed that DARPA hasalready connected the the prosthetic to the human sensing fibers.

All these mechanisms of feedback allow to delineate an approach to the work devel-oped. Although, the lack of technical information of these prosthetic hands it has beendescribed all the mechanisms of control and feedback.

Page 37: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Chapter 3

Signal acquisition

In this chapter is described the approach made to the signal acquisition, also is de-scribed the sensors used, what other options were available as long as all the componentsused like microprocessors.

The choice of the components used was based in what has been developed in otherprojects also as the price. The main goal was to build a sensing hand keeping everythingperceptible and simple as it should be.

3.1 Introduction

As it is known in projects like this one, the signal acquisition is one of the mostimportant steps. It is important because a simple and a good acquisition system allowsthe developer and also the user to achieve excellent overall results. Before choosing thecomponents, a previous study of the market was made. Some companies all around theworld were asked about their solutions and prices. Projects developed in this area werealso an excellent help. The goal was the development of a sensing hand. In other words,having a robotic hand, or a prosthesis it should be implemented various sensors in specificlocations in order to feel and identify the object touched. This signal acquisition was basedin FSR, using ADC and also OPA (Operational Amplifiers).

3.2 Description

The architecture of the signal acquisition is very simple. The most important are thesensors. These are FSR, spread all over the hand. After the sensors it is necessary totreat the signal, so it was used, OPA. Next it was the filtering for that it was used a lowpass filter, connected to a multiplexer. This multiplexer is connected to the ADC of the

19

Page 38: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

20 Signal acquisition

microcontroller. This microcontroller has the ability of process this signals and accordingto each one giving the control orders. The architecture is seen in figure 3.1.

Figure 3.1: Acquisition architecture.

3.3 Components

In this step of the project a lot of options were available since the sensors to the mi-croprocessor, after some search and market study it was chosen the next components.

3.3.1 Sensors

Choosing the best sensors is not an easy task, it was necessary to contact companiesthat develop sensors. The chosen sensors are force based. When a force is applied theoutput value changes, whether it is in voltage or in other type of output. One of theparameters was the price of the sensor. According to this, some options were excluded atthe beginning.

3.3.1.1 Weiss Robotics

Initially, it was contacted Weiss Robotics. These sensors are pressure sensors inte-grated in various applications. The sensor available was DSA 9205 with a price of 650Eur, it is necessary the acquisition system provided by the company with a estimated priceof 1980 Eur. This option was excluded.

Page 39: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

3.3 Components 21

3.3.1.2 Peratech

The sensors provided by Peratech are QTC based. Since they are not sold as individu-als and it is necessary to develop them. The project cost is estimated to be around 20,000to 40,000 Eur. Option excluded.

3.3.1.3 Pressure Profile

Robot touch - The system includes 7 sensors molded on Barrette Hand provided bycustomer, D500 board, visualization software, expansion module with at ribbon, exiblewiring harness. The system is priced at 15,000 Eur.

3.3.1.4 TME

The sensors provided by TME are FSR. They are force based although they are notrobust if used often they are very practical and cheap. Each one costs 10 Eur. These werethe sensors used.

3.3.2 Operational amplifiers

The first parameter for the choice of the OPA was that it had to been rail-to-rail, so itis only necessary to supply with positive voltage. The other parameter was to use as manyas possible in one single chip. The choice of the OPA was the LMC6484AIN. It is a quadrail to rail amplifier. Each unity costs 3.15 Eur.

3.3.3 Multiplexer

The multiplexer chosen was the 74HCT4051. This is a 8-channel analog multiplexerand demultiplexer. Each unit has a cost of 0.303 Eur.

3.3.4 Microcontroller

Doing a quick search on the available microprocessors there are a lot of companies.The choice made was the AVR company, because of the more familiar microcontrollers.It was chosen the Atmega32. This has 32k of memory, with a lot of available protocolcommunications, also has 8 ADC channels so it was enough for the acquisition system.With these 8 ADC channels, in the future it is possible to extend the acquisition system tomore sensors. It was chosen this microcontroller also because of 32k of memory, that ismore than enough to control the system. The price of this microcontrol is about 4 Eur.

Page 40: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

22 Signal acquisition

3.4 System designing

After the selection of the sensors it is necessary to put them in the prosthesis. Sinceit was not available, the test was made in a human right handed glove. There were only5 sensors available, so it was necessary to put them in some specific points. These wereplaced in key locations to the human hand, in other words in the top of fingers, and palmof the hand. In figure 3.2, it is seen the location. There is one sensor in the middle finger,two on the index finger, one in the thumb finger, and other in the palm hand.

Figure 3.2: Location of the sensors.

These are strategical places, for example when picking up a pen only the thumb andindex finger are activated, easily identifying one type of object. In figure 3.3 at page 23it is possible to see the test glove with all this sensors stitched. This procedure was madein order to not destroy the sensors, so later they can be used in the real prosthesis.

Since the sensors are force sensing resistor, they act as a resistance. This value changeswhen a force or pressure is applied. The resistance is inversely proportional to the forceapplied, i.e. the resistance decreases as the force increases. Having this as backgroundit was decided to use this FSR in a voltage divider. Using a supply of 5 V connected tothe sensor and then to a 260k Ohm connected to the ground. In figure 3.4 at page 23 itis seen the resistance vs force. This resistance was chosen because, first it was suggestedby the producer that the maximum current should be 2.5 mA. Next with a resistance in kOhm it is possible to obtain a good voltage measure with a small force, and so easier tothe system to feel a touch in a object.

Page 41: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

3.4 System designing 23

Figure 3.3: Test glove.

Voltage : Vo =260k

260k+RVi (3.1)

Analyzing the equation 3.1 it is possible to see that when no pressure is applied theFSR resistance is about M Ohm, so in this case the output voltage will be 0. When apressure is applied and the FSR resistance comes under the 260k Ohm, the output voltageis half of the input. When the FSR resistance is much more lower than the resistor, it ispossible to despise the FSR and the output voltage will be the input voltage, in this caseit will be 5v.

The configuration used to the OPA was voltage follower. It was used this voltage fol-lower because although there is no change in the voltage value it allows that the input ofthe OPA does not load down the source or draw any current from it. Because the outputimpedance of the OPA is very low, it drives the load as if it were a perfect voltage source.According to this configurations and to the input resistance it is possible to reduce powerconsumption in the source, distortion from overloading, crosstalk and other electromag-

Figure 3.4: Resistance vs force.

Page 42: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

24 Signal acquisition

netic interference. In this system it is used only five OPA although it is possible to extendit to 16, extending to 16 sensors.

These channels of the sensors are going to be connected to the multiplexer. Choosingthe right commands S0,S1 or S2, is possible to choose the right input, and so having iton the output. Each one has 8 channels, and it was used 2 multiplexers. Once again it ispossible to extend to 16 inputs. Each multiplexer output is connected to a microprocessorADC. Since it is only used 2 multiplexers it is necessary two ADC from microcontroller.

The control system is quite simple, mainly the microprocessor gives order to the mul-tiplexer. According to the order this changes the input channel, reading various inputchannels.

Figure 3.5: Sensor diagram.

In figure 3.5 is possible to see the diagram of the control of the sensors. Like it wassaid if control=1 then it starts the algorithm control. In the beginning the sensors are read.The sampling time is 0.25 Hz for this configuration. After, is send to the UART(UniversalAsynchronous Receiver Transmitter) the values. UART is a device that translates databetween parallel and serial forms. According to the instructions some measures are takenand send to the circuits controlling the stimulation to the human. These instructions willbe explained later in the document. The control is activated by UART interrupt. Whenthere is a interrupt the message is read and if is a control message for the acquisitionsystem it will test if is ’senson’ and so control=1. If the string is ’sensof’ then control=0.

Page 43: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

3.5 Tests 25

If it is not a control message, this is sent over SPI to the other systems. In the beginningeverything is shutdown, control=0.

3.5 Tests

Before connecting it to the stimulation systems some tests were made, in order to seeif it was everything working. Connecting the microcontroller to a max232 it was possibleto have a connections with the computer. Some steps were followed.

1. Test if the UART interruption was working. Connecting a led to a port of the micro-processor. If the string from UART port was ’senson’ the led will turn on, and if itwas ’sensof’, it will shutdown. Overall result, interruption working.

2. Test if the values of the sensors and the multiplexer were working. Choosing differ-ent sensors, send the values to the UART port. Using a multimeter it was comparedthe values received from microcontroller to those that the multimeter was reading.

3. Test if everything was working. After the previous tests if was assembled all theacquisition system and checked if it was everything working and searching for somebugs.

3.6 Conclusions

The acquisition system developed proved to be effective. The objective of keeping itas simple as possible was partially completed. It was necessary to develop a test glove,and analyze how human hand behavior when grabbing some objects in order to knowthe key locations for the sensors. This glove proved to be effective, although the sensorswere stitched. One problem of this procedure was the sensors sometimes cannot readefficiently, because the sensors do not keep their original locations. For example, whenthe size of the hand changes the overall result will also change. It was necessary to usemultiplexers and thus increasing the difficulty to accomplish the main objective. Ledswere placed for a feedback, green and red. These allow to know when the system isturned on or off.

Page 44: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

26 Signal acquisition

Page 45: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Chapter 4

Mechanical stimulation

This chapter will address the stimulation of the human body by motors. This is oneof the most used stimulations in projects like these, by many reasons. Whether is theextremely low cost of this motors, whether is the non invasive way of this method. It willbe described the assembly of a mechanical stimulation system, what components wereused, as the mainly results achieved.

4.1 Introduction

Stimulations of prosthesis can be divided in two main groups. One is the invasiveone, and the other the non-invasive. Mechanical stimulation is considered non-invasivebecause it is not necessary any surgery to human body to implement sensors, or stimu-lators. The main objective was to develop a such way system. This system is based insmall electric motors, attached to a t-shirt in some specific locations. When some sensoris activated it should turn on a motor. To accomplish this goal it is necessary having allthe right circuits implemented as well as good control algorithm.

4.2 Description

The mechanical stimulation system must respond like the impulses do in human body.This means, when there is some changing in the skin, for example when the hand is touch-ing something, is possible to feel and act according to what is felt. In the mechanicalstimulation it also should work like that, when the sensor “feels” it should be transmittedto the motors to turn on, and only when there is a change of state this should shut down.Receiving commands from the signal acquisition system, the motor system should inter-pret them, and change the state of the motors. This can be understood in figure 4.1 at

27

Page 46: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

28 Mechanical stimulation

Figure 4.1: Mechanical stimulation architecture.

page 28. It will be used PWM(Pulse Width Modulation) from microcontroller. Originallywas thought to use PWM in order to change the frequency of the vibration, according tothe sensors value. Since it is not possible to use a different PWM for all motors it waschosen to have the same PWM for all motors, the only difference is the time that each oneis going to be on and off.

4.3 The math

When the work is about motors it is necessary to know how to drive them. In thisproject the motors were already provided. The maximum operating voltage is 5v. Fordriving this motors it is necessary a bigger amount of current and so it is necessary todo the scaling of the circuit. It is not important in which direction the motor is spinningand for that it is not necessary a H-bridge controlling the rotation direction. The bestway and cheapest to drive a motor is with transistors, since it is not necessary a highcontrolled system it was used NPN(Bipolar Transistor Negative Positive Negative) tran-sistors. Considering all options the best one, was to use a Darlington circuit. This allowsa high current on the output with a minimal one on the input, and so it can be driven bythe microcontroller. Usually a Darlington has a gain of 1000 over its base current, so it ismore than enough to drive this motors. It is seen the configuration chosen in figure 4.2 atpage 29. According to [35], the resistance between base and emitter allows a dischargepath for the charge accumulated on the base emitter junction, allowing a faster transistorturn-off.

Darl1 : Vm −Vr −Vbe−Vbe = 0 (4.1)

Page 47: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

4.4 Components 29

Figure 4.2: Darlington configuration.

5−Vr −0.7−0.7 = 0 (4.2)

Vr = 3.6V (4.3)

I =3.62.7k

(4.4)

I = 1.33mA (4.5)

Considering the Vm from microprocessor and Vbe the voltage drop between the baseand emitter. In 4.5, with an 1.33 mA current is possible, if the supply can handle it, havean output current of about 1.33 A, which is more than enough to drive one motor.

4.4 Components

For this system some components were used from previous projects developed, likefor instance the electric motors.

4.4.1 Motors

The motors provided to this project are vibrating electric motors from cell phones.Since they are available in old cell phones it is possible to have as much as necessary,with a minimum cost.

4.4.2 Mosfet

Mosfet is a well known and used transistor in different applications. It is necessary touse one for the PWM to the motors. By suggestion it was chosen the IRLZ44N becauseit is only necessary 5v to drive this mosfet, and so Vd >Vg−Vt . It has a cost of 0.616 Eur.

4.4.3 Darlington

The choice of the Darlington circuit was ULN2803A. This is a eight Darlington array,and so we have 8 possible controllers for 8 different motors. The price is 0.323 Eur.

Page 48: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

30 Mechanical stimulation

4.4.4 Microcontroller

The microcontroller chosen was an Atmega16. It was chosen this one, because it isnot necessary so much memory like in the acquisition system. It has also UART com-munication, and so it is possible to interface it whether it is with the computer whether iswith the acquisition system. The connection is similar to atmega32. The price is about 4Eur.

4.5 System designing

Some aspects were considered in order to achieve the best solution for the mechanicalstimulation. The first, all motors spin at the same frequency. This option was choseninstead of different speeds for motors because it was difficult to differentiate various spin-ning speeds when for example there was a body movement like walking. And so cuttingon the necessity of 8 mosfets. With the same frequency for all motors it is only neces-sary one mosfet controlling the opening and closing in order to produce a PWM signal.The microcontroller is controlling the mosfet directly, and mosfet is connected to the 5V supply. The second aspect, at the same time that microcontroller controls the PWM,also controls the Darlington array. With this is possible turn on and turn off the motors,independently. For example is possible to control the motor with a PWM fixed, and withthe Darlington turning on and turning off with a frequency desired.

The control for the mechanical stimulation system is basically, according to the in-struction received, the microcontroller co-ordinates which motors and what frequency arethey going to spin.

In figure 4.3 at page 31 is seen the algorithm of control of this system. The systemis on stand-by, if receives an interrupt from UART checks the slave. If it is for him thenprocess the message and the instructions are saved. These will be explained further inthe document. In the main loop it will check if the control is activated. This is activatedwith a message from acquisition system. If control is equal to 1, the timers are initialized,the data is processed and each motor is activated. With this option is possible to have amodular system, interchangeable with other different ones.

4.6 Tests

In order to check the effectiveness of this system some tests were made before con-necting it to the global system. Once again, with a max232 and using the UART waspossible to check and to control this motors. Some steps were followed.

1. Test if the UART interruption was working. Having a led turning on and turning offwas possible to check if the UART interruption was working.

Page 49: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

4.7 Conclusion 31

Figure 4.3: Motor control diagram.

2. Test if the PWM was working. Also having a led as background was possible tocheck if the PWM was working. By changing this frequency was possible to changethe intensity of the led, implying that everything was working.

3. Test if the Darlington array was working. Connecting a single motor to the PWMand to the Darlington circuit, was changed the on and off frequency, also was con-trolled if the system was on or off.

4. Test if the system was working. With all the motors connected to the mosfet and tothe Darlington array it was possible with the computer change which one was on.This allows the control of the frequency.

4.7 Conclusion

This is one of the most used non-invasive stimulation systems in this type of projects.The system developed is a simple and time effective. The distribution of the motors, forexample in a t-shirt is easily changeable. The motors turn on and off only when there is achange of state. For example, the system receives an order to turn on the motor 1 with xfrequency, it will only shut it down again when receives a new order from the commandsystem, in this case the acquisition system. This system has a drawback because it is usingUART interrupt. So if it takes to long the interrupt the frequency of turning on and off the

Page 50: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

32 Mechanical stimulation

circuit will also change. This will be explained in detail further in the document. It wasalso connected two leds, green and red, to identify how was the state of the system.

Page 51: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Chapter 5

Electrical stimulation

Another type of stimulation is by means of current. This method is also a non invasiveway, it stimulates the nerves. This stimulation is used in medical therms to treat pain. Inthis chapter will be discussed how this system was developed, what has been done, whatapproaches were followed, what components were chosen as well all the tests necessaryto check the effectiveness of this method.

5.1 Introduction

One of the electrical stimulation methods used whether is for this kind of project or formedical ones, is called TENS. TENS means Transcutaneous electrical nerve stimulation,it is used to treat pain. The unit is usually connected to the skin using two or moreelectrodes. This is able to modulate pulse width, frequency and intensity. Following theselines it was developed a TENS module but for different purposes. Using electrodes insome key locations it is possible to identify objects. Changing the frequency as also asthe amplitude, much more effective pattern recognition is achieved.

5.2 Description

The electrical stimulation system will behave like the mechanical stimulation. It willrespond to a impulse from the sensors. The main difference is that this stimulation systemwill only be used to identify objects. For example, the glove is holding a pen, since onlytwo sensors are activated and it is a simple object two electrodes in a key locations shouldstimulate the nerves, and so it is possible to identify without watching the object.

In figure 5.1 at page 34 is seen the architecture of the system, once again, this is similarto the motor stimulation.

33

Page 52: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

34 Electrical stimulation

Figure 5.1: Electrical stimulation architecture.

5.3 The math

Before actually developing a electrical stimulator, was necessary to figure it out whichapproach to follow. Some research was made and after two options were available. Firstone was to develop a voltage controlled source, and the second one current controlledsource. The choice made was the current controlled by many reasons. Although it ismore difficult, it has one great advantage. As it is known, human skin resistance also asthe muscles resistance changes from person to person. Having a controlled voltage, withchanges in resistance it will lead to different currents and small current of 5 mA in theheart is enough to make some damage. Having a controlled current circuit, this problemdoes not exist, because in spite of the resistance changes the current is always constant,[36] .

Primary is necessary enough power to drive the current circuit. For that, the bestsolution considered was a boost converter. A boost converter is a type of DC-DC converterthat has an output voltage magnitude that is greater than the input voltage.

5.3.1 Boost converter

A typical boost converter is seen in figure 5.2 at page 35.It was defined before the input voltage is 9 V and the output should be 150 V with 150

mA. This values were chosen because of eventual losses in the circuits and it was thoughtto drive all the circuits at same time. The following equations are best explained in [37].

Dutycycle :Vo

Vi=

11−D

(5.1)

Page 53: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

5.3 The math 35

Figure 5.2: Boost converter.

D = 0.94 (5.2)

Inductor : IL =Io

1−D(5.3)

= 2.5A (5.4)

In equation 5.2 is possible to see what is the necessary duty cycle to this boost. Inequation 5.4 is calculated the average current passing through the inductor. Initially wasthought to develop this boost converter using a microcontroller, so the frequency cho-sen was a multiple of the clock frequency, equation 5.6. After the period is calculated,equation 5.8.

Clock : F =Fc

256(5.5)

= 62.5kHz (5.6)

Period : T =1Fc

(5.7)

= 16us (5.8)

Now, it is possible to know the time that the transistor should be on and off, equation5.10.

Ton : D =tonT

(5.9)

ton = 15.04us (5.10)

After knowing the variables it was possible to scale the inductor size, the approachused was simple. Considering a 10% of the input current, ∆i = 0.250A it is possible toobtain the size of the inductor, equation 5.12.

Inductors : Vi = Ldidt

(5.11)

L =Viton

∆i(5.12)

Page 54: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

36 Electrical stimulation

= 541uH (5.13)

Another approach was followed using the current formula.

Inductors : Lm ≥ DVi(1−D)

F2Io(5.14)

≥= 67uH (5.15)

The capacitor was also based in simple equation. Considering a 0.5 voltage ripple thecapacitor voltage output, equation 5.17.

Inductors : io =Cdvdt

(5.16)

C =Io∆T∆V

(5.17)

= 4.8uF (5.18)

Having this calculations as background, the inductor available was a 100uH and thecapacitor was a 10uF.

5.3.2 Current controlled circuit

Before developing this circuit it was necessary some background. According to [38],it was proposed a constant current circuit followed by transistors that can control whichelectrodes are activated. This circuit uses two fly-back power converters. This is used forpositive and negative current on the electrodes. Biphasic current allows the depolarizationof the skin, allows a much more efficient power transfer for muscle stimulation avoidingalso chemical reactions. Also it is difficult to get skin burns due to high voltages. Sinceit was not necessary so much efficiency and though having negative current because itis not going to be used for medical terms, it was only developed one stage circuit. In[39] is proposed another approach, using a H-bridge for stimulation. Like before, is usedbiphasic current. Having these lines, the proposed circuit was based in a half H bridge,and instead of controlling a motor it is electrodes. The power supply is the boost converter.This proposed circuit allows a square wave. Usually, TENS waveforms are short squarepeaks with ajustable duty cycles and pulse widths [40].

In figure 5.3 at page 37 it is the proposed circuit, in upper quadrant it will be controlledby a PNP(Bipolar Transistor Positive Negative Positive) transistor, and in lower quadrantby a NPN transistor, with an attached resistor which will allow a controlled current, figure5.4 at page 38. Every half bridge has one pair of electrodes, the positive and negative. Itwas used this configuration with two power transistors because it is safer and controllable.

Page 55: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

5.4 Components 37

Figure 5.3: Proposed circuit.

With the PNP transistor it is possible to isolate the voltage output(150 v) from the positiveelectrode in the skin. This leads to a safer circuit. In case of contact with ground, havingboth NPN and PNP off, there is no voltage in the positive electrode. The DAC is used inorder to obtain a controlled voltage which will allow a controlled current. Doing somemath, having 5 V from the DAC, and 50 Ohm from the resistor.

Current : 5−V be− ir ∗R1 = 0 (5.19)

ir = 94mA (5.20)

With this configuration it is possible to obtain from 0-94 mA, which is enough tostimulate the nerves, 5.20. This is the maximum current value. It was chosen consideringsome eventual losses, although it is easily configurable by changing the resistor and outputvoltage of the DAC. The upper part of the circuit it will be using a PNP transistor, thisone allows a good opening and shut down of the circuit. Since it has a high voltage on thebase, it was chosen to drive this transistor with an optocoupler, isolating this high voltagefrom the microcontroller. In figure 5.5 at page 38, it is seen the configuration. R1 is usedas a pull-up resistor that insures that the transistor is off (or not sourcing any current)when the switch is open. R2 is connected in series with the switch, this is used to limitthe current coming out of the base when the base is grounded by the switch.

5.4 Components

It was necessary to choose components to the boost converter circuit and the controlof the system. Some components were chosen by suggestion, others it was necessary a

Page 56: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

38 Electrical stimulation

Figure 5.4: Lower quadrant.

previous market search.

5.4.1 Boost converter

For the boost converter instead of using a microcontroller it was used a timer, to con-trol the on and off time of the transistor.

5.4.1.1 Transistors

The transistor chosen was a mosfet, IRF730. This mosfet must be able to handle acurrent of 2.5 A and a voltage of 300 V, two times Vo. Looking at the datasheet thevoltage it can handle is about 400 V and a current of 5.5 A. The price is 1.12 Eur.

5.4.1.2 Diode

The diode had to be a fast recovery diode, capable of 2.5 a and a voltage of 300 V.Because of the shop availability it was chosen the By399. This diode can stand a voltageof 800 V and a current of 3 A. It costs 0.35 Eur.

Figure 5.5: Upper quadrant.

Page 57: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

5.5 System designing 39

5.4.1.3 Timer

It was used a ne555 timer. This allows to control the on and off time of the transistor,allowing the voltage output desired. It costs 0.63 Eur.

5.4.2 Current circuit

For the current circuit it were chosen the next components.

5.4.2.1 Transistors

Since the voltage necessary it quite high, it is also necessary good isolation transis-tors. The ones chosen were the NPN, MJE-340, and the PNP, MJE-350. These are lowcost transistors, having a maximum voltage between collector and emitter of 300v, and amaximum collector current of about 0.5 A. The price of the pair is about 0.60 Eur, whatmakes them excellent choices for this project. As it was necessary an optocoupler, it waschosen the H11D1, this one allows a maximum voltage between of collector and emitterof 300v, and a collector current of 100 mA. The optocoupler has a price of 0.731 Eur.

5.4.2.2 DAC

The DAC is a digital to analog converter. This DAC communicates using SPI. It waschosen this DAC because it was used in previous projects. The DAC is MCP4921 with acost of 2.20 Eur.

5.4.3 Control

This stimulation circuit needs more instructions than the mechanical system. Accord-ing to this it is necessary to control 4 different DAC. These DAC work with SPI, so it wasnecessary some functions. The control algorithm is very similar. It was decided to chosea microcontroller with more memory than the one used in mechanical stimulation circuit.It was used a microcontroller of 32k, atmega32, with an average price of 4 Eur.

5.5 System designing

The electrical stimulation system is consisted in a power converted connected to 4controlled current circuits. These circuits have 2 electrodes each. It is possible by chang-ing the output voltage, to change the current passing by these electrodes and change thestimulation of the nerves. Each circuit is independently controlled, whether in voltagewhether in frequency.

Page 58: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

40 Electrical stimulation

Like said before the boost converter is controlled with the ne555. In figure 5.6, isseen the configuration for this timer. Configuring the timer as astable operation, andfor a frequency of 62.5kHz, R2=100 Ohm, R3=2 kOhm, C1=0.01uF. These values wereachieved in a timer calculator. In 5.22 are the equations for the timer555. The transistorused is BC547 and R1=56 k Ohm. With this configuration it is possible to control theoutput voltage by connecting the base of the transistor to a potentiometer on the boostvoltage output.

Timer : ton = 0.693(R3+R2)C1 (5.21)

to f f = 0.693(R2)C1 (5.22)

f =1.44

(R1+2R2)C1(5.23)

Figure 5.6: Ne555 configuration.

Before the assembly, these circuits were simulated using the Multisim. The simulationhad some differences, it was not used the controller transistor of the timer, and instead ofa microcontroller it was used a function generator with a square wave of 5 V. The skinresistance is about 1 k Ohm. In figure 5.7 at page 41 is possible to see the tested circuit.When the pair of transistors is on, the current passing the 1 k Ohm is about 94 mA, asexpected. The voltage around the resistance of the human skin is seen in figure 5.8 atpage 41.

The control of the electrical stimulation system is very similar to the mechanical one.This system receives information, it processes what has received and activate each circuitindividually. In figure 5.9 at page 42, is seen the control algorithm. Initially is in stand-by,if it receives an interruption from UART checks if it is for him. If yes process the message

Page 59: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

5.6 Tests 41

Figure 5.7: Simulation Circuit.

and save the values, if not return. In the main loop, checks if the control is activated, ifyes, process instructions and activates the electrodes with the chosen frequency.

5.6 Tests

This system was a bit more complex than motor stimulation because it was necessaryto be sure about frequencies, and currents. For that some tests were made before theassembly of the circuit.

1. Test the output voltage. Using a multimeter was checked if the output voltage wasthe one expected. Also changing the Potentiometer was possible to change thisoutput voltage.

2. Test if the UART interruption was working. Like before it was used a Led to checkif the interrupt was working.

Figure 5.8: Simulation Circuit, voltage around human skin.

Page 60: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

42 Electrical stimulation

Figure 5.9: Control circuit.

3. Test the output voltage of DAC. It was tested the four DAC output.

4. Test if the current controlled circuit was working with the microcrontroller. Usinga supply of 5 V and a oscilloscope it was checked the output wave, of the currentcontrolled circuit.

5. Test if the stimulation was working. Connecting the electrodes to the human bodyit was checked if some stimulations was achieved.

6. Test if the system was working. Using a max232 connected to the computer it waspossible to change frequency and which electrode should be turned on.

5.7 Conclusion

The electrical stimulation circuit used is based in medical TENS, and it is used forpattern recognition. In other words, it identifies objects. The system has 4 controlledcircuits, each one for a different type of object identified like pencils or pens and biggerobjects. Every stimulator has a power PNP and NPN transistor with one pair of electrodes.The power PNP allow to control which circuit is turned on, and so brings safety to thecircuit. Each circuit is independent and it is possible to control current and frequency. Thiscurrent control is possible due to the voltage control on the DAC by the microprocessor,connected to the power NPN.

Page 61: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Chapter 6

Communications

Communication assume in this project as the bridge between all circuits. Withoutthis connection the circuits will behave as independent systems and not as global one. Inthis chapter will be explained the algorithm, the hardware used, as well as the protocols.Another important theme is the control used by each individual system described till here.The control messages are also going to be explained.

6.1 Introduction

Nowadays there are a lot of developed protocols whether it is by companies whether itis by private users. The protocol developed is based in Modbus and Hostlink by Omron. Itis a simple protocol. After the protocol designed was defined the control messages everysystem should use. The main goal is to obtain the most effective communication protocolalso as short control messages.

6.2 Communications design

It is necessary to define the type of communications, in this case who is the slave andwho is the master. The global communication system is based in a graphical interfacecapable of controlling the acquisition system, the mechanical and electrical stimulationsystems. Having this as background, was defined that there is one master the acquisitionsystem. Electrical and mechanical systems are working as slaves. The user interface isused to send commands to the acquisition system, turning it on or off.

In figure 6.1 at page 44 is seen the communication diagram. As said, the computercontrols the acquisition system, and this sends to the user interface the values of eachsensor. The events are asynchronous because it is impossible to know when the user is

43

Page 62: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

44 Communications

Figure 6.1: Diagram.

going to activate each different system. The communications between the acquisition sys-tem and user interface are UART based, they will be done using the serial port. This ispossible because of max232 device. As said before, electrical and mechanical systemsare slaves. These slaves are using UART. The main difference is instead of using Rs232they use Rs485 in half-duplex. This is achieved with max485 device. The baudrate usedto this communication is 500 Kbps. One great disadvantage of this communication sys-tem is due to the fact that acquisition system is connected to the max232 and the slavesare using max485. In order to solve this problem some options were available. It wasthought to use max485 with all systems and using a rs485 to rs232 converter to connectto the interface user, computer. This option was excluded because of the price of thisconverter. It is about 25 Eur. The option used was, acquisition and user interface areusing the rs232. Since there is no more UART port available was decided to acquire asimple microcontroller, described as the sender in figure 6.1. This microcontroller willuse SPI or serial peripheral interface communication with the acquisition system, and useUART port connected to a max485 device to connect with the other slaves system. Thesender system will be used for replying messages. For example, it receives a control mes-

Page 63: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

6.3 SMP-Protocol 45

sage from the acquisition system and will reply it in the UART port for the stimulationsystems. The price of this microcontroller is about 4 Eur, compared to the 25 Eur of theconverter. Summarizing, computer and acquisition system use rs232 protocol communi-cation, acquisition system and sender system use SPI protocol communication and sendersystem with the stimulation systems use rs485 communication protocol. In this rs485communication it was developed a protocol. This protocol is called SMP-protocol. It wasgiven this name because it is a simple and custom made protocol(SIMPLE-SMP).

6.3 SMP-Protocol

It was chosen to design and implement a communication protocol. The advantagesare a custom made protocol for this system, a more familiarization about how to developa protocol in spite of being necessary twice as work as implementing a already developedone. By suggestion, the protocol is based in Modbus and Hostlink from Omron. It is basedin characters, and it is possible to address to different slaves, with different messages. Thisprotocol has three functions, Smp-write, Smp-read and slave receive. Within this protocolcontrol messages were developed.

6.3.1 Control messages

In order to obtain effective control in the different systems it was needed control mes-sages. This control messages are specific for each system. They are arrays of characters,and have 6 chars. The only exception is the values from the sensors sent to the userinterface, which are 5 characters message.

6.3.1.1 Acquisition system

Within the acquisition system there are only two control messages.

• SENSON - This message allows the user interface to turn on the acquisition system.

• SENSOF - This message allows the user interface to turn off the acquisition system.

When the acquisition system is activated it reads the value of the sensors and sendsmessages to the user interface. These messages identify the different sensors and theirrespective values. This messages are structured like

• 1st character - The first character identify which multiplexer is chosen, it can be ’1’or ’2’.

• 2nd character - The second character allows to choose which sensor was read.

Page 64: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

46 Communications

• 3rd-5th character - These last characters carry the value of the sensor. This value isbetween ’000’ and ’500’, from 0 to 5 V.

6.3.1.2 Stimulation systems

Sending the right control messages to the stimulation systems allows to turn on eachindependently motor or pair of electrodes, with a different frequency. The messages toboth systems are similar. The only exception is the first character which identifies thesystem.

• 1st character - The first character can be ’m’ or ’e’, each one identify the mechanicalor electrical stimulation system.

• 2nd character - The second character allows to choose which motor or circuit isgoing to be activated, the values are numbers, for example ’1’ or ’2’. For mechanicalsystem the maximum value is ’8’ and for electrical system the maximum value is’4’..

• 3rd character - The third character can be ’1’ or ’0’, it allows to turn on or off,respectively the circuit or the motor choose.

• 4th character - The fourth character is a ’f’, this one allows to chose frequency.

• 5th and 6th character - These last characters allow to chose 3 different frequenciesalready defined in the control. It can be ’11’ and it is choose the third frequency,the slowest, ’10’ and it is choose the second frequency, ’01’ and it is choose the firstfrequency, or the fastest.

The on/off control of the systems has different control messages. These are:

• ECONNN/MCONNN - According to the first character it is chosen which system isgoing to be turned on.

• ECOFFF/MCOFFF - This messages allows to turn off the different systems.

It is also possible to redefine the frequencies of the stimulation systems

• 1st character - The first character can be ’m’ or ’e’, each one identify the mechanicalor electrical stimulation system.

• 2nd character - The second character is a ’f’, this one allows to chose frequencyconfiguration.

• 3rd character - The third character can be ’1’, ’2’ or’3’. It allows to chose whichfrequency is going to be redefined.

Page 65: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

6.3 SMP-Protocol 47

• 4th, 5th and 6th character - These last characters allow to define the frequency. Theycan be from ’000’ to ’999’. According to the frequency defined in the timer of themicrocontroller it is possible to extend it.

6.3.2 SMP-write

This function is used to send a command to the slave. It uses a specific built message,based as said before in characters. It accepts as input parameters the slave number and themessage to be sent. After a new message is built. In figure 6.2 is seen the diagram of thisfunction.

Figure 6.2: SMP-Write function.

• 1st character - The first character identifies the slave.

Page 66: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

48 Communications

• 2nd character - The second character chooses the function, in this case ’w’.

• 3rd, 8th character - These characters have the message to control the stimulationsystems.

• 9th, 10th character - These characters have the CRC value.

• 11th character - The last character is the finishing one.

After the message is built it is necessary to send it to the stimulation circuits. Themicrocontroller chooses the max485 as sender, all slaves listen, in order to prevent crashmessages. After this message is sent. It waits for a acknowledge. If it takes to long toreceive acknowledge it will return an error, timeout error. If the first character is differentthan ’0’, the transmission will be repeated. If it continues to happen this error and itwas sent 5 times the same message it returns an error. If it receives a message of twocharacters, ’01’, from the slave the message was processed. If it receives a message ’02’there is a problem in the slave, and so return an error. If none of this cycles is detected itshould return a different error, nothing processed.

6.3.3 SMP-read

This function is used to send a command status to the slave. It is common to theSMP-write, it also uses a specific built message, based in characters. It accepts as inputparameters the slave number and the message to be sent. After a new message is built. Infigure 6.3 at page 49 is seen the diagram of this function.

• 1st character - The first character identifies the slave.

• 2nd character - The second character chooses the function, in this case ’r’.

• 3rd, 8th character - These characters have the message to ask for the status of thestimulation systems, ’status’.

• 9th, 10th character - These characters have the CRC value.

• 11th character - The last character is the finishing one.

After the message is composed it is necessary to send it to the stimulation circuits.The microcontroller chooses the max485 as sender, all slaves listen, in order to preventcrash messages. It waits for a acknowledge. If it takes to long to receive acknowledge itwill return an error, timeout error. Here is the big difference from SMP-write, it is waitingfor the status of the system, if it receives a message of 4 characters, ’01ok’, from the slavethe message was processed, return. if it receives ’01nk’ it means some problem in systemand it should return with an error. If it receives a message ’02’ there is a problem in the

Page 67: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

6.3 SMP-Protocol 49

Figure 6.3: SMP-Read function.

slave. If the first character is different than ’0’, the transmission will be repeated. After5 times if the same continues to happen it should return an error. If none of this cycles isdetected it should return an error, nothing processed.

6.3.4 Slave receive

This function must be implemented in all slaves, because it is programmed to answerthe functions of SMP-write, and SMP-read. In 6.4 at page 50 is seen the diagram ofthis function. It takes as input parameters the slave, the status message, and the messagereceived. First this tests the slave number, if it is not ok, return. Then test the Crc, if itis not ok, send a error message and return. If everything ok, test which is the function

Page 68: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

50 Communications

Figure 6.4: Slave receive.

received. If it is write, send acknowledge, if is read send the status message. Finally itshould return.

6.4 Conclusion

It was designed and implemented a new protocol. It is called SMP-protocol. It has3 basic functions, for reading, writing commands and receiving. The communicationsbetween all the systems was achieved with great success. Using a microcontroller insteadof converter complicated too much the communications. Instead of using only one typeof protocol, it was used 3. Another disadvantage is, the communication between sendingand receiving for answer of this protocol takes a lot of time. It is believed that the cause isdue to the use of characters based message, of crc calculation and confirmation by slave-receive as well as the time taken by the microcontroller to process this communications.This is due to the time taken to switch the device max485 from sender to receiver. The

Page 69: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

6.4 Conclusion 51

messages are based in 5 and 6 characters. This was chosen because the microcontrollersslaves are driven by UART interrupts. The messages are read as an array, and if thesize changed it was necessary to change the form each different message was going tobe read. The answers from the slaves are very simple. It was chosen this because, forexample if it was included crc the time necessary it would be much more higher. It isonly used the SMP protocol in the communication between sender and slaves becauseof many aspects. Using the protocol between acquisition and slaves it was necessary foreverytime that sender replied the message change it from master to slave because of theSPI communication. This would take even more time. Although of using the protocolonly in sender-slave the overall results are quite good.

Page 70: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

52 Communications

Page 71: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Chapter 7

Control

In chapter 7 will be referred the control of the systems as well as some code imple-mentations and the solutions adopted. It will also be described the user interface and howthe control is made. Every control system is going to be referred independently, each onehas a microcontroller.

7.1 Introduction

The control algorithm defines the effectiveness of this system. According to this itwas tried to develop simple control algorithms, in the various systems. The acquisitionsystem defines which motors and electrical circuits are going to be turned on, accordingwith the sensors activated and object identified. The motor stimulation system as well asthe electrical one receives control messages from acquisition.

7.2 Acquisition system

As said before the acquisition system assumes an important task. It is responsible forobject recognition and it controls which commands are going to be sent to the the othersstimulation systems. This is seen in figure 3.1 at page 20.

7.2.1 Control

The control algorithm in the acquisition system was already described in chapter 3.Like said, the sensors are read and after is sent to the interface program. According to thevalues of the sensors it is going to be processed and defined the control instructions forthe other systems. Acquisition has 5 sensors, every sensor has a correspondent motor, 5motors. The sensors and the motors were classified with numbers. The motors numeration

53

Page 72: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

54 Control

is based in the Darlington array, the first port was defined to be connected to motor1, andthe last port is connected to motor 8. Because of some problems the port of motor 1 wasnot working. According to this was used the port of motor 2,3,4,5 and motor 6.

Figure 7.1: Location of the sensors.

In figure 7.1 is seen the sensors location. The thumb finger has one sensor, sensor 1,this is connected to motor 3, the palm of the hand has one sensor, sensor 4, this one isconnected to motor 6. The middle finger has one sensor, sensor 2, and it is connected tomotor 4. The index finger has two sensors one in the top, sensor 3 and one next to thepalm sensor 0. The sensor 3 is connected to the motor 5 and the sensor 0 is connectedto motor 2. It was defined a function for reading the sensors. This takes as an input thenumber of the multiplexer and the number of the sensor. It is chosen the sensor and it isread the ADC, it turns on a bit. This bit allows the function to be in a infinite loop. Aftera conversion, an interrupt is activated and it is turned off the same bit. When this bit isturned off the function returns from the infinite loop and it is returned the value read.

if((choice==2) & (channel==7)){ //Y7 channel multiplexor 2

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

PORTD|=_BV(S2)| _BV(S1)| _BV(S0);

adc_init0();

ADCSRA |= _BV(ADSC);

test=1;

}

while(test==1);

PORTD|=_BV(E1);

return value;

}

Page 73: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

7.2 Acquisition system 55

The control of the motors was divided in 3 different steps, three different value inter-vals for the sensors. It was made a small change how the microcontroller will interpretthe value from sensor. When sensor has the value from 0-5 V, the numerical value to themicrocontroller is between 0-500. According to this, the intervals were defined. If thevalue of the sensor 0 is between [0-100] it will turn off the correspondent motor. Themessage sent is ’m20f11’. If the value of the sensor is between [100-250] it will activatethe motor with the smallest frequency. The message sent is ’m21f11’. If the value is be-tween [251-399] it will be activated the motor with a faster frequency. The message sentis ’m21f10’. When it has the maximum value, and it is bigger than 400, it will activatethe motor with the fastest frequency. The message sent is ’m21f01’. For every differentsensor it will be done the exact control algorithm. For example, if it is the sensor 2, itwill be the motor 4, and the message sent is ’m41f11’ according to the value read by themicrocontroller.

The control of the electrical stimulation system is a little different. This is used toidentify objects. According to the key locations of the sensors, it was defined 4 typesof objects. When sensor 1 and sensor 3 are activated it is a thin object like a pencil inthis case. When sensors 1,2 and 3 are activated it is a bigger object like for example themouse from the computer. If the object continues to get bigger then sensor 1 and sensor0 are activated, like a glass. Finally, when sensor 0 and sensor 4 are activated all thehand is grabbing a object in this case a water gun. Having this, each combination wascorresponded to a stimulation circuit. Also it will work in 3 different steps, three differentvalues for the combinations of the sensors, like the motor stimulation. The combinationof sensors 0 and 1 activated the circuit 1. Sensors 1,2 and 3 activates circuit 2. Sensors0 and 1 activate circuit 3. Sensor 0 and 4 activate circuit 4. The control of the frequencyis similar to the motor stimulation. For example if it a object like a pencil and the valuesof the sensors are between [100-250] it will be activated the correspondent circuit, withthe slowest frequency. The message sent is ’e11f11’. The same reasoning for the otheridentified objects.

7.2.2 User interface

It was decided to have a user interface. In the beginning two programs were thought,Lazarus and Matlab. It was chosen Matlab for two reasons. First this is a global prototypeso it is justified the use of Matlab. The second it is more familiar because it was alreadyused already in other projects. The user interface based in Matlab allows to control allthe systems developed. It is possible to turn on and off each individual system. Likedescribed in the previous chapter, gui uses the serial port connected to the computer anduart connected to microcontroller through max232. In figure 7.2 is possible to be seenthe aspect of the user interface. As said before it is possible to see the graphics of the

Page 74: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

56 Control

sensors and the control commands. It is also possible to control the frequencies of eachindividual stimulation system. The method of control is simple. It is necessary to turnon the acquisition system, this is only possible in user gui. After the user defines thefrequency or it can let the ones already predefined, he can activate each individual circuit.When the acquisition system is activated the axis start to plot the values of each individualsensor. Here it is possible to be seen the changes or the objects identified.

Figure 7.2: User interface.

When the sensors button on is pressed the user interface starts a loop, and every timethere is 25 bytes available on the serial port, the gui reads it, separate each message in thenumber of the sensor and the value. It was choose to send all sensors and their values inthe same message, a 25 byte message. Each sensor needs 5 bytes. The 25 bytes availableassumes that there is no failure, and since it was only a prototype for laboratory tests, itwas simplified the communication. Next it is described some code implementation forone sensor. The message is read, and it is separated for the first sensor the number andthe value. This value is converted to number.

if s1.BytesAvailable==25

status = fread(s1, 25);

status=char(status);

sensor0(1,1:2)=status(1:2,1);

s_value(1,1:3)=status(3:5,1);

value0=str2num(svalue);

After it compares if it is the multiplexer 1 and sensor 0. It it is true than the value of thesensor will be plotted in the correspondent axis. The variable vector is the x coordinate

Page 75: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

7.3 Mechanical stimulation system 57

and every time a new value is plotted this variable is incremented. The same reasoning isfollow for the other 4 sensors.

if strcmp(sensor0,’10’)

g1(1)=0;

g1(vector)=value0;

vector=vector+1;

axes(handles.axes10);

plot(g1);

guidata(hObject, handles);

end

7.3 Mechanical stimulation system

Having a different system it is necessary to describe the control messages and someimplementation code specific to this microcontroller. According to the message receivedfrom the acquisition system the mechanical stimulation must process this message andactivate the correspondent motor.

7.3.1 Control

As explained in chapter 4 in 4.3 at page 31 the system receives control messageand it should process it. According to this control message it should turn on the differentmotors on. When system is activated two timers are switched on. One is the PWM forthe motors and the other is for establish the frequency for each independent circuit. ThePWM has a frequency of 250 Hz. The frequency for switching on and off is based in atimer counter interruption, and for every interrupt it increases a variable for each motor.The interrupt frequency is 1 MHz. When this variable is bigger then a predefined value itturn on the motor for 100ms, and then switch it off. For example if the motor 2 is activatedwith the message ’m21f10’, the frequency will be the second fastest. When the variablecorrespondent to the second motor is counted more than 250 times this motor is switchedon and 100 ms later is switched off. If no more control messages are processed this motorwill continue the same procedure. After the variable reaches more than 250 counts it willturn on the motor and 100 ms later will switch it off. With this procedure it is possible tofeel small vibrations. The same reasoning is used for the other motors.

A function was defined to make everything more simple. It is called motor spin andaccepts as inputs the number of the motor, if it is necessary to turn on or off and thefrequency. After was only necessary to call it in the main loop. A part of this function isin example below. If the n==1 it is chosen the first motor. If the step counter1 is biggerthan the predefined frequency and motor is on, then it turns on the port PA0, and it turnsoff 100 ms later. Then the variables step counter1 is again 0. The variable timer on allowsa different circuit different from the first one to be activated for the first time.

Page 76: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

58 Control

if(n==1){

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter1>=freq_osc) )){

PORTA|= _BV(PA0);

_delay_ms(100);

PORTA&=~ _BV(PA0);

timer_on=1;

step_counter1=0;

} }

The main loop is shown next. Like said before it was only used 5 motors but the circuitis projected for 8 motors.

while(control==1) {

motor_spin(1, motor1, freq_1);

motor_spin(2, motor2, freq_2);

motor_spin(3, motor3, freq_3);

motor_spin(4, motor4, freq_4);

motor_spin(5, motor5, freq_5);

motor_spin(6, motor6, freq_6);

motor_spin(7, motor7, freq_7);

motor_spin(8, motor8, freq_8);

}

7.3.2 Key locations

It was thought to make the distribution of the motors in different locations of thehuman body. In figure 7.3 at page 59 , it is possible to be seen the proposed locations.These locations are easily configurable.

7.4 Electrical stimulation system

The electrical stimulation system behaves exactly like the mechanical stimulation sys-tem. It receives a control message and activates the correspondent circuit. Once again isgoing to be described the specific code to this system, microcontroller.

7.4.1 Control

The control algorithm was explained in chapter 5 in 5.1 at page 34. Summarizingthe system receives a control message and according to it, activates the respective circuit.When the system is turned on a timer counter is activated. This has a frequency of 1 Mhz.Every time it reaches the 1 Mhz a new interrupt is activated. This interruption incrementsa variable for every circuit. Since it is only available 4 circuits, it only has 4 variables.Like before was defined a function similar to the mechanical stimulation system Whenthis variable is bigger than the predefined frequency is activated the power PNP transistorand the NPN transistor. The NPN is activated by the DAC and it is possible to control

Page 77: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

7.4 Electrical stimulation system 59

Figure 7.3: Location of the motor.

it with a voltage of 0-5v, from 0-4095. In the example code it is possible to see whenthe circuit is on, all interrupts are off, it activated the DAC with an output of 3000, andthe power PNP. After 6 us, it is turned off, and interruptions activated. The variable stepcounter is initialized again. The variable timer has the same goal as defined in previoussection.

if(n==1){

if(((circuit==1) && (timer_on==0) ) || ((circuit==1) && (step_counter1>=freq_osc) )) {

cli();

dac_output(1, 3000);

PORTC|=_BV(tra4);

_delay_us(6);

PORTC&=~_BV(tra4);

dac_output(1, 0);

sei();

timer_on=1;

step_counter1=0;

} }

The main loop is similar as the mechanical stimulation. The variable circuit is used asa control, on and off.

while(control==1){

shock(1,circuit1,freq_1);

shock(2,circuit2,freq_2);

shock(3,circuit3,freq_3);

shock(4,circuit4,freq_4);

}

Page 78: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

60 Control

Figure 7.4: Location of the circuits.

7.4.2 Key locations

The electrodes can actually be putted in every human muscle, but for precautionsit was decided to not put next to the human heart. In figure 7.4 at page 60 is seen thelocations of the electrodes on the human body. Each circuit has two electrodes from wherecurrent flows in and flows out. The electrodes are simple electrodes used in medicine.

7.5 Conclusion

The control design and implementation achieved excellent results. With the user inter-face is easily controllable the different system and frequencies. It is possible to identifyby looking at the plotted axes which type of object is. According to the value of the

Page 79: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

7.5 Conclusion 61

sensors it is possible to spin different motors at different speeds and is identified whichsensor is turned on. With the electrical stimulation is possible to identify objects. It waschosen different locations in order for better results. Since it is a experimental work, andthe user does not have to walk, two circuits were placed in the legs. One disadvantage ofthis system is the acquisition. The sensors are stitched to a glove and it is necessary to usea human hand. This hand is soft and the sensors do not have their full potential as with ahard surface. When some object is touched the skin of the hand bends, and sensor is notable to sense the full touch.

Page 80: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

62 Control

Page 81: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Chapter 8

Conclusions and Future developments

Like every project in life when it comes to an end it is exactly when it should start.Some future developments should be made in order to achieve a better effectiveness.

8.1 Conclusion

The work developed by many investigators around the world allow to delineate a sim-ilar approach to the problem of feedback of a prosthetic hand. Darpa as well as an Eu-ropean union collaboration already developed what is possible to say the state of the artfeedback, combined they use tactors and electrical stimulation to the nerves. A few isknown about the algorithms, and it is believed if these were spread to all investigatorsmuch more and faster developments can be achieved.

The acquisition system is simple yet very effective. It has 5 FSR sensors spread allover a glove. These sensors are in key locations which allow to identify objects. Summa-rizing the system is consisted with 5 sensors connected to OPA, after they are connectedto multiplexer which is connected to ADC of a microcontroller. This reads the sensorsvalues and according to it gives instructions to the stimulation systems. It also sends tothe user interface the sensors values. This system has one big disadvantage, it lacks ofsensors so the objects identification are very simple, it also the sensors stitched to a gloveare not the best solution since they move a few centimeters, changing also the overallresults.

The mechanical stimulation system is based in tactors, or vibrating motors. The sys-tem was developed for 8 motors. These motors are spinning at the same frequency. Thisfrequency is based in PWM and can be easily modified. The time that every motor turnon and off is going to define the feedback of this system. In other words the frequency

63

Page 82: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

64 Conclusions and Future developments

that every motor is going to be turned on and off changes, so it is possible to have at thesame time motors spinning at different speeds.

The electrical stimulation system has 4 circuits with independent current control andfrequency. Each circuit has one power PNP and NPN transistor. PNP transistor allowsto choose which circuit is turned on, while NPN transistor connected to a DAC allows tocontrol the current of the circuit. The wave produced is a square wave based in normalTENS developed for medical purpose. This wave is usually a square wave with a timeron between 50-200 us, and a frequency defined by user.

The communications between all of this systems are working. They are based incharacter control messages. It was developed a new protocol, although with it there area few disadvantages. The communication takes too long between systems, it is believedthat the main problem is the source code in microcontroller which takes much time toprocess. Instead of using a max485 converter to connect the user interface was used amicrocontroller. This reduce the price cost but increases largely the complexity of thesystem.

The acquisition control reads the value of the sensors and according to it will be sendthe instructions to the stimulation systems. Every sensor is connected to a motor, andevery combination of sensors that identify a object are connected to a circuit. This systemsare based in UART interruptions, and counters and this led to some frequency problems.When a message is receive by stimulation systems they will activate the correspondentstimulators, with a specific frequency. The problem is when it receives another messageit will delay the timer interruption because the message is being processed. In spite ofthis frequency problems, the intervals are spaced in order if a delay happens a frequencywill never be too affected. Although it is a experimental work and it was developed aprototype some changes need to be made. In spite, the overall results of the project areexcellent.

8.2 Future Developments

As said before the sensors are stitched to the glove. This is not the best solution, yetit is possible to re-use this sensors. In the future, this sensors are going to be placed ina robotic hand. After, it is possible to check if the location of the sensors suits up. In afurther stage it is going to be necessary more sensors in the prosthetic hand. These shouldbe position sensors, encoders, also is going to be necessary accelerometers. The pressuresensors should be matrix sensors, in other words, having a matrix pressure sensor it ispossible to identify exactly where the pressure is made. All this sensors allow a excellentacquisition system and a much better pattern recognition. Another improvement can beusing a more powerful microcontroller, for example atmega128. This microcontroller hasenough memory for control and has several protocols of communication and the ability to

Page 83: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

8.2 Future Developments 65

extend to 4 UART protocols at the same time. Every each one capable of communicationwith different circuits.

The mechanical stimulation system can be improved, first by using its full potential,using all motors. In a further step, it can be included more motors like the ones used inDARPA projects.

Instead of using a normal power boost, it can be changed to a fly back converter. Theinductor is split to form a transformer. This has a great advantage, that is isolation. Withthis fly back converter more efficiency is achieved. Another topic to improve is the factthat this system can be updated with more stimulation circuits. This guarantees morepossibility for stimulation.

The communications can be improved by instead of using a microcontroller to replythe control messages from acquisition system use a converter. This converter can be Usb-Rs485. With this converter the communications start to use the same protocol for allsystems, Rs485. It is necessary to optimize the protocol developed, in order to achievefaster transmissions, and processing.

Page 84: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

66 Conclusions and Future developments

Page 85: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

References

[1] Kim M. Norton. A brief history of prosthetics. http://www.

amputee-coalition.org/inmotion/nov_dec_07/history_

prosthetics.html.

[2] Medical Terms. Definition about prosthesis, September 2003. http://www.

medterms.com/script/main/art.asp?articlekey=24504.

[3] Compact Oxford English Dictionary. Definition of muscle, June 2008. http:

//www.askoxford.com/concise_oed/muscle.

[4] Janet Rae-Dupree e Pat Dupree. Anatomy and Physiology Workbook for Dummies.Wiley Publishing, Inc., 2007.

[5] Dr. Roberto R. Albuquerque Dr. Paulo C. Chaves e Prof. Dr. Adelino L. Moreira.Notes about medicine physiology, 2001.

[6] Marie De Ryck Richard Greenhill. Comparison of the shadow dexterous hand to thehuman hand. www.shadowrobot.com.

[7] Peratech. Force conduction level, qtc. http://www.peratech.com/

qtcscience.php.

[8] R. Walker. Using air muscles for compliant bipedal and many-legged robotics. pági-nas 3/1 – 3/3, August 2002.

[9] Shadow Robot Company Limited. Air muscles, 2010. http://www.

shadowrobot.com/airmuscles/overview.shtml.

[10] Department of Mechanical Engineering. Different contractions levels of the artificialmuscles. http://lucy.vub.ac.be/gendes/actuators/muscles.htm.

[11] editorial director David Pope. Darpa prosthetics programs seek natural upper limb.http://www.neurotechreports.com/pages/darpaprosthetics.

html.

67

Page 86: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

68 REFERENCES

[12] Donna Miles. Darpa’s cutting-edge programs revolutionize prosthetics, February2006. http://www.defense.gov/news/newsarticle.aspx?id=14914.

[13] Sarah Adee. Reengineering the prosthetic-arm socket, February2008. http://spectrum.ieee.org/biomedical/devices/

reengineering-the-prostheticarm-socket.

[14] Tom Phillips. Tomorrow, the cyborgs will beour friends. http://www.metro.co.uk/news/

100699-tomorrow-the-cyborgs-will-be-our-friends.

[15] Sarah Adee. Dean kamen luke arm prosthesis readies for clinical trials,February 2008. http://spectrum.ieee.org/biomedical/bionics/

dean-kamens-luke-arm-prosthesis-readies-for-clinical-trials/

0.

[16] Kuiken T. Targeted reinnervation for improved prosthetic function. páginas 17(1):1–13, February 2006.

[17] Keith Kleiner. Bionic arm controlled by patient’s own thoughts, February 2009.http://singularityhub.com/tag/prosthetic-arm/.

[18] P. Campbell. Revolutionizing prosthetics 2009 team delivers first darpa limb pro-totype. http://www.jhuapl.edu/newscenter/pressreleases/2007/

070426.asp, MONTH=April, YEAR=2007.

[19] P. Campbell. Darpa gives apl-led revolutionizing prosthetics 2009 team greenlight for phase 2, February 2008. http://www.jhuapl.edu/newscenter/

pressreleases/2008/080204.asp.

[20] Sally Adee. A manhattan project for the next generation of bionic arms,March 2008. http://spectrum.ieee.org/biomedical/bionics/

a-manhattan-project-for-the-next-generation-of-bionic-arms/

0.

[21] David F. Salisbury. Unconventional power source could revolutionize thedesign of prostheticlimbs, August 2007. http://www.vanderbilt.edu/

exploration/stories/bionicarm.html.

[22] Tom Phillips. Tomorrow, the cyborgs will beour friends. http://www.metro.co.uk/news/

100699-tomorrow-the-cyborgs-will-be-our-friends.

Page 87: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

REFERENCES 69

[23] Applied Physics Laboratory. Revolutionizing prosthetics 2009: Apl-led team ad-vances prosthetic arm technology, January 2010. http://www.jhuapl.edu/

ourwork/stories/st090829.asp#.

[24] Sally Adee. Winner: The revolution will be prosthetized, January2009. http://spectrum.ieee.org/robotics/medical-robots/

winner-the-revolution-will-be-prosthetized/0.

[25] Todd A. Kuiken. Targeted muscle reinnervation for improved control of artificiallimbs, October 2009.

[26] Drew Halley. i-limb revolutionizes the commercial prosthetic,March 2009. http://singularityhub.com/2009/03/26/

i-limb-revolutionizes-the-commercial-prosthetic/.

[27] Touch Bionics. i-limb hand holding glass. http://www.touchbionics.com/image.php?pic=1184614591TB_0708_Small.jpg&caption=i-LIMB%

20hand%20holding%20glass&site=professionals.

[28] Drew Halley. Touch bionics ilimb, 2010. http://www.touchbionics.com/

i-LIMB/controls.

[29] Loz Blain. ilimb: world’s first fully articulating and commercially available bionichand, 2007. http://www.gizmag.com/go/7661/.

[30] Tara Rajan. Phantom limbs: A neurobiological explanation, 2002. http://

serendip.brynmawr.edu/exchange/node/2059.

[31] Kit Eaton. Smarthand: Cyborg limbs will feel like user’s own, December2008. http://www.fastcompany.com/blog/kit-eaton/technomix/

prosthetic-limbs-feel-users-own.

[32] CNN. The artificial hand that can ’feel’. http://www.cnn.com/2009/

HEALTH/11/06/artificial.hand.feel/index.html.

[33] Mark Tutton. The artificial hand that can feel, November 2009. http://www.

cnn.com/2009/HEALTH/11/06/artificial.hand.feel/index.html.

[34] ScienceDaily. Applause for the smarthand: Human-machine interface is essen-tial link in groundbreaking prosthetic hand, November 2009. http://www.

sciencedaily.com/releases/2009/11/091104132708.htm.

[35] Paul Horowitz. The Art of Electronics. Cambridge University Press; 2 edition, July1989.

Page 88: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

70 REFERENCES

[36] Lynn Snyder-Mackler Andrem J. Robinson. Clinical Electrophysiology: Elec-trotherapy and Electrophysiologic Testing. Lippincott Williams, Wilkins; Third Edi-tion edition, 2007.

[37] William P. Robbins Ned Mohan, Tore M. Undeland. Power Electronics: Converters,Applications and Design. Wiley; 2 edition, 1995.

[38] Padraig Fogarty Michael John McNulty. Design of a highly efficient circuit forelectrical muscle stimulation. 2008.

[39] Haibin Wang Jie Wu Xiaoyuan Wang, Chao Hu e Max Q.-H. Meng. A novel wirelesselectrical muscle simulator for female urinary incontinence. February 2009.

[40] Daniel W. Repperger David C. Johnson. Skin impedance implications of tens func-tion and the development of an improved stimulation waveform. 1995.

Page 89: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Appendix A

Drawings

In this appendix is presented the drawings of the circuits. These were made withprogram Eagle. Some elements, were not found on the provided lybraries so two optionswere available. When there is some component similar it was susbtituted by it. Whenthere isnt it was chosen not to draw it.

71

Page 90: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

72 Drawings

Figure A.1: Acquisition system.

Page 91: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Drawings 73

Figure A.2: Mechanical stimulation system.

Page 92: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

74 Drawings

Figure A.3: Electrical stimulation system.

Page 93: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Appendix B

Source code Acquisition System

The source code developed for this system is going to be refered in the next pages.

B.1 Header

#define F_CPU 16000000UL

#include <avr/io.h>

#include <inttypes.h>

#include <avr/interrupt.h>

#define Baud 38400

#define Ubrr1 F_CPU/16/Baud-1

void uart_init( unsigned int Ubrr );

void uart_transmit( unsigned char caract );

unsigned char uart_receive( void );

void port_definition(void);

void adc_init0(void);

void adc_init1(void);

void spi_slaveinit(void);

void spi_masterinit(void);

void spi_transmit(char cData);

char spi_receive(void);

void uart_transmit( unsigned char caract )

{

while (! (UCSRA & _BV(UDRE)));

UDR = caract;

75

Page 94: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

76 Source code Acquisition System

}

unsigned char uart_receive( void )

{

while (! (UCSRA & _BV(RXC)));

return UDR;

}

void uart_init( unsigned int Ubrr)

{

UBRRH = (unsigned char)(Ubrr>>8);

UBRRL = (unsigned char)Ubrr;

UCSRB |= _BV(RXEN) | _BV(TXEN)| _BV(RXCIE) ;

}

void spi_slaveinit(void)

{

DDRB |= _BV(PB6);

SPCR |= _BV(SPE);

}

void spi_masterinit(void)

{

DDRB |= _BV(DDB5)|_BV(DDB7)|_BV(DDB4);

SPCR |= _BV(SPE)| _BV(MSTR);//|(1<<SPR0);

PORTD|=_BV(PD4);

}

void spi_transmit(char cData)

{

PORTD&=~_BV(PD4);

SPDR = cData;

while(!(SPSR & (1<<SPIF)));

PORTD|=_BV(PD4);

}

char spi_receive(void)

{

while(!(SPSR & (1<<SPIF)));

return SPDR;

}

void port_definition(void)

{

DDRD|=_BV(PD1) |_BV(PD2) | _BV(PD3) |_BV(PD4) | _BV(PD5)| _BV(PD6)| _BV(PD7);

PORTD|= _BV(PD2)| _BV(PD3);

}

void adc_init0(void)

{

ADMUX = _BV(REFS0);

ADCSRA |= _BV(ADEN) | _BV( ADPS1) | _BV(ADPS0) | _BV( ADPS2) | _BV( ADIE);

Page 95: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

B.2 Main loop 77

}

void adc_init1(void)

{

ADMUX = _BV(REFS0)| _BV(MUX0);

ADCSRA |= _BV(ADEN) | _BV( ADPS1) | _BV(ADPS0) | _BV( ADPS2) | _BV( ADIE);

}

B.2 Main loop

#include "header.h"

#include <util/delay.h>

#include <string.h>

#define E2 PD2

#define E1 PD3

#define S0 PD4

#define S1 PD5

#define S2 PD6

volatile char read[6], leit[25], message[54], message1[6], message2[6], message3[6];

volatile uint32_t valor0=0, valor1=0, valor2=0, valor3=0, valor4=0, valor5=0, valor=0,a=0, b=0,c=0,d=0,e=0;;

volatile int test=0, con1=0, con2=0, con3=0, con4=0, con5=0, con6=0, con7=0, con8=0, control=0;

//interrupt from ADC

ISR(ADC_vect)

{

valor=ADCL;

valor=valor + ADCH*256;

valor=valor*500/1024;

test=0;

}

//Interrupt from serial port

ISR(USART_RXC_vect)

{

for(int i=0;i<6;i++)

{

read[i]=uart_receive();

}

if((read[0]==’s’) & (read[1]==’e’)& (read[2]==’n’)& (read[4]==’o’)& (read[5]==’n’)){control=1;PORTD|= _BV(PD7);}

if((read[0]==’s’) & (read[1]==’e’)& (read[2]==’n’)& (read[4]==’o’)& (read[5]==’f’)){control=0;PORTD&=~ _BV(PD7);}

if((read[0]==’m’) | (read[0]==’e’)) {

for(int i=0;i<6;i++)

{

spi_transmit(read[i]);

}}

Page 96: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

78 Source code Acquisition System

}

//function for sensor read

uint32_t read_sensor( int choice, int channel)

{

valor=0;

if((choice==1) & (channel==0)) //Y0 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E1);

adc_init1();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==1) & (channel==1)) //Y1 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E1);

PORTD|=_BV(S0);

adc_init1();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==1) & (channel==2)) //Y2 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E1);

PORTD|=_BV(S1);

adc_init1();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==1) & (channel==3)) //Y3 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E1);

PORTD|=_BV(S1)|_BV(S0);

adc_init1();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==1) & (channel==4)) //Y4 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E1);

PORTD|=_BV(S2);

adc_init1();

ADCSRA |= _BV(ADSC);

test=1;

Page 97: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

B.2 Main loop 79

}

if((choice==1) & (channel==5)) //Y5 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E1);

PORTD|=_BV(S2)|_BV(S0);

adc_init1();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==1) & (channel==6)) //Y6 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E1);

PORTD|=_BV(S2)|_BV(S1);

adc_init1();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==1) & (channel==7)) //Y7 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E1);

PORTD|=_BV(S2)| _BV(S1)| _BV(S0);

adc_init1();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==2) & (channel==0)) //Y0 channel second choice

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

adc_init0();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==2) & (channel==1)) //Y1 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

PORTD|=_BV(S0);

adc_init0();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==2) & (channel==2)) //Y2 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

PORTD|=_BV(S1);

adc_init0();

Page 98: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

80 Source code Acquisition System

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==2) & (channel==3)) //Y3 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

PORTD|=_BV(S1)|_BV(S0);

adc_init0();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==2) & (channel==4)) //Y4 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

PORTD|=_BV(S2);

adc_init0();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==2) & (channel==5)) //Y5 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

PORTD|=_BV(S2)|_BV(S0);

adc_init0();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==2) & (channel==6)) //Y6 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

PORTD|=_BV(S2)|_BV(S1);

adc_init0();

ADCSRA |= _BV(ADSC);

test=1;

}

if((choice==2) & (channel==7)) //Y7 channel

{

PORTD&=~_BV(S0) & ~_BV(S1) & ~_BV(S2)& ~_BV(E2);

PORTD|=_BV(S2)| _BV(S1)| _BV(S0);

adc_init0();

ADCSRA |= _BV(ADSC);

test=1;

}

while(test==1)

Page 99: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

B.2 Main loop 81

{}

PORTD|=_BV(E1);

return valor;

}

int main(void)

{

uart_init(Ubrr1);

spi_masterinit();

port_definition();

int z=500;

sei();

while(1)

{

while(control==1)

{

valor0=read_sensor(1,0);

a=valor0/100;

b=a*100;

c=(valor0-b)/10;

d=c*10;

e=(valor0-b-d);

a=a+0x30;

c=c+0x30;

e=e+0x30;

leit[0]=’1’;

leit[1]=’0’;

leit[2]=a;

leit[3]=c;

leit[4]=e;

valor1=read_sensor(1,1);

a=valor1/100;

b=a*100;

c=(valor1-b)/10;

d=c*10;

e=(valor1-b-d);

a=a+0x30;

c=c+0x30;

e=e+0x30;

leit[5]=’1’;

leit[6]=’1’;

leit[7]=a;

leit[8]=c;

Page 100: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

82 Source code Acquisition System

leit[9]=e;

valor2=read_sensor(1,2);

a=valor2/100;

b=a*100;

c=(valor2-b)/10;

d=c*10;

e=(valor2-b-d);

a=a+0x30;

c=c+0x30;

e=e+0x30;

leit[10]=’1’;

leit[11]=’2’;

leit[12]=a;

leit[13]=c;

leit[14]=e;

valor3=read_sensor(1,3);

a=valor3/100;

b=a*100;

c=(valor3-b)/10;

d=c*10;

e=(valor3-b-d);

a=a+0x30;

c=c+0x30;

e=e+0x30;

leit[15]=’1’;

leit[16]=’3’;

leit[17]=a;

leit[18]=c;

leit[19]=e;

valor4=read_sensor(1,6);

a=valor4/100;

b=a*100;

c=(valor4-b)/10;

d=c*10;

e=(valor4-b-d);

a=a+0x30;

c=c+0x30;

e=e+0x30;

leit[20]=’1’;

leit[21]=’6’;

leit[22]=a;

leit[23]=c;

leit[24]=e;

Page 101: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

B.2 Main loop 83

for(int i=0;i<25;i++)

{

uart_transmit(leit[i]);

}

if(valor0<=100)

{

message[0]=’m’;

message[1]=’2’;

message[2]=’0’;

message[3]=’f’;

message[4]=’1’;

message[5]=’1’;

}

if(valor0>=100 && valor0<=250)

{

message[0]=’m’;

message[1]=’2’;

message[2]=’1’;

message[3]=’f’;

message[4]=’1’;

message[5]=’1’;

}

if(valor0>=251 && valor0<=399)

{

message[0]=’m’;

message[1]=’2’;

message[2]=’1’;

message[3]=’f’;

message[4]=’1’;

message[5]=’0’;

}

if(valor0>=400)

{

message[0]=’m’;

message[1]=’2’;

message[2]=’1’;

message[3]=’f’;

message[4]=’0’;

message[5]=’1’;

}

if(valor1<=100)

{

message[6]=’m’;

Page 102: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

84 Source code Acquisition System

message[7]=’3’;

message[8]=’0’;

message[9]=’f’;

message[10]=’1’;

message[11]=’1’;

}

if(valor1>=100 && valor1<=250)

{

message[6]=’m’;

message[7]=’3’;

message[8]=’1’;

message[9]=’f’;

message[10]=’1’;

message[11]=’1’;

}

if(valor1>=251 && valor1<=399)

{

message[6]=’m’;

message[7]=’3’;

message[8]=’1’;

message[9]=’f’;

message[10]=’1’;

message[11]=’0’;

}

if(valor1>=400)

{

message[6]=’m’;

message[7]=’3’;

message[8]=’1’;

message[9]=’f’;

message[10]=’0’;

message[11]=’1’;

}

if(valor2<=100)

{

message[12]=’m’;

message[13]=’4’;

message[14]=’0’;

message[15]=’f’;

message[16]=’1’;

message[17]=’1’;

}

if(valor2>=100 && valor2<=250)

{

message[12]=’m’;

Page 103: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

B.2 Main loop 85

message[13]=’4’;

message[14]=’1’;

message[15]=’f’;

message[16]=’1’;

message[17]=’1’;

}

if(valor2>=251 && valor2<=399)

{

message[12]=’m’;

message[13]=’4’;

message[14]=’1’;

message[15]=’f’;

message[16]=’1’;

message[17]=’0’;

}

if(valor2>=400)

{

message[12]=’m’;

message[13]=’4’;

message[14]=’1’;

message[15]=’f’;

message[16]=’0’;

message[17]=’1’;

}

if(valor3<=100)

{

message[18]=’m’;

message[19]=’5’;

message[20]=’0’;

message[21]=’f’;

message[22]=’1’;

message[23]=’1’;

}

if(valor3>=100 && valor3<=250)

{

message[18]=’m’;

message[19]=’5’;

message[20]=’1’;

message[21]=’f’;

message[22]=’1’;

message[23]=’1’;

}

if(valor3>=251 && valor3<=399)

{

message[18]=’m’;

message[19]=’5’;

message[20]=’1’;

message[21]=’f’;

message[22]=’1’;

Page 104: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

86 Source code Acquisition System

message[23]=’0’;

}

if(valor3>=400)

{

message[18]=’m’;

message[19]=’5’;

message[20]=’1’;

message[21]=’f’;

message[22]=’0’;

message[23]=’1’;

}

if(valor4<=100)

{

message[24]=’m’;

message[25]=’6’;

message[26]=’0’;

message[27]=’f’;

message[28]=’1’;

message[29]=’1’;

}

if(valor4>=100 && valor4<=250)

{

message[24]=’m’;

message[25]=’6’;

message[26]=’1’;

message[27]=’f’;

message[28]=’1’;

message[29]=’1’;

}

if(valor4>=251 && valor4<=399)

{

message[24]=’m’;

message[25]=’6’;

message[26]=’1’;

message[27]=’f’;

message[28]=’1’;

message[29]=’0’;

}

if(valor4>=400)

{

message[24]=’m’;

message[25]=’6’;

message[26]=’1’;

message[27]=’f’;

message[28]=’0’;

message[29]=’1’;

}

if(valor1<=100 && valor3<=100) // objecto fino

{

message[30]=’e’;

Page 105: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

B.2 Main loop 87

message[31]=’1’;

message[32]=’0’;

message[33]=’f’;

message[34]=’1’;

message[35]=’1’;

}

if((valor1>=100 && valor3>=100) && (valor1<=250 && valor3<=250)) // objecto fino

{

message[30]=’e’;

message[31]=’1’;

message[32]=’1’;

message[33]=’f’;

message[34]=’1’;

message[35]=’1’;

}

if((valor1>=250 && valor3>=250) && (valor1<=400 && valor3<=400)) // objecto fino

{

message[30]=’e’;

message[31]=’1’;

message[32]=’1’;

message[33]=’f’;

message[34]=’1’;

message[35]=’0’;

}

if((valor1>=400 && valor3>=400) ) // objecto fino

{

message[30]=’e’;

message[31]=’1’;

message[32]=’1’;

message[33]=’f’;

message[34]=’0’;

message[35]=’1’;

}

if(valor1<=100 && valor3<=100 && valor2<=100) // objecto mais grosso

{

message[36]=’e’;

message[37]=’2’;

message[38]=’0’;

message[39]=’f’;

message[40]=’1’;

message[41]=’1’;

}

if((valor1>=100 && valor3>=100 && valor2>=100) && (valor1<=250 && valor3<=250 && valor2<=250)) // objecto grosso

{

message[36]=’e’;

message[37]=’2’;

message[38]=’1’;

Page 106: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

88 Source code Acquisition System

message[39]=’f’;

message[40]=’1’;

message[41]=’1’;

}

if((valor1>=250 && valor3>=250 && valor2>=250) && (valor1<=400 && valor3<=400 && valor2<=400)) // objecto grosso

{

message[36]=’e’;

message[37]=’2’;

message[38]=’1’;

message[39]=’f’;

message[40]=’1’;

message[41]=’0’;

}

if((valor1>=400 && valor3>=400 && valor2>=400) ) // objecto grosso

{

message[36]=’e’;

message[37]=’2’;

message[38]=’1’;

message[39]=’f’;

message[40]=’0’;

message[41]=’1’;

}

if(valor1<=100 && valor0<=100) // objecto fino

{

message[42]=’e’;

message[43]=’3’;

message[44]=’0’;

message[45]=’f’;

message[46]=’1’;

message[47]=’1’;

}

if((valor1>=100 && valor0>=100) && (valor1<=250 && valor0<=250)) // objecto fino

{

message[42]=’e’;

message[43]=’3’;

message[44]=’1’;

message[45]=’f’;

message[46]=’1’;

message[47]=’1’;

}

if((valor1>=250 && valor0>=250) && (valor1<=400 && valor0<=400)) // objecto fino

{

message[42]=’e’;

message[43]=’3’;

message[44]=’1’;

message[45]=’f’;

Page 107: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

B.2 Main loop 89

message[46]=’1’;

message[47]=’0’;

}

if((valor1>=400 && valor0>=400) ) // objecto fino

{

message[42]=’e’;

message[43]=’3’;

message[44]=’1’;

message[45]=’f’;

message[46]=’0’;

message[47]=’1’;

}

if(valor4<=100 && valor0<=100) // objecto fino

{

message[48]=’e’;

message[49]=’4’;

message[50]=’0’;

message[51]=’f’;

message[52]=’1’;

message[53]=’1’;

}

if((valor4>=100 && valor0>=100) && (valor4<=250 && valor0<=250)) // objecto fino

{

message[48]=’e’;

message[49]=’4’;

message[50]=’1’;

message[51]=’f’;

message[52]=’1’;

message[53]=’1’;

}

if((valor4>=250 && valor0>=250) && (valor4<=400 && valor0<=400)) // objecto fino

{

message[48]=’e’;

message[49]=’4’;

message[50]=’1’;

message[51]=’f’;

message[52]=’1’;

message[53]=’0’;

}

if((valor4>=400 && valor0>=400) ) // objecto fino

{

message[48]=’e’;

message[49]=’4’;

message[50]=’1’;

message[51]=’f’;

message[52]=’0’;

message[53]=’1’;

}

Page 108: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

90 Source code Acquisition System

for(int i=0;i<6;i++)

{

spi_transmit(message[i]);

}

_delay_ms(z);

for(int i=6;i<12;i++)

{

spi_transmit(message[i]);

}

_delay_ms(z);

for(int i=12;i<18;i++)

{

spi_transmit(message[i]);

}

_delay_ms(z);

for(int i=18;i<24;i++)

{

spi_transmit(message[i]);

}

_delay_ms(z);

for(int i=24;i<30;i++)

{

spi_transmit(message[i]);

} _delay_ms(z);

for(int i=30;i<36;i++)

{

spi_transmit(message[i]);

} _delay_ms(z);

for(int i=36;i<42;i++)

{

spi_transmit(message[i]);

} _delay_ms(z);

for(int i=42;i<48;i++)

{

spi_transmit(message[i]);

Page 109: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

B.2 Main loop 91

} _delay_ms(z);

for(int i=48;i<54;i++)

{

spi_transmit(message[i]);

} _delay_ms(z);

}

}//while

}//main

Page 110: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

92 Source code Acquisition System

Page 111: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Appendix C

Source code Mechanical System

The source code developed for this system is going to be refered in the next pages.The header is similar to the acquisition system. It is defined UART, SPI and the ports.

C.1 Main Loop

#include "serial_port_h.h"

#include "smp_protocol_h.h"

#include "crc.h"

#include <avr/interrupt.h>

#include <inttypes.h>

#include <util/delay.h>

#include <avr/io.h>

#include <string.h>

volatile char vector[11],status[2];

volatile int control=0, motor1=0, motor2=0, motor3=0, motor4=0, motor5=0, motor6=0, motor7=0, motor8=0, timer_on=0;

volatile uint32_t step_counter1=0,step_counter2=0, step_counter3=0 , step_counter4=0, step_counter5=0, step_counter6=0, step_counter7=0, step_counter8=0;

volatile unsigned int freq_osc1=50, freq_osc2=250, freq_osc3=500, a,b,c,valor;

volatile unsigned int freq_1=0,freq_2=0,freq_3=0,freq_4=0,freq_5=0,freq_6=0,freq_7=0,freq_8=0;

void process( char *message)

{

if(message[3]==’c’ && message[4]==’o’ && message[5]==’n’)

{ control=1;

PORTD|=_BV(PD7);

PORTC&=~_BV(PC0);

return;

}

if(message[3]==’c’ && message[4]==’o’ && message[5]==’f’)

{ control=0;

PORTC|=_BV(PC0);

PORTD&=~_BV(PD7);

return;

}

if(message[3]==’f’)

{

93

Page 112: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

94 Source code Mechanical System

a=message[5]-0x30;

b=message[6]-0x30;

c=message[7]-0x30;

valor=a*100+b*10+c;

if(message[4]==’1’)

{

freq_osc1=valor;

return;

}

if(message[4]==’2’)

{

freq_osc2=valor;

return;

}

if(message[4]==’3’)

{

freq_osc3=valor;

return;

}

}

if(message[3]==’1’)

{

if(message[4]==’1’)

{ motor1=1;

}

if(message[4]==’0’)

{ motor1=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_1=freq_osc1;

return;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_1=freq_osc2;

return;

}

if(message[6]==’1’ && message[7]==’1’)

Page 113: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

C.1 Main Loop 95

{ freq_1=freq_osc3;

return;

}

}

}

if(message[3]==’2’)

{

if(message[4]==’1’)

{ motor2=1;

}

if(message[4]==’0’)

{ motor2=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_2=freq_osc1;

return;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_2=freq_osc2;

return;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_2=freq_osc3;

return;

}

}

}

if(message[3]==’3’)

{

if(message[4]==’1’)

{ motor3=1;

}

if(message[4]==’0’)

{ motor3=0;

Page 114: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

96 Source code Mechanical System

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_3=freq_osc1;

return;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_3=freq_osc2;

return;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_3=freq_osc3;

return;

}

}

}

if(message[3]==’4’)

{

if(message[4]==’1’)

{ motor4=1;

}

if(message[4]==’0’)

{ motor4=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_4=freq_osc1;

return;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_4=freq_osc2;

return;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_4=freq_osc3;

return;

}

}

}

if(message[3]==’5’)

Page 115: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

C.1 Main Loop 97

{

if(message[4]==’1’)

{ motor5=1;

}

if(message[4]==’0’)

{ motor5=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_5=freq_osc1;

return;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_5=freq_osc2;

return;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_5=freq_osc3;

return;

}

}

}

if(message[3]==’6’)

{

if(message[4]==’1’)

{ motor6=1;

}

if(message[4]==’0’)

{ motor6=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_6=freq_osc1;

return;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_6=freq_osc2;

return;

}

if(message[6]==’1’ && message[7]==’1’)

Page 116: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

98 Source code Mechanical System

{ freq_6=freq_osc3;

return;

}

}

}

if(message[3]==’7’)

{

if(message[4]==’1’)

{ motor7=1;

}

if(message[4]==’0’)

{ motor7=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_7=freq_osc1;

return;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_7=freq_osc2;

return;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_7=freq_osc3;

return;

}

}

}

if(message[3]==’8’)

{

if(message[4]==’1’)

{ motor8=1;

}

if(message[4]==’0’)

{ motor8=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_8=freq_osc1;

Page 117: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

C.1 Main Loop 99

return;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_8=freq_osc2;

return;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_8=freq_osc3;

return;

}

}

}

}

ISR(TIMER1_COMPA_vect)

{

step_counter1++;

step_counter2++;

step_counter3++;

step_counter4++;

step_counter5++;

step_counter6++;

step_counter7++;

step_counter8++;

}

ISR(USART_RXC_vect)

{

char a;

for( int a=0; a<11;a++)

{

vector[a]=uart_receive();

if(vector[0]!=’4’)

{return;}

}

slave_receive( ’4’, vector, status);

process(vector);

}

Page 118: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

100 Source code Mechanical System

void motor_spin(int n, int motor, unsigned int freq_osc)

{

if(n==1)

{

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter1>=freq_osc) ))

{

PORTA|= _BV(PA0);

_delay_ms(100);

PORTA&=~ _BV(PA0);

timer_on=1;

step_counter1=0;

}

}

if(n==2)

{

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter2>=freq_osc) ))

{

PORTA|= _BV(PA1);

_delay_ms(100);

PORTA&=~ _BV(PA1);

timer_on=1;

step_counter2=0;

}

}

if(n==3)

{

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter3>=freq_osc) ))

{

PORTA|= _BV(PA2);

_delay_ms(100);

PORTA&=~ _BV(PA2);

timer_on=1;

step_counter3=0;

}

}

if(n==4)

{

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter4>=freq_osc) ))

{

Page 119: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

C.1 Main Loop 101

PORTA|= _BV(PA3);

_delay_ms(100);

PORTA&=~ _BV(PA3);

timer_on=1;

step_counter4=0;

}

}

if(n==5)

{

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter5>=freq_osc) ))

{

PORTA|= _BV(PA4);

_delay_ms(100);

PORTA&=~ _BV(PA4);

timer_on=1;

step_counter5=0;

}

}

if(n==6)

{

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter6>=freq_osc) ))

{

PORTA|= _BV(PA5);

_delay_ms(100);

PORTA&=~ _BV(PA5);

timer_on=1;

step_counter6=0;

}

}

if(n==7)

{

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter7>=freq_osc) ))

{

PORTA|= _BV(PA6);

_delay_ms(100);

PORTA&=~ _BV(PA6);

timer_on=1;

step_counter7=0;

}

}

if(n==8)

{

if(((motor==1) && (timer_on==0) ) || ((motor==1) && (step_counter8>=freq_osc) ))

{

Page 120: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

102 Source code Mechanical System

PORTA|= _BV(PA7);

_delay_ms(100);

PORTA&=~ _BV(PA7);

timer_on=1;

step_counter8=0;

}

}

}

int main (void)

{

uart_init(Ubrr1);

port_definition();

PORTD&=~_BV(PD6); //starts down for receiving

PORTB&=~_BV(PB0);

sei();

freq_1=freq_osc1;

while(1)

{

if(control==1)

{

timer0_begin(250);

timer1_begin(15000);

while(control==1)

{

motor_spin(1, motor1, freq_1);

motor_spin(2, motor2, freq_2);

motor_spin(3, motor3, freq_3);

motor_spin(4, motor4, freq_4);

motor_spin(5, motor5, freq_5);

motor_spin(6, motor6, freq_6);

motor_spin(7, motor7, freq_7);

motor_spin(8, motor8, freq_8);

}

}

}

}

Page 121: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

Appendix D

Source code Electrical System

The source code developed for this system is going to be refered in the next pages.Like in previous systems the headers are very similar to the ones already showes. Thedifference is the library DAC

D.1 DAC

void dac_output( int n, uint16_t j)

{

int aux1=0, aux2=0;

aux1=j;

aux2=(j>>8);

if(n==1){

PORTB|=_BV(PB1);

PORTC|=_BV(PC2);

PORTB&=~_BV(PB1);

SPI_MasterTransmit(0x70|aux2);

SPI_MasterTransmit(aux1);

PORTB|=_BV(PB1);

PORTC&=~_BV(PC2);

PORTC|=_BV(PC2);

}

if(n==2){

PORTD|=_BV(PD3);

PORTD|=_BV(PD2);

PORTD&=~_BV(PD2);

SPI_MasterTransmit(0x70|aux2);

SPI_MasterTransmit(aux1);

PORTD|=_BV(PD2);

PORTD&=~_BV(PD3);

PORTD|=_BV(PD3);

}

if(n==3){

103

Page 122: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

104 Source code Electrical System

PORTD|=_BV(PD5);

PORTD|=_BV(PD4);

PORTD&=~_BV(PD4);

SPI_MasterTransmit(0x70|aux2);

SPI_MasterTransmit(aux1);

PORTD|=_BV(PD4);

PORTD&=~_BV(PD5);

PORTD|=_BV(PD5);

}

if(n==4){

PORTD|=_BV(PD7);

PORTD|=_BV(PD6);

PORTD&=~_BV(PD6);

SPI_MasterTransmit(0x70|aux2);

SPI_MasterTransmit(aux1);

PORTD|=_BV(PD6);

PORTD&=~_BV(PD7);

PORTD|=_BV(PD7);

}

}

D.2 Main loop

#include "serial_port_h.h"

#include "smp_protocol_h.h"

#include "crc.h"

#include "dac.h"

#include <avr/interrupt.h>

#include <inttypes.h>

#include <util/delay.h>

#include <avr/io.h>

#include <string.h>

//Definition of the ports for the transistors 4 pairs of transistors

#define tra1 PC0

#define tra2 PC1

#define tra3 PC6

#define tra4 PC7

volatile char vector[11];

volatile char status[2];

volatile int control=0, circuit1=0, circuit2=0, circuit3=0, circuit4=0; //variables for circuit controll

volatile int counter=50; // for the wave of 200 us

volatile int timer_on=0; // initiate timer on first loop

volatile uint32_t step_counter1=0,step_counter2=0, step_counter3=0 , step_counter4=0;

volatile unsigned int freq_osc1=100, freq_osc2=250, freq_osc3=500, a,b,c,valor; // mudar isto

Page 123: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

D.2 Main loop 105

volatile unsigned int freq_1=0,freq_2=0,freq_3=0,freq_4=0;

void process( char *message)

{

if(message[2]==’e’){

if(message[3]==’c’ && message[4]==’o’ && message[5]==’n’)

{ control=1;

PORTC|=_BV(PC3);

PORTC&=~_BV(PC4);

}

if(message[3]==’c’ && message[4]==’o’ && message[5]==’f’)

{ control=0;

PORTC|=_BV(PC4);

PORTC&=~_BV(PC3);

}

if(message[3]==’f’)

{

a=message[5]-0x30;

b=message[6]-0x30;

c=message[7]-0x30;

valor=a*100+b*10+c;

if(message[4]==’1’)

{

freq_osc1=valor;

return;

}

if(message[4]==’2’)

{

freq_osc2=valor;

return;

}

if(message[4]==’3’)

{

freq_osc3=valor;

return;

}

}

Page 124: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

106 Source code Electrical System

if(message[3]==’1’)

{

if(message[4]==’1’)

{ circuit1=1;

}

if(message[4]==’0’)

{ circuit1=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_1=freq_osc1;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_1=freq_osc2;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_1=freq_osc3;

}

}

}

if(message[3]==’2’)

{

if(message[4]==’1’)

{ circuit2=1;

}

if(message[4]==’0’)

{ circuit2=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_2=freq_osc1;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_2=freq_osc2;

}

if(message[6]==’1’ && message[7]==’1’)

Page 125: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

D.2 Main loop 107

{ freq_2=freq_osc3;

}

}

}

if(message[3]==’3’)

{

if(message[4]==’1’)

{ circuit3=1;

}

if(message[4]==’0’)

{ circuit3=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_3=freq_osc1;

}

if(message[6]==’1’ && message[7]==’0’)

{ freq_3=freq_osc2;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_3=freq_osc3;

}

}

}

if(message[3]==’4’)

{

if(message[4]==’1’)

{ circuit4=1;

}

if(message[4]==’0’)

{ circuit4=0;

}

if(message[5]==’f’)

{

if(message[6]==’0’ && message[7]==’1’)

{ freq_4=freq_osc1;

}

Page 126: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

108 Source code Electrical System

if(message[6]==’1’ && message[7]==’0’)

{ freq_4=freq_osc2;

}

if(message[6]==’1’ && message[7]==’1’)

{ freq_4=freq_osc3;

}

}

}

}

}

ISR(TIMER1_COMPA_vect)

{

step_counter1++;

step_counter2++;

step_counter3++;

step_counter4++;

}

ISR(USART_RXC_vect)

{

for( int a=0; a<11;a++)

{

vector[a]=uart_receive();

if(vector[0]!=’5’)

{return;}

Page 127: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

D.2 Main loop 109

}

slave_receive( ’5’, vector, status);

process(vector);

}

void shock(int n, int circuit, unsigned int freq_osc)

{

if(n==1)

{

if(((circuit==1) && (timer_on==0) ) || ((circuit==1) && (step_counter1>=freq_osc) ))

{ cli();

dac_output(1, 3000);

PORTC|=_BV(tra4);

_delay_us(6);

PORTC&=~_BV(tra4);

dac_output(1, 0);

sei();

timer_on=1;

step_counter1=0;

}

}

if(n==2)

{

if(((circuit==1) && (timer_on==0) ) || ((circuit==1) && (step_counter2>=freq_osc) ))

{ cli();

dac_output(2, 3000);

PORTC|=_BV(tra3);

_delay_us(7);

dac_output(2, 0);

PORTC&=~_BV(tra3);

sei();

timer_on=1;

step_counter2=0;

}

}

if(n==3)

Page 128: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

110 Source code Electrical System

{

if(((circuit==1) && (timer_on==0) ) || ((circuit==1) && (step_counter3>=freq_osc) ))

{

cli();

dac_output(3, 3000);

PORTC|=_BV(tra2);

_delay_us(2);

dac_output(3, 0);

PORTC&=~_BV(tra2);

sei();

timer_on=1;

step_counter3=0;

}

}

if(n==4)

{

if(((circuit==1) && (timer_on==0) ) || ((circuit==1) && (step_counter4>=freq_osc) ))

{

cli();

dac_output(4, 3000);

PORTC|=_BV(tra1);

_delay_us(7);

dac_output(4, 0);

PORTC&=~_BV(tra1);

sei();

timer_on=1;

step_counter4=0;

}

}

}

int main (void)

{

Page 129: Perceptual Feedback of Grasping Touch to Prosthesis Hand User · a new user interface. 1.3 Mechanical Stimulation The mechanical stimulation is the most used stimulation in projects

D.2 Main loop 111

SPI_MasterInit();

uart_init(Ubrr1);

port_definition();

PORTB&=~_BV(PB0);

sei();

dac_output(1, 0);

PORTC&=~_BV(tra4);

dac_output(2, 0);

PORTC&=~_BV(tra3);

dac_output(3, 0);

PORTC&=~_BV(tra2);

dac_output(4, 0);

PORTC&=~_BV(tra1);

while(1)

{

if(control==1)

{

timer1_begin(15000); // 1 ms period

while(control==1)

{

shock(1,circuit1,freq_1);

shock(2,circuit2,freq_2);

shock(3,circuit3,freq_3);

shock(4,circuit4,freq_4);

}

}

}

}