Components and supplies
Arduino Nano R3
Board-To-Board Connector, 1 Contacts
SparkFun Solder-able Breadboard - Mini
Tools and machines
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
all_in_one.ino
arduino
copy on nano board
1/* 2rear Steering and fpv cam controller with blinker and rear light for cheap 3ch radio trasmitters without any mix functions. 3 4I used an inexpensive nano board v3 5the pins used are VIN(+)and GND(-) 6you can feed the power from your speed controller bec or by an external bec circuit, check your servo max voltage. 7 8the pins I used are: 9pin D7 throttle signal input. 10pin D8 front steering input signal. D10 rear steering signal output. 11pin D9 aux signal input 12pin D4 D5 blinking leds 13pin D6 brake rev led light 14pin D3 dazzling maxspeed light 15pin D10 output steering rear servo 16pin D11 output fpv cam rotating servo. 17----------------------------------------- 18basic setup instructions: 19first you must get the best mechanical setup of your front and rear servos, best adjusting link rod best without subtrims and radio adjustements. 20the values you find by default should make the controller work quite right away. 21however if you want to be sure about your real values about your radio signal inputs check them before starting this sketch. 22to check values send by thr str aux channels you must create a new tab in arduino.ide and check your input signals with the serial monitor using this program below 23(number 7 is for steering - 8 for throttle - 9 for aux) you must load and launch 3 times, one for each value to check. 24 25int rxpulse; 26void setup () { 27Serial.begin (9600); 28} 29void loop () { 30rxpulse = pulseIn (7, HIGH); // - 7 to know true front steering signal range, 8 throttle, 9 aux 31Serial.println (rxpulse); 32 33you can read the values in the serial monitor by turning the steering wheel of the radio control or moving the throttle. 34write the values obtained from your rx and fill the first part of the controller setup, replace the default ones with yours custom values send by transmitter. 35-------------------------------------------------- ------ 36the user driving setup consists of 2 functions: 37you can choose how much throttle allow at low speed before the width of the rear servo starts to close (Speedlimit function). 38 39the second function allows you to determine the rear servo width at maximum throttle (Max_gain). 40you can choose to close rear steering completely or leave a limitate width available to turn with 4 steering wheels even at maximum speed. 41 42servo cam setup: basically with a 3ch cheap radio aux channel is an on-off interrupt. 43aux function 1 set servo cam in fix streight front position and you can set fix angle cam direction to adjust your best visual. 44aux function 2 set servo moving by copy steering and you can adjust travel endpoint camsx damdx for max 180 rotation. 45also you can adjust centering for moving position in a different visual angle respect function 1 fix position. 46 47 48both tolerances are used to cutoff vibrations and servo tremors. 49 50led setup: 51 52Blinkpoint: allow value steering travel where direction led start to blink. 53Streight: is used to define steering center position just for blinking led light. can be the same of center value of your transmitter but somethimes you must add small corrections if steering center is not set to 1500 or if you have add some center correction. 54 55rearstart: allow to decide reverse value where brake light start on. 56---------- 57troubleshooting: 58somethimes it can happen that you exceed with the max values and the steering direction and it result inverted, be careful to find the best suitable max values for your model. 59to get the servo reversed you just have to exchange the Postsx Postdx rear steering values and put a sign (-) in front of the Max_gain value 60there is a relationship between Slowlimit, Max_gain and rear endpoints, so it can happen that if you lower one value you will have to raise the others or center again wheels centering. 61particular model assembly situation give throttle stick in reverse position values, so max thr will be 1000 and min 2000. 62in this situation you must check instructions in program line (Gaspulse > Slowlimit) read grey notes about. 63inside "loop" in normal RC condition there is nothing really important to modify, just fill all define values numbers and load your setup to nano. 64I have written all default values in grey notes, helpful if you wrong some. 65however I am sure that it will be easy to understand how all controller works 66 67*/ 68 69//----------- signal setup ------------------------------------- 70#define Neutral 1500 // -- default 1500//minimum throttle forward signal or neutral position 71#define Maxspeed 2000 // -- default 2000//maximum throttle forward signal 72#define Antsx 1000 // -- default 1000//in front servo signal sx 73#define Antdx 2000 // -- default 2000//in front servo signal dx 74 75 76//----------- rear servo setup ------------------------------- 77#define Postsx 1000 //-- default 1000//out rear servo sx end point (if inverted with postdx it reverse) 78#define Postdx 2000 //-- default 2000//out rear servo dx endpoint (if inverted with postsx it reverse) 79#define Center 0 //-- default 0//add or subtract your value to center steering (+- 50 or more) 80 81 82//--------- user driving setup ------------------------------ 83#define Max_gain 400 //-- default 400//gain steering reduction width at max throttle (if work reverse add (-) before value) 84#define Slowlimit 1600 //-- default 1600//slow forward percentage without endpoint correction 85 86 87 88//------------ servo cam setup ------------------------------ 89#define tolerance 4 //-- default 4//servo cam vibration cutoff 90#define front 0 //-- default 0//servo cam front centering in moving aux position 91#define Camsx 5 //--default 5// servo cam endpoint sx (reverse with camdx) 92#define Camdx 175//-- default 175// servo cam endpoint dx (reverse with camsx) 93#define fix 1500 //-- default 1500//servo cam front centering in fix aux position 94 95 96//-------------led setup ------------------------------------ 97#define Streight 1500 //-- default 1500//neutral signal steering centered position for blinking arrow light 98#define Blinkpoint 200 //-- default 300//steering value where led start to blink. 99#define rearstart 1400 //-- default 1300// reverse gear light start at 1300 100 101//----------------------------------------- program part, nothing to do here --------------- 102 103#include <Servo.h> 104Servo myservo; 105Servo camservo; 106#define N_STST 7 // default 7//rear steering vibration cutoff 107unsigned int stSt[ N_STST ]; 108long toStSt = 0; 109int inSt = 0; 110int Tol = 0; 111unsigned int auxpulse; 112unsigned int Rxpulse; 113unsigned int Gaspulse; 114unsigned int Gain; 115unsigned int NewPos, OldPos; 116unsigned int newloc, oldloc; 117unsigned int Centerpos = fix ; 118int led1 = 4; 119int led2 = 5; 120int led3 = 6; 121int led4 = 3; 122void setup() { 123for ( int i=0; i<N_STST; i++ ) stSt[ i ] = 0; 124 125myservo.attach(10); //-- rear servo signal out pin 10 126pinMode(8, INPUT); //-- front servo signal in pin 8 127pinMode(7, INPUT); //-- throttle signal in pin 7 128camservo.attach(11); //-- cam servo out pin 11 129pinMode(9, INPUT); //--aux servo signal in pin 9 130pinMode(led1, OUTPUT); //--led blinker dx out pin 4 131pinMode(led2, OUTPUT); //--led blinker sx out pin 5 132pinMode(led3, OUTPUT); //--led retro brake out pin 6 133pinMode (led4, OUTPUT); //-- led maxspeed out pin 3 134} 135void loop(){ 136auxpulse = pulseIn(9, HIGH); 137Gaspulse = pulseIn(7, HIGH); 138 noInterrupts(); 139Rxpulse = pulseIn(8, HIGH); 140interrupts(); 141delay(5); 142if (Gaspulse > Slowlimit){ //-- default >// if your throttle signal is reversed must change "<" 143Gain = map(Gaspulse, Slowlimit, Maxspeed, 0, Max_gain ); 144NewPos = map(Rxpulse, Antsx, Antdx, (Postsx + Gain), (Postdx - Gain)); 145} 146else{ 147NewPos = map(Rxpulse, Antsx, Antdx, Postsx, Postdx); 148} 149if (abs(NewPos - OldPos)> Tol){ 150OldPos = NewPos; 151myservo.write(NewPos + Center);} 152 153//-- led part ---------- 154 if (RXpulse > Streight+Blinkpoint) {digitalWrite(led1, (millis() / 100) % 2); //--default 100// this is led blink speed 155 156 }else digitalWrite(led1, LOW); 157if (Rxpulse < Streight-Blinkpoint){ digitalWrite(led2, (millis() / 100) % 2); //--default 100// this is led blink speed 158 159} else digitalWrite(led2, LOW); 160 161if (Gaspulse < rearstart){digitalWrite(led3,HIGH); 162 163}else digitalWrite(led3, LOW); 164if (Gaspulse > Maxspeed-100){digitalWrite(led4,HIGH); //-- default 100// higher values start light before maxspeed limit 165 166}else digitalWrite(led4, LOW); 167 168//-- aux cam part ---------- 169 170 171if (auxpulse > 1600){//--default > 1600// define and change aux position 172camservo.write(fix); 173delay (4); 174 175}else { 176 newloc = map(pulseIn(8, HIGH),Antsx,Antdx,Camsx,Camdx); 177 178 179if(abs(newloc - oldloc) > tolerance){ 180oldloc = newloc; 181camservo.write(newloc + front); 182} 183} 184} 185
all_in_one.ino
arduino
copy on nano board
1/* 2rear Steering and fpv cam controller with blinker and rear light 3 for cheap 3ch radio trasmitters without any mix functions. 4 5I used an inexpensive 6 nano board v3 7the pins used are VIN(+)and GND(-) 8you can feed the power 9 from your speed controller bec or by an external bec circuit, check your servo max 10 voltage. 11 12the pins I used are: 13pin D7 throttle signal input. 14pin 15 D8 front steering input signal. D10 rear steering signal output. 16pin D9 aux signal 17 input 18pin D4 D5 blinking leds 19pin D6 brake rev led light 20pin D3 dazzling 21 maxspeed light 22pin D10 output steering rear servo 23pin D11 output fpv cam rotating 24 servo. 25----------------------------------------- 26basic setup instructions: 27 28first you must get the best mechanical setup of your front and rear servos, 29 best adjusting link rod best without subtrims and radio adjustements. 30the values 31 you find by default should make the controller work quite right away. 32however 33 if you want to be sure about your real values about your radio signal inputs check 34 them before starting this sketch. 35to check values send by thr str aux channels 36 you must create a new tab in arduino.ide and check your input signals with the serial 37 monitor using this program below 38(number 7 is for steering - 8 for throttle 39 - 9 for aux) you must load and launch 3 times, one for each value to check. 40 41int 42 rxpulse; 43void setup () { 44Serial.begin (9600); 45} 46void loop () { 47rxpulse 48 = pulseIn (7, HIGH); // - 7 to know true front steering signal range, 8 throttle, 49 9 aux 50Serial.println (rxpulse); 51 52you can read the values in the serial 53 monitor by turning the steering wheel of the radio control or moving the throttle. 54write 55 the values obtained from your rx and fill the first part of the controller setup, 56 replace the default ones with yours custom values send by transmitter. 57-------------------------------------------------- 58 ------ 59the user driving setup consists of 2 functions: 60you can choose how 61 much throttle allow at low speed before the width of the rear servo starts to close 62 (Speedlimit function). 63 64the second function allows you to determine the rear 65 servo width at maximum throttle (Max_gain). 66you can choose to close rear steering 67 completely or leave a limitate width available to turn with 4 steering wheels even 68 at maximum speed. 69 70servo cam setup: basically with a 3ch cheap radio aux channel 71 is an on-off interrupt. 72aux function 1 set servo cam in fix streight front position 73 and you can set fix angle cam direction to adjust your best visual. 74aux function 75 2 set servo moving by copy steering and you can adjust travel endpoint camsx damdx 76 for max 180 rotation. 77also you can adjust centering for moving position in a 78 different visual angle respect function 1 fix position. 79 80 81both tolerances 82 are used to cutoff vibrations and servo tremors. 83 84led setup: 85 86Blinkpoint: 87 allow value steering travel where direction led start to blink. 88Streight: is 89 used to define steering center position just for blinking led light. can be the 90 same of center value of your transmitter but somethimes you must add small corrections 91 if steering center is not set to 1500 or if you have add some center correction. 92 93rearstart: 94 allow to decide reverse value where brake light start on. 95---------- 96troubleshooting: 97 98somethimes it can happen that you exceed with the max values and the steering 99 direction and it result inverted, be careful to find the best suitable max values 100 for your model. 101to get the servo reversed you just have to exchange the Postsx 102 Postdx rear steering values and put a sign (-) in front of the Max_gain value 103there 104 is a relationship between Slowlimit, Max_gain and rear endpoints, so it can happen 105 that if you lower one value you will have to raise the others or center again wheels 106 centering. 107particular model assembly situation give throttle stick in reverse 108 position values, so max thr will be 1000 and min 2000. 109in this situation you 110 must check instructions in program line (Gaspulse > Slowlimit) read grey notes about. 111inside 112 "loop" in normal RC condition there is nothing really important to modify, just 113 fill all define values numbers and load your setup to nano. 114I have written all 115 default values in grey notes, helpful if you wrong some. 116however I am sure that 117 it will be easy to understand how all controller works 118 119*/ 120 121//----------- 122 signal setup ------------------------------------- 123#define Neutral 1500 // -- 124 default 1500//minimum throttle forward signal or neutral position 125#define Maxspeed 126 2000 // -- default 2000//maximum throttle forward signal 127#define Antsx 1000 128 // -- default 1000//in front servo signal sx 129#define Antdx 2000 // -- default 130 2000//in front servo signal dx 131 132 133//----------- rear servo setup ------------------------------- 134#define 135 Postsx 1000 //-- default 1000//out rear servo sx end point (if inverted with postdx 136 it reverse) 137#define Postdx 2000 //-- default 2000//out rear servo dx endpoint 138 (if inverted with postsx it reverse) 139#define Center 0 //-- default 0//add or 140 subtract your value to center steering (+- 50 or more) 141 142 143//--------- user 144 driving setup ------------------------------ 145#define Max_gain 400 //-- default 146 400//gain steering reduction width at max throttle (if work reverse add (-) before 147 value) 148#define Slowlimit 1600 //-- default 1600//slow forward percentage without 149 endpoint correction 150 151 152 153//------------ servo cam setup ------------------------------ 154#define 155 tolerance 4 //-- default 4//servo cam vibration cutoff 156#define front 0 //-- 157 default 0//servo cam front centering in moving aux position 158#define Camsx 5 //--default 159 5// servo cam endpoint sx (reverse with camdx) 160#define Camdx 175//-- default 161 175// servo cam endpoint dx (reverse with camsx) 162#define fix 1500 //-- default 163 1500//servo cam front centering in fix aux position 164 165 166//-------------led 167 setup ------------------------------------ 168#define Streight 1500 //-- default 169 1500//neutral signal steering centered position for blinking arrow light 170#define 171 Blinkpoint 200 //-- default 300//steering value where led start to blink. 172#define 173 rearstart 1400 //-- default 1300// reverse gear light start at 1300 174 175//----------------------------------------- 176 program part, nothing to do here --------------- 177 178#include <Servo.h> 179Servo 180 myservo; 181Servo camservo; 182#define N_STST 7 // default 7//rear steering vibration 183 cutoff 184unsigned int stSt[ N_STST ]; 185long toStSt = 0; 186int 187 inSt = 0; 188int Tol = 0; 189unsigned int 190 auxpulse; 191unsigned int Rxpulse; 192unsigned int Gaspulse; 193unsigned 194 int Gain; 195unsigned int NewPos, OldPos; 196unsigned int newloc, oldloc; 197unsigned 198 int Centerpos = fix ; 199int led1 = 4; 200int led2 = 5; 201int led3 = 6; 202int 203 led4 = 3; 204void setup() { 205for ( int i=0; i<N_STST; i++ ) stSt[ i ] = 0; 206 207myservo.attach(10); 208 //-- rear servo signal out pin 10 209pinMode(8, INPUT); //-- front servo signal 210 in pin 8 211pinMode(7, INPUT); //-- throttle signal in pin 7 212camservo.attach(11); 213 //-- cam servo out pin 11 214pinMode(9, INPUT); //--aux servo signal in pin 9 215pinMode(led1, 216 OUTPUT); //--led blinker dx out pin 4 217pinMode(led2, OUTPUT); //--led blinker 218 sx out pin 5 219pinMode(led3, OUTPUT); //--led retro brake out pin 6 220pinMode 221 (led4, OUTPUT); //-- led maxspeed out pin 3 222} 223void loop(){ 224auxpulse = 225 pulseIn(9, HIGH); 226Gaspulse = pulseIn(7, HIGH); 227 noInterrupts(); 228Rxpulse 229 = pulseIn(8, HIGH); 230interrupts(); 231delay(5); 232if (Gaspulse > Slowlimit){ 233 //-- default >// if your throttle signal is reversed must change "<" 234Gain 235 = map(Gaspulse, Slowlimit, Maxspeed, 0, Max_gain ); 236NewPos = map(Rxpulse, Antsx, 237 Antdx, (Postsx + Gain), (Postdx - Gain)); 238} 239else{ 240NewPos = map(Rxpulse, 241 Antsx, Antdx, Postsx, Postdx); 242} 243if (abs(NewPos - OldPos)> Tol){ 244OldPos 245 = NewPos; 246myservo.write(NewPos + Center);} 247 248//-- led part ---------- 249 250 if (RXpulse > Streight+Blinkpoint) {digitalWrite(led1, (millis() / 100) % 2); //--default 251 100// this is led blink speed 252 253 }else digitalWrite(led1, 254 LOW); 255if (Rxpulse < Streight-Blinkpoint){ digitalWrite(led2, (millis() / 100) 256 % 2); //--default 100// this is led blink speed 257 258} else digitalWrite(led2, 259 LOW); 260 261if (Gaspulse < rearstart){digitalWrite(led3,HIGH); 262 263}else 264 digitalWrite(led3, LOW); 265if (Gaspulse > Maxspeed-100){digitalWrite(led4,HIGH); 266 //-- default 100// higher values start light before maxspeed limit 267 268}else 269 digitalWrite(led4, LOW); 270 271//-- aux cam part ---------- 272 273 274if (auxpulse 275 > 1600){//--default > 1600// define and change aux position 276camservo.write(fix); 277delay 278 (4); 279 280}else { 281 newloc = map(pulseIn(8, HIGH),Antsx,Antdx,Camsx,Camdx); 282 283 284if(abs(newloc 285 - oldloc) > tolerance){ 286oldloc = newloc; 287camservo.write(newloc + front); 288} 289} 290} 291
Downloadable files
schematics fritzing
schematics fritzing
schematics fritzing
schematics fritzing
schematics
you can also add the LED pins to the breadboard. all the servos and the speed regulator go plugged to breadboard pins, only 3 plugs come out of the controller which must be connected to the radio receiver. the breadboard offers the possibility to bypass the 3 rc channels without having to cut the wires to pick up the signals.
schematics
Comments
Only logged in users can leave comments
wrighi
0 Followers
•0 Projects
Table of contents
Intro
0
0