View unanswered posts | View active topics It is currently Sat Oct 25, 2014 3:01 pm






Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
NXT CNC 
Author Message
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: NXT CNC
don't mind, you'll learn by doing 8-)
actual speed is = (newEncoder - oldEncoder)*100/looptime // looptime=laptime=dtime

I understand, it's lot of stuff, all messed up, and all at once :)

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Thu Dec 05, 2013 1:22 pm
Profile
Novice

Joined: Sat Apr 12, 2008 11:09 am
Posts: 55
Location: holland
Post Re: NXT CNC
A different way to solve this: Dont look at your speed, but look at your position.

First determine how far each motor has to run and in how fast you want the motors to run.
Say 3000 degrees 50 degrees per second.
Now take a variable "step" and load it with the actual encoder value.
Go into a loop:
Let "step" count up with a speed of 50 degrees per second every loopcycle until you reach the setpoint.
This variable contains the value you want the motor to be every loopcycle.
Every loopcycle you compare the actual encoder value with "step". There will be a small difference between them. This difference will be the new setspeed for the motor.

I use this theory a lot and it works pretty good. It can be used up to 3 motors the same time and synched.
It does not have a ramp up and down, but is pretty easy to integrate (just left it out to keep things more clear)

in pseudo

Code:
store setpoint
step = motorencoder value

go into a loop
calculate looptime
calculate steppoint: steppoint += desired speed *(looptime/1000)
    if step >setpoint
       step = setpoint
error=motorencoder value - steppoint
motor output =error


As soon setpoint is reached the motor stops automatically, because the error will reach 0.
the internal PID wil run the motors.
The looptime is something to play with, since the motor output power is set every cycle. this resets the PID
Sometimes 25 ms works best. other times 100ms

Hope i made it clear a little


Sun Dec 08, 2013 8:14 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 17 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.