Friday, October 24, 2008

Lab Report for 10.17.2008 & 10.19.2008

On 10.17.2008, the N.M.E. design team met up to continue working on the ongoing problem with the operation of the servo. The same day we ordered our ExpressPCB boards and necessary components from Digikey and Parallax. Before our team met up to continue working on the project we had a quick meeting with Dr. Ducharme to discuss our problems that we were having with the servo. During the quick meeting he gave us very useful tips and helpful guidelines to follow during our testing on the servo.

After the meeting we continued our progress on the coding for the servo. The original plan that our group followed was using and modifying the servo demos that we’ve downloaded from the Parallax Object Exchange in the past. We were following the code coming from the Servo32v3 and Servo4 objects. Of course the servo demos would activate our servo, but it wouldn’t function the way we desired. So our first attempts to revise the code didn’t work. We went back and forth from servo demo to servo demo to try and make our servo motor turn at our desired angles for at a certain period in time. So our second option was to embed our working (demo) servo code into our main program. We already knew our servo was activating properly, so we decided “hey, since the servos working, let’s just throw it into our main code and move on from there”. But heading in that route just made our problems even bigger.

Previously in our last weeks lab testing our group successfully initialized two new cogs to run in our main program; one for the ADC and the second for the datalogger. So seeing that the main program compiled successfully, we decided to make things a little bit easier. So we went ahead and initiated a new cog for the servo to operate in, that way we could have the servo code in its own environment; since we already knew that the main program compiled well. So our main goal of the day was to run the .spin program to activate our ADC, datalogger, and servo simultaneously. But going down that path didn’t go so well either. Our main problem that our group was encountering was that the datalogger and servo wouldn’t operate simultaneously. The ADC was working successfully the whole time. As we initialized the servo the datalogger wouldn’t respond, but when we deactivated the servo the datalogger worked fine. So we all knew that the actual datalogger and servo itself were working correctly. So it had to be the code. Our group made numerous attempts to modify our .spin code. We attempted to run the whole program off one main cog, run each program in separate cogs, and even rearranged the process flow of the code. But then again our several attempts at revising the code were a failure.

Before our group lab testing on 10.17.08 & 10.19.08, our group had a hunch that maybe the servo needs to operate off a different power supply rather than the power supply coming from the Propeller board. Because we noticed that each time the servo moved its position the green LED on the Propeller board would turn on and off in relation to the activity of the servo. In another words, it seemed like each time the servo moved from angle-to-angle it would reset the whole program. Possibly because we assumed that the servo might be drawing out too much current. According to research, the GWS Pico servo can reach up to a MAX of 500 milli-amperes. So we decided to go with our hunch and give it a try. During the middle of the week our group went to the lab and continued to make the impossible, possible. Previously the servo was drawing the 5 volts coming from the Propeller board. So we connected the positive (+) and ground wire to a different power supply running at 5 volts, but we left the signal (white) to PIN2 on the propeller chip. Unfortunately, we didn’t get any successful results. The servo was still doing the same thing it was doing previously.

After our meeting with Dr. Ducharme, our group decided to start off on a clean slate with the servo. We discarded all the servo demo programs we were previously using and agreed to create our code from scratch, step-by-step. We wanted to work on the code for the servo “alone” before doing anything else (like running it with the main prog. simultaneously). Our group did our research and discovered that all servos operate by sending a pulse of variable width through the signal (control) wire. These pulses have ranges and they are: minimum pulse, maximum pulse, and repetition rate. The angle is determined by the duration of the pulse which is also known as Pulse Width Modulation. The period of the servo’s clock cycle is 20 milli-seconds. So what we had to do in order for the servo to stay at its turned angle was to send repetitive pulse signals through the signal wire. Also depending on the length of the pulse that was sent determines the increase in the motor turns. So in our code we initialized PIN2 as our output, because the signal (red) wire from the servo was connected to PIN2 on the propeller board. We calculated the delay when the servo should be on and off. So basically if the servo expects to see a pulse every 20 milli-seconds, we would turn the servo motor at an Xo angle for a Y amount of time, then leave it off for a Z amount of time so the servo can hold its position.

Our calculation we derived was:

  • The servo motor turned at Xo angle in Y amount of time

  • Then the servo motor held its position at Xo angle for a Z amount of time

  • We calculated the amount of time (delay) for Z by taking the difference of 20ms & Y.

Ex: 20ms – Y = Z

We would use this calculation in our code to get our desired angle on the servo. Since the pulse of variable width has a repetition rate, we simply just threw these delays into a loop so it would send pulse signals repeatedly in the program.

Once we got that working we attempted to try to run our servo simultaneously with our main .spin program and it did the same exact same thing as our previous attempts. So then we decided to go back to the drawing board and use another power supply, but this time we connected the red (+) wire to the different power supply at 5 volts and connected the ground (-) wire to the common ground of the Propeller board ( we did NOT do this in our previous attempt, we connected ground to the power supply). We compiled and ran the program. It was a success!

We measured the current drawing from the servo at each stroke. The range of current coming from the servo was a minimum of 200mA to a maximum of 500mA. That's a strong pico servo!


B. Justin Rosario

N.M.E. Design Team


No comments: