View unanswered posts | View active topics It is currently Fri Aug 07, 2020 2:54 pm

Reply to topic  [ 2 posts ] 
PID Control 
Author Message

Joined: Tue Nov 04, 2014 5:04 pm
Posts: 2
Post PID Control
Hi guys im attempting to learn PID control for my robotics classroom. I was looking over some example code and was wondering if anyone can explain some of these statements to me or maybe to the whole code. I have been unable to find any teaching source for PID and at this point I have excelled my teacher so he is unable to teach me this.

The things i dont know are what these things stand for nLastPos, nPos, nNumbOfHits, nSensor, nWeight, ++nCycles.

I have no idea what the n in front of the statements mean aswell.

Here is the code that I am looking at ... sp=sharing

Mon Jan 12, 2015 8:42 pm

Joined: Wed Feb 24, 2010 11:51 pm
Posts: 31
Post Re: PID Control

It is common in some styles of programming to prefix variable names with their type.

Thus, the 'n' prefix means this variable is a 'number'.

As for the other variables, I can guess at a couple of them, but the others aren't obvious when taken out of context. I can't follow the link you posted as it's blocked for me.

A PID control is designed to use sensors to adjust a robot in order to match a desired, or 'target', position or speed. To accomplish this task, the sensor is repeatedly sampled, and the reading is used to compute a correction, which is applied by turning a motor. Given that, I'd apply the following guesses to some of the variable names:
nSensor - is either the sensor number or the last raw value read from the sensor.
nPos - is probably the current position, derived from the last raw sensor value. This is where the sensor says the robot is right now.
nLastPos - is probably the last position. This is where the sensor says the robot was the last time it checked. Probably 1-20 milliseconds ago. This is used for the 'D' part of the PID calculation.

The others are unclear without context.


Vex & FLL Coach and robotics instructor

Tue Jan 13, 2015 1:41 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

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.