Skip to content

Commit 830be55

Browse files
committed
FingerLib V2.0
Major New Release - FingerLib V2.0 - 12/01/17 - cleaned up (grouped functions) - commented pretty much everything - added PID controller - added force control (Chestnut PCB) - updated library reference (now in /extras) - updated license - disabled timer0 period modification on the Atmega2560, as it broke delay() - changed control scheme (now uses a main - updated all examples by removing any reference to other
1 parent 7c78549 commit 830be55

23 files changed

Lines changed: 2571 additions & 499 deletions

FingerLib_Library_Reference.pdf

-91.6 KB
Binary file not shown.

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1-
# Open Bionics - FingerLib
1+
# Open Bionics - FingerLib.h
22

3-
Included in this repositry;
3+
##Description
4+
This library can be used to control up to 6 fingers, which allows control for an Open Bionics robotic hand (Ada, Brunel). Each finger is actuated using a Firgelli
5+
linear actuator, where the position is determined by using the embedded linear potentiometer.
46

5-
- FingerLib - Custom motor control library which creates servo-like functionality to control fingers
7+
FingerLib.h has been designed to closely resemble the Servo.h library, to allow ease of implementation for hobbyists and researchers. Feel free
68

9+
10+
##Supported Boards
11+
- [Almond board](https://www.openbionics.com/shop/pcb)
12+
- Chestnut board
13+
- Atmega2560
14+
- Arduino Zero
15+
16+
##License
17+
18+
###Creative Commons
719
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
820
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/
21+
22+
###Beer-ware
23+
"THE BEER-WARE LICENSE" (Revision 42):
24+
<ollymcbride@openbionics.com> wrote this file. As long as you retain this notice you
25+
can do whatever you want with this stuff. If we meet some day, and you think
26+
this stuff is worth it, you can buy me a beer in return Olly McBride

examples/HandDemo/HandDemo.ino

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,16 @@
1818
*/
1919

2020
// uncomment one of the following to select the board
21-
//#define ADULT_BOARD
22-
//#define FOUR_MOTOR_BOARD
23-
//#define CHILD_BOARD
2421
#define ALMOND_BOARD
22+
//#define CHESTNUT_BOARD
2523

2624
// number of controllable fingers (number of motors)
27-
#if defined(ADULT_BOARD)
28-
#define NUM_FINGERS 5
29-
#elif defined(FOUR_MOTOR_BOARD)
25+
#if defined(ALMOND_BOARD)
3026
#define NUM_FINGERS 4
31-
#elif defined(CHILD_BOARD)
32-
#define NUM_FINGERS 3
33-
#elif defined(ALMOND_BOARD)
27+
#elif defined(CHESTNUT_BOARD)
3428
#define NUM_FINGERS 5
29+
#else
30+
#error 'No board selected'
3531
#endif
3632

3733
// uncomment one of the following to select which hand is used
@@ -222,4 +218,3 @@ void pinch(void)
222218
finger[0].writeSpeed(normalSpeed);
223219
finger[1].writeSpeed(normalSpeed);
224220
}
225-

examples/HandDemo/Pins.ino

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,39 @@
1+
// attach the pins to the finger instances
12
void pinAssignment(void)
23
{
34
if(handFlag == RIGHT)
45
{
5-
#if defined(ADULT_BOARD)
6-
finger[0].attach(8,9,A4);
7-
finger[1].attach(7,6,A3);
8-
finger[2].attach(5,12,A2);
9-
finger[3].attach(2,10,A1);
10-
finger[4].attach(4,3,A0);
11-
#elif defined(FOUR_MOTOR_BOARD)
12-
finger[0].attach(2,10,A1,1);
13-
finger[1].attach(7,6,A3);
14-
finger[2].attach(5,12,A2);
15-
finger[3].attach(4,3,A0);
16-
#elif defined(CHILD_BOARD)
17-
finger[0].attach(2,10,A1,1);
18-
finger[1].attach(8,9,A4);
19-
finger[2].attach(4,3,A0);
20-
#elif defined(ALMOND_BOARD)
21-
finger[0].attach(13,4,A5); // Right motor connector
6+
#if defined(ALMOND_BOARD)
7+
finger[0].attach(13,4,A5); // Right motor connector
228
finger[1].attach(3,6,A1);
239
finger[2].attach(7,8,A2);
2410
finger[3].attach(10,9,A3);
2511
finger[4].attach(11,12,A4);
12+
#elif defined(CHESTNUT_BOARD)
13+
finger[0].attach(5, 12, A2, A5, false); // attach the thumb
14+
finger[1].attach(4, 3, A0, A6, true); // attach the index (finger is inverted)
15+
finger[2].attach(10, 11, A1, A7, true); // attach the middle (finger is inverted)
16+
finger[3].attach(9, 6, A3, A8, true); // attach the ring & pinky (finger is inverted)
2617
#else
2718
#error 'No board selected'
2819
#endif
2920
}
3021
else if(handFlag == LEFT)
3122
{
32-
#if defined(ADULT_BOARD)
33-
finger[0].attach(8,9,A4);
34-
finger[4].attach(4,3,A0);
35-
finger[3].attach(2,10,A1);
36-
finger[2].attach(5,12,A2);
37-
finger[1].attach(7,6,A3);
38-
#elif defined(FOUR_MOTOR_BOARD)
39-
finger[0].attach(5,12,A2,1);
40-
finger[1].attach(4,3,A0);
41-
finger[2].attach(2,10,A1);
42-
finger[3].attach(7,6,A3);
43-
#elif defined(CHILD_BOARD)
44-
finger[0].attach(2,10,A1,1);
45-
finger[1].attach(4,3,A0);
46-
finger[2].attach(8,9,A4);
47-
#elif defined(ALMOND_BOARD)
48-
finger[0].attach(5,2,A0); // Left motor connector
23+
#if defined(ALMOND_BOARD)
24+
finger[0].attach(5,2,A0); // Left motor connector
4925
finger[1].attach(11,12,A4);
5026
finger[2].attach(10,9,A3);
5127
finger[3].attach(7,8,A2);
5228
finger[4].attach(3,6,A1);
29+
#elif defined(CHESTNUT_BOARD)
30+
finger[0].attach(9, 6, A3, A8, true); // attach the thumb
31+
finger[1].attach(10, 11, A1, A7, true); // attach the index (finger is inverted)
32+
finger[2].attach(4, 3, A0, A6, true); // attach the middle (finger is inverted)
33+
finger[3].attach(5, 12, A2, A5, false); // attach the ring & pinky (finger is inverted)
5334
#else
5435
#error 'No board selected'
5536
#endif
5637
}
5738
}
39+

examples/MotorTest/MotorTest.ino

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,27 @@
1919
* Entering any value greater than the number of motors stops all of the motors (>6)
2020
*
2121
*/
22-
23-
24-
// MACROS
25-
#define IS_BETWEEN(x,a,b) ((((x)>=(a))&&((x)<=(b)))?(1):(0)) // check if value x is between values a and b
2622

2723
// uncomment one of the following to select the board
28-
//#define ADULT_BOARD
29-
//#define FOUR_MOTOR_BOARD
30-
//#define CHILD_BOARD
3124
#define ALMOND_BOARD
25+
//#define CHESTNUT_BOARD
3226

3327
// number of controllable fingers (number of motors)
34-
#if defined(ADULT_BOARD)
35-
#define NUM_FINGERS 5
36-
#elif defined(FOUR_MOTOR_BOARD)
28+
#if defined(ALMOND_BOARD)
3729
#define NUM_FINGERS 4
38-
#elif defined(CHILD_BOARD)
39-
#define NUM_FINGERS 3
40-
#elif defined(ALMOND_BOARD)
41-
#define NUM_FINGERS 5 // 6 motors instead of 5 as it is not hand (left/right) specific
30+
#elif defined(CHESTNUT_BOARD)
31+
#define NUM_FINGERS 5
32+
#else
33+
#error 'No board selected'
4234
#endif
4335

4436
// uncomment one of the following to select which hand is used
4537
//int handFlag = LEFT;
4638
int handFlag = RIGHT;
39+
40+
41+
// MACROS
42+
#define IS_BETWEEN(x,a,b) ((((x)>=(a))&&((x)<=(b)))?(1):(0)) // check if value x is between values a and b
4743

4844
// initialise Finger class to array
4945
Finger finger[NUM_FINGERS];
@@ -65,28 +61,32 @@ void setup()
6561
void loop()
6662
{
6763
int i;
64+
65+
// if a serial char is available
6866
if(MYSERIAL.available())
6967
{
7068
fingerNum = (int) MYSERIAL.read() - 48; // convert ASCII to number
71-
if(IS_BETWEEN(fingerNum,0,(NUM_FINGERS-1)))
69+
70+
if(IS_BETWEEN(fingerNum,0,(NUM_FINGERS-1))) // if the number entered is a valid finger number
7271
{
73-
finger[fingerNum].open_close(); // toggle direction
72+
finger[fingerNum].open_close(); // toggle finger direction
7473
}
75-
else if(fingerNum == NUM_FINGERS)
74+
else if(fingerNum == NUM_FINGERS) // else if the number entered is equal to the number of fingers
7675
{
7776
for(int i=0;i<NUM_FINGERS;i++)
7877
{
79-
finger[i].open_close(); // toggle direction
78+
finger[i].open_close(); // toggle direction of all fingers
8079
}
8180
}
82-
else if(fingerNum > NUM_FINGERS)
81+
else // else if another character is entered
8382
{
84-
stopMotors();
83+
stopMotors(); // stop all motors
8584
MYSERIAL.println("MOTORS STOPPED");
8685
delay(500);
8786
}
8887
}
8988

89+
// print current finger position
9090
for(i=0;i<NUM_FINGERS;i++)
9191
{
9292
MYSERIAL.print(names[i]);
@@ -99,14 +99,12 @@ void loop()
9999

100100
}
101101

102+
// stop all motors and maintain the current position
102103
void stopMotors(void)
103104
{
104105
int i;
105106
for(i=0;i<NUM_FINGERS;i++)
106107
{
107108
finger[i].stopMotor();
108-
//finger[i].writePos(finger[i].readPos());
109109
}
110110
}
111-
112-
//void fullyExtendMotors

examples/MotorTest/Pins.ino

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,39 @@
1+
// attach the pins to the finger instances
12
void pinAssignment(void)
23
{
34
if(handFlag == RIGHT)
45
{
5-
#if defined(ADULT_BOARD)
6-
finger[0].attach(8,9,A4);
7-
finger[1].attach(7,6,A3);
8-
finger[2].attach(5,12,A2);
9-
finger[3].attach(2,10,A1);
10-
finger[4].attach(4,3,A0);
11-
#elif defined(FOUR_MOTOR_BOARD)
12-
finger[0].attach(2,10,A1,1);
13-
finger[1].attach(7,6,A3);
14-
finger[2].attach(5,12,A2);
15-
finger[3].attach(4,3,A0);
16-
#elif defined(CHILD_BOARD)
17-
finger[0].attach(2,10,A1,1);
18-
finger[1].attach(8,9,A4);
19-
finger[2].attach(4,3,A0);
20-
#elif defined(ALMOND_BOARD)
21-
finger[0].attach(13,4,A5); // Right motor connector
6+
#if defined(ALMOND_BOARD)
7+
finger[0].attach(13,4,A5); // Right motor connector
228
finger[1].attach(3,6,A1);
239
finger[2].attach(7,8,A2);
2410
finger[3].attach(10,9,A3);
2511
finger[4].attach(11,12,A4);
12+
#elif defined(CHESTNUT_BOARD)
13+
finger[0].attach(5, 12, A2, A5, false); // attach the thumb
14+
finger[1].attach(4, 3, A0, A6, true); // attach the index (finger is inverted)
15+
finger[2].attach(10, 11, A1, A7, true); // attach the middle (finger is inverted)
16+
finger[3].attach(9, 6, A3, A8, true); // attach the ring & pinky (finger is inverted)
2617
#else
2718
#error 'No board selected'
2819
#endif
2920
}
3021
else if(handFlag == LEFT)
3122
{
32-
#if defined(ADULT_BOARD)
33-
finger[0].attach(8,9,A4);
34-
finger[4].attach(4,3,A0);
35-
finger[3].attach(2,10,A1);
36-
finger[2].attach(5,12,A2);
37-
finger[1].attach(7,6,A3);
38-
#elif defined(FOUR_MOTOR_BOARD)
39-
finger[0].attach(5,12,A2,1);
40-
finger[1].attach(4,3,A0);
41-
finger[2].attach(2,10,A1);
42-
finger[3].attach(7,6,A3);
43-
#elif defined(CHILD_BOARD)
44-
finger[0].attach(2,10,A1,1);
45-
finger[1].attach(4,3,A0);
46-
finger[2].attach(8,9,A4);
47-
#elif defined(ALMOND_BOARD)
48-
finger[0].attach(5,2,A0); // Left motor connector
23+
#if defined(ALMOND_BOARD)
24+
finger[0].attach(5,2,A0); // Left motor connector
4925
finger[1].attach(11,12,A4);
5026
finger[2].attach(10,9,A3);
5127
finger[3].attach(7,8,A2);
5228
finger[4].attach(3,6,A1);
29+
#elif defined(CHESTNUT_BOARD)
30+
finger[0].attach(9, 6, A3, A8, true); // attach the thumb
31+
finger[1].attach(10, 11, A1, A7, true); // attach the index (finger is inverted)
32+
finger[2].attach(4, 3, A0, A6, true); // attach the middle (finger is inverted)
33+
finger[3].attach(5, 12, A2, A5, false); // attach the ring & pinky (finger is inverted)
5334
#else
5435
#error 'No board selected'
5536
#endif
5637
}
5738
}
39+

examples/MultipleFingers/MultipleFingers.ino

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@
1919
*/
2020

2121
// uncomment one of the following to select the board
22-
//#define ADULT_BOARD
23-
//#define FOUR_MOTOR_BOARD
24-
//#define CHILD_BOARD
2522
#define ALMOND_BOARD
23+
//#define CHESTNUT_BOARD
2624

2725
// number of controllable fingers (number of motors)
28-
#if defined(ADULT_BOARD)
29-
#define NUM_FINGERS 5
30-
#elif defined(FOUR_MOTOR_BOARD)
26+
#if defined(ALMOND_BOARD)
3127
#define NUM_FINGERS 4
32-
#elif defined(CHILD_BOARD)
33-
#define NUM_FINGERS 3
34-
#elif defined(ALMOND_BOARD)
28+
#elif defined(CHESTNUT_BOARD)
3529
#define NUM_FINGERS 5
30+
#else
31+
#error 'No board selected'
3632
#endif
3733

3834
// uncomment one of the following to select which hand is used
@@ -60,11 +56,14 @@ void loop()
6056
// set all of the fingers to OPEN
6157
openHand();
6258
MYSERIAL.println("Opening");
59+
6360
// give them time to OPEN
6461
delay(2000);
62+
6563
// set all of the fingers to CLOSE
6664
closeHand();
6765
MYSERIAL.println("Closing");
66+
6867
// give them time to CLOSE
6968
delay(2000);
7069
}
@@ -89,3 +88,5 @@ void closeHand(void)
8988
}
9089
}
9190

91+
92+

0 commit comments

Comments
 (0)