Hey guys, I recently got into drawing in 3D printing and design and ended up designing this thing:
it is controlled by an Arduino Due with a CNC shield and DRV8825 step sticks, i attached the arduino project.
Now, i knew from the beginning that the problem was going to be the fact that it doesn't move in a straight line.
The second problem being that i haven't actually decided what i want to use it for?
Anyways, i have spent 10+ hours writing the program to get this thing to move to an XYZ Coordinate with my goal (at this point) being to have it be able to read G code (somehow) from cura(possibly) and maybe draw something on a piece of paper. It's just an idea for a youtube video i guess.
Heres where I'm at with that:
It will move to the XYZ coordinate that i specify with the code that i have written, and it will move anywhere i want it to. But the obvious issue with reading G-code is that it will not move in a straight line between points.
Whats the best way to solve this issue?
Would anybody like to write code for this in return for a youtube video of it running the code with a mention of your name/username?
Im going to loose interest in this thing pretty quickly...
I thought this was really interesting regarding controlling robotic arms: http://walter.readthedocs.io/en/latest/Trajectory/
It goes beyond just getting the arm to the desired coordinates and actually considers the aesthetics of the movement which is a bit of an information overload since just getting to the coordinates at all is already incredibly complex.
Before i down the rabbit hole of actually trying to wrap my head around this, is the arduino Due going to be quick enough to do the math and keep this robot moving at a decent rate?
My understanding is the Walter arm project I linked above computes the trajectories on an Odroid SBC, then sends the data to the Teensy 3.5, which controls the stepper motors. The creator of that project started with an AVR microcontroller for this purpose but found the acceleration calculations to be too computationally intensive for the AVR to handle well and so switched to the Teensy 3.5, which has FPU (hardware floating point handling). Unfortunately the Due does not have FPU but it is a pretty powerful microcontroller. Obviously Walter has a ton of computational power between the Odroid and the Teensy but it also does a lot more than the bare minimum to get from point A to point B. I'm sure you can accomplish this with the Due. The question is the rate and how many bells and whistles you can manage to throw in there. It's also usually possible to wring significantly more performance out of a system through optimization but this may come at the expense of many hours of work and end up making the code more difficult to maintain.
void FindPointsOnLine (float XC1, float YC1, float ZC1){
 float XLP;
 float YLP;
 float ZLP;
 if (FirstScan == 0){
Â
 float Resolution = .3;
 if (GetNewXYZ == 1){
 float Compute1 = (XO-XC1 ) * (XO-XC1 ); // Add the Beginning and End Points Together and Square them all this is essentially A squared + B Squared = C Squared
 float Compute2 = (YO-YC1 ) * (XO-XC1 );
 float Compute3 = (ZO-ZC1 ) * (ZO-ZC1 );
 float P2PDist = sqrt(Compute1 + Compute2 + Compute3) ;// Take the Square Root of the Entire Equation Should give the Length of the Line
 if( P2PDist > Resolution){ // If the Point to Point Distance is Greater than the Resolution(.1 mm), we need to create points along that line to move to in order to move in a straight line
  NumPoints = P2PDist / Resolution ;// Figure Out How Many Different Points are Needed .1 is the resolution
 }
 GetNewXYZ = 0;
 }
Â
XLP = map(CurPoint, 1, NumPoints, XO, XC1); // This Baiscally Maps out points of the line by looking at the values on each axis as percentage of the start and end points
YLP = map(CurPoint, 1, NumPoints, YO, YC1);
ZLP = map(CurPoint, 1, NumPoints, ZO, ZC1); // 1 is the starting Point, Point 1 is sent on the first scan, then point 2, and ECT. all the way untill it has completed the line
// once it has completely traveled the length of its imaginary line, Curpoint will be equal to the number of points it calculated, it will then ask for the next point to move to, then begin the move
if(CurPoint >= NumPoints){
 CurPoint = 1;
 GetNewXYZ = 1;
 XO = XC1;
 YO = YC1;
 ZO = ZC1;
}else{
CurPoint++;
}
 }
 else{
 XO = XC1;
 YO = YC1;
 ZO = ZC1;
 XLP = XC1;
 YLP = YC1;
 ZLP = ZC1;
 FirstScan = 0;
 }
Â
CalcJointAngles(XLP, YLP, ZLP);
Â
Â
}
Sorry to drag this thread to the top again, i thought i would post my solution!