View unanswered posts | View active topics It is currently Sat Oct 01, 2016 6:22 pm

 Page 1 of 1 [ 6 posts ]
 Print view Previous topic | Next topic
How to use PID Control so that robot follows line smoothly
Author Message
Rookie

Joined: Wed Oct 24, 2012 2:51 pm
Posts: 8
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
Rookie

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

Wed Oct 24, 2012 3:01 pm
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
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
Rookie

Joined: Thu Sep 13, 2012 9:43 am
Posts: 47
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
Rookie

Joined: Wed Oct 24, 2012 2:51 pm
Posts: 8
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
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 6 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning