A current project Coal_Basin_Control used multiple servos. Rather than try and adjust the servos using the final firmware it would have been beneficial to have an independent servo driver/tester. Such a device could be used to (i) initially centre the servos before connecting the servo arm and other linkages, and (ii) with all linkages connected to determine the timings to give the required left and right rotaion**.
For the design a LCD with push buttons was proposed. The photo shows the LCD Keypad Shield that inserts directly into the Arduino UNO.
In the photo the three coloured wires to the lower right go to the servo under test. The Red wire goes to +5volts, the drown to 0V and the yellow or signal wire to pin 2.
To drive the servos a pulse would be supplied every 20mS. By experiment the pulse width to centre the servo corresponded to 325 counts. The proposed design on reset sets the servo timing count to 325 which corresponds to the servo rotated 90 degrees. By using either the left or right buttons the servo would be rotated either left or right with the count displayed on the screen. This way the desired left and right values could be found for each servo linkage combination.
** The servo project was written in Cpp included 12 servos. At startup twelve servo objects were created. Each object required specifying the servo timings. The cycle time to modify the program to adjust the servo count/time, compile, run and observe the results could be quite large depending upon the number of iterations required. Hence the need for this project.
---------------------------------------------------------
The program uses the two libraries Servo.h and LiquidCrystal.h that are available in the Arduino IDE. The Servo object myservo does not require any parameters** while the LiquidCrystal lcd object specifies the wirings for the Arduino interface.
The keys on the keypad are wired to a resistor chain with one side of each push button key going to the junction between each resistor. On the other side they are wired to the A0 pin of the Arduino. The analog input will then depend upon which key is pressed. The Arduino ADC has a resolution of 1023 so if the reading is 50 this is close to zero and the RIGHT key has been pressed A reading between 50 and 450 implies the LEFT key while between 450 and 650 implies the DOWN key which is used to centre the servo.
//Keypad Shield_Servo.ino** Parenthesis should not be used to create objects without parameters. That is use Servo myservo rather than Servo myservo( ). With parenthesis the complier will not complain at that point but will find an error elsewhere in the code. (The compiler treats myservo( ) as a function). The servo wiring is then specified with the attach function/method. In this example pin 2.
__________________________________________
Initially the following code was used to set an unloaded servo moving from 0 to 180 degrees and return**.
void loop( ) {** To avoid driving the servos to their stops and possibly damaging it the servos should be unloaded.
-----------------------------------------------------------------
The Servo Tester was used with the Coal_Basin_Control project. Initially the tester output was centred. The LEFT and RIGHT keys were used to adjust the final left and right servo positions. These should be adjusted so that the points are firmly at their limits but not so firm that the servos are still trying to force the points further**. The left and right readings should be noted and added to the servo constructor in the Coal_Basin_Control project.
** Note the Arduino has only a limited 5V supply. If a servo is driven too hard the voltage will drop and the LCD screen will fade. This is a sure sign that the servo is being over driven and the settings wound back until at least the LCD is full brightness.
---------------------------------------