Controlling 2 stepper motors for 5-bar pkm using grbl 1.1

Hi there.
I want to control my 5-bar parallel plotter with 2 stepper motors by using grbl 1.1 and universal g-code sender.
I am using an arduino uno, a cnc shield and 2 A4988 stepper drivers, (1 for x-axis movement and 1 for y-axis movement). However, I am not using belts of pulleys in this project; the motor shaft is mounted directly on the proximal links.
I have attached pictures to show the project. Is controlling a plotter like this possible with using grbl 1.1?

Additional Information:
Stepper motor current rating: 1.7A
Degrees per step: 1.8


Yes but you have to work out the trigonometry of the rotation angles you want the motors to be at. Which will involve knowing what the grbl does with the Gode.
So I would drop the grbl and just use your drivers to move the motor.

I would also use shaft couplers instead of direct connection to the motors, otherwise the motors stand a good chance of sustaining damage over time.

I've tried using only the drivers and arduino code, but it didnt work at all. Here is the code I wrote to draw an 85x35 mm rectangle. The weird decimal numbers are steps that the motor needs to turn. position(0) is for the angle of the right proximal link and position(1) is for the angle of the left proximal link. The change in angle between points on the rectangle have been converted into steps. Maybe you can help me fix this code, or if not, help me continue with grbl?

// MultiStepper.pde
// -*- mode: C++ -*-
// Use MultiStepper class to manage multiple steppers and make them all move to
// the same position at the same time for linear 2d (or 3d) motion.

#include <AccelStepper.h>
#include <MultiStepper.h> //The Multistepper is a sub-class of the AccelStepper library therefore only called after the AccelStepper library

// EG X-Y position bed driven by two steppers

AccelStepper stepper1(1,3,5); //The first value in brackets '1' means that a driver is being used to power the stepper, The 2nd (CLK) and 3rd (CW) values are the PWM pins on the Arduino.
AccelStepper stepper2(1,9,11);

// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;

void setup() {
Serial.begin(9600);

// Configure each stepper
stepper1.setMaxSpeed(150); //Steps per second
stepper2.setMaxSpeed(150);
// Then give them to MultiStepper to manage

steppers.addStepper(stepper1);
steppers.addStepper(stepper2);
}

void loop() {
long positions[2]; // Array of stepper positions

// Point 1: Bottom Left
positions[0] = 9.683; //references to a coordinate
positions[1] = 8.839;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position

// Point 2: Top Left
positions[0] = -2.1; //references to a coordinate
positions[1] = 3.91;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position

// Point 3: Top Right
positions[0] = -21.9; //references to a coordinate
positions[1] = -20.317;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position

// Point 4: Bottom Right
positions[0] = 5.367; //references to a coordinate
positions[1] = -2.061;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position

// Point 1: Bottom Left
positions[0] = 18.63; //references to a coordinate
positions[1] = 18.467;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position

The thing is that you are not in Cartesian space so that calculating the end point of your motors is not going to work. You need to do the conversion just one step at a time as you move from your current position to your new one.

Could you please show me how you would implement that code?

Well the big problem is I don't think my maths is up to it.

I have built polar coordinate drawing machines before and here is a video of one I built out of LEGO, the idea is roughly the same as you want, that is to translate from one coordinate space to another.

The video is an animation of a presentation I made with Keynote, for a talk I was giving. It eventually shows the drawing of a spiral. It is slow because each movement was split up like I said. I could give you the code for this but it is in Python, so I am not sure how useful it would be for you.

There is another way of translating between coordinate systems and that is with a transformation matrix. Here I mean matrix in the mathematical sense of the word. The idea is used in these telescopes that can swing round to any celestial coordinate you enter. It does this by asking you to manually point the scope at two bright but widely spaced stars.

The unit knows where the stars are in the sky's celestial coordinate system, and knows where your telescope is pointing through the angle sensors mounted on the scope. It then calculates a four by four transformation matrix. Then the required celestial coordinate is multiplied by this transformation matrix to give the position the scope must be pointed.

I know this is how they work but again my maths is not good enough to know how to set this up for you geometry.

A similar, but different problem is posed by those drawing machines that suspend a pen on a chord between two stepping motors, and by altering the slack between them governs the position of the pen. These are mounted vertically on a wall.

So while I know what to do in theory I am not sure I could implement something for your geometry.
Sorry.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.