SPG30E-30K do i need PID compensation?

LINIX Brushless, VEXTA Brushless, RC Servo, DC Geared, Linear, Stepper, Tamiya.....

SPG30E-30K do i need PID compensation?

Postby j6433 » Sun Apr 28, 2013 9:37 pm

i am using 2 SPG30E-30K to move my robot on square line following grids..

from http://www.pjrc.com/teensy/td_libs_Encoder.html i got a nice 4X encoding library to include and i successfully use this library to determine directions of the motor rotations, and by manually rotating the wheel attached to my motor, completing 1 CW revolution via the wheel, gives +360 count to the program, and i connected CHA and CHB to 2 interrupt pins so the positions i get from encoder is very accurate...

problem comes when i want the robot to move forward another 10cm after it meets the junction, and then turn right 90degrees so that it will be in the right track
even with accurate counts from the encoder i did not successfully control the robot to move in such way...i just need it to move for 180counts then exit the while loop, but it only stops after it moves for over 600counts (meaning more than 2 revolutions) the robot travelled too far from what i needed...at first i thought it was because of my robot momentum but when i left the wheels moving without touching the ground the result is still the same.. happens that the loop that i write, when the robot applies PWM to the motor driver, it exceeds the encoder counter way too much before it exits the loop..

i have written getEncoder() to get encoder values, resetEncoder() to reset encoder values when it arrive junction, tempStop() to stop the motor driver and goStraight to make it go another 10cm from junction, the



CODE: SELECT_ALL_CODE
  float lengthPerCount = (80 * 3.1416) / 360;
// π X Diameter of wheel divide by 360(<- 1 revolution of wheel gives 360 counts, so i find distance travelled if count increase  by 1)
 
  float offsetLength = 125;    //this is the distance i need to travel  From Junction Distance, in mm
  long needCount1 = offsetLength / lengthPerCount;  //so i set loop conditions using the extra count needed to travel 125mm

====
   void goStraight ()    //GO STRAIGHT FOR OFFSET 125MM//
    {   resetEncoder();
        getEncoder();   //get the new encoder value and put it in positionLeft and positionRight, and this is 0 before it loops
       
        while(positionLeft < needCount1 || positionRight < needCount1)
        {
        getEncoder();
       
        digitalWrite (M1, LOW);   //apply pwm to motor driver making it to move forward
        digitalWrite (M2, HIGH);
        analogWrite(E1,110);
        analogWrite(E2,110);
       
        }
       
        tempStop(); //stop after it finished travel 125mm
        delay(1000);
       
        //goRight();
    }


the goRight() function is written in the same manner but implementing it will make the robot rotate itself for 2 circles instead of 90 degrees...

its just a simple go and turn but i failed already... figuring about the loops for days already...what can i do to improve this condition? :cry: or do i need to apply PID algorithm? the code from http://www.cytron.com.my/viewProduct.php?pcode=SPG30E-30K&name=DC%20Geared%20Motor%20with%20Encoder was not for arduino...
j6433
Novice
 
Posts: 20
Joined: Tue Oct 16, 2012 2:08 pm

Re: SPG30E-30K do i need PID compensation?

Postby waiweng83 » Wed May 08, 2013 12:21 pm

Can you post your whole source code?
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 205
Joined: Wed Apr 15, 2009 2:17 pm

Re: SPG30E-30K do i need PID compensation?

Postby j6433 » Thu May 09, 2013 3:02 pm

waiweng83 WROTE:Can you post your whole source code?

i tried adapt codes from robot head to toe volume 4 and this condition happened... viewtopic.php?f=7&t=12142
j6433
Novice
 
Posts: 20
Joined: Tue Oct 16, 2012 2:08 pm

Re: SPG30E-30K do i need PID compensation?

Postby Pitbul » Sun Jan 04, 2015 3:21 am

i have written getEncoder() to get encoder values, resetEncoder() to reset encoder values when it arrive junction, tempStop() to stop the motor driver and goStraight to make it go another 10cm from junction, the
Get Braindumps demos head first pmp passguide with 100% success ccna ccnp Our high quality MCITP Certification itil prepares you well before appearing in www.sckans.edu
Pitbul
Fledgling
 
Posts: 1
Joined: Sun Jan 04, 2015 3:20 am


Return to DC Motor

Who is online

Users browsing this forum: No registered users and 7 guests