go away spammer

Author Topic: The PID idea  (Read 3231 times)

0 Members and 1 Guest are viewing this topic.

Offline yakirLLCTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
The PID idea
« on: September 08, 2015, 04:23:09 AM »
Hi,

I need to build an EV3 robot that does self balancing.
I know that the method to do that includes using PID, my question is - how does this PID mechanism works? Can any1 help me?
I couldnt get the idea of it. I've found an online code that works but is WAY too big and contains things I dont even need so I cant really understand why he did what he did in there.
Plus, I've tried to read about it in a few places but still - its too long and I just keep missing the idea.
HOW is this PID goes? What do I need to know in order to implement it in my code?
My robot should be pretty simple, just self balancing himself. No need to move anywhere, just to stay still.
I'd really appriciate your help cuz I'm at my limit and clueless.

Thanks alot.

Offline mklrobo

  • Supreme Robot
  • *****
  • Posts: 558
  • Helpful? 15
  • From Dream to Design at the speed of Imagination!
Re: The PID idea
« Reply #1 on: September 08, 2015, 05:27:01 AM »
 ;D Hello!
Parallax has a processor, called the propeller. Check this out on youtube;
! No longer available
for more information, go to Parallax.com; I have seen the robot and code there.(Been a while!)
Good Luck!!  ;) :) :D ;D

Offline cyberjeff

  • Full Member
  • ***
  • Posts: 114
  • Helpful? 7
Re: The PID idea
« Reply #2 on: September 08, 2015, 06:05:29 AM »
Self balancing robots don't need a lot of code. The PID is to control overshoot. Any of the setups you have will have enough inertia to slow the overshoot and the robot will have enough time to correct.

In other words, you can tweak the hardware rather than the software.

Here is a simple device using minimal processing power:

http://www.instructables.com/id/2-Wheel-Self-Balancing-Robot-by-using-Arduino-and-/?ALLSTEPS

There are quite a few self balancing robot rolling around out there. The difference in the software is largely in how they process the accelerometer to remove noise and get a stable baseline.

Offline yakirLLCTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: The PID idea
« Reply #3 on: September 08, 2015, 06:25:04 AM »
Hi,

Thanks for the reply, but I'm still lost. I'm gonna use EV3 robot with just 1 Gyro sensor, the code I found was large but my main problem was understanding the PID mechanism. How can I implement them? How can I set the forumlas in my code? I saw what they did there and I didn't understand the WHY they did that?
Can you please explain, in short, how is this PID supposed to work? What it's real goal and a bit of the math there?
I'm sorry if I'm giving u hard time with my questions but it's really cuz I'm lost.

Thanks in advance.

Offline yakirLLCTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: The PID idea
« Reply #4 on: September 09, 2015, 09:08:57 AM »
Help...? :(

Offline mklrobo

  • Supreme Robot
  • *****
  • Posts: 558
  • Helpful? 15
  • From Dream to Design at the speed of Imagination!
Re: The PID idea
« Reply #5 on: September 10, 2015, 07:15:32 AM »
 ;D Hello!
OK, to establish a base line definition;
A proportional-integral-derivative controller (PID controller) is a control loop feedback mechanism (controller) commonly used in industrial control systems. A PID controller continuously calculates an "error value" as the difference between a measured process variable and a desired setpoint. The controller attempts to minimize the error over time by adjustment of a control variable, such as the position of a control valve, a damper, or the power supplied to a heating element, to a new value determined by a weighted sum:
(The formula can be found on Wikipedia, too many variable to put here.)
OK, so we have the definition, and what the hardware is supposed to do, so how do we implement it?
I am not familiar with an EV3 robot, so the code is specific to that processor is unknown to me. This
unfamiliarity is normal for anybody approaching  a new MCU system. This is why I can not help you in that
specific instance, except to indicate, go to Parallax.com, for their code; which  is specific to their
processor. This is why everybody else can only provide general directions, unless they have specific info to your MCU. In cases where you need to cross - platform the code, you need to obtain a logical block diagram
of somebody's working robot, (and hopefully code too), then you can start cross - programming the
program. If you are lucky, somebody has already done this; which, in that case, it is a matter of
searching the internet for the program. Good Luck!!   ;) :) :D ;D
« Last Edit: September 10, 2015, 07:17:26 AM by mklrobo »

Offline cyberjeff

  • Full Member
  • ***
  • Posts: 114
  • Helpful? 7
Re: The PID idea
« Reply #6 on: September 10, 2015, 10:25:01 AM »
;D Hello!
OK, to establish a base line definition;
A proportional-integral-derivative controller (PID controller) is a control loop feedback mechanism (controller) commonly used in industrial control systems. A PID controller continuously calculates an "error value" as the difference between a measured process variable and a desired setpoint. The controller attempts to minimize the error over time by adjustment of a control variable, such as the position of a control valve, a damper, or the power supplied to a heating element, to a new value determined by a weighted sum:
(The formula can be found on Wikipedia, too many variable to put here.)

+1 to mklrobo

A quick Google search yielded this on how to set PID parameters on an EV3:

http://thetechnicgear.com/2014/03/howto-create-line-following-robot-using-mindstorms/

Some knowledge of summation and integrals would be helpful.

Another quick Google search yielded multiple entries for "EV3 self balancing".

I doubt that anyone here owns an EV3, we are pretty much build it from scratch people.

Learning a new technology can take a bit of research and time. Myself, I've been learning Barrycentric coordinates. Which curiously enough has nothing to do with either Mayor Marion Barry, Barry Manilow or Barry White.
Sometimes you just have to work your way through the weeds with some divine provinance from Google.

Offline mklrobo

  • Supreme Robot
  • *****
  • Posts: 558
  • Helpful? 15
  • From Dream to Design at the speed of Imagination!
Re: The PID idea
« Reply #7 on: September 10, 2015, 10:46:45 AM »
  8) +1 to CyberJeff for the AWESOME info!!   8)

Offline yakirLLCTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: The PID idea
« Reply #8 on: September 17, 2015, 05:57:00 AM »
Hi,

Thank u all for the replys.
I wans't asking of how exactly do I write it in EV3 code, I just mentioned it so u guys can know that and maybe if u have any information regarding the EV3, u might share it.
My request is to be provided with some direction of how to put the PID into code(pseudo code). I saw the Pseudo code in ur link(I've seen it b4, when I searched google) but its regarding line follower, not self balancer. It's different.
I'll show u the PID function I saw in the code I've found, maybe it will help u to help me :). The language is C.
float PID( float input, float reference )
{
   // Integration part
   static float accumulatedError = 0.0;
   // Differentiation part
   static float diffError = 0.0;
   static float previousError = 0.0;
   float currentError = input - reference;
   accumulatedError += currentError * dt;
   diffError = ( currentError - previousError ) / dt;
   previousError = currentError;
   return kp * currentError + accumulatedError * ki + diffError * kd;
}

Thanks.

 


Get Your Ad Here

data_list