Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Puffin Rock Characters Plush Toy Set
anil1961
Updated:
Nov 7, 2026
Toyota Vitz scp10 For Sale
Lakmal Bandara
Updated:
Nov 4, 2026
Kandy
Welcome all my all new pet shop Bark.lk
dilumrane
Updated:
Nov 2, 2026
Windows RDP Only Rs.500 a month
Blogerwiki
Updated:
Nov 1, 2026
Ad icon
V2ray VPN for Tunneling
hu KANNA
Updated:
Oct 22, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
PID arduino
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="gembaknb" data-source="post: 20633209" data-attributes="member: 515883"><p>[CODE] void loop()</p><p>{</p><p> int lastError;</p><p></p><p> // read calibrated sensor values and obtain a measure of the line position from 0 to 5000</p><p> unsigned int position = qtrrc.readLine(sensorValues);</p><p></p><p> //compute error from line position. error will be near-zero when robot is centered</p><p> //over line.</p><p></p><p> int error = position - 2460;</p><p></p><p> delay(250);</p><p></p><p> // set the motor speed based on proportional and derivative PID terms (experimentally determined)</p><p> // KP is the a floating-point proportional constant</p><p> // KD is the floating-point derivative constant</p><p></p><p> float KP = 0.05;</p><p> float KD = 2.0;</p><p></p><p> lastError = error;</p><p></p><p> int motorSpeed = KP * error + KD * (error - lastError);</p><p></p><p> //change our motor speeds based on PD calculation</p><p> int m1Speed = 100 + motorSpeed;</p><p> int m2Speed = 100 - motorSpeed;</p><p></p><p> //force motor speeds to be positive</p><p> if (m1Speed < 0)</p><p> m1Speed = 0;</p><p> if (m2Speed < 0)</p><p> m2Speed = 0;</p><p></p><p> // set motor speeds using the two motor speed variables above</p><p> digitalWrite(E1, m2Speed);</p><p> digitalWrite(E2, m1Speed);</p><p>}</p><p></p><p>[/CODE]</p><p></p><p><span style="font-size: 18px"> machan meke error eka gannawa.. ita passe laaterror=error walata.. </span></p><p><span style="font-size: 18px">Motorspeed eka ganiddi KD(error-lasterror )wenawa.. e kiyanne eeka always 0 ne bn.. ithn eeka wadak na ne.. ai bn ehema karala thiyenne?</span></p></blockquote><p></p>
[QUOTE="gembaknb, post: 20633209, member: 515883"] [CODE] void loop() { int lastError; // read calibrated sensor values and obtain a measure of the line position from 0 to 5000 unsigned int position = qtrrc.readLine(sensorValues); //compute error from line position. error will be near-zero when robot is centered //over line. int error = position - 2460; delay(250); // set the motor speed based on proportional and derivative PID terms (experimentally determined) // KP is the a floating-point proportional constant // KD is the floating-point derivative constant float KP = 0.05; float KD = 2.0; lastError = error; int motorSpeed = KP * error + KD * (error - lastError); //change our motor speeds based on PD calculation int m1Speed = 100 + motorSpeed; int m2Speed = 100 - motorSpeed; //force motor speeds to be positive if (m1Speed < 0) m1Speed = 0; if (m2Speed < 0) m2Speed = 0; // set motor speeds using the two motor speed variables above digitalWrite(E1, m2Speed); digitalWrite(E2, m1Speed); } [/CODE] [SIZE="5"] machan meke error eka gannawa.. ita passe laaterror=error walata.. Motorspeed eka ganiddi KD(error-lasterror )wenawa.. e kiyanne eeka always 0 ne bn.. ithn eeka wadak na ne.. ai bn ehema karala thiyenne?[/SIZE] [/QUOTE]
Insert quotes…
Verification
Winadiyakata thappara keeyak tibeda?
Post reply
Top
Bottom