View unanswered posts | View active topics It is currently Sun May 01, 2016 8:50 am

 Page 2 of 2 [ 17 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
NXT CNC
Author Message
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Re: NXT CNC
don't mind, you'll learn by doing
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)

Thu Dec 05, 2013 1:22 pm
Novice

Joined: Sat Apr 12, 2008 11:09 am
Posts: 60
Location: holland
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 setpointstep = motorencoder valuego into a loopcalculate looptimecalculate steppoint: steppoint += desired speed *(looptime/1000)    if step >setpoint       step = setpointerror=motorencoder value - steppointmotor 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
Display posts from previous:  Sort by
 Page 2 of 2 [ 17 posts ] Go to page Previous  1, 2

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning