RCCanada - Canada Radio Controlled Hobby Forum - View Single Post - MonoBot: Aerial Robotics Project
View Single Post
Old 08-23-2016, 12:06 AM   #16
vaalleon
RCC Contributor
 
vaalleon's Avatar
 
I am: VAL
Join Date: Feb 2014
Location: phoenix

Feedback: 0 / 0%
Posts: 406
Total Props: 1
Re: MonoBot: Aerial Robotics Project

This is my first code solution to the servo jittering. It helped reduce jittering significantly. None of the electrical solutions seemed to work.

The problem is: the servo signal drops from 1480/90 level to as low as 1410 ish periodically, causing the servo to jitter. My current solution is to read the pulse twice in 20 milliseconds after the first reading. If the second reading is below “first reading – 10”, write the first reading. If not, write the second reading. Here is the part of the code that does that:

val = digitalRead(2); //read ir
ch1p = pulseIn(5, HIGH, 25000);
Serial.print ("ch1p: ");
Serial.println(ch1p);
delay (30);
ch1p1 = pulseIn(5, HIGH, 25000);
Serial.print ("ch1p1: ");
Serial.println(ch1p1);

if (ch1p1 < ch1p-10)
{
ch1c = ch1p;
}
else
{
ch1c = ch1p1;
}


And this is the resulting readings. As you will see, whenever there is a large drop the signal is ignored.
ch1p: First reading
ch1p1: Second reading
Channel 1: The value to be written to the servo


Channel 2:0
Channel 3:0
Channel 4:0
ch1p: 1478
ch1p1: 1429
Channel 1:1478
Channel 2:0
Channel 3:0
Channel 4:0
ch1p: 1488
ch1p1: 1488
Channel 1:1488
Channel 2:0
Channel 3:0
Channel 4:0
ch1p: 1488
ch1p1: 1488
Channel 1:1488
Channel 2:0
Channel 3:0
Channel 4:0
ch1p: 1495
ch1p1: 1494
Channel 1:1494
Channel 2:0
Channel 3:0
Channel 4:0
ch1p: 1473
ch1p1: 1436
Channel 1:1473
Channel 2:0
Channel 3:0
Channel 4:0
ch1p: 1495
ch1p1: 1495
Channel 1:1495
Channel 2:0
Channel 3:0
Channel 4:0
ch1p: 1493
ch1p1: 1495
Channel 1:1495
Channel 2:0
Channel 3:0
Channel 4:0
ch1p: 1488
ch1p1: 1487
vaalleon is offline  
vBulletin Message


Sponsored Links - Subscribe to remove this ad.