Posted January 10, 201312 yr Hello everyone, after spending years with my nxts I finally made something I want to share with others :) as the Title states, it's a cnc mill based on a linear delta robot. The programming is finished and was done with RobotC, but I still have to do some remodelling of the robot itselfs. For more info visit my also unfinished blog :) http://www.industrialmindstorms.org Feel free to ask questions if you have one! Edited January 10, 201312 yr by VASH321
January 10, 201312 yr Author what part of the code do you need? :) Since it is my bachelor thesis I am planning to make some tutorials about the whole thing and I will release the full source code when I feel comfortable with it :)
January 10, 201312 yr Well, any part, I just love looking and source code (is it really some C like code)? EDIT: for example the G code interpreter would be nice to look at. I did an interpreter/parser for 2D, but that was pretty specialized, so not too interesting. Edited January 10, 201312 yr by Lipko
January 10, 201312 yr Reminds me of a project I started a few months ago with.. It was cancelled due to the software.. Good job! Maybe I should rebuild it, though..
January 10, 201312 yr Author this is the code for my PD-controller, I run 3 tasks on the NXT for each motor. it's only works with small movements because I use another function to give the motor a new target every 10ms. int Ta = 10; //sampling time int aTarget = 0; //current motor Target bool aWaiting = false; //we arrived at the Target task maController() { int pos = 0; //current position int e = 0; //current error int ealt = 0; //old error float Kp = 2.2; //proportional gain float Kd = 0.5; //differential gain float y = 0; //computed motor power int MotorNumber = 0; bFloatDuringInactiveMotorPWM = false; //brake motors nSyncedMotors = synchNone; //disable any sync nMotorPIDSpeedCtrl[MotorNumber] = mtrNoReg; //disable PID nMotorEncoder[MotorNumber] = 0; //set encode to 0 while(true) { wait1Msec(Ta); //wait for the sampling time aWaiting = false; //we are moving pos = nMotorEncoder[MotorNumber]; //reading the current position e = -aTarget - pos; //calculating the error to the target int d = e-ealt; //calculate difference between old error y = Kp * e + Kd * (d)/Ta; //calculate the motor power ealt = e; //set the current error as old error if(abs(e) < 2) aWaiting = true; //if we are less then 2 degree from the target we are finished motor[MotorNumber] = y; //set the motor power } } @Ramacco: what was the problem with you're software?
January 10, 201312 yr I wanted to use PID to make the movement smooth. So I wrote a program that calculates the dimentions,... in coordinates.. I was stuck right here already.. This didn't work..:( Btw: what kind of robot arm did you use? Edited January 10, 201312 yr by Ramacco
January 10, 201312 yr Author PID won't give you smooth movement, you'll need to calculate a trajectory for smooth movements. you can find a picture of the robot here: http://www.industrialmindstorms.org/2013/01/milling-time-lapse/
January 10, 201312 yr Author If you look at my motor controller above, I am using a PD-Controller which is very fast in reducing error but does this by using huge acceleration and suddenly stop when reaching the desired angle or overshoots. like this: so you get an very rash start than overshoot and move back to the desired angle so I am using this function: void trajectory(float x, float y, float z){ float length = sqrt((x-oldx)*(x-oldx) + (y-oldy)*(y-oldy) + (z-oldz)*(z-oldz)); float incx = (x-oldx) / length/speed; float incy = (y-oldy) / length/speed; float incz = (z-oldz) / length/speed; for(int i = 1; i < length*speed; i++){ move(oldx+incx*i,oldy+incy*i,oldz+incz*i); wait1Msec(Ta*2); } wait1Msec(Ta); oldx = x; oldy = y; oldz = z; } basically this code creates a lot of small point on a straight line between A and B. I calculate the length from my current position to the desired one. divide the error between the two points by the length and a variable speed (to change the speed) than I use a for loop over the full length of the path between point A and B, where I add the increments and give my motor controller new target in the move function. this happens every 20 ms, so the controller only has to correct very small changes before he gets the next value, this way all motors stop at the same time and you get a constant velocity over the movement. Since I already wrote so much about it, I will try to get my tutorials with working RobotC examples uploaded this weekend :) Edited January 10, 201312 yr by VASH321
January 10, 201312 yr I get it.. Did you also make an interface where you can select your 3D image? I was writing it in Java (LeJOS) I also think that your drawings can be made with a higher resolution. Slow down the process? Calculate more point in your traject? Wouldn't this be a solution? Edited January 10, 201312 yr by Ramacco
January 10, 201312 yr Author I use http://pycam.sourceforge.net/ to create G-code which I than process on the nxt. I tried out bluetooth and wifi for sending the data, but this was to unreliable and slow. I simply upload the G-code as a .txt, read it line by line and interpret the commands it looks like this: G0 Z5.0 X-39 Y-70 G1 Z-497.3 X-3 G0 Z5.0 X-39 G1 Z-497.3 X-3 G0 Z5.0 G0 is for fast movements G1 for slow movements and there are only values for the changing axis... I can make much better resolution, just look at the picutes in my blog, but the problem is that with better resolution the G-code file gets to big for the nxt (only 100 kb free space), so I have to split the G-code files in 2 files and run it one by one, which I was to lazy to do in this video ;) The Step size of the trajectory si only about 0.05 mm while my layer width in the g-code was 1.5 mm that's the reason for the bad quality.
January 10, 201312 yr If I understand it correctly, Pycam provides the code and dimensions for the 3D model. Then in RobotC you flip those to a .txt file. The rest of your program in RobotC is based on the .txt file? Edited January 10, 201312 yr by Ramacco
January 10, 201312 yr Are you sure what you are allowed to talk about? Isn't there some kind of Thesis privacy? Don't get in trouble, but it would surely by awesome to see the tutorial and the source code. EDIT: so, the whole G code is stored on the nxt? If so, then using a binary format would be much more efficient IMHO. No parsing and less space. Edited January 10, 201312 yr by Lipko
January 10, 201312 yr Author Yes, I store the G-code.txt on the nxt and simply interpret it, I like to use Gcode because it's a standard. @Ramacco: no I don't modify the file in any way simply read it line by line and follow the commands. I don't have any NDA on my bachelor thesis, but I'm gonna ask about that :)
January 10, 201312 yr Very cool project! Thanks! If you're allowed to post more details, I'll ve glad to read those articles!!
January 10, 201312 yr I know it's a standard but it's not forbidden to use an own format for the actual controlling. I would guess that even real CNC machines do that. With raw data you could store 2..3 times more data, and the fetching would be easier too. That means, of course, that you would have to make a small desktop program that converts the .txt to a binary file. But you already have the interpreter, so it's should be pretty easy. EDIT: if 0.01 mm precision is enough, you could even use fixed point representation too (0.00 to 655.65 mm), doubling the amount of storable data Okay, I don't want to derail the thread, keep us posted! Edited January 10, 201312 yr by Lipko
January 10, 201312 yr Author I thought about that, but since EV3 is coming next summer I wont have to bother with 100kb file limit anymore :)
January 22, 201312 yr Author I found the time to start building a new robot: http://www.industrialmindstorms.org/2013/01/building-a-new-delta-mill/
January 24, 201312 yr this looks amazing... whast the working area? and whats the resolution? this looks amazing... whast the working area? and whats the resolution?
January 29, 201312 yr Author kinematics aren't that hard, I will upload them when i have time. It's some sort of drill for keramik 3.2mm diameter
August 6, 201311 yr Hello..I really like your robot. I built similiar robot as you but i can not move from one point. I have gcode but i cant find out how to translate it that nxt will understand it.Could you please send me your source code? Thank you really much!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.