Home Forum Everything Else Arduino uno 6dof

• This topic has 2 voices and 15 replies.
Viewing 16 posts - 1 through 16 (of 16 total)
• Author
Posts
• #6106 Anonymous
Inactive

Hi,
as a Newbie I’m struggeling with a code for Arduino uno and six servos connected to pins 3,5,6,9,10,11.
I’v build Steward platform, but I can’ get servos moving with code bellow
Any Ideas, thank you in advance

``````#include
const float pi = 3.14159,
theta_s[] = { -pi / 3, 2 * pi / 3, pi, 0, pi / 3, -2 * pi / 3},
RD = 2.395,
PD = 3.3,
L1 = 1.0,
L2 = 4.72,
z_home = 4.25,
servo_min = 3.5,
servo_max = 5.5,
servo_mult = 6,
p = {{PD * cos(pi / 6 + theta_p), PD * cos(pi / 6 - theta_p), PD * cos(-(pi / 2 - theta_p)), -PD * cos(-(pi / 2 - theta_p)), -PD * cos(pi / 6 - theta_p), -PD * cos(pi / 6 + theta_p)},
{PD * sin(pi / 6 + theta_p), PD * sin(pi / 6 - theta_p), PD * sin(-(pi / 2 - theta_p)), PD * sin(-(pi / 2 - theta_p)), PD * sin(pi / 6 - theta_p), PD * sin(pi / 6 + theta_p)}
},
re = {{RD * cos(pi / 6 + theta_r), RD * cos(pi / 6 - theta_r), RD * cos(-(pi / 2 - theta_r)), -RD * cos(-(pi / 2 - theta_r)), -RD * cos(pi / 6 - theta_r), -RD * cos(pi / 6 + theta_r)},
{RD * sin(pi / 6 + theta_r), RD * sin(pi / 6 - theta_r), RD * sin(-(pi / 2 - theta_r)), RD * sin(-(pi / 2 - theta_r)), RD * sin(pi / 6 - theta_r), RD * sin(pi / 6 + theta_r)}
};

/*
theta_r = angle between attachment points
theta_p = angle between rotation points
theta_s = orientation of the servos
RD = distance to end effector attachment points
PD = distance to servo rotation points
L1 = servo arm length
L2 = connecting arm length
z_home = default z height with servo arms horizontal
servo_min = lower limit for servo arm angle
servo_max = upper limit for servo arm angle
servo_mult = multiplier to convert to milliseconds
p = location of servo rotation points in base frame [x/y][1-6]
re = location of attachment points in end effector frame [x/y][1-6]
*/
const int servo_pin[] = {9, 3, 5, 11, 6, 10};
const int servo_zero = {1710, 1280, 1700, 1300, 1680, 1300};
/*
servo_pin = servo pin assignments,
servo_zero = zero angles for each servo (horizontal)
*/
Servo servo;
/*
Servos 0, 2, 4: reversed (+ = down, - = up)
Servos 1, 3, 5: normal (+ = up, - = down)
*/
void setup()
{
//Serial.begin(9600);
for (int i = 0; i < 6; i++)
{

servo.attach(servo_pin);
servo.writeMicroseconds(servo_zero);
}
delay(1000);
}

void loop()
{

}
/*
pe = location and orientation of end effector frame relative to the base frame [sway, surge, heave, pitch, roll, yaw)
theta_a = angle of the servo arm
servo_pos = value written to each servo
q = position of lower mounting point of connecting link [x,y,x][1-6]
r = position of upper mounting point of connecting link
dl = difference between x,y,z coordinates of q and r
dl2 = distance between q and r
*/
``````
#7035 Anonymous
Inactive

I prefer to work with vectors and think in dot products, cross products, etc.
I can draw the model and how to build the equations easier that way.

#7036 Anonymous
Inactive

@i-make-robots wrote:

I prefer to work with vectors and think in dot products, cross products, etc.
I can draw the model and how to build the equations easier that way.

Would you be so kind and show me an example, maybe one relating to Stewart Platform 6dof

regards
Mario

#7037 Anonymous
Inactive
#7038 Anonymous
Inactive

thank you i-make-robots,
how to assemble rods and motors, but there is a missing image of wireing
and other description. If you have any information or description Il be gratefull.
@i-make-robots wrote:

https://github.com/MarginallyClever/RotaryStewartPlatform

As I’m a real newbie I looked at the code named rap-center.ino and I would like to know
what i stands for in the code bellow
int i;
for(i=0;i<6;++i) {
arm.attach(7-i);
arm
.write( 90 );

thank you again
Mario

#7039 Anonymous
Inactive

It’s connecting servos to pins 1-6 (inclusive) and then moving them to middle position. I used this code to center the servos so then I could attach the servo arms and know they’re *pretty close* to horizontal.

#7040 Anonymous
Inactive

thank you, for replay.

I’v used RSP_Center.ino, to set up the positions of servos to zero position ,parallel to the horizon.
I’v run RSP_Test.ino and I think that the servos have to wide range of motion. I was again unsuccesfull trying
to reduce the range of oscilation in the code bellow. Any tips what to change

void loop() {
float t=millis()*0.001;

int i,j;
for(i=0;i<6;++i) {
j = sin(t+(float)i*PI/3.0)*30;
set_servo(i,j);
Serial.print(j);
Serial.print(‘t’);
}

Serial.print(‘n’);
delay(50);

#7041 Anonymous
Inactive

change *30 to *20 or *10… the smaller the number, the smaller the oscillation.

#7042 Anonymous
Inactive

Hi,
thank you again. I managed to succesfully run my first 6DOF experiment.
Next step would probably be Rumba controller.
But right now I would like to do the following procedure:
Use the platform as it is, but servos connected to inputs as
you programmed in RSP_Listen.ino. Than record movements in to
software CoolTerm.
Run RSP_MasterSlave.ino and use recorded data from CoolTerm instead
of the second 6DOF platform functioning as remote.
What do you think

Regards
MArio

#7043 Anonymous
Inactive

#7044 Anonymous
Inactive

Hi,
What I expected did not happen.
When CoolTerm saves received data to a text file, the time stamps tell you when which data was received. Sending the same text file via CoolTerm, however, does not interpret the time stamps as pauses. It treats the timestamps in the file as text, just like any other data in the text file. Thus, CoolTerm will send the timestamps as text to the your servo controller. Any file sent by CoolTerm will be sent all at once.

So I decided to replicate your Master Slave Scenario.
I build two Platforms and Arduino Uno. Servos from Platform A connected to outputs, pins 2-7,
Servos from Platform B to inputs A0-A5.
When I run RSP Center Platform A moves in to Zero position. So OK
When I Run RSP Listen Platform B when I move it transfers data, which can be observed
on seriam Monitor. So, probably OK
When I run RSP Master Slave I calibrate MIN MAX positions, but when finished Platform A
starts to move erratically

#7045 Anonymous
Inactive

erratically how? Can you make a video please?

#7046 Anonymous
Inactive

immediately after calibration the following behavior

#7047 Anonymous
Inactive

Something is sending random PWM signals to your servos. What happens if your arduino sends only (MAX+MIN)/2 to all the servos?

#7048 Anonymous
Inactive

How do I do that?

#7049 Anonymous
Inactive

It was my mistake.