Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: +- tolerances from a signal  (Read 344 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm running an RC tx/rx setup on my bot for motion until I get the speech rec polished for voice control. Hardware is a 3 channel RC unit (only using 2 channels though) being read by a Mega ADK board running a pair of brushed DC motors through an Adafruit Motor Shield. I've read as much as I can find online and am confident that this will work the way I want it to, mostly basing my code and setup on the tutorials from http://rcarduino.blogspot.com/2012/05/interfacing-rc-channels-to-l293d-motor.html.

I've calibrated my RC set as best I can. The 2 channels in use are throttle and turn with the following pulse values after calibration: Throttle: neutral = 1410, full ahead=1800, full brake/reverse = 1200. Turn: neutral=1400, full left = 1000, full right = 1800.

The problem: The above listed values are not solid, rather they all have a range somewhere between +- 10 and +- 20.

The question: How do I program that in? ie: For sitting at idle/stop, I am thinking I would program the equivalent of the following psuedocode:

Code:
ch1 = throttle position
read ch1
if ch1 = 1410
    motor1.run(RELEASE);
    motor2.run(RELEASE);
else
    some mapping of read value to - 255 to 255

But neutral is not always 1410. It ranges anywhere between 1400-1420 ish. Is it as simple as
if 1400<ch1<1420?

regards, Richard
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
if ((ch1 > 1400) && (ch1 < 1420)) {
  ...
}
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Brilliant, thanks.
Logged

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: