Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 37d0ba1

Browse files
author
astronomer80
committed
Merge branch 'softstart' of https://github.com/arduino-org/Braccio
2 parents 7478cb5 + 8d65150 commit 37d0ba1

File tree

8 files changed

+97
-36
lines changed

8 files changed

+97
-36
lines changed

README.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
= Braccio Library for Arduino =
22

3-
The library offers easy access to the data from the onboard Arduino Braccio, and provides moves the Arduino Braccio.
3+
The library offers easy access to the data from the onboard TinkerKit Braccio, and provides moves for the Braccio.
4+
5+
- Upgrades:
6+
Soft-Start: Used with the Braccio Shield V4 create a slow and soft start for the TinkerKit Braccio
47
58
For more information about this library please visit us at
69
http://www.arduino.org/products/tinkerkit/17-arduino-tinkerkit/arduino-tinkerkit-braccio
710

811
== License ==
912

10-
Copyright (c) Medea-Solutions. All right reserved.
11-
1213
This library is free software; you can redistribute it and/or
1314
modify it under the terms of the GNU Lesser General Public
1415
License as published by the Free Software Foundation; either

examples/ciaoBraccio/ciaoBraccio.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void setup() {
4848
//Initialization functions for Ciao
4949
Ciao.begin();
5050
//Initialization functions for Braccio
51-
Braccio.begin();
51+
Braccio.begin(MEDIUM);
5252
}
5353

5454
/**

examples/simpleMovements/simpleMovements.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void setup() {
2929
//Wrist vertical (M4): 180 degrees
3030
//Wrist rotation (M5): 90 degrees
3131
//gripper (M6): 10 degrees
32-
Braccio.begin();
32+
Braccio.begin(MEDIUM);
3333
}
3434

3535
void loop() {

examples/takethesponge/takethesponge.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void setup() {
3030
//Wrist vertical (M4): 180 degrees
3131
//Wrist rotation (M5): 90 degrees
3232
//gripper (M6): 10 degrees
33-
Braccio.begin();
33+
Braccio.begin(MEDIUM);
3434
}
3535

3636
void loop() {

examples/testBraccio90/testBraccio90.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void setup() {
3232
//Wrist vertical (M4): 180 degrees
3333
//Wrist rotation (M5): 90 degrees
3434
//gripper (M6): 10 degrees
35-
Braccio.begin();
35+
Braccio.begin(MEDIUM);
3636
}
3737

3838
void loop() {

keywords.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ step_elbow LITERAL1
3232
step_wrist_rot LITERAL1
3333
step_wrist_ver LITERAL1
3434
step_gripper LITERAL1
35+
FAST LITERAL1
36+
MEDIUM LITERAL1
37+
SLOW LITERAL1

src/Braccio.cpp

Lines changed: 80 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
#include "Braccio.h"
2121

22+
#define LOW_LIMIT_TIMEOUT 2000
23+
#define HIGH_LIMIT_TIMEOUT 6000
24+
25+
2226
extern Servo base;
2327
extern Servo shoulder;
2428
extern Servo elbow;
@@ -32,6 +36,7 @@ extern int step_elbow = 180;
3236
extern int step_wrist_rot = 180;
3337
extern int step_wrist_ver = 90;
3438
extern int step_gripper = 10;
39+
3540

3641
_Braccio Braccio;
3742

@@ -44,38 +49,85 @@ _Braccio::_Braccio() {
4449
* Modifing this function you can set up the initial position of all the
4550
* servo motors of the Braccio
4651
*/
47-
unsigned int _Braccio::begin() {
52+
unsigned int _Braccio::begin(int val) {
53+
54+
pinMode(12,OUTPUT);
55+
digitalWrite(12,LOW);
56+
4857
// initialization pin Servo motors
49-
#if defined(ARDUINO_ARCH_SAMD)
50-
base.attach(11);
51-
shoulder.attach(7);
52-
elbow.attach(9);
53-
wrist_rot.attach(6);
54-
wrist_ver.attach(8);
55-
gripper.attach(3);
56-
#else
57-
base.attach(11);
58-
shoulder.attach(10);
59-
elbow.attach(9);
60-
wrist_rot.attach(6);
61-
wrist_ver.attach(5);
62-
gripper.attach(3);
63-
#endif
64-
65-
//For each step motor this set up the initial degree
66-
base.write(90);
67-
shoulder.write(45);
58+
base.attach(11);
59+
shoulder.attach(10);
60+
elbow.attach(9);
61+
wrist_rot.attach(6);
62+
wrist_ver.attach(5);
63+
gripper.attach(3);
64+
65+
//For each step motor this set up the initial degree
66+
base.write(0);
67+
shoulder.write(40);
6868
elbow.write(180);
69-
wrist_ver.write(180);
70-
wrist_rot.write(90);
71-
gripper.write(10);
69+
wrist_ver.write(170);
70+
wrist_rot.write(0);
71+
gripper.write(73);
7272
//Previous step motor position
73-
step_base = 90;
74-
step_shoulder = 45;
73+
step_base = 0;
74+
step_shoulder = 40;
7575
step_elbow = 180;
76-
step_wrist_ver = 180;
77-
step_wrist_rot = 90;
78-
step_gripper = 10;
76+
step_wrist_ver = 170;
77+
step_wrist_rot = 0;
78+
step_gripper = 73;
79+
80+
81+
long int tmp=millis();
82+
// soft start implementation
83+
if (val==FAST){
84+
85+
while(millis()-tmp < LOW_LIMIT_TIMEOUT){
86+
digitalWrite(12,HIGH);
87+
delayMicroseconds(125);
88+
digitalWrite(12,LOW);
89+
delayMicroseconds(50);
90+
}
91+
92+
while(millis()-tmp < HIGH_LIMIT_TIMEOUT){
93+
digitalWrite(12,HIGH);
94+
delayMicroseconds(125);
95+
digitalWrite(12,LOW);
96+
delayMicroseconds(105);
97+
}
98+
99+
}else if (val==MEDIUM){
100+
while(millis()-tmp < LOW_LIMIT_TIMEOUT){
101+
digitalWrite(12,HIGH);
102+
delayMicroseconds(15);
103+
digitalWrite(12,LOW);
104+
delayMicroseconds(125);
105+
}
106+
107+
while(millis()-tmp < HIGH_LIMIT_TIMEOUT){
108+
digitalWrite(12,HIGH);
109+
delayMicroseconds(15);
110+
digitalWrite(12,LOW);
111+
delayMicroseconds(145);
112+
}
113+
114+
115+
}else if (val==SLOW){
116+
while(millis()-tmp < LOW_LIMIT_TIMEOUT){
117+
digitalWrite(12,HIGH);
118+
delayMicroseconds(5);
119+
digitalWrite(12,LOW);
120+
delayMicroseconds(155);
121+
}
122+
123+
while(millis()-tmp < HIGH_LIMIT_TIMEOUT){
124+
digitalWrite(12,HIGH);
125+
delayMicroseconds(5);
126+
digitalWrite(12,LOW);
127+
delayMicroseconds(165);
128+
}
129+
}
130+
digitalWrite(12,HIGH);
79131
return 1;
80132
}
81133

src/Braccio.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#include <Arduino.h>
2424
#include <Servo.h>
2525

26+
#define FAST 2
27+
#define MEDIUM 3
28+
#define SLOW 4
29+
30+
2631
class _Braccio {
2732

2833
public:
@@ -33,7 +38,7 @@ class _Braccio {
3338
* Modifing this function you can set up the initial position of all the
3439
* servo motors of the Braccio
3540
*/
36-
unsigned int begin();
41+
unsigned int begin(int val);
3742

3843
/**
3944
* This functions allow you to control all the servo motors in the Braccio

0 commit comments

Comments
 (0)