Hi guys. I am working on IMU's and various stabilization algorithms with many other friends here in Milan. We are working on a little production of robot kits and components. Here it is a demo of PICO kit used to build a very simple self balancing robot:
Hey, gbm, something appears wrong with the code as posted above in this thread (I'm not saying your code is wrong, just that what you posted appears "mangled"). Can you repost the code (or correct your first post)?
Hi guys. No, inclination is a deadzone for PICO, without a gyro/acc/IMU it can't know where is down, he only know the distance from his front and ground, and his back and ground. For this reason the only way to let it go on a inclinated plan (with only ir sensors) would be to move the battery according to reactions. But it is a littlebit complex.
this is a first try but is very effective. Not powerful in micro-corrections but very nice when the robot is drifting. If you try a project like this you surely find big problems to stabilize robot if it get speed in one direction. The key is to follow science laws. I get a sort of inertia data and I add it to servo correction. For this reason if the robot get speed in one direction inertia goes up and add power to servos to undo the inertia momentum.
Hi guys, I worked a lot and I implemented PID algoritm. IT IS INCREDIBLE!!! It Workssss!!! ;D ;D ;D ;D ;D ;D ;D ;D
I am the happiest man on the planet now!!!
Hi guys. I have a brainfight with friends about PID. I use (you can see it in the code or article) a "variable time PID". It is simple, I take the loop duration value (time - previousTime = interval) and I multiply that with I and D.
My engineer friends says that thing should not work and the pid MUST be used in fixed time. Their programs do thing and then if the loop duration is less then the fixed duration spleeps until get fixed duration.
I think is stupid to loose time in that way. They say that is important to have the same "weight" per acquisition. Simply every acquisition MUST have the same duration to be proportial. I use a variable (interval) that is multiplied to I and D that rise and lowdown porportional to acquisition duration. If a loop is very long interval is a big value, for this reason the weight of this value is more then others with smaller interval. My sistem works take a look:
Is there some coder/skilled that can clarify this question?
Hi retrolefty! Thank you for the answer.
This is not a cobbled/modified code. I wrote it down from the first raw.
I think this is only a new approach to PID.
void loop() {
float previousTime = time;
time = millis();
float interval = time - previousTime;
P = orientation / kP;
I = I + (P * interval) / kI;
D = (orientation - previousOrientation) / interval / kD;
float PID = P + I + D;
if(P > 90) P = 90; //stop increase or decrease of the value
if(P < -90) P = -90;
if(PID <= 1 && PID > 0) PID = 0; //cut off micro-corrections
if(PID >= -1 && PID < 0) PID = 0;
left.write(81 - PID);
right.write(81 + PID);
previousOrientation = orientation;
}
If I have a value that is proportional to interval duration and I use it as time is used in PID i get a value that gives a weight, proportional to time duration, to I and D values. If I(value) is adding and get a value that is very low, but has a long interval, that has more influence to trend then a value with a low interval. I think this is logically demostrated by my last video and this 3 raws of text ;).
Think about extending your code with the standard version. This tunes itself automatically. The other has problems and must be regulated every time you add routines or functions. Another bad thing is the sleep time loss in every loop.
There's a whole article here that suggests you can have a variable delta T (time step), and I don't see why it wouldn't work - that's how integration works.