Answers.Body: <p>According to <a href="https://bricks.stackexchange.com/users/550/philo">Philo</a>'s <a href="http://philohome.com/pfservo/pfservo.htm" rel="nofollow noreferrer">detailed analysis</a> of the servomotor, it takes its commands from the C lines but needs to be powered as well:</p>
  
  <blockquote>
    <p>Being a Power Functions range member, it is fully integrated with this system, and receives its commended position through C1/C2 lines, and its power from supply lines. On a normal motor, C1/C2 duty cycle directly control motor speed, here they set the angular position of the shaft.</p>
  </blockquote>
  
  <p>This makes sense since there's electronics involved and these need to be powered by a regular, reliable power supply which is exactly the purpose of the +9V and Ground wires. The same holds for the IR receiver (although that one ignores the C1/C2 lines completely).</p>
  
  <p>For more information on the PF wiring, you should also check Philo's <a href="http://philohome.com/pf/pf.htm" rel="nofollow noreferrer">presentation of the Power Functions system</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-02-21T22:27:08.913Z
Answers.Text: I did a bit more reading and most servo motors are a three wire affair and that's what got me thinking I was missing a wire. I didn't add my pin wires to all 4 wires on the pf connector because for all the other motors they are not used and they just get in the way. Luckily I had parts to make a new connector . . . although RIP to one of my Lego LEDs :(. And these links are wonderful reads I hadn't seen before so thanks!
Answers.UserDisplayName: tooshel
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-02-22T09:42:17.600Z
Answers.Text: Just a thought, you may want to sacrifice extension cables instead of leds.
Answers.UserDisplayName: Joubarc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-02-22T19:46:06.293Z
Answers.Text: Oh, I've sacrificed plenty of extension cables . . . but I ran out! And not even the Lego Store carries them.
Answers.UserDisplayName: tooshel
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-10T01:44:49.917Z
Answers.Text: @tooshel necro-comment: the Lego Store seems to carry [extension cables](http://shop.lego.com/en-US/LEGO-Power-Functions-Extension-Wire-8886) now at a somewhat reasonable price compared to normal Lego prices.. I don't feel too bad about cutting one of them up as I get two usable wires out of each
Answers.UserDisplayName: user2813274
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-02-21T19:03:31.240Z
Answers.LastActivityDate: 2013-02-21T19:03:31.240Z
Answers.LastEditDate: 2017-04-13T12:47:56.390Z
Answers.UserDisplayName: Joubarc
Answers.Body: <p>Turns out the problem is that Servo motors need at least THREE wires. Two for the PWM and one for full power. I made a new connector (and I can attach a picture if anyone is interested . . . just don't have one handy right now) that had all four of the wires from the Lego brick connected to breadboarding pins and then I wired the two new wires to +9 and ground. That did the trick! As soon as it powered up I could hear the servo motor moving to center. Then, I sent pulses with the Arduino and I once again had control of the steering!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-18T04:33:58.573Z
Answers.Text: How did you end up sending the pulses? I couldn't get the servo to respond to neither `analogWrite()` nor the Servo library's `write()`. From some Googling, I got the impression that this is because Arduino's built-in PWM frequency is 500 Hz while the PF servo expects 1150 Hz. I'll try "manual" PWM to get the frequency that's needed. Also, it's still not clear to me whether the PWM is on both C1 and C2 or just on whichever is not LOW.
Answers.UserDisplayName: Ates Goral
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-19T17:06:44.783Z
Answers.Text: @AtesGoral Wow! It's been a long time since I looked at this. All of my code is on github if that helps. https://github.com/tooshel/androdino/tree/master/arduino Another notable problem I had was the 9 volts from the Lego power pack would end up as about 6 volts by the time it went though the Arduino Motor Shield so I had to rig up an extra Lego power pack with only 3 batteries and aluminum foil for the other three, and make another custom cable that put the two batter packs in serial. Yeah, it was crazy. Thank goodness for sbrick!
Answers.UserDisplayName: tooshel
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-19T17:42:40.947Z
Answers.Text: Oh my goodness! I hadn't heard about SBrick. I think I'm going to order one soon :) In the meantime, I'm still trying to solve my problem with Arduino because I'm basically doing it as an electronics learning exercise instead of powering up an actual model. I'll see if the voltage drop is the cause of the problem. Thanks!
Answers.UserDisplayName: Ates Goral
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-02-21T17:47:59.787Z
Answers.LastActivityDate: 2013-02-21T17:47:59.787Z
Answers.UserDisplayName: tooshel
Body: <p>I have a Arduino motor shield connected to XL, L and M motors and can control the speed with PWM (Pulse Width Modulation). I made my own connector by cutting a Lego PF connector in half and wiring up the two inner connectors to "pins" that are easy to connect to a breadboard.</p>
  
  <p>When I connect those two pins to the PF Servo Motor that comes with the Crawler, well, nothing happens no matter what pulse I send (Arduino handles the pulses . . I just set a "direction" pin and a value between 0 and 255 . . . and PWM or not the net effect is that with a voltmeter you see voltages between about -9 Volts and 9 volts, same as when you measure from the IR receiver).</p>
  
  <p>Anyway, what am I missing? What is different about PWM on a servo motor?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-02-20T20:34:10.990Z
Comments.Text: That doesn't quite seem as a real question so far... (but I'm fairly confident you can reformulate once you have the answer)
Comments.UserDisplayName: Joubarc
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-02-20T23:26:35.153Z
Comments.Text: Sorry man I was in a rush! Panic! I'll fix it after my presentation tonight. And, I do have the answer so I'll post that too. Sometimes in asking the question and having to think about it you come up with the answer on your own.
Comments.UserDisplayName: tooshel
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-02-21T07:57:31.853Z
Comments.Text: Well [it's ok to ask and answer your own question](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/) but you'll certainly want to rewrite the question so that it looks like one.
Comments.UserDisplayName: Joubarc
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-02-21T17:51:34.310Z
Comments.Text: @Joubarc Okay, it's fixed. You can further change it if you want (you're a moderator!) but if you have other suggestions I'll fix it further. And I should add some pictures . . . describing these things is difficult and a picture would make it way easier. I just hope this kind of question is relevant here . . . I was going to post in the electronics SE too but figured it out before I got to that.
Comments.UserDisplayName: tooshel
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-02-21T18:54:24.623Z
Comments.Text: Editing questions to make them better isn't limited to moderators, quite the contrary - everyone is welcome to contribute in that way, too. That said, the question & answer looks fine to me now.
Comments.UserDisplayName: Joubarc
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2013-02-21T22:21:39.263Z
Comments.Text: @Joubarc And you STILL added your own answer! You are all over the place! Of course your answer is good too and adds great links. And the graphics from that site are perfect.
Comments.UserDisplayName: tooshel
Tags: <motor><electronics><arduino>
Title: Is the PWM on the PF Servo motor different than the PWM from an Arduino?
UserDisplayName: tooshel
ThreadText: # Is the PWM on the PF Servo motor different than the PWM from an Arduino?
  
  (Asked by: username_0 on 2013-02-20)
  
  I have a Arduino motor shield connected to XL, L and M motors and can control the speed with PWM (Pulse Width Modulation). I made my own connector by cutting a Lego PF connector in half and wiring up the two inner connectors to "pins" that are easy to connect to a breadboard.
  
  When I connect those two pins to the PF Servo Motor that comes with the Crawler, well, nothing happens no matter what pulse I send (Arduino handles the pulses . . I just set a "direction" pin and a value between 0 and 255 . . . and PWM or not the net effect is that with a voltmeter you see voltages between about -9 Volts and 9 volts, same as when you measure from the IR receiver).
  
  Anyway, what am I missing? What is different about PWM on a servo motor?
  
  **Tags:** motor, electronics, arduino
  
  > **Comments:**
  > **username_1**: That doesn't quite seem as a real question so far... (but I'm fairly confident you can reformulate once you have the answer)  
  > **username_0**: Sorry man I was in a rush! Panic! I'll fix it after my presentation tonight. And, I do have the answer so I'll post that too. Sometimes in asking the question and having to think about it you come up with the answer on your own.  
  > **username_1**: Well [it's ok to ask and answer your own question](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/) but you'll certainly want to rewrite the question so that it looks like one.  
  > **username_0**: @username_1 Okay, it's fixed. You can further change it if you want (you're a moderator!) but if you have other suggestions I'll fix it further. And I should add some pictures . . . describing these things is difficult and a picture would make it way easier. I just hope this kind of question is relevant here . . . I was going to post in the electronics SE too but figured it out before I got to that.  
  > **username_1**: Editing questions to make them better isn't limited to moderators, quite the contrary - everyone is welcome to contribute in that way, too. That said, the question & answer looks fine to me now.  
  > **username_0**: @username_1 And you STILL added your own answer! You are all over the place! Of course your answer is good too and adds great links. And the graphics from that site are perfect.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2013-02-21. Score: 5
  
  According to [Philo](https://bricks.stackexchange.com/users/550/philo)'s [detailed analysis](http://philohome.com/pfservo/pfservo.htm) of the servomotor, it takes its commands from the C lines but needs to be powered as well:
  
  > Being a Power Functions range member, it is fully integrated with this system, and receives its commended position through C1/C2 lines, and its power from supply lines. On a normal motor, C1/C2 duty cycle directly control motor speed, here they set the angular position of the shaft.
  
  This makes sense since there's electronics involved and these need to be powered by a regular, reliable power supply which is exactly the purpose of the +9V and Ground wires. The same holds for the IR receiver (although that one ignores the C1/C2 lines completely).
  
  For more information on the PF wiring, you should also check Philo's [presentation of the Power Functions system](http://philohome.com/pf/pf.htm).
  
  > **Comments:**
  > **username_0**: I did a bit more reading and most servo motors are a three wire affair and that's what got me thinking I was missing a wire. I didn't add my pin wires to all 4 wires on the pf connector because for all the other motors they are not used and they just get in the way. Luckily I had parts to make a new connector . . . although RIP to one of my Lego LEDs :(. And these links are wonderful reads I hadn't seen before so thanks!  
  > **username_1**: Just a thought, you may want to sacrifice extension cables instead of leds.  
  > **username_0**: Oh, I've sacrificed plenty of extension cables . . . but I ran out! And not even the Lego Store carries them.  
  > **username_2**: @username_0 necro-comment: the Lego Store seems to carry [extension cables](http://shop.lego.com/en-US/LEGO-Power-Functions-Extension-Wire-8886) now at a somewhat reasonable price compared to normal Lego prices.. I don't feel too bad about cutting one of them up as I get two usable wires out of each  
  
  ---
  
  ### Answer by username_0 on 2013-02-21. Score: 4
  
  Turns out the problem is that Servo motors need at least THREE wires. Two for the PWM and one for full power. I made a new connector (and I can attach a picture if anyone is interested . . . just don't have one handy right now) that had all four of the wires from the Lego brick connected to breadboarding pins and then I wired the two new wires to +9 and ground. That did the trick! As soon as it powered up I could hear the servo motor moving to center. Then, I sent pulses with the Arduino and I once again had control of the steering!
  
  > **Comments:**
  > **username_3**: How did you end up sending the pulses? I couldn't get the servo to respond to neither `analogWrite()` nor the Servo library's `write()`. From some Googling, I got the impression that this is because Arduino's built-in PWM frequency is 500 Hz while the PF servo expects 1150 Hz. I'll try "manual" PWM to get the frequency that's needed. Also, it's still not clear to me whether the PWM is on both C1 and C2 or just on whichever is not LOW.  
  > **username_0**: @username_3 Wow! It's been a long time since I looked at this. All of my code is on github if that helps. https://github.com/username_0/androdino/tree/master/arduino Another notable problem I had was the 9 volts from the Lego power pack would end up as about 6 volts by the time it went though the Arduino Motor Shield so I had to rig up an extra Lego power pack with only 3 batteries and aluminum foil for the other three, and make another custom cable that put the two batter packs in serial. Yeah, it was crazy. Thank goodness for sbrick!  
  > **username_3**: Oh my goodness! I hadn't heard about SBrick. I think I'm going to order one soon :) In the meantime, I'm still trying to solve my problem with Arduino because I'm basically doing it as an electronics learning exercise instead of powering up an actual model. I'll see if the voltage drop is the cause of the problem. Thanks!  
  
  ---
  
  