Skip to content

Commit 1d9d1d9

Browse files
committed
V2.0.4
- fixed pins in examples for Chestnut board - added ability to enable/disable timer interrupt - added MS timer and delay
1 parent 927a5bb commit 1d9d1d9

16 files changed

Lines changed: 531 additions & 407 deletions

README.md

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

3-
## Description
3+
##Description
44
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
55
linear actuator, where the position is determined by using the embedded linear potentiometer.
66

77
FingerLib.h has been designed to closely resemble the Servo.h library, to allow ease of implementation for hobbyists and researchers.
88

99

10-
## Supported Boards
11-
- Almond board
10+
##Supported Boards
11+
- [Almond board](https://www.openbionics.com/shop/pcb)
1212
- Chestnut board
13-
- Arduino UNO (Timer 1)
14-
- Atmega2560 (Timer 5)
15-
- Arduino Zero (TC4)
13+
- Atmega2560
14+
- Arduino Zero
1615

17-
## License
16+
##License
1817

19-
### Creative Commons
18+
###Creative Commons
2019
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
2120
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/
2221

23-
### Beer-ware
22+
###Beer-ware
2423
"THE BEER-WARE LICENSE" (Revision 42):
2524
<ollymcbride@openbionics.com> wrote this file. As long as you retain this notice you
2625
can do whatever you want with this stuff. If we meet some day, and you think

examples/HandDemo/Pins.ino

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
2-
3-
// throw up an error if boards are included incorrectly
4-
5-
/* If an error is thrown by one of the statements below, make sure that you have selected the correct board
6-
* within 'Tools -> Board' and also make sure that you have uncommented the correct board in MotorTest.ino
7-
*
8-
* ALMOND_BOARD -> Arduino/Genuino Mega or Mega 2560
9-
* CHESTNUT_BOARD -> Chestnut (Open Bionics Boards)
10-
*/
11-
#if defined(ARDUINO_AVR_MEGA2560) && !defined(ALMOND_BOARD)
12-
#error Incorrect board selected, Atmega 2560 is selected in 'Tools -> Board', but ALMOND_BOARD is not selected
13-
#elif !defined(ARDUINO_AVR_MEGA2560) && defined(ALMOND_BOARD)
14-
#error Incorrect board selected, ALMOND_BOARD is selected, but 'Mega 2560' is not selected in 'Tools -> Board'
15-
#elif defined(ARDUINO_SAMD_CHESTNUT) && !defined(CHESTNUT_BOARD)
16-
#error Incorrect board selected, Chestnut is selected in 'Tools -> Board', but CHESTNUT_BOARD is not selected
17-
#elif defined(ARDUINO_SAMD_CHESTNUT) && !defined(CHESTNUT_BOARD)
18-
#error Incorrect board selected, CHESTNUT_BOARD is selected, but 'Chestnut' is not selected in 'Tools -> Board'
19-
#endif
20-
21-
22-
23-
24-
251
// attach the pins to the finger instances
262
void pinAssignment(void)
273
{
@@ -34,7 +10,7 @@ void pinAssignment(void)
3410
finger[3].attach(10, 9, A3);
3511
finger[4].attach(11, 12, A4);
3612
#elif defined(CHESTNUT_BOARD)
37-
finger[0].attach(4, 8, A2, A8, false); // attach the thumb
13+
finger[0].attach(4, 8, A2, A8, false); // attach the thumb
3814
finger[1].attach(1, 2, A0, A6, true); // attach the index (finger is inverted)
3915
finger[2].attach(7, 5, A1, A9, true); // attach the middle (finger is inverted)
4016
finger[3].attach(0, 9, A3, A7, true); // attach the ring & pinky (fingers are inverted)
@@ -51,10 +27,10 @@ void pinAssignment(void)
5127
finger[3].attach(7, 8, A2);
5228
finger[4].attach(3, 6, A1);
5329
#elif defined(CHESTNUT_BOARD)
54-
finger[0].attach(7, 5, A1, A9, false); // attach the thumb
55-
finger[1].attach(0, 9, A3, A7, true); // attach the index (finger is inverted)
30+
finger[0].attach(7, 5, A1, A9, false); // attach the thumb
31+
finger[1].attach(0, 9, A3, A7, true); // attach the index (finger is inverted)
5632
finger[2].attach(4, 8, A2, A8, true); // attach the middle (finger is inverted)
57-
finger[3].attach(1, 2, A0, A6, true); // attach the ring & pinky (fingers are inverted)
33+
finger[3].attach(1, 2, A0, A6, true); // attach the ring & pinky (fingers are inverted)
5834
#else
5935
#error 'No board selected'
6036
#endif

examples/MotorTest/MotorTest.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
//int handFlag = LEFT;
3838
int handFlag = RIGHT;
3939

40+
4041
// MACROS
4142
#define IS_BETWEEN(x,a,b) ((((x)>=(a))&&((x)<=(b)))?(1):(0)) // check if value x is between values a and b
4243

examples/MotorTest/Pins.ino

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
2-
3-
// throw up an error if boards are included incorrectly
4-
5-
/* If an error is thrown by one of the statements below, make sure that you have selected the correct board
6-
* within 'Tools -> Board' and also make sure that you have uncommented the correct board in MotorTest.ino
7-
*
8-
* ALMOND_BOARD -> Arduino/Genuino Mega or Mega 2560
9-
* CHESTNUT_BOARD -> Chestnut (Open Bionics Boards)
10-
*/
11-
#if defined(ARDUINO_AVR_MEGA2560) && !defined(ALMOND_BOARD)
12-
#error Incorrect board selected, Atmega 2560 is selected in 'Tools -> Board', but ALMOND_BOARD is not selected
13-
#elif !defined(ARDUINO_AVR_MEGA2560) && defined(ALMOND_BOARD)
14-
#error Incorrect board selected, ALMOND_BOARD is selected, but 'Mega 2560' is not selected in 'Tools -> Board'
15-
#elif defined(ARDUINO_SAMD_CHESTNUT) && !defined(CHESTNUT_BOARD)
16-
#error Incorrect board selected, Chestnut is selected in 'Tools -> Board', but CHESTNUT_BOARD is not selected
17-
#elif defined(ARDUINO_SAMD_CHESTNUT) && !defined(CHESTNUT_BOARD)
18-
#error Incorrect board selected, CHESTNUT_BOARD is selected, but 'Chestnut' is not selected in 'Tools -> Board'
19-
#endif
20-
21-
22-
23-
24-
251
// attach the pins to the finger instances
262
void pinAssignment(void)
273
{
@@ -34,7 +10,7 @@ void pinAssignment(void)
3410
finger[3].attach(10, 9, A3);
3511
finger[4].attach(11, 12, A4);
3612
#elif defined(CHESTNUT_BOARD)
37-
finger[0].attach(4, 8, A2, A8, false); // attach the thumb
13+
finger[0].attach(4, 8, A2, A8, false); // attach the thumb
3814
finger[1].attach(1, 2, A0, A6, true); // attach the index (finger is inverted)
3915
finger[2].attach(7, 5, A1, A9, true); // attach the middle (finger is inverted)
4016
finger[3].attach(0, 9, A3, A7, true); // attach the ring & pinky (fingers are inverted)
@@ -51,10 +27,10 @@ void pinAssignment(void)
5127
finger[3].attach(7, 8, A2);
5228
finger[4].attach(3, 6, A1);
5329
#elif defined(CHESTNUT_BOARD)
54-
finger[0].attach(7, 5, A1, A9, false); // attach the thumb
55-
finger[1].attach(0, 9, A3, A7, true); // attach the index (finger is inverted)
30+
finger[0].attach(7, 5, A1, A9, false); // attach the thumb
31+
finger[1].attach(0, 9, A3, A7, true); // attach the index (finger is inverted)
5632
finger[2].attach(4, 8, A2, A8, true); // attach the middle (finger is inverted)
57-
finger[3].attach(1, 2, A0, A6, true); // attach the ring & pinky (fingers are inverted)
33+
finger[3].attach(1, 2, A0, A6, true); // attach the ring & pinky (fingers are inverted)
5834
#else
5935
#error 'No board selected'
6036
#endif

examples/MultipleFingers/Pins.ino

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
2-
3-
// throw up an error if boards are included incorrectly
4-
5-
/* If an error is thrown by one of the statements below, make sure that you have selected the correct board
6-
* within 'Tools -> Board' and also make sure that you have uncommented the correct board in MotorTest.ino
7-
*
8-
* ALMOND_BOARD -> Arduino/Genuino Mega or Mega 2560
9-
* CHESTNUT_BOARD -> Chestnut (Open Bionics Boards)
10-
*/
11-
#if defined(ARDUINO_AVR_MEGA2560) && !defined(ALMOND_BOARD)
12-
#error Incorrect board selected, Atmega 2560 is selected in 'Tools -> Board', but ALMOND_BOARD is not selected
13-
#elif !defined(ARDUINO_AVR_MEGA2560) && defined(ALMOND_BOARD)
14-
#error Incorrect board selected, ALMOND_BOARD is selected, but 'Mega 2560' is not selected in 'Tools -> Board'
15-
#elif defined(ARDUINO_SAMD_CHESTNUT) && !defined(CHESTNUT_BOARD)
16-
#error Incorrect board selected, Chestnut is selected in 'Tools -> Board', but CHESTNUT_BOARD is not selected
17-
#elif defined(ARDUINO_SAMD_CHESTNUT) && !defined(CHESTNUT_BOARD)
18-
#error Incorrect board selected, CHESTNUT_BOARD is selected, but 'Chestnut' is not selected in 'Tools -> Board'
19-
#endif
20-
21-
22-
23-
24-
251
// attach the pins to the finger instances
262
void pinAssignment(void)
273
{
@@ -34,7 +10,7 @@ void pinAssignment(void)
3410
finger[3].attach(10, 9, A3);
3511
finger[4].attach(11, 12, A4);
3612
#elif defined(CHESTNUT_BOARD)
37-
finger[0].attach(4, 8, A2, A8, false); // attach the thumb
13+
finger[0].attach(4, 8, A2, A8, false); // attach the thumb
3814
finger[1].attach(1, 2, A0, A6, true); // attach the index (finger is inverted)
3915
finger[2].attach(7, 5, A1, A9, true); // attach the middle (finger is inverted)
4016
finger[3].attach(0, 9, A3, A7, true); // attach the ring & pinky (fingers are inverted)
@@ -51,10 +27,10 @@ void pinAssignment(void)
5127
finger[3].attach(7, 8, A2);
5228
finger[4].attach(3, 6, A1);
5329
#elif defined(CHESTNUT_BOARD)
54-
finger[0].attach(7, 5, A1, A9, false); // attach the thumb
55-
finger[1].attach(0, 9, A3, A7, true); // attach the index (finger is inverted)
30+
finger[0].attach(7, 5, A1, A9, false); // attach the thumb
31+
finger[1].attach(0, 9, A3, A7, true); // attach the index (finger is inverted)
5632
finger[2].attach(4, 8, A2, A8, true); // attach the middle (finger is inverted)
57-
finger[3].attach(1, 2, A0, A6, true); // attach the ring & pinky (fingers are inverted)
33+
finger[3].attach(1, 2, A0, A6, true); // attach the ring & pinky (fingers are inverted)
5834
#else
5935
#error 'No board selected'
6036
#endif

examples/SingleFinger/SingleFinger.ino

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,34 @@
11
/* Open Bionics - FingerLib Example - SingleFinger
2-
Author - Olly McBride
3-
Date - October 2015
4-
5-
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
6-
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.
7-
8-
Website - http://www.openbionics.com/
9-
GitHub - https://github.com/Open-Bionics
2+
* Author - Olly McBride
3+
* Date - October 2015
4+
*
5+
* This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
6+
* To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.
7+
*
8+
* Website - http://www.openbionics.com/
9+
* GitHub - https://github.com/Open-Bionics
1010
*/
1111

1212
#include <FingerLib.h>
1313

1414
/*
15-
WHAT IT DOES
16-
Uses the FingerLib.h library to open and close a single finger every 2 seconds
17-
18-
*/
19-
20-
// uncomment one of the following to select the board
21-
//#define ALMOND_BOARD
22-
#define CHESTNUT_BOARD
15+
* WHAT IT DOES
16+
* Uses the FingerLib.h library to open and close a single finger every 2 seconds
17+
*
18+
*/
2319

2420
// initialise Finger class to array, and assigns pins
2521
Finger finger;
2622

2723
void setup()
28-
{
29-
// MYSERIAL.print is used to allow compatability between both the Mega (Serial.print)
30-
//and the Zero Native Port (SerialUSB.print), and is defined in FingerLib.h
24+
{
25+
// MYSERIAL.print is used to allow compatability between both the Mega (Serial.print)
26+
// and the Zero Native Port (SerialUSB.print), and is defined in FingerLib.h
3127
MYSERIAL.begin(38400);
3228
MYSERIAL.println("Started");
3329

3430
// configure finger pins
35-
#if defined(ALMOND_BOARD)
36-
finger.attach(3, 6, A1);
37-
#elif defined(CHESTNUT_BOARD)
38-
finger.attach(1, 2, A0, A6, true); // attach the index (finger is inverted)
39-
#else
40-
#error No finger pins configured
41-
#endif
42-
31+
finger.attach(1, 2, A0);
4332
MYSERIAL.println("Pins configured");
4433
}
4534

extras/CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ All notable changes to this project will be documented in this file.
77
The format is based on [Keep a Changelog](http://keepachangelog.com/)
88
and this project adheres to [Semantic Versioning](http://semver.org/).
99

10+
## [2.0.4] - Aug 10th, 2017
11+
12+
### Added
13+
- The ability to prevent the motor control from being called via an interrupt (Servo.h compatible)
14+
15+
### Changed
16+
- The hardware timers now check the validity of the function pointers before calling them
17+
- Pins in library examples are now correct
18+
1019
## [2.0.3] - June 6th, 2017
1120

1221
### Added
@@ -41,7 +50,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4150
## [2.0.0] - Jan 12th, 2017
4251

4352
### Added
44-
- Comments to pretty much everything
53+
- Commented to pretty much everything
4554
- Optional PID controller (enabled by default)
4655
- Optional force controller (only available on the Chestnut PCB)
4756

extras/library_reference.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ Toggle the finger between open and closed
290290

291291
####Syntax
292292
Finger.open_close()
293-
294293
Finger.open_close(dir)
295294

296295
####Parameters
@@ -509,6 +508,36 @@ val: boolean. true will enable the motor. false will disable the motor
509508
none
510509

511510

511+
####enableInterrupt
512+
513+
####Description
514+
Enable the motor control to be called via an interrupt (enabled by default)
515+
516+
####Syntax
517+
Finger.enableInterrupt()
518+
519+
####Parameters
520+
none
521+
522+
####Returns
523+
none
524+
525+
526+
####disableInterrupt
527+
528+
####Description
529+
Disable the motor control being called via an interrupt. The motor control function '_fingerControlCallback()' must be called manually in the main loop in order for the motors to move.
530+
531+
####Syntax
532+
Finger.disableInterrupt()
533+
534+
####Parameters
535+
none
536+
537+
####Returns
538+
none
539+
540+
512541
####enableForceSense
513542

514543
####Description

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name=FingerLib
2-
version=2.0.3
2+
version=2.0.4
33
author=Olly McBride
44
maintainer=Olly McBride <ollymcbride@openbionics.com>
5-
sentence=Allows for servo-like functionality for finger control. For Almond board, Chestnut board, Arduino UNO, Atmega 2560 & Arduino Zero.
5+
sentence=Allows for servo-like functionality for finger control. For Atmega 2560 (Almond PCB) and Arduino Zero (Chestnut) only.
66
paragraph=This library is created and maintained by Olly McBride on behalf of Open Bionics.
77
category=Device Control
88
url=http://www.openbionics.com

0 commit comments

Comments
 (0)