Answers.Body: <p>The answer to the question you linked contains the answer you are looking for:</p>
  
  <blockquote>
    <ul>
    <li>To move in one direction, send a PWM signal (1200 Hz, 0 to 100% duty cycle) on C1 and keep C2 at GND level. As duty cycle varies, servo motor will move along 7 positions on one side. See this video.</li>
    <li>To move in the other direction and reach the 7 other positions, send PWM to C2 and keep C1 at ground level.</li>
    </ul>
  </blockquote>
  
  <p>PWM means <a href="https://en.wikipedia.org/wiki/Pulse-width_modulation" rel="nofollow">Pulse Width Modulation</a>, so you need something capable of generating this signal. The voltage is the same as what you apply to the 9V terminal. Only the pulse width is varied. And GND means "ground" which is another way of saying 0V.</p>
  
  <p>So, to do this with a Raspberry Pi or other microcontroller, you will need a transistor to convert the voltage. There is virtually no load on C1/C2 in this case, so any size of transistor will do the job without risk of overload. See <a href="http://www.elinux.org/RPi_GPIO_Interface_Circuits#Output_circuits" rel="nofollow">this page</a> for some example circuits.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-08T19:49:38.083Z
Answers.Text: Not seeing the source for the fact that the PWM signal is 9v, and having the signal voltage at the same level as the motor voltage would be something quite unusual - have you tested it with 9v and it worked? have you looked at the c1/c2 lines under an oscilloscope to verify the voltage levels from a standard lego controller?
Answers.UserDisplayName: user2813274
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-09T00:50:17.213Z
Answers.Text: Yes, it is unusual and yes I have looked at it with an oscilloscope. On other power functions motors, C1 and C2 are actually used to drive the motor itself and the 9V and GND pins are not used at all. So, of course, C1 and C2 are full battery voltage since they power the motor. The servo motor just takes advantage of this existing mechanism as a means of transmitting a variable signal from the controller to the motor.
Answers.UserDisplayName: David Lechner
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-08T17:48:47.153Z
Answers.LastActivityDate: 2015-09-08T17:48:47.153Z
Answers.UserDisplayName: David Lechner
Answers.Body: <p>The C1 and C2 lines are either connected to the 9V power supply or grounded because they directly drive classic PF motors and are not just used to carry commands. The 9V and GND poles also need to be properly connected because the PF servo will draw power from those.</p>
  
  <p>To drive <strong>any</strong> LEGO Power Functions motor using a single-board computer (Pi / BeagleBone / Arduino), the easiest way is to use an H-bridge Integrated Circuit, which will safely separate the SBC (3.3V or 5V) from the high-power stuff (9V motors). There are readily-made circuit boards which are easy to interface with an SBC on e.g. <a href="http://dx.com" rel="nofollow">dx.com</a> or <a href="http://aliexpress.com" rel="nofollow">aliexpress</a>.</p>
  
  <p>Don't drive LEGO PF motors with the output of your SBC directly or you may very well fry it, because motors will draw too much current.</p>
  
  <p>I successfully used <a href="http://www.dx.com/p/navo-l298n-stepper-driver-and-power-supply-module-wi-fi-motor-drive-controller-module-board-yellow-294341" rel="nofollow">this L298N-based circuit board</a> to drive up to 4 PF motors at any speed in both directions with a Beaglebone Black. It can accept 3.3V commands directly but the PWM output from the SBC better be level-shifted to 5V so that the duty cycle is really respected.
  You can use <a href="http://www.dx.com/p/jy-mcu-5v-3v-iic-uart-spi-level-4-way-converter-module-adapter-178286" rel="nofollow">something like this</a> to shift the voltage.
  The board also features a 5V power source so you can power the SBC from it using only LEGO battery boxes.</p>
  
  <p>This H-brige module accepts 3 inputs per motor:</p>
  
  <ul>
  <li>forward</li>
  <li>barckward</li>
  <li>enable</li>
  </ul>
  
  <p><code>forward</code>/<code>backward</code> inputs of the control module can be tied to ON/OFF outputs of the GPIO and the <code>enable</code> input to a PWM output of the GPIO. The duty cycle of the PWM can then be used to control the speed of a classic PF motor, or the angle of a PF servo motor, while <code>forward</code>/<code>backward</code> will control the direction (enabling both will result in braking the motor).</p>
  
  <p>Note that you'll have to be carefull with the outputs of the RPi as those are open-collector outputs, so don't fry your SBC. Arduino and Beaglebone are easier to use.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-10T20:04:48.760Z
Answers.Text: Thanks for the clarification - I have looked at the level converter boards, but I didn't see any that go all the way up to 9v, 5v or 5.5v seems to be the common stopping point, and I imagine that the servo would still work with mostly drained li-ion batteries (2s ~ 6v or so) - any idea what the lower bound of the input voltage is like?
Answers.UserDisplayName: user2813274
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-11T06:53:13.527Z
Answers.Text: Level converters are for converting logic levels, not for converting low-current commands to drive a load. That's what H-bridges are for. So the circuit you are looking for is an H-bridge. The L298N I used expects 5V TTL inputs, but the input is considered high from 2.5V on so they can be driven with 3.3V outputs and this normally wouldn't need level converters. However I found that the PWM ouputs of the Beaglebone were not clean, so the amount of time the signal is above 2.5V does not match the required duty cycle, hence the level converters to "clean" the signal.
Answers.UserDisplayName: Shadocko
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-11T17:58:48.000Z
Answers.Text: so I use an H bridge to convert the PWM signal to 9v for the C1/C2 lines for a servo motor?
Answers.UserDisplayName: user2813274
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-14T09:59:10.247Z
Answers.Text: Yes, you should use an H-bridge so that you don't have to connect the mass of your RPi to the 9V mass, thus avoiding any current surge that could damage your SBC (loads are active components!). The output circuit using a FET in the page linked-to by David Lechner would also work but you would need a more complicated setup to rotate the servo in both directions. An H-bridge (which is just four MOSFETs and diodes) plus logic gates, like what the L298N provides in an IC package, is easier and requires less PWM outputs (the RPi's don't have many). The LEGO IR receiver V2 uses a  DRV8833 from TI.
Answers.UserDisplayName: Shadocko
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-10T10:42:36.870Z
Answers.LastActivityDate: 2015-09-10T12:15:19.450Z
Answers.LastEditDate: 2015-09-10T12:15:19.450Z
Answers.UserDisplayName: Shadocko
Answers.Body: <p>You can make a level converter that will safely mediate between 9v and 3.3 or 5v using a couple of resistors and a FET - the operation is a bit subtle, as it depends on a peculiar characteristic of typical FETs, but it does work. See sketch - you can buy these as ready made units with four or more level shifters per tiny board, for very little money, from the same kind of suppliers who sell arduinos etc. This design has the added advantage of being bi-directional in a way that works with I2C, too. <a href="https://i.sstatic.net/bczsD.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bczsD.jpg" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-16T12:39:39.683Z
Answers.LastActivityDate: 2023-01-16T12:39:39.683Z
Answers.UserDisplayName: Carl Williams
Body: <p>related: <a href="https://bricks.stackexchange.com/questions/4886/how-to-control-a-88004-servo-motor-with-a-raspberry-pi">how to control a servo motor from a raspberry pi</a></p>
  
  <p>The raspberry Pi normally outputs 3.3 V signals from it's pins, however there are logic level converters for interfacing with higher-voltage parts as well, and I am not sure if there was one in use in the linked question or not (yes, I asked it as a comment a while ago - no answer), thus this question</p>
  
  <p>Philo has managed to DIY-control it, but I don't see the details from <a href="http://www.philohome.com/pfservo/pfservo.htm" rel="nofollow noreferrer">his site</a></p>
  
  <p>P.S. If it wasn't clear, I am looking for the level at which the control signal is, not the 9v/7.4v power line runs at</p>
  
Tags: <piece-information><technic><motor><power-functions><compatibility>
Title: At what voltage do the c1 and c2 lines run at when controlling a lego servo motor?
UserDisplayName: user2813274
ThreadText: # At what voltage do the c1 and c2 lines run at when controlling a lego servo motor?
  
  (Asked by: username_0 on 2015-08-14)
  
  related: [how to control a servo motor from a raspberry pi](https://bricks.stackexchange.com/questions/4886/how-to-control-a-88004-servo-motor-with-a-raspberry-pi)
  
  The raspberry Pi normally outputs 3.3 V signals from it's pins, however there are logic level converters for interfacing with higher-voltage parts as well, and I am not sure if there was one in use in the linked question or not (yes, I asked it as a comment a while ago - no answer), thus this question
  
  Philo has managed to DIY-control it, but I don't see the details from [his site](http://www.philohome.com/pfservo/pfservo.htm)
  
  P.S. If it wasn't clear, I am looking for the level at which the control signal is, not the 9v/7.4v power line runs at
  
  **Tags:** piece-information, technic, motor, power-functions, compatibility
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2015-09-08. Score: 2 | Accepted answer
  
  The answer to the question you linked contains the answer you are looking for:
  
  > * To move in one direction, send a PWM signal (1200 Hz, 0 to 100% duty cycle) on C1 and keep C2 at GND level. As duty cycle varies, servo motor will move along 7 positions on one side. See this video.
  > * To move in the other direction and reach the 7 other positions, send PWM to C2 and keep C1 at ground level.
  
  PWM means [Pulse Width Modulation](https://en.wikipedia.org/wiki/Pulse-width_modulation), so you need something capable of generating this signal. The voltage is the same as what you apply to the 9V terminal. Only the pulse width is varied. And GND means "ground" which is another way of saying 0V.
  
  So, to do this with a Raspberry Pi or other microcontroller, you will need a transistor to convert the voltage. There is virtually no load on C1/C2 in this case, so any size of transistor will do the job without risk of overload. See [this page](http://www.elinux.org/RPi_GPIO_Interface_Circuits#Output_circuits) for some example circuits.
  
  > **Comments:**
  > **username_0**: Not seeing the source for the fact that the PWM signal is 9v, and having the signal voltage at the same level as the motor voltage would be something quite unusual - have you tested it with 9v and it worked? have you looked at the c1/c2 lines under an oscilloscope to verify the voltage levels from a standard lego controller?  
  > **username_1**: Yes, it is unusual and yes I have looked at it with an oscilloscope. On other power functions motors, C1 and C2 are actually used to drive the motor itself and the 9V and GND pins are not used at all. So, of course, C1 and C2 are full battery voltage since they power the motor. The servo motor just takes advantage of this existing mechanism as a means of transmitting a variable signal from the controller to the motor.  
  
  ---
  
  ### Answer by username_2 on 2015-09-10. Score: 2
  
  The C1 and C2 lines are either connected to the 9V power supply or grounded because they directly drive classic PF motors and are not just used to carry commands. The 9V and GND poles also need to be properly connected because the PF servo will draw power from those.
  
  To drive **any** LEGO Power Functions motor using a single-board computer (Pi / BeagleBone / Arduino), the easiest way is to use an H-bridge Integrated Circuit, which will safely separate the SBC (3.3V or 5V) from the high-power stuff (9V motors). There are readily-made circuit boards which are easy to interface with an SBC on e.g. [dx.com](http://dx.com) or [aliexpress](http://aliexpress.com).
  
  Don't drive LEGO PF motors with the output of your SBC directly or you may very well fry it, because motors will draw too much current.
  
  I successfully used [this L298N-based circuit board](http://www.dx.com/p/navo-l298n-stepper-driver-and-power-supply-module-wi-fi-motor-drive-controller-module-board-yellow-294341) to drive up to 4 PF motors at any speed in both directions with a Beaglebone Black. It can accept 3.3V commands directly but the PWM output from the SBC better be level-shifted to 5V so that the duty cycle is really respected.
  You can use [something like this](http://www.dx.com/p/jy-mcu-5v-3v-iic-uart-spi-level-4-way-converter-module-adapter-178286) to shift the voltage.
  The board also features a 5V power source so you can power the SBC from it using only LEGO battery boxes.
  
  This H-brige module accepts 3 inputs per motor:
  
  * forward
  * barckward
  * enable
  
  `forward`/`backward` inputs of the control module can be tied to ON/OFF outputs of the GPIO and the `enable` input to a PWM output of the GPIO. The duty cycle of the PWM can then be used to control the speed of a classic PF motor, or the angle of a PF servo motor, while `forward`/`backward` will control the direction (enabling both will result in braking the motor).
  
  Note that you'll have to be carefull with the outputs of the RPi as those are open-collector outputs, so don't fry your SBC. Arduino and Beaglebone are easier to use.
  
  > **Comments:**
  > **username_0**: Thanks for the clarification - I have looked at the level converter boards, but I didn't see any that go all the way up to 9v, 5v or 5.5v seems to be the common stopping point, and I imagine that the servo would still work with mostly drained li-ion batteries (2s ~ 6v or so) - any idea what the lower bound of the input voltage is like?  
  > **username_2**: Level converters are for converting logic levels, not for converting low-current commands to drive a load. That's what H-bridges are for. So the circuit you are looking for is an H-bridge. The L298N I used expects 5V TTL inputs, but the input is considered high from 2.5V on so they can be driven with 3.3V outputs and this normally wouldn't need level converters. However I found that the PWM ouputs of the Beaglebone were not clean, so the amount of time the signal is above 2.5V does not match the required duty cycle, hence the level converters to "clean" the signal.  
  > **username_0**: so I use an H bridge to convert the PWM signal to 9v for the C1/C2 lines for a servo motor?  
  > **username_2**: Yes, you should use an H-bridge so that you don't have to connect the mass of your RPi to the 9V mass, thus avoiding any current surge that could damage your SBC (loads are active components!). The output circuit using a FET in the page linked-to by David Lechner would also work but you would need a more complicated setup to rotate the servo in both directions. An H-bridge (which is just four MOSFETs and diodes) plus logic gates, like what the L298N provides in an IC package, is easier and requires less PWM outputs (the RPi's don't have many). The LEGO IR receiver V2 uses a  DRV8833 from TI.  
  
  ---
  
  ### Answer by username_3 on 2023-01-16. Score: 0
  
  You can make a level converter that will safely mediate between 9v and 3.3 or 5v using a couple of resistors and a FET - the operation is a bit subtle, as it depends on a peculiar characteristic of typical FETs, but it does work. See sketch - you can buy these as ready made units with four or more level shifters per tiny board, for very little money, from the same kind of suppliers who sell arduinos etc. This design has the added advantage of being bi-directional in a way that works with I2C, too. [![enter image description here](https://i.sstatic.net/bczsD.jpg)](https://i.sstatic.net/bczsD.jpg)
  
  
  ---
  
  