Perceptual Feedback of Grasping Touch to Prosthesis Hand User

advertisement
FACULDADE DE E NGENHARIA DA U NIVERSIDADE 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
c Jorge Filipe Luís, 2010
Abstract
Nowadays with the technology development, new resources are available. It is up to us
to use and develop new systems that allow a much better life quality. One of this fields is
the prosthetic field. Investigators around the world are developing new control and mainly
feedback systems to human. Having this as background it was proposed the development
of such system. This consists in perceptual feedback to human. Summarizing, having
a 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 are
controlled with myoelectric sensors that can feel the sparkling between the nerves and
muscles. Usually the feedback is based in tactors, or vibrating motors. More developed
stimulations systems consist in electrical feedback, stimulating directly on the human skin
the sensory system. A European collaboration involving different universities has already
developed such a system. From a sensory system it is possible to the user to feel the object
if it was its own hand.
With all this development the global proposed system will consist in two non-invasive
stimulations, and one acquisition system. The acquisition is based in force sensing resistors connected to microcontrollers. These sensors are spread in key locations around the
hand, using voltage dividers. After, they are connected to microcontroller and then it is
possible to be seen the values in a user interface program. The stimulation is based in
mechanical 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 a
sensor ’senses’ touch, a motor will start to vibrate. These will increase their frequency
as the sensors increase their voltage. The second stimulation system is electrical and it
is used to identify objects. For example, when some sensors are activated a object is
identified and so the system stimulates the nerves. This is based in an already developed
system used in medical nerve stimulation, called TENS. Having it as background it was
proposed the development of a controlled current and frequency stimulator. This system
consists in half H-bridge but instead of controlling a usual motor is used to control a pair
of electrodes, allowing a current to flow in a muscle. The user interface is based in Matlab, and allows a easier way of identifying objects. The main advantage is the plotting of
the sensors value, and so when they are activated is possible to be seen the value changing
and it is graphically easily to identify objects.
i
ii
Acknowledgments
I want to thank my family for giving me the opportunity of going abroad to a different
country and for all the support they have given me. I want to thank my friends i have met
during these long chapters of my life. In special to Juan Ortiz for being a truly friend in
the moments i needed the most. I also want to thank to my roommate for all the nights
without sleeping and disturbances, Albert Gancedo thank you.
I want to thank to my supervisor in Poland, Dr. Andrzej Wolczowski for giving me
the opportunity of being part of this extraordinary project. I want to thank my supervisor
in Portugal, Dr. António Paulo Gomes Mendes Moreira for the coordination necessary
and for all the help in this project. A special thanks to Mateusz Cholewinski and Jacek
Urbanowicz for all the willingness.
Jorge Filipe Luís
iii
iv
“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
vi
Contents
1
2
3
Introduction
1.1 Basis . . . . . . . . . .
1.2 Acquisition System . .
1.3 Mechanical Stimulation
1.4 Electrical Stimulation .
1.5 Structure . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
1
2
2
2
2
State of the Art
2.1 Introduction . . . . . . . . . . . . . .
2.2 Human Physiology . . . . . . . . . .
2.2.1 How muscles work . . . . . .
2.2.2 Sensory system . . . . . . . .
2.3 Shadow Robot . . . . . . . . . . . . .
2.3.1 Tactile and Position sensors .
2.3.2 Air muscles . . . . . . . . . .
2.3.3 Communications and Control
2.4 DARPA . . . . . . . . . . . . . . . .
2.4.1 DEKA - Luke Arm . . . . . .
2.4.2 APL - Proto 1 and Proto 2 . .
2.5 Touch Bionics i-LIMB . . . . . . . .
2.5.1 Specifications . . . . . . . . .
2.5.2 Motor Control . . . . . . . .
2.5.3 Sensory Feedback . . . . . .
2.5.4 Future . . . . . . . . . . . . .
2.6 SmartHand . . . . . . . . . . . . . .
2.6.1 Specifications . . . . . . . . .
2.6.2 Motor control . . . . . . . . .
2.6.3 Sensory Feedback . . . . . .
2.6.4 Future . . . . . . . . . . . . .
2.7 Conclusion . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5
5
5
5
6
7
7
8
8
9
9
11
14
15
15
15
16
16
16
16
17
17
17
Signal acquisition
3.1 Introduction . . . . . . . . . .
3.2 Description . . . . . . . . . .
3.3 Components . . . . . . . . . .
3.3.1 Sensors . . . . . . . .
3.3.2 Operational amplifiers
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
19
19
19
20
20
21
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
vii
.
.
.
.
.
viii
CONTENTS
3.3.3 Multiplexer . .
3.3.4 Microcontroller
System designing . . .
Tests . . . . . . . . . .
Conclusions . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
21
21
22
25
25
Mechanical stimulation
4.1 Introduction . . . . . .
4.2 Description . . . . . .
4.3 The math . . . . . . .
4.4 Components . . . . . .
4.4.1 Motors . . . .
4.4.2 Mosfet . . . .
4.4.3 Darlington . .
4.4.4 Microcontroller
4.5 System designing . . .
4.6 Tests . . . . . . . . . .
4.7 Conclusion . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
27
27
27
28
29
29
29
29
30
30
30
31
Electrical stimulation
5.1 Introduction . . . . . . . . . . .
5.2 Description . . . . . . . . . . .
5.3 The math . . . . . . . . . . . .
5.3.1 Boost converter . . . . .
5.3.2 Current controlled circuit
5.4 Components . . . . . . . . . . .
5.4.1 Boost converter . . . . .
5.4.2 Current circuit . . . . .
5.4.3 Control . . . . . . . . .
5.5 System designing . . . . . . . .
5.6 Tests . . . . . . . . . . . . . . .
5.7 Conclusion . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
33
33
33
34
34
36
37
38
39
39
39
41
42
.
.
.
.
.
.
.
.
43
43
43
45
45
47
48
49
50
.
.
.
.
53
53
53
53
55
3.4
3.5
3.6
4
5
6
7
Communications
6.1 Introduction . . . . . . .
6.2 Communications design .
6.3 SMP-Protocol . . . . . .
6.3.1 Control messages
6.3.2 SMP-write . . .
6.3.3 SMP-read . . . .
6.3.4 Slave receive . .
6.4 Conclusion . . . . . . .
Control
7.1 Introduction . . . . .
7.2 Acquisition system .
7.2.1 Control . . .
7.2.2 User interface
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
CONTENTS
7.3
.
.
.
.
.
.
.
57
57
58
58
58
60
60
Conclusions and Future developments
8.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2 Future Developments . . . . . . . . . . . . . . . . . . . . . . . . . . . .
63
63
64
7.4
7.5
8
Mechanical stimulation system
7.3.1 Control . . . . . . . .
7.3.2 Key locations . . . . .
Electrical stimulation system .
7.4.1 Control . . . . . . . .
7.4.2 Key locations . . . . .
Conclusion . . . . . . . . . .
ix
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
References
67
A Drawings
71
B Source code Acquisition System
B.1 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.2 Main loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
75
75
77
C Source code Mechanical System
C.1 Main Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
93
93
D Source code Electrical System
103
D.1 DAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
D.2 Main loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
x
CONTENTS
List of Figures
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
Comparison of the Human hand to Shadow Hand.
QTC conduction . . . . . . . . . . . . . . . . . .
Air muscle in action. . . . . . . . . . . . . . . .
DEKA Luke Arm. . . . . . . . . . . . . . . . . .
Power source. . . . . . . . . . . . . . . . . . . .
TMR with IMES control. . . . . . . . . . . . . .
i-Limb. . . . . . . . . . . . . . . . . . . . . . .
SmartHand. . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
7
8
8
10
12
13
15
16
3.1
3.2
3.3
3.4
3.5
Acquisition architecture.
Location of the sensors. .
Test glove. . . . . . . . .
Resistance vs force. . . .
Sensor diagram. . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
20
22
23
23
24
4.1
4.2
4.3
Mechanical stimulation architecture. . . . . . . . . . . . . . . . . . . . .
Darlington configuration. . . . . . . . . . . . . . . . . . . . . . . . . . .
Motor control diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
29
31
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
Electrical stimulation architecture. . . . . . . .
Boost converter. . . . . . . . . . . . . . . . . .
Proposed circuit. . . . . . . . . . . . . . . . .
Lower quadrant. . . . . . . . . . . . . . . . . .
Upper quadrant. . . . . . . . . . . . . . . . . .
Ne555 configuration. . . . . . . . . . . . . . .
Simulation Circuit. . . . . . . . . . . . . . . .
Simulation Circuit, voltage around human skin.
Control circuit. . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
34
35
37
38
38
40
41
41
42
6.1
6.2
6.3
6.4
Diagram. . . . . . .
SMP-Write function.
SMP-Read function.
Slave receive. . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
44
47
49
50
7.1
7.2
7.3
7.4
Location of the sensors.
User interface. . . . . .
Location of the motor. .
Location of the circuits.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
54
56
59
60
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
xi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
xii
LIST OF FIGURES
A.1 Acquisition system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.2 Mechanical stimulation system. . . . . . . . . . . . . . . . . . . . . . . .
A.3 Electrical stimulation system. . . . . . . . . . . . . . . . . . . . . . . . .
72
73
74
Abbreviations and Symbols
PWR
Politechnika Wroclawska
CPU
Central Process Unit
PWM
Pulse-width modulation
NPN
Bipolar Transistor Negative Positive Negative
PNP
Bipolar Transistor Positive Negative Positive
CNS
Central nervous system
QTC
Quantum Tunneling Composite
PSoC
on-board Programmable System-on-Chip
PAM
Pneumatic Artificial Muscles
ADC
Analog-to-Digital Converter
CAN
Controlled Area network
DARPA Defense Advanced Research Projects Agency
FDA
Food and Drug analysis
APL
Applied Physics Laboratory
RIC
Rehabilitation Institute of Chicago
TMR
Targeted Muscle Reinnervation
IMES
Injectable Myoelectric Sensors
USEA
Utah Slant Electrode Array
TSR
Targeted Sensory Reinnervation
FSR
Force Sensitive Resistor
OPA
Operational Amplifier
TENS
Transcutaneous Electrical Nerve Stimulation
UART
Universal Asynchronous Receiver Transmitter
DAC
Digital to analog converter
SPI
Serial peripheral interface
xiii
xiv
Abbreviations and Symbols
Chapter 1
Introduction
This document describes the work developed in PWR - Politechnika Wroclawska. It
is referred what has been done, what were the approaches followed, the design circuits
also as the future work to be developed. In this chapter it will be described what led to
the 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 background
it is necessary to develop intelligent systems able to replace this lost limbs. Usually these
systems are prosthesis based in robotics. They are called bionic arms. But one of the
biggest problems is how to feedback what this arm is doing, what is it touching, what
is its space position. It is believed that one of the USA military problems is the soldiers
that come home and have lost their limbs serving their country, according to SSgt Reina
Barnett survival rates for combat wounded are higher than ever before and that means
many more service members are coming home with severe injuries such as a lost of a
limb. With this new approach it is possible to rehabilitate them whether in new military
missions whether in normal day life.
The scope of this project is to help investigators to develop more advanced feedback
systems. And when the objective is completed there will be greater satisfaction from the
investigator and from the users that can actually get back their normal life, and realize that
someone is actually doing something for them. In a scientific field this project development can be understood as the search for the perfect super human, the perfect symbioses
between human machine and all of the applications that can be achieved.
“ The most important and urgent problems of the technology of today are
no longer the satisfactions of the primary needs or of archetypal wishes, but
1
2
Introduction
the reparation of the evils and damages by the technology of yesterday.” by
Dennis Gabor, Innovations: Scientific, Technological and Social, 1970.
1.2
Acquisition System
Acquisition systems assume a very important task. In order to achieve the most effective system it is necessary to check previous systems already developed. It is also
necessary to study what are the best options for the design of the system, such as sensors
and controllers. The main objective of this project is to develop a simple yet effective
network of sensors. This network will be based in force sensors connected to microcontrollers. These sensors must feel what is being touched by the prosthetic hand. Having
this as background, it is also considered the control of the system and the development of
a new user interface.
1.3
Mechanical Stimulation
The mechanical stimulation is the most used stimulation in projects like this one. This
method is based in vibrating motors connected to the human body. It is a non invasive
method because no surgery is needed. The main objective is to develop a mechanical stimulation with independent control of the motors. According to this, the proposed system
is based in a master microcontroller connected to different vibrating motors or stimulators. 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, in
other words, more force more vibration.
1.4
Electrical Stimulation
The electrical stimulation system is like the mechanical system, non invasive. The
method is based in what has been already developed and used in medicine called TENS.
These stimulation is called Transcutaneous Electrical Nerve Stimulation. Having a pair
of electrodes attached to the human body is possible to stimulate the nerves. The main
objective of the electrical stimulation system is to identify objects. This means, when
some object is identified the specific electric stimulator is activated. Another objective is
to 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. In
chapter 2 is described the state of the art, what has been developed by some companies all
1.5 Structure
3
around the world, is also described how muscles work in order to understand more about
electrical stimulations. Chapter 3 presents the first system developed, the acquisitions
system. It is described what approaches have been made, what components chose as well
as 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 been
done, the system designing including mathematics and the tests performed. In chapter 6 is
based 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 presented
the user interface developed. The last chapter 8 is described the conclusions of this project
also as the future developments, what can be improved.
4
Introduction
Chapter 2
State of the Art
In this chapter is briefly described how muscles work as an introduction to the matter
of robotic artificial hand specifically prosthesis. After, it will be referred what has been
brought 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 many
examples is the prosthetic field. In 424 B.C., Herodotus wrote of a Persian seer who was
condemned to death but escaped by amputating his own foot and making a wooden filler
to 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, nowadays
these 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 necessary
a briefly background in medicine about muscles and sensory system.
2.2
2.2.1
Human Physiology
How muscles work
Muscle comes from Latin musculus, diminutive of mus ’mouse’, it is a band of fibrous
tissue in the body that has the ability to contract, producing movement [3]. Muscles are
the engine the body uses to move, without them it would be impossible. Most people think
the muscles are those which are visible, like the biceps or triceps, but it is completely
5
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 contract
involuntarily, like stomach muscles. Cardiac muscles are only in the heart, they can stretch
like smooth muscle, and contract like a skeleton muscle. Skeleton muscles come in pairs
and are attached to the skeleton. One muscle is responsible to move the bone in one
direction and another to move it back the other way. The interest falls on the skeleton
muscles.
A muscle is comprised of cells called fibers. These are arranged in long cylinders and
made up of protein filaments, myofibrils. Myofibrils are made of protein myofilaments
called actin and myosin. They are the so called thick and thin filaments. These allow muscles to contract. The triggering of these fibers, muscles, is an electrical impulse. Doing
an analogy to electronics this is how it works. The brain is the CPU(Central Processing
Unit). From the brain, through the spinal chord there are nerve fibers, like wires. The
neuromuscular 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 to
contract [4].
2.2.2
Sensory system
The nervous system has a specific sensory system, one to each sense. Usually they are
divided in five classifications. They are touch, sight, hearing, smell and taste, according
to Aristotle. The interest is in touch system, or somatosensory system. This system is
based on sensory receptors and afferent neurons in the skin or muscle, to even neurones
within the CNS(Central Nervous System). The feeling of touch is a perception. This
results from activation of neural receptors on the skin. The neural receptors cover all the
skin. They detect stimulus, this stimulus is converted into information and it is directed
to the CNS by afferent neurons [5]. Afferent neurons are composed of sensory nerve
fibers put together. These carry impulses from receptors to the CNS. The afferent neurons
communicate one with each other, through what is called synapses. In the spinal cord, the
sensory system includes paths from the body to the brain. Between the spinal chord and
the brain afferent neurons there is the association neurons [4]. In the brain, the primary
somatosensory 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.
2.3 Shadow Robot
2.3
7
Shadow Robot
The Shadow Robot company is placed in London, United Kingdom. Currently, they
have 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 it
is possible to be seen in figure 2.1. Shadow Hand has touch and position sensors and
the 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, the
hand 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 Hall
effect sensor with resolution of 0.2 degrees. This data is sampled by 12 bit ADC(Analog
to Digital Converter) and transmitted on the CAN(Controlled Area Network) bus. The
tactile sensors are based in QTC(Quantum Tunneling Composite). QTC is a new type
of conductive material developed by Peratech. It is made mixing metal filler particles
with some elastomeric binder, usuallty silicone rubber. Under pressure this sensor has the
ability to change from electrical insulator to conductive properties. What gives the QTC
extremely good conductive is the fact that the metal particles have a surface normally with
spikes. When pressed, all of the metal particles get closer allowing the sensor to conduct
as it is possible to see in figure 2.2 at page 8. Each tactile sensor of Shadow hand has
an PSoC (on-board Programmable System-on-Chip), which allows the user to actively
control whether the range whether the sensitivity.
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 first
developed in the 1950s. The main objective was to use in artificial limbs. They are
extremely similar to human muscles. Like biological muscles contract, these muscles
contract when pressurized with gas. With a supply of compressed air, they contract by
up to 40% of its original length [8]. They are a very powerful mechanism to provide
movement. The core is an inflatable rubber tube, figure 2.3. The air muscle provides a
light-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 PIC18F4580
are used for control in the system. All sensor data, components, configuration and controller set points can be accessed over this bus [8]. Shadow company developed their own
protocol interface.
2.4 DARPA
2.4
9
DARPA
DARPA means Defense Advanced Research Projects Agency. DARPA was created in
February 1958 as an agency of the United States Department of Defense. They are responsible for the development of technology. This was intended to use by the military. Its
creation was attributed to the launching of Sputnik by Soviet Union. In 2005, DARPA has
announced a very ambitious program. This program is Revolutionizing Prosthetics Program. It is a two inter related program. Revolutionizing Prosthetics Program 2007 which
intends to deliver a working prosthetic arm with a neural interface by 2007, and Revolutionizing Prosthetics Program 2009 which will have a neurally controlled arm ready
for 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 Revolutionizing
Prosthetics program will create, within this decade, a fully functional upper limb that
responds to direct neural control. It was awarded to DEKA Research and Development
Corp. $18.1 million by the Revolutionizing Prosthetics Program 2007, and $30.4 million
to APL(Applied Physics Laboratory) of Johns Hopkins University by Revolutionizing
Prosthetics 2009 [12]. The Revolutionizing Prosthetics 2009 program is divided into two
24-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 by
Dean Kamen. The name DEKA is derived from his name, and is worldwide known as
the 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 strikes
back after Luke Skywalker, who gets a artificial hand in. This prosthetic arm is state-ofthe-art functional arm with usable fingers and sensory feedback [13].
“...after the initial shock of amputation wears off, usually within a year or
two, patients stop wearing their prostheses. Even extreme levels of amputation
don’t much curb this tendency. Wearing the burdensome prosthetic is simply
not 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 modeled
based on the weight of a female arm. The arm is powered by a lithium battery. The motors
used are electrical. It was built mostly in aluminiun because titanium is too heavy to keep
the weight limit, proposed by DARPA.
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 two
way of controlling the prosthesis. The first is controlled by specific controllers placed in
the soles of shoes and the second way is thought controlled. The shoes controller can
be fully customizable. For example when user pushes down his left big toe, the arm
moves 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 is
only possible to the innovative surgery developed by Dr. Todd Kuiken from RIC. It is
TMR(Targeted Muscle Reinnervation). TMR is a method by which the target muscle of
an amputated patient is denervated, then reinnervated with residual nerves of the amputated limb [16]. In the specific case, like arm prosthesis, this method consists in reassign
the nerves that once controlled the patient’s arm and hand to the patient’s pectoral muscles [17]. With this new approach the patient thinks about moving the arm, and the signals
are 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 signals
to an amplifier and digital signal processor, which sends command signals to the motors
of 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 is
needed. The feedback is based in two different approaches. The feedback is given by
a tactor. A tactor is a vibrating motor. A tactile sensor on the fingertip of the Luke
Arm, connected to a microprocessor, sends a signal to the tactor, and that signal changes
2.4 DARPA
11
with grip and force. When a user grabs something lightly, the tactor vibrates slowly. As
the 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 full
with this tiny balloons. These have two objectives. The first is to give much more modular
and comfortable prosthesis, and second transmit the feedback sensing. When the user
lifts something these balloons inflate proportional, giving at the same time a comfortable
position and heavy sensation.
2.4.1.4
Future
According to Dean Kamen before the arm can be commercialized, it needs to be approved by the FDA. Current stage of the Luke arm is clinical trials. The Luke Arm sent
to clinical trials is the one that uses controllers placed within the soles of shoes, and it is
expected 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 center
located in Maryland, US. The Revolutionizing Prosthetics 2009 program that is being
managed 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, APL
led a team of approximately 30 organizations. Against all expectations one year before the
deadline, 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 Light
for Phase 2[19].
2.4.2.1
Specifications
Proto 1 has been built with eight degrees of freedom compared to the 25 degrees of the
Proto 2. This has almost has much dexterity as a human limb [20]. Proto 1 is a complete
prosthetic system. This system is based in a virtual environment with the objective of
patient training and clinical configuration. It has the ability to record movements and
control signals. Proto 2, has also a virtual environment but it goes further ahead with
15 motors in the hand alone capable of extraordinary mechanical agility. Proto 1 and
Proto 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 in
figure 2.5 page 12 . The power unit provides about ten times as much power as other
prosthetic limbs, according to Michael Goldfarm, professor of Mechanical Engineering
at Vanderbilt University. It contains a special catalyst that causes hydrogen peroxide to
burn, producing pure steam. The steam is used to open and close the valves. These are
12
State of the Art
connected to the spring loaded joints of the prosthesis by belts. A small sealed canister of
hydrogen peroxide that easily fits in the upper arm can provide enough energy to power
the 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 the
invasiveness of the method. APL team is working with four levels of neural interface. For
low level amputation it is used simple electrodes on the limb skin, because the muscles and
nerves are still there. The electrodes detect and amplify those signals. After with pattern
recognition 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 second
level is application of IMES(Injectable Myoelectric Sensors), for the control of the fingers
individually. These sensors are injected into the muscle tissue of the remaining limb, they
are capable of detecting and transmitting a cleaner and higher fidelity signal, and so, allow
better 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 previous
section. It is based in TMR. With IMES and amplifiers it is possible to detect the muscle
firing up, and control the motor. It is seen this effective control in figure 2.6 at page
13. The most extreme solution is meant for people whom the TMR surgery is not even
an option. In such cases University of Utah developed an implantable device called the
USEA(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 specifically
on the top of the skull. These pick up the brain’s signals and are capable of intercept the
neurons firing up. With the help of complex algorithms it is translated the related signals
into a language that can control the mechanics of the arms [20].
2.4 DARPA
13
“The Rehabilitation Institute of Chicago continues to advance this applied research and bring the application of the Targeted Reinnervation technique to
the 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 a
sense of touch, temperature, pressure, and vibration, as well as a sense of where the limb
is situated in space [23]. Proto 1 and Proto 2, use the same mechanism used in the Luke’s
arm, the tactor or vibrating motors. This is the best mechanism on the market today. Like
explained in previous section it is based of a vibrating motor against the skin that vibrates
more or less intensely to feedback, force factors. According to APL other technologies
are being explored as well [23].
14
State of the Art
“This work offers the possibility that an amputee may one day be able to feel
with an artificial limb as though it was his own. Sensors could be placed in
a prosthetic hand to measure contact forces and temperature, while a device
could press or thermally stimulate the reinnervated skin to provide sensory
feedback that appropriately correlates to hand perception.” by Dr. Kuiken.
Dr. Kuiken discovered that TMR was responsible not only for muscle control but also
for sensation, in other words, rerouted nerves sensitized the skin. But the volunteers didn’t
feel 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 chest
next to the electrodes, they created a complete feedback loop [24]. In the end, Dr. Kuiken
complex rewiring scheme and the brain simulated a real arm. In [25] is shown a patients
sensory map, due to this TSR. Dr. Kuiken has been working to redefine the map of the
phantom limb to determine the connection between the exact location on a prosthetic
finger and the corresponding feeling perceived in the phantom limb [20]. This feedback
system was developed by Kinea Design and it is called Prosthetic Haptic Interface System
Project. The system is composed of three subsystems. Fingertip sensor - this sensor is
placed on the fingertip of a prosthetic hand and senses force and accelerations. Haptic
tactor - vibrating motor which displays the force, texture and friction sensed by the sensor.
Embedded controller system - the signals from the sensor are converted into command
signals 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 human
somatosensory system.
2.5
Touch Bionics i-LIMB
In 2007, Touch Bionics, a company situated in Scotland, introduced the world what
is called the i-Limb [26]. It was invented in Edinburgh, Scotland, by David Gow. i-Limb
has become the first commercially available hand. This has five individually powered
digits. These digits are simple robotic fingers. i-LIMB, figure 2.7 page 15 , is capable of
different grip positions. It allows the user to balance power and precision. Extending the
index finger it is possible to type on a computer. The ut pageser can grip a key by rotating
the thumb. These prosthetic hand has a cost of approximately $18,000 US.
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 by
removing one screw. It has electric motors and it is powered by a battery. It takes between one and four hours to charge. i-LIMB has multi position thumb, which allows to
manipulate the thumb into different positions, grips. These grips are normal predefined
positions of the hand [28]. It has key grip - the thumb closes onto the side of the index
finger. Power Grip - all fingers close to create a full wrap grip. Precision Grip - where
the index finger and thumb meet. Index Point - the thumb and fingers close but the index
finger does not. Fingers can be controlled from sensors. These sensors are from either
FSR(Force Sensitive Resistor) or Remote Electrodes.
2.5.2
Motor Control
i-LIMB Hand, uses myoelectric principles already developed and spread in other prosthetic hands. It is controlled using two sensors. These are myoelectric sensor, it reads
nerve impulses through the skin with non invasive fittings, easily configurable. One is situated in upper prosthetic and the other down. The hand uses a stall detection system. This
is system allows to tell when is applied enough pressure. After is able to stop powering to
prevent crushing the object. It is also capable of self adjusting to the shape of the object
thanks 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 a
sensation that their hand still exists despite it being amputated [28]. This is experienced
between 80%-100% of patients who lost a limb, by many reasons. This is explained as if
one part of the somatosensory cortex is deprived of input, the somatosensory cortex will
reorganize the inputs so that the idle areas of the cortex become active [30].
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 is
possible to start the development of a new i-LIMB.
2.6
SmartHand
The SmartHand is a European Union collaborative project to produce a functional
artificial hand that looks and feels to a patient like a real hand [31]. SmartHand is the
first device of its kind to feedback signals to the wearer, figure 2.8, allowing them to feel
what they touch. This project counts with the participation of Tel Aviv University (Israel),
ARTS Lab, Scuola Superiore Sant’Anna (Italy), Aalborg University (Denmark), Tyndall
Institute (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 movement of a human hand. It is able to provide the user with a sensation of feeling and
touch.
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, these
signals activate muscles that would have moved the fingers. Myolelectric signals from
2.7 Conclusion
17
those muscles are recorded by electrodes applied to the forearm and then transmitted to
motors 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. According
to Prof. Shacham-Diamand from from Tel Aviv University perfectly good nerve endings
remain at the stem of a severed limb [34]. His team connected the sensors in the hand
to the nerves in the arm. Now, it is possible to feel as well as to control. The sensory
information provided by the arm has to be fed back to the residuum remainder of the
amputated arm, the only problem is to find out where [33]. It is very difficult to identify
the sensing of each finger. In this perspective, different techniques described in previous
sections can be used, like TMR and TSR. Robin af Ekenstam is the project’s first human
subject.
“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 them
anymore. It’s amazing.” by Robin af Ekenstam.
2.6.4
Future
The long term objective is developing a neural interface. The researchers are also
planning to equip the smart hand with artificial skin. This will give the brain even more
tactile feedback. In 1 year, 2011, is possible that the Smarthand will be commercially
available.
2.7
Conclusion
The prosthetic field is becoming a field of great interest. A field of excellent opportunities for investigators and for market success. With what technology offers is possible
to build similar prosthesis as human limbs. All around the world, efforts are being made
and it is possible to see what has already been done whether in electronics whether in
medicine. DARPA and the revolutionizing program have made extraordinary developments in prosthetic control, using pattern recognition algorithms, but it is definitely the
Smarthand the most interesting program, because it has already shown a human machine
interface, allowing to the user to feel the prosthetic hand. Human feels not with help of
18
State of the Art
tactors but electrical stimulation directly on the nerves. It is believed that DARPA has
already connected the the prosthetic to the human sensing fibers.
All these mechanisms of feedback allow to delineate an approach to the work developed. Although, the lack of technical information of these prosthetic hands it has been
described all the mechanisms of control and feedback.
Chapter 3
Signal acquisition
In this chapter is described the approach made to the signal acquisition, also is described the sensors used, what other options were available as long as all the components
used like microprocessors.
The choice of the components used was based in what has been developed in other
projects also as the price. The main goal was to build a sensing hand keeping everything
perceptible 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 most
important steps. It is important because a simple and a good acquisition system allows
the developer and also the user to achieve excellent overall results. Before choosing the
components, a previous study of the market was made. Some companies all around the
world were asked about their solutions and prices. Projects developed in this area were
also 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 specific
locations in order to feel and identify the object touched. This signal acquisition was based
in FSR, using ADC and also OPA (Operational Amplifiers).
3.2
Description
The architecture of the signal acquisition is very simple. The most important are the
sensors. These are FSR, spread all over the hand. After the sensors it is necessary to
treat the signal, so it was used, OPA. Next it was the filtering for that it was used a low
pass filter, connected to a multiplexer. This multiplexer is connected to the ADC of the
19
20
Signal acquisition
microcontroller. This microcontroller has the ability of process this signals and according
to 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 microprocessor, 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 companies
that develop sensors. The chosen sensors are force based. When a force is applied the
output value changes, whether it is in voltage or in other type of output. One of the
parameters was the price of the sensor. According to this, some options were excluded at
the beginning.
3.3.1.1
Weiss Robotics
Initially, it was contacted Weiss Robotics. These sensors are pressure sensors integrated in various applications. The sensor available was DSA 9205 with a price of 650
Eur, it is necessary the acquisition system provided by the company with a estimated price
of 1980 Eur. This option was excluded.
3.3 Components
3.3.1.2
21
Peratech
The sensors provided by Peratech are QTC based. Since they are not sold as individuals and it is necessary to develop them. The project cost is estimated to be around 20,000
to 40,000 Eur. Option excluded.
3.3.1.3
Pressure Profile
Robot touch - The system includes 7 sensors molded on Barrette Hand provided by
customer, D500 board, visualization software, expansion module with at ribbon, exible
wiring 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 not
robust if used often they are very practical and cheap. Each one costs 10 Eur. These were
the 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 it
is only necessary to supply with positive voltage. The other parameter was to use as many
as possible in one single chip. The choice of the OPA was the LMC6484AIN. It is a quad
rail 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 multiplexer
and 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 protocol
communications, 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 to
more sensors. It was chosen this microcontroller also because of 32k of memory, that is
more than enough to control the system. The price of this microcontrol is about 4 Eur.
22
3.4
Signal acquisition
System designing
After the selection of the sensors it is necessary to put them in the prosthesis. Since
it was not available, the test was made in a human right handed glove. There were only
5 sensors available, so it was necessary to put them in some specific points. These were
placed in key locations to the human hand, in other words in the top of fingers, and palm
of 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 and
index finger are activated, easily identifying one type of object. In figure 3.3 at page 23
it is possible to see the test glove with all this sensors stitched. This procedure was made
in 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 changes
when a force or pressure is applied. The resistance is inversely proportional to the force
applied, i.e. the resistance decreases as the force increases. Having this as background
it was decided to use this FSR in a voltage divider. Using a supply of 5 V connected to
the sensor and then to a 260k Ohm connected to the ground. In figure 3.4 at page 23 it
is seen the resistance vs force. This resistance was chosen because, first it was suggested
by the producer that the maximum current should be 2.5 mA. Next with a resistance in k
Ohm it is possible to obtain a good voltage measure with a small force, and so easier to
the system to feel a touch in a object.
3.4 System designing
23
Figure 3.3: Test glove.
Voltage :
Vo =
260k
Vi
260k + R
(3.1)
Analyzing the equation 3.1 it is possible to see that when no pressure is applied the
FSR resistance is about M Ohm, so in this case the output voltage will be 0. When a
pressure is applied and the FSR resistance comes under the 260k Ohm, the output voltage
is half of the input. When the FSR resistance is much more lower than the resistor, it is
possible to despise the FSR and the output voltage will be the input voltage, in this case
it will be 5v.
The configuration used to the OPA was voltage follower. It was used this voltage follower because although there is no change in the voltage value it allows that the input of
the OPA does not load down the source or draw any current from it. Because the output
impedance 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 power
consumption in the source, distortion from overloading, crosstalk and other electromag-
Figure 3.4: Resistance vs force.
24
Signal acquisition
netic interference. In this system it is used only five OPA although it is possible to extend
it to 16, extending to 16 sensors.
These channels of the sensors are going to be connected to the multiplexer. Choosing
the right commands S0,S1 or S2, is possible to choose the right input, and so having it
on the output. Each one has 8 channels, and it was used 2 multiplexers. Once again it is
possible to extend to 16 inputs. Each multiplexer output is connected to a microprocessor
ADC. 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 multiplexer. According to the order this changes the input channel, reading various input
channels.
Figure 3.5: Sensor diagram.
In figure 3.5 is possible to see the diagram of the control of the sensors. Like it was
said 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(Universal
Asynchronous Receiver Transmitter) the values. UART is a device that translates data
between parallel and serial forms. According to the instructions some measures are taken
and send to the circuits controlling the stimulation to the human. These instructions will
be explained later in the document. The control is activated by UART interrupt. When
there is a interrupt the message is read and if is a control message for the acquisition
system it will test if is ’senson’ and so control=1. If the string is ’sensof’ then control=0.
3.5 Tests
25
If it is not a control message, this is sent over SPI to the other systems. In the beginning
everything is shutdown, control=0.
3.5
Tests
Before connecting it to the stimulation systems some tests were made, in order to see
if it was everything working. Connecting the microcontroller to a max232 it was possible
to 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 microprocessor. If the string from UART port was ’senson’ the led will turn on, and if it
was ’sensof’, it will shutdown. Overall result, interruption working.
2. Test if the values of the sensors and the multiplexer were working. Choosing different sensors, send the values to the UART port. Using a multimeter it was compared
the 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 the
acquisition system and checked if it was everything working and searching for some
bugs.
3.6
Conclusions
The acquisition system developed proved to be effective. The objective of keeping it
as 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 know
the key locations for the sensors. This glove proved to be effective, although the sensors
were stitched. One problem of this procedure was the sensors sometimes cannot read
efficiently, because the sensors do not keep their original locations. For example, when
the size of the hand changes the overall result will also change. It was necessary to use
multiplexers and thus increasing the difficulty to accomplish the main objective. Leds
were placed for a feedback, green and red. These allow to know when the system is
turned on or off.
26
Signal acquisition
Chapter 4
Mechanical stimulation
This chapter will address the stimulation of the human body by motors. This is one
of the most used stimulations in projects like these, by many reasons. Whether is the
extremely low cost of this motors, whether is the non invasive way of this method. It will
be described the assembly of a mechanical stimulation system, what components were
used, as the mainly results achieved.
4.1
Introduction
Stimulations of prosthesis can be divided in two main groups. One is the invasive
one, and the other the non-invasive. Mechanical stimulation is considered non-invasive
because it is not necessary any surgery to human body to implement sensors, or stimulators. The main objective was to develop a such way system. This system is based in
small electric motors, attached to a t-shirt in some specific locations. When some sensor
is activated it should turn on a motor. To accomplish this goal it is necessary having all
the 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 touching something, is possible to feel and act according to what is felt. In the mechanical
stimulation it also should work like that, when the sensor “feels” it should be transmitted
to 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 interpret them, and change the state of the motors. This can be understood in figure 4.1 at
27
28
Mechanical stimulation
Figure 4.1: Mechanical stimulation architecture.
page 28. It will be used PWM(Pulse Width Modulation) from microcontroller. Originally
was thought to use PWM in order to change the frequency of the vibration, according to
the sensors value. Since it is not possible to use a different PWM for all motors it was
chosen to have the same PWM for all motors, the only difference is the time that each one
is 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 this
project the motors were already provided. The maximum operating voltage is 5v. For
driving this motors it is necessary a bigger amount of current and so it is necessary to
do the scaling of the circuit. It is not important in which direction the motor is spinning
and for that it is not necessary a H-bridge controlling the rotation direction. The best
way and cheapest to drive a motor is with transistors, since it is not necessary a high
controlled system it was used NPN(Bipolar Transistor Negative Positive Negative) transistors. Considering all options the best one, was to use a Darlington circuit. This allows
a high current on the output with a minimal one on the input, and so it can be driven by
the microcontroller. Usually a Darlington has a gain of 1000 over its base current, so it is
more than enough to drive this motors. It is seen the configuration chosen in figure 4.2 at
page 29. According to [35], the resistance between base and emitter allows a discharge
path for the charge accumulated on the base emitter junction, allowing a faster transistor
turn-off.
Darl1 :
Vm −Vr −Vb e −Vb e = 0
(4.1)
4.4 Components
29
Figure 4.2: Darlington configuration.
5 −Vr − 0.7 − 0.7 = 0
(4.2)
Vr = 3.6V
3.6
I=
2.7k
I = 1.33mA
(4.3)
(4.4)
(4.5)
Considering the Vm from microprocessor and Vbe the voltage drop between the base
and emitter. In 4.5, with an 1.33 mA current is possible, if the supply can handle it, have
an 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, like
for 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 to
use one for the PWM to the motors. By suggestion it was chosen the IRLZ44N because
it 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.
30
Mechanical stimulation
4.4.4
Microcontroller
The microcontroller chosen was an Atmega16. It was chosen this one, because it is
not necessary so much memory like in the acquisition system. It has also UART communication, and so it is possible to interface it whether it is with the computer whether is
with the acquisition system. The connection is similar to atmega32. The price is about 4
Eur.
4.5
System designing
Some aspects were considered in order to achieve the best solution for the mechanical
stimulation. The first, all motors spin at the same frequency. This option was chosen
instead of different speeds for motors because it was difficult to differentiate various spinning speeds when for example there was a body movement like walking. And so cutting
on the necessity of 8 mosfets. With the same frequency for all motors it is only necessary 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 5
V 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 with
the Darlington turning on and turning off with a frequency desired.
The control for the mechanical stimulation system is basically, according to the instruction received, the microcontroller co-ordinates which motors and what frequency are
they going to spin.
In figure 4.3 at page 31 is seen the algorithm of control of this system. The system
is on stand-by, if receives an interrupt from UART checks the slave. If it is for him then
process the message and the instructions are saved. These will be explained further in
the document. In the main loop it will check if the control is activated. This is activated
with 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 a
modular system, interchangeable with other different ones.
4.6
Tests
In order to check the effectiveness of this system some tests were made before connecting it to the global system. Once again, with a max232 and using the UART was
possible 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 off
was possible to check if the UART interruption was working.
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 to
check if the PWM was working. By changing this frequency was possible to change
the intensity of the led, implying that everything was working.
3. Test if the Darlington array was working. Connecting a single motor to the PWM
and to the Darlington circuit, was changed the on and off frequency, also was controlled if the system was on or off.
4. Test if the system was working. With all the motors connected to the mosfet and to
the 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, for
example in a t-shirt is easily changeable. The motors turn on and off only when there is a
change of state. For example, the system receives an order to turn on the motor 1 with x
frequency, it will only shut it down again when receives a new order from the command
system, in this case the acquisition system. This system has a drawback because it is using
UART interrupt. So if it takes to long the interrupt the frequency of turning on and off the
32
Mechanical stimulation
circuit will also change. This will be explained in detail further in the document. It was
also connected two leds, green and red, to identify how was the state of the system.
Chapter 5
Electrical stimulation
Another type of stimulation is by means of current. This method is also a non invasive
way, it stimulates the nerves. This stimulation is used in medical therms to treat pain. In
this chapter will be discussed how this system was developed, what has been done, what
approaches were followed, what components were chosen as well all the tests necessary
to check the effectiveness of this method.
5.1
Introduction
One of the electrical stimulation methods used whether is for this kind of project or for
medical 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 more
electrodes. This is able to modulate pulse width, frequency and intensity. Following these
lines it was developed a TENS module but for different purposes. Using electrodes in
some key locations it is possible to identify objects. Changing the frequency as also as
the amplitude, much more effective pattern recognition is achieved.
5.2
Description
The electrical stimulation system will behave like the mechanical stimulation. It will
respond to a impulse from the sensors. The main difference is that this stimulation system
will only be used to identify objects. For example, the glove is holding a pen, since only
two sensors are activated and it is a simple object two electrodes in a key locations should
stimulate 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 similar
to the motor stimulation.
33
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 which
approach to follow. Some research was made and after two options were available. First
one was to develop a voltage controlled source, and the second one current controlled
source. The choice made was the current controlled by many reasons. Although it is
more difficult, it has one great advantage. As it is known, human skin resistance also as
the muscles resistance changes from person to person. Having a controlled voltage, with
changes in resistance it will lead to different currents and small current of 5 mA in the
heart is enough to make some damage. Having a controlled current circuit, this problem
does 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 best
solution considered was a boost converter. A boost converter is a type of DC-DC converter
that 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 thought
to drive all the circuits at same time. The following equations are best explained in [37].
Dutycycle :
Vo
1
=
Vi
1−D
(5.1)
5.3 The math
35
Figure 5.2: Boost converter.
Inductor :
D = 0.94
Io
IL =
1−D
= 2.5A
(5.2)
(5.3)
(5.4)
In equation 5.2 is possible to see what is the necessary duty cycle to this boost. In
equation 5.4 is calculated the average current passing through the inductor. Initially was
thought to develop this boost converter using a microcontroller, so the frequency chosen was a multiple of the clock frequency, equation 5.6. After the period is calculated,
equation 5.8.
Fc
256
= 62.5kHz
1
Period : T =
Fc
= 16us
Clock :
F=
(5.5)
(5.6)
(5.7)
(5.8)
Now, it is possible to know the time that the transistor should be on and off, equation
5.10.
ton
T
ton = 15.04us
Ton :
D=
(5.9)
(5.10)
After knowing the variables it was possible to scale the inductor size, the approach
used was simple. Considering a 10% of the input current, ∆i = 0.250A it is possible to
obtain the size of the inductor, equation 5.12.
Inductors :
di
dt
Viton
L=
∆i
Vi = L
(5.11)
(5.12)
36
Electrical stimulation
= 541uH
(5.13)
Another approach was followed using the current formula.
Inductors :
Lm ≥
DVi (1 − D)
F2Io
≥= 67uH
(5.14)
(5.15)
The capacitor was also based in simple equation. Considering a 0.5 voltage ripple the
capacitor voltage output, equation 5.17.
Inductors :
dv
dt
Io ∆T
C=
∆V
= 4.8uF
io = C
(5.16)
(5.17)
(5.18)
Having this calculations as background, the inductor available was a 100uH and the
capacitor 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 which
electrodes are activated. This circuit uses two fly-back power converters. This is used for
positive and negative current on the electrodes. Biphasic current allows the depolarization
of the skin, allows a much more efficient power transfer for muscle stimulation avoiding
also chemical reactions. Also it is difficult to get skin burns due to high voltages. Since
it was not necessary so much efficiency and though having negative current because it
is 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 used
biphasic 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 square
peaks 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 controlled
by a PNP(Bipolar Transistor Positive Negative Positive) transistor, and in lower quadrant
by a NPN transistor, with an attached resistor which will allow a controlled current, figure
5.4 at page 38. Every half bridge has one pair of electrodes, the positive and negative. It
was used this configuration with two power transistors because it is safer and controllable.
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 positive
electrode in the skin. This leads to a safer circuit. In case of contact with ground, having
both NPN and PNP off, there is no voltage in the positive electrode. The DAC is used in
order to obtain a controlled voltage which will allow a controlled current. Doing some
math, 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 to
stimulate the nerves, 5.20. This is the maximum current value. It was chosen considering
some eventual losses, although it is easily configurable by changing the resistor and output
voltage of the DAC. The upper part of the circuit it will be using a PNP transistor, this
one allows a good opening and shut down of the circuit. Since it has a high voltage on the
base, it was chosen to drive this transistor with an optocoupler, isolating this high voltage
from the microcontroller. In figure 5.5 at page 38, it is seen the configuration. R1 is used
as 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 limit
the 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 control
of the system. Some components were chosen by suggestion, others it was necessary a
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 control 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 a
current of 2.5 A and a voltage of 300 V, two times Vo. Looking at the datasheet the
voltage 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 voltage
of 800 V and a current of 3 A. It costs 0.35 Eur.
Figure 5.5: Upper quadrant.
5.5 System designing
5.4.1.3
39
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 transistors. The ones chosen were the NPN, MJE-340, and the PNP, MJE-350. These are low
cost transistors, having a maximum voltage between collector and emitter of 300v, and a
maximum collector current of about 0.5 A. The price of the pair is about 0.60 Eur, what
makes them excellent choices for this project. As it was necessary an optocoupler, it was
chosen the H11D1, this one allows a maximum voltage between of collector and emitter
of 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 was
chosen this DAC because it was used in previous projects. The DAC is MCP4921 with a
cost of 2.20 Eur.
5.4.3
Control
This stimulation circuit needs more instructions than the mechanical system. According to this it is necessary to control 4 different DAC. These DAC work with SPI, so it was
necessary some functions. The control algorithm is very similar. It was decided to chose
a 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 4
controlled current circuits. These circuits have 2 electrodes each. It is possible by changing the output voltage, to change the current passing by these electrodes and change the
stimulation of the nerves. Each circuit is independently controlled, whether in voltage
whether in frequency.
40
Electrical stimulation
Like said before the boost converter is controlled with the ne555. In figure 5.6, is
seen the configuration for this timer. Configuring the timer as astable operation, and
for a frequency of 62.5kHz, R2=100 Ohm, R3=2 kOhm, C1=0.01uF. These values were
achieved in a timer calculator. In 5.22 are the equations for the timer555. The transistor
used is BC547 and R1=56 k Ohm. With this configuration it is possible to control the
output voltage by connecting the base of the transistor to a potentiometer on the boost
voltage output.
Timer :
ton = 0.693(R3 + R2)C1
(5.21)
to f f = 0.693(R2)C1
1.44
f=
(R1 + 2R2)C1
(5.22)
(5.23)
Figure 5.6: Ne555 configuration.
Before the assembly, these circuits were simulated using the Multisim. The simulation
had some differences, it was not used the controller transistor of the timer, and instead of
a microcontroller it was used a function generator with a square wave of 5 V. The skin
resistance 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, as
expected. The voltage around the resistance of the human skin is seen in figure 5.8 at
page 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 circuit
individually. 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
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, if
yes, 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 necessary
to be sure about frequencies, and currents. For that some tests were made before the
assembly of the circuit.
1. Test the output voltage. Using a multimeter was checked if the output voltage was
the one expected. Also changing the Potentiometer was possible to change this
output voltage.
2. Test if the UART interruption was working. Like before it was used a Led to check
if the interrupt was working.
Figure 5.8: Simulation Circuit, voltage around human skin.
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. Using
a supply of 5 V and a oscilloscope it was checked the output wave, of the current
controlled circuit.
5. Test if the stimulation was working. Connecting the electrodes to the human body
it was checked if some stimulations was achieved.
6. Test if the system was working. Using a max232 connected to the computer it was
possible 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 for
pattern recognition. In other words, it identifies objects. The system has 4 controlled
circuits, each one for a different type of object identified like pencils or pens and bigger
objects. 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 the
circuit. Each circuit is independent and it is possible to control current and frequency. This
current control is possible due to the voltage control on the DAC by the microprocessor,
connected to the power NPN.
Chapter 6
Communications
Communication assume in this project as the bridge between all circuits. Without
this connection the circuits will behave as independent systems and not as global one. In
this 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 it
is by private users. The protocol developed is based in Modbus and Hostlink by Omron. It
is a simple protocol. After the protocol designed was defined the control messages every
system should use. The main goal is to obtain the most effective communication protocol
also as short control messages.
6.2
Communications design
It is necessary to define the type of communications, in this case who is the slave and
who is the master. The global communication system is based in a graphical interface
capable of controlling the acquisition system, the mechanical and electrical stimulation
systems. Having this as background, was defined that there is one master the acquisition
system. Electrical and mechanical systems are working as slaves. The user interface is
used 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 computer
controls the acquisition system, and this sends to the user interface the values of each
sensor. The events are asynchronous because it is impossible to know when the user is
43
44
Communications
Figure 6.1: Diagram.
going to activate each different system. The communications between the acquisition system and user interface are UART based, they will be done using the serial port. This is
possible because of max232 device. As said before, electrical and mechanical systems
are slaves. These slaves are using UART. The main difference is instead of using Rs232
they use Rs485 in half-duplex. This is achieved with max485 device. The baudrate used
to this communication is 500 Kbps. One great disadvantage of this communication system is due to the fact that acquisition system is connected to the max232 and the slaves
are using max485. In order to solve this problem some options were available. It was
thought to use max485 with all systems and using a rs485 to rs232 converter to connect
to the interface user, computer. This option was excluded because of the price of this
converter. It is about 25 Eur. The option used was, acquisition and user interface are
using the rs232. Since there is no more UART port available was decided to acquire a
simple microcontroller, described as the sender in figure 6.1. This microcontroller will
use SPI or serial peripheral interface communication with the acquisition system, and use
UART port connected to a max485 device to connect with the other slaves system. The
sender system will be used for replying messages. For example, it receives a control mes-
6.3 SMP-Protocol
45
sage from the acquisition system and will reply it in the UART port for the stimulation
systems. The price of this microcontroller is about 4 Eur, compared to the 25 Eur of the
converter. Summarizing, computer and acquisition system use rs232 protocol communication, acquisition system and sender system use SPI protocol communication and sender
system with the stimulation systems use rs485 communication protocol. In this rs485
communication it was developed a protocol. This protocol is called SMP-protocol. It was
given 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 advantages
are a custom made protocol for this system, a more familiarization about how to develop
a protocol in spite of being necessary twice as work as implementing a already developed
one. By suggestion, the protocol is based in Modbus and Hostlink from Omron. It is based
in characters, and it is possible to address to different slaves, with different messages. This
protocol has three functions, Smp-write, Smp-read and slave receive. Within this protocol
control messages were developed.
6.3.1
Control messages
In order to obtain effective control in the different systems it was needed control messages. 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 user
interface, 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 sends
messages to the user interface. These messages identify the different sensors and their
respective 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.
46
Communications
• 3rd-5th character - These last characters carry the value of the sensor. This value is
between ’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 each
independently motor or pair of electrodes, with a different frequency. The messages to
both systems are similar. The only exception is the first character which identifies the
system.
• 1st character - The first character can be ’m’ or ’e’, each one identify the mechanical
or electrical stimulation system.
• 2nd character - The second character allows to choose which motor or circuit is
going to be activated, the values are numbers, for example ’1’ or ’2’. For mechanical
system 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 frequencies
already 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 first
frequency, 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 is
going 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 mechanical
or electrical stimulation system.
• 2nd character - The second character is a ’f’, this one allows to chose frequency
configuration.
• 3rd character - The third character can be ’1’, ’2’ or’3’. It allows to chose which
frequency is going to be redefined.
6.3 SMP-Protocol
47
• 4th, 5th and 6th character - These last characters allow to define the frequency. They
can be from ’000’ to ’999’. According to the frequency defined in the timer of the
microcontroller 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 the
message to be sent. After a new message is built. In figure 6.2 is seen the diagram of this
function.
Figure 6.2: SMP-Write function.
• 1st character - The first character identifies the slave.
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 stimulation
systems.
• 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. The
microcontroller chooses the max485 as sender, all slaves listen, in order to prevent crash
messages. After this message is sent. It waits for a acknowledge. If it takes to long to
receive acknowledge it will return an error, timeout error. If the first character is different
than ’0’, the transmission will be repeated. If it continues to happen this error and it
was sent 5 times the same message it returns an error. If it receives a message of two
characters, ’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 it
should 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 the
SMP-write, it also uses a specific built message, based in characters. It accepts as input
parameters the slave number and the message to be sent. After a new message is built. In
figure 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 the
stimulation 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 prevent
crash messages. It waits for a acknowledge. If it takes to long to receive acknowledge it
will return an error, timeout error. Here is the big difference from SMP-write, it is waiting
for the status of the system, if it receives a message of 4 characters, ’01ok’, from the slave
the message was processed, return. if it receives ’01nk’ it means some problem in system
and it should return with an error. If it receives a message ’02’ there is a problem in the
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. After
5 times if the same continues to happen it should return an error. If none of this cycles is
detected 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 answer
the functions of SMP-write, and SMP-read. In 6.4 at page 50 is seen the diagram of
this function. It takes as input parameters the slave, the status message, and the message
received. First this tests the slave number, if it is not ok, return. Then test the Crc, if it
is not ok, send a error message and return. If everything ok, test which is the function
50
Communications
Figure 6.4: Slave receive.
received. If it is write, send acknowledge, if is read send the status message. Finally it
should return.
6.4
Conclusion
It was designed and implemented a new protocol. It is called SMP-protocol. It has
3 basic functions, for reading, writing commands and receiving. The communications
between all the systems was achieved with great success. Using a microcontroller instead
of converter complicated too much the communications. Instead of using only one type
of protocol, it was used 3. Another disadvantage is, the communication between sending
and receiving for answer of this protocol takes a lot of time. It is believed that the cause is
due to the use of characters based message, of crc calculation and confirmation by slavereceive 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
6.4 Conclusion
51
messages are based in 5 and 6 characters. This was chosen because the microcontrollers
slaves are driven by UART interrupts. The messages are read as an array, and if the
size changed it was necessary to change the form each different message was going to
be read. The answers from the slaves are very simple. It was chosen this because, for
example if it was included crc the time necessary it would be much more higher. It is
only used the SMP protocol in the communication between sender and slaves because
of many aspects. Using the protocol between acquisition and slaves it was necessary for
everytime that sender replied the message change it from master to slave because of the
SPI communication. This would take even more time. Although of using the protocol
only in sender-slave the overall results are quite good.
52
Communications
Chapter 7
Control
In chapter 7 will be referred the control of the systems as well as some code implementations and the solutions adopted. It will also be described the user interface and how
the control is made. Every control system is going to be referred independently, each one
has a microcontroller.
7.1
Introduction
The control algorithm defines the effectiveness of this system. According to this it
was tried to develop simple control algorithms, in the various systems. The acquisition
system defines which motors and electrical circuits are going to be turned on, according
with the sensors activated and object identified. The motor stimulation system as well as
the electrical one receives control messages from acquisition.
7.2
Acquisition system
As said before the acquisition system assumes an important task. It is responsible for
object recognition and it controls which commands are going to be sent to the the others
stimulation 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 the
values of the sensors it is going to be processed and defined the control instructions for
the other systems. Acquisition has 5 sensors, every sensor has a correspondent motor, 5
motors. The sensors and the motors were classified with numbers. The motors numeration
53
54
Control
is based in the Darlington array, the first port was defined to be connected to motor1, and
the last port is connected to motor 8. Because of some problems the port of motor 1 was
not 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 is
connected to motor 6. The middle finger has one sensor, sensor 2, and it is connected to
motor 4. The index finger has two sensors one in the top, sensor 3 and one next to the
palm sensor 0. The sensor 3 is connected to the motor 5 and the sensor 0 is connected
to motor 2. It was defined a function for reading the sensors. This takes as an input the
number of the multiplexer and the number of the sensor. It is chosen the sensor and it is
read the ADC, it turns on a bit. This bit allows the function to be in a infinite loop. After
a conversion, an interrupt is activated and it is turned off the same bit. When this bit is
turned 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;
}
7.2 Acquisition system
55
The control of the motors was divided in 3 different steps, three different value intervals for the sensors. It was made a small change how the microcontroller will interpret
the value from sensor. When sensor has the value from 0-5 V, the numerical value to the
microcontroller is between 0-500. According to this, the intervals were defined. If the
value of the sensor 0 is between [0-100] it will turn off the correspondent motor. The
message sent is ’m20f11’. If the value of the sensor is between [100-250] it will activate
the motor with the smallest frequency. The message sent is ’m21f11’. If the value is between [251-399] it will be activated the motor with a faster frequency. The message sent
is ’m21f10’. When it has the maximum value, and it is bigger than 400, it will activate
the motor with the fastest frequency. The message sent is ’m21f01’. For every different
sensor it will be done the exact control algorithm. For example, if it is the sensor 2, it
will be the motor 4, and the message sent is ’m41f11’ according to the value read by the
microcontroller.
The control of the electrical stimulation system is a little different. This is used to
identify objects. According to the key locations of the sensors, it was defined 4 types
of objects. When sensor 1 and sensor 3 are activated it is a thin object like a pencil in
this case. When sensors 1,2 and 3 are activated it is a bigger object like for example the
mouse from the computer. If the object continues to get bigger then sensor 1 and sensor
0 are activated, like a glass. Finally, when sensor 0 and sensor 4 are activated all the
hand is grabbing a object in this case a water gun. Having this, each combination was
corresponded to a stimulation circuit. Also it will work in 3 different steps, three different
values for the combinations of the sensors, like the motor stimulation. The combination
of sensors 0 and 1 activated the circuit 1. Sensors 1,2 and 3 activates circuit 2. Sensors
0 and 1 activate circuit 3. Sensor 0 and 4 activate circuit 4. The control of the frequency
is similar to the motor stimulation. For example if it a object like a pencil and the values
of the sensors are between [100-250] it will be activated the correspondent circuit, with
the slowest frequency. The message sent is ’e11f11’. The same reasoning for the other
identified 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 prototype
so it is justified the use of Matlab. The second it is more familiar because it was already
used already in other projects. The user interface based in Matlab allows to control all
the systems developed. It is possible to turn on and off each individual system. Like
described in the previous chapter, gui uses the serial port connected to the computer and
uart connected to microcontroller through max232. In figure 7.2 is possible to be seen
the aspect of the user interface. As said before it is possible to see the graphics of the
56
Control
sensors and the control commands. It is also possible to control the frequencies of each
individual stimulation system. The method of control is simple. It is necessary to turn
on the acquisition system, this is only possible in user gui. After the user defines the
frequency 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 individual
sensor. 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 time
there is 25 bytes available on the serial port, the gui reads it, separate each message in the
number of the sensor and the value. It was choose to send all sensors and their values in
the same message, a 25 byte message. Each sensor needs 5 bytes. The 25 bytes available
assumes that there is no failure, and since it was only a prototype for laboratory tests, it
was simplified the communication. Next it is described some code implementation for
one sensor. The message is read, and it is separated for the first sensor the number and
the 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 the
sensor will be plotted in the correspondent axis. The variable vector is the x coordinate
7.3 Mechanical stimulation system
57
and every time a new value is plotted this variable is incremented. The same reasoning is
follow 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 some
implementation code specific to this microcontroller. According to the message received
from the acquisition system the mechanical stimulation must process this message and
activate the correspondent motor.
7.3.1
Control
As explained in chapter 4 in 4.3 at page 31 the system receives control message
and it should process it. According to this control message it should turn on the different
motors on. When system is activated two timers are switched on. One is the PWM for
the motors and the other is for establish the frequency for each independent circuit. The
PWM has a frequency of 250 Hz. The frequency for switching on and off is based in a
timer 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 it
turn on the motor for 100ms, and then switch it off. For example if the motor 2 is activated
with the message ’m21f10’, the frequency will be the second fastest. When the variable
correspondent to the second motor is counted more than 250 times this motor is switched
on and 100 ms later is switched off. If no more control messages are processed this motor
will continue the same procedure. After the variable reaches more than 250 counts it will
turn on the motor and 100 ms later will switch it off. With this procedure it is possible to
feel 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 and
accepts as inputs the number of the motor, if it is necessary to turn on or off and the
frequency. After was only necessary to call it in the main loop. A part of this function is
in example below. If the n==1 it is chosen the first motor. If the step counter1 is bigger
than the predefined frequency and motor is on, then it turns on the port PA0, and it turns
off 100 ms later. Then the variables step counter1 is again 0. The variable timer on allows
a different circuit different from the first one to be activated for the first time.
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 circuit
is 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 the
human 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 system. It receives a control message and activates the correspondent circuit. Once again is
going 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. Summarizing
the 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 increments
a 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 When
this variable is bigger than the predefined frequency is activated the power PNP transistor
and the NPN transistor. The NPN is activated by the DAC and it is possible to control
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 when
the circuit is on, all interrupts are off, it activated the DAC with an output of 3000, and
the power PNP. After 6 us, it is turned off, and interruptions activated. The variable step
counter is initialized again. The variable timer has the same goal as defined in previous
section.
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 as
a 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);
}
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 precautions
it was decided to not put next to the human heart. In figure 7.4 at page 60 is seen the
locations of the electrodes on the human body. Each circuit has two electrodes from where
current 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 interface is easily controllable the different system and frequencies. It is possible to identify
by looking at the plotted axes which type of object is. According to the value of the
7.5 Conclusion
61
sensors it is possible to spin different motors at different speeds and is identified which
sensor is turned on. With the electrical stimulation is possible to identify objects. It was
chosen different locations in order for better results. Since it is a experimental work, and
the user does not have to walk, two circuits were placed in the legs. One disadvantage of
this system is the acquisition. The sensors are stitched to a glove and it is necessary to use
a human hand. This hand is soft and the sensors do not have their full potential as with a
hard surface. When some object is touched the skin of the hand bends, and sensor is not
able to sense the full touch.
62
Control
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 similar approach to the problem of feedback of a prosthetic hand. Darpa as well as an European union collaboration already developed what is possible to say the state of the art
feedback, combined they use tactors and electrical stimulation to the nerves. A few is
known about the algorithms, and it is believed if these were spread to all investigators
much more and faster developments can be achieved.
The acquisition system is simple yet very effective. It has 5 FSR sensors spread all
over a glove. These sensors are in key locations which allow to identify objects. Summarizing the system is consisted with 5 sensors connected to OPA, after they are connected
to multiplexer which is connected to ADC of a microcontroller. This reads the sensors
values and according to it gives instructions to the stimulation systems. It also sends to
the user interface the sensors values. This system has one big disadvantage, it lacks of
sensors so the objects identification are very simple, it also the sensors stitched to a glove
are not the best solution since they move a few centimeters, changing also the overall
results.
The mechanical stimulation system is based in tactors, or vibrating motors. The system was developed for 8 motors. These motors are spinning at the same frequency. This
frequency is based in PWM and can be easily modified. The time that every motor turn
on and off is going to define the feedback of this system. In other words the frequency
63
64
Conclusions and Future developments
that every motor is going to be turned on and off changes, so it is possible to have at the
same time motors spinning at different speeds.
The electrical stimulation system has 4 circuits with independent current control and
frequency. Each circuit has one power PNP and NPN transistor. PNP transistor allows
to choose which circuit is turned on, while NPN transistor connected to a DAC allows to
control the current of the circuit. The wave produced is a square wave based in normal
TENS developed for medical purpose. This wave is usually a square wave with a timer
on between 50-200 us, and a frequency defined by user.
The communications between all of this systems are working. They are based in
character control messages. It was developed a new protocol, although with it there are
a few disadvantages. The communication takes too long between systems, it is believed
that the main problem is the source code in microcontroller which takes much time to
process. Instead of using a max485 converter to connect the user interface was used a
microcontroller. This reduce the price cost but increases largely the complexity of the
system.
The acquisition control reads the value of the sensors and according to it will be send
the instructions to the stimulation systems. Every sensor is connected to a motor, and
every combination of sensors that identify a object are connected to a circuit. This systems
are 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 correspondent
stimulators, with a specific frequency. The problem is when it receives another message
it will delay the timer interruption because the message is being processed. In spite of
this frequency problems, the intervals are spaced in order if a delay happens a frequency
will never be too affected. Although it is a experimental work and it was developed a
prototype some changes need to be made. In spite, the overall results of the project are
excellent.
8.2
Future Developments
As said before the sensors are stitched to the glove. This is not the best solution, yet
it is possible to re-use this sensors. In the future, this sensors are going to be placed in
a robotic hand. After, it is possible to check if the location of the sensors suits up. In a
further stage it is going to be necessary more sensors in the prosthetic hand. These should
be position sensors, encoders, also is going to be necessary accelerometers. The pressure
sensors should be matrix sensors, in other words, having a matrix pressure sensor it is
possible to identify exactly where the pressure is made. All this sensors allow a excellent
acquisition system and a much better pattern recognition. Another improvement can be
using a more powerful microcontroller, for example atmega128. This microcontroller has
enough memory for control and has several protocols of communication and the ability to
8.2 Future Developments
65
extend to 4 UART protocols at the same time. Every each one capable of communication
with 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 in
DARPA projects.
Instead of using a normal power boost, it can be changed to a fly back converter. The
inductor is split to form a transformer. This has a great advantage, that is isolation. With
this fly back converter more efficiency is achieved. Another topic to improve is the fact
that this system can be updated with more stimulation circuits. This guarantees more
possibility for stimulation.
The communications can be improved by instead of using a microcontroller to reply
the control messages from acquisition system use a converter. This converter can be UsbRs485. With this converter the communications start to use the same protocol for all
systems, Rs485. It is necessary to optimize the protocol developed, in order to achieve
faster transmissions, and processing.
66
Conclusions and Future developments
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 the
human hand. www.shadowrobot.com.
[7] Peratech.
Force conduction level, qtc.
qtcscience.php.
http://www.peratech.com/
[8] R. Walker. Using air muscles for compliant bipedal and many-legged robotics. páginas 3/1 – 3/3, August 2002.
[9] Shadow Robot Company Limited.
Air muscles, 2010.
shadowrobot.com/airmuscles/overview.shtml.
http://www.
[10] Department of Mechanical Engineering. Different contractions levels of the artificial
muscles. 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
68
REFERENCES
[12] Donna Miles. Darpa’s cutting-edge programs revolutionize prosthetics, February
2006. http://www.defense.gov/news/newsarticle.aspx?id=14914.
[13] Sarah
2008.
Adee.
Reengineering
the
prosthetic-arm
socket,
February
http://spectrum.ieee.org/biomedical/devices/
reengineering-the-prostheticarm-socket.
[14] Tom
our
Phillips.
friends.
Tomorrow,
the
cyborgs
will
be
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 prototype. http://www.jhuapl.edu/newscenter/pressreleases/2007/
070426.asp, MONTH=April, YEAR=2007.
[19] P. Campbell. Darpa gives apl-led revolutionizing prosthetics 2009 team green
light 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 the
design of prostheticlimbs, August 2007. http://www.vanderbilt.edu/
exploration/stories/bionicarm.html.
[22] Tom
our
Phillips.
friends.
Tomorrow,
the
cyborgs
will
be
http://www.metro.co.uk/news/
100699-tomorrow-the-cyborgs-will-be-our-friends.
REFERENCES
69
[23] Applied Physics Laboratory. Revolutionizing prosthetics 2009: Apl-led team advances prosthetic arm technology, January 2010. http://www.jhuapl.edu/
ourwork/stories/st090829.asp#.
[24] Sally Adee.
Winner:
The revolution will be prosthetized, January
2009.
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 artificial
limbs, October 2009.
[26] Drew Halley.
March
2009.
i-limb
revolutionizes
the
commercial
prosthetic,
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 bionic
hand, 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, December
2008.
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 essential 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, July
1989.
70
REFERENCES
[36] Lynn Snyder-Mackler Andrem J. Robinson. Clinical Electrophysiology: Electrotherapy and Electrophysiologic Testing. Lippincott Williams, Wilkins; Third Edition 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 for
electrical muscle stimulation. 2008.
[39] Haibin Wang Jie Wu Xiaoyuan Wang, Chao Hu e Max Q.-H. Meng. A novel wireless
electrical muscle simulator for female urinary incontinence. February 2009.
[40] Daniel W. Repperger David C. Johnson. Skin impedance implications of tens function and the development of an improved stimulation waveform. 1995.
Appendix A
Drawings
In this appendix is presented the drawings of the circuits. These were made with
program Eagle. Some elements, were not found on the provided lybraries so two options
were available. When there is some component similar it was susbtituted by it. When
there isnt it was chosen not to draw it.
71
72
Drawings
Figure A.1: Acquisition system.
Drawings
73
Figure A.2: Mechanical stimulation system.
74
Drawings
Figure A.3: Electrical stimulation system.
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
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);
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(P
if((read[0]==’s’) & (read[1]==’e’)& (read[2]==’n’)& (read[4]==’o’)& (read[5]==’f’)){control=0;PORTD&=~ _BV(
if((read[0]==’m’) | (read[0]==’e’)) {
for(int i=0;i<6;i++)
{
spi_transmit(read[i]);
}}
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;
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();
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)
B.2 Main loop
{}
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;
81
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;
B.2 Main loop
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’;
83
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’;
B.2 Main loop
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’;
85
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’;
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 g
{
message[36]=’e’;
message[37]=’2’;
message[38]=’1’;
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’;
B.2 Main loop
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’;
}
89
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]);
B.2 Main loop
} _delay_ms(z);
for(int i=48;i<54;i++)
{
spi_transmit(message[i]);
} _delay_ms(z);
}
}//while
}//main
91
92
Source code Acquisition System
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, tim
volatile uint32_t step_counter1=0,step_counter2=0, step_counter3=0 , step_counter4=0, step_counter5=0, step
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
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’)
C.1 Main Loop
{ 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;
95
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’)
C.1 Main Loop
{
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’)
97
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;
C.1 Main Loop
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);
}
99
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) ))
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) ))
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);
}
}
}
}
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. The
difference 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
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
D.2 Main loop
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;
}
}
105
106
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’)
Source code Electrical System
D.2 Main loop
{ 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;
}
107
108
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;}
Source code Electrical System
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) &&
{ 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)
(step_counter2>=freq_osc) ))
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) &&
{
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)
{
(step_counter4>=freq_osc) ))
D.2 Main loop
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);
}
}
}
}
111
Download