Parallax Standard Servo | 900-00005- Code assistance
SIIG75
Posts: 2
If anyone could help me or point me in the right direction, I need help on the code for using 2 Parallax servo motors 900-00005 on a dual axis solar tracker using 4 LDR's runing with "Audrino Uno" for a school project. I have somewhat education with learning C here at the college bu not enough and it is more in depth when it comes to using the servos and the code I currently have does not work out too well, example I am attempting to get the motors to flow with the LDR's and also trying to prevent the "pitch servo motor" going into a full 180 degree I only need it to be at 160 degree so it does not bottom out on the solar tracker frame. Again any help in the matter or a complete code using C Program since time is not on my side at the moment and project is due in 2 weeks. Thank you for your time.
Comments
These are generic R/C hobby servos that determine position by the width of the pulse. (Actually, the Parallax servos are OEM Futuba R/C servos.. good quality.)
Here is the documentation page http://www.parallax.com/product/900-00005
But you may want more background about how the servo works....
It basically holds a center position at 1.5ms width pulse, and turns clockwise or counter-clockwith if the the pulse width is increased or decreased. The direction of turn is pretty much determined by your mechanical configuration and point of reference. The pulse needs to be sent no less than 50 times a second (or every 20ms).
The extreme 90 degree positons are roughly a 1ms pulse in one direction and a 2ms pulse in the other. You might have to test a bit to verify those are good limits for your project. You can go frorm 0.75ms to 2.25ms for greater range.
Run the trial code to confirm the servo is working properly and read the trial code to confirm the timing.
http://www.josepino.com/projects/simple_sun_tracker
In C, much depends on whether you are using an Arduino or a Propeller, unless you want to use the Propelleruino library to port Arduino code to the Propeller.
The Propeller will allow any i/o pin to output PWM. But the Arduino uses AVR chips that have certain pins that must be used to get PWM output. The difference is the the Propeller generates PWM in code; and the AVR chips have circuitry in the siicon for PWM on a limited amount of pins.
One of the most interesting quotes of Kernighan and Ritche's classic text is "..., there is no input or output defined in C itself." [The C Programming Language:2nd ed -- ANSI C, c1988: page 11]
What this means is that the user has to depend on libraries (some are standard libraries, but on microcontrollers many are not-so-standard libraries) created for a specific platform to have any i/o at all. And different chips will always have different i/o resources. If you are indeed using C or C++ (which is really what the Arduino uses in a weird way), the majority of your efforts will be to learn which libaries provide the i/o you need.
I'd have to say that Arduino C++ uses libraries that are very particular to the Arduino. Propeller GCC and Catalina C are more likely to be closer to mainstread GCC. But on microcontrollers, nothing is really standard. Just knowing this is important as you really need to learn the Standard Libraries for career developement.
If you are using SPIN, the OBEX provides all the i/o code that is available.