View unanswered posts | View active topics It is currently Thu Jul 10, 2014 3:54 pm






Reply to topic  [ 6 posts ] 
How to use PID Control so that robot follows line smoothly 
Author Message
Rookie

Joined: Wed Oct 24, 2012 2:51 pm
Posts: 8
Post How to use PID Control so that robot follows line smoothly
Hello.

Newbie here.

My robot has got only one light sensor (reflected light) to read in lightest & darkest values and calculate a threshold and move left and right according to the threshold. The robot moves in a zig zag pattern and I want to make it smoother. I saw people on post talking about PID control and I researched for it.

My 1st question is you just simply add these lines? Say my motor variables are 'motorA' for left and 'motorC' for right.

nMotorPIDSpeedCtrl[motorA] = mtrSpeedReg;
nMotorPIDSpeedCtrl[motorC] = mtrSpeedReg;

I mean just like that? Seems too good to be true and yeah I know I could just test the code but I don't own any robot. Only able to test it at school lab.

Hope to be replies a.s.a.p
Many thanks!


Wed Oct 24, 2012 3:00 pm
Profile
Rookie

Joined: Wed Oct 24, 2012 2:51 pm
Posts: 8
Post Re: How to use PID Control so that robot follows line smooth
And I'm talking about RobotC please no other languages.


Wed Oct 24, 2012 3:01 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: How to use PID Control so that robot follows line smooth
To make the robot follow the line smoothly, you need to be able to tune PID. I am not familiar with the RobotC built-in PID control but I do not believe you can make use of built-in PID for that. Refer to the following post for an example on how to implement PID control for line following:
viewtopic.php?f=55&t=4973&p=20864&hilit=+PID+follow#p20864


Wed Oct 24, 2012 6:51 pm
Profile
Rookie

Joined: Thu Sep 13, 2012 9:43 am
Posts: 47
Post Re: How to use PID Control so that robot follows line smooth
half_pirate wrote:
Hello.

Newbie here.

My robot has got only one light sensor (reflected light) to read in lightest & darkest values and calculate a threshold and move left and right according to the threshold. The robot moves in a zig zag pattern and I want to make it smoother. I saw people on post talking about PID control and I researched for it.

My 1st question is you just simply add these lines? Say my motor variables are 'motorA' for left and 'motorC' for right.

nMotorPIDSpeedCtrl[motorA] = mtrSpeedReg;
nMotorPIDSpeedCtrl[motorC] = mtrSpeedReg;

I mean just like that? Seems too good to be true and yeah I know I could just test the code but I don't own any robot. Only able to test it at school lab.

Hope to be replies a.s.a.p
Many thanks!


re. testing. RobotC has a robot emulator called Robot Worlds, and there is a free trial, have a look at http://www.robotc.net/download/rvw/

PID may well be overkill for what you want to do, basic on/off control would probably be simpler to code, is that what you were trying in your other post? For PID you also need a measurable error range and I'm not sure that the light threshold really provides that, I may be wrong. Good luck.


Fri Oct 26, 2012 8:52 am
Profile
Rookie

Joined: Wed Oct 24, 2012 2:51 pm
Posts: 8
Post Re: How to use PID Control so that robot follows line smooth
Hi.

I implemented PID control and my robot followed the line either way. Not that smoothly but it's ok for now; focusing what works and optimize later. But a new issue is that it didn't work on any line. I noticed that my robot only works on thick line and not on thin line. Any idea to fix this? Is it about tuning PID more?

My assignment stated that it should work on any line and unfortunately I can't risk sharing my code here; to avoid plagiarism from students in the same class.

Many thanks!


Thu Nov 01, 2012 4:43 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: How to use PID Control so that robot follows line smooth
half_pirate wrote:
Hi.
I implemented PID control and my robot followed the line either way. Not that smoothly but it's ok for now; focusing what works and optimize later. But a new issue is that it didn't work on any line. I noticed that my robot only works on thick line and not on thin line. Any idea to fix this? Is it about tuning PID more?

My assignment stated that it should work on any line and unfortunately I can't risk sharing my code here; to avoid plagiarism from students in the same class.

Many thanks!

Well, if the line is too thin, the diameter of the light spot is probably bigger than the width of the line. In that case, you won't get very good threshold because the sensor will see mostly white (assume black line) and you can't tell the difference very well whether you are on it or not. In any case, the only thing you can do is to really carefully tune the threshold accurately and slow the robot way down to give it time to tell the lighting difference.


Thu Nov 01, 2012 4:53 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.