DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Grounding 6V servo?

Sat Aug 13, 2016 6:47 pm

Hi, I have servo motor that operates of a 6V power supply, but the Pi's GPIO pins only support 3.3v and my servo needs to be grounded through the Pi as the PWM circuit needs to be complete.

Is there any way of doing this, but stepping the voltage down to 3.3v without a buck converter or other transformer. I have tried using a transistor and a voltage divider but none of these have worked. I have left circuit diagrams of what I have tried attached to this post.

This method didn't work because the PWM was not grounded through the Pi...
Attempt 1.PNG
Failed Method 1
Attempt 1.PNG (51.15 KiB) Viewed 4359 times
I don't really know why this one didn't work, it made the servo rotate to random positions constantly...
Attempt 2.PNG
Failed Method 2
Attempt 2.PNG (61.23 KiB) Viewed 4359 times
Again, I don't know why this one didn't work, the servo was not active at all here...
Attempt 1.PNG
Failed Method 1
Attempt 1.PNG (51.15 KiB) Viewed 4359 times
Servo's datasheet
The minimum PWM and supply voltage is ~4V and the maximum PWM and supply voltage is ~7V
I don't have a 7V power supply, so I can only operate at 6V.

Thanks in advance for any help :D

I have put my successful method here, but the Servo is weaker (does not have as much torque).

This is the same image as what is on imgur...
[img]//imgur.com/gallery/uZ3Yk[/img]
Attachments
Attempt 3.PNG
Failed Method 3
Attempt 3.PNG (57.54 KiB) Viewed 4359 times

User avatar
joan
Posts: 16214
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Grounding 6V servo?

Sat Aug 13, 2016 6:57 pm

Connect the control wire direct to a GPIO.

Power the servo from 6V (and ground).

Connect a Pi ground to the power supply/servo ground.

User avatar
mikronauts
Posts: 2823
Joined: Sat Jan 05, 2013 7:28 pm

Re: Grounding 6V servo?

Sat Aug 13, 2016 6:59 pm

First method will work fine if and only if:

1) no difference in ground potential between the Pi and the servo's power supply (MEASURE voltage between Pi's GND and servo power supply, should be 0v or open circuit, any non-zero voltage reading is not safe )

2) you tie the Pi's GND to the servo's GND
DibDibs wrote:Hi, I have servo motor that operates of a 6V power supply, but the Pi's GPIO pins only support 3.3v and my servo needs to be grounded through the Pi as the PWM circuit needs to be complete.

Is there any way of doing this, but stepping the voltage down to 3.3v without a buck converter or other transformer. I have tried using a transistor and a voltage divider but none of these have worked. I have left circuit diagrams of what I have tried attached to this post.

This method didn't work because the PWM was not grounded through the Pi...
Attempt 1.PNG
I don't really know why this one didn't work, it made the servo rotate to random positions constantly...
Attempt 2.PNG
Again, I don't know why this one didn't work, the servo was not active at all here...
Attempt 3.PNG
Servo's datasheet
The minimum PWM and supply voltage is ~4V and the maximum PWM and supply voltage is ~7V
I don't have a 7V power supply, so I can only operate at 6V.

Thanks in advance for any help :D

I have put my successful method here, but the Servo is weaker (does not have as much torque).

This is the same image as what is on imgur...
[img]//imgur.com/gallery/uZ3Yk[/img]
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:01 pm

joan wrote:Connect the control wire direct to a GPIO.

Power the servo from 6V (and ground).

Connect a Pi ground to the power supply/servo ground.
That will mean 6V is going through one of the Pi's pins, is that OK?

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:02 pm

mikronauts wrote:First method will work fine if and only if:

1) no difference in ground potential between the Pi and the servo's power supply (MEASURE voltage between Pi's GND and servo power supply, should be 0v or open circuit, any non-zero voltage reading is not safe )

2) you tie the Pi's GND to the servo's GND

Oh ok, so all potential difference on the ground rail should be 0V, so 6V is not going through one of the Pi's pins if the ground rail for the PSU is at 0V?

User avatar
joan
Posts: 16214
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:10 pm

DibDibs wrote:
joan wrote:Connect the control wire direct to a GPIO.

Power the servo from 6V (and ground).

Connect a Pi ground to the power supply/servo ground.
That will mean 6V is going through one of the Pi's pins, is that OK?
Putting anything over 3V3 into a Pi GPIO is not okay.

But you are not doing that. You are just connecting the grounds.

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:13 pm

OK, so I've tried it with this design
Image
and it just rotates the servo to its minimum threshold and it won't move, even if I drastically change the duty cycle (PWM).
Attachments
Attempt 4.PNG
New Design, doesn't work...
Attempt 4.PNG (47.64 KiB) Viewed 4262 times

User avatar
joan
Posts: 16214
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:31 pm

You must have a duff servo, or possibly you aren't sending the correct control signals.

How are you sending the servo pulses?

pootle
Posts: 436
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:34 pm

What are you using to generate the duty cycle - it sounds like it's not coming out right. If the servo runs at all after any initial power on glitch, it thinks it has got a control pulse.

Can you post a link to the particular servo you are using? I am using sg90 servos with no problems with
  • servo psu gnd <-> pi gnd <-> servo gnd
  • servo psu +ve <-> servo +ve
  • pi gpio xx <-> servo control
I use pigpio's set_servo_pulsewidth to drive the servos

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:43 pm

To generate the duty cycle, I am using this equation...
DutyCycle = PulseWidth*frequency
and I am using the RPi.GPIO package in python the set the PWM output.

the code looks like this...

Code: Select all

GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT) #SERVO PIN, PIN 11 (TRUST ME, THIS IS CORRECT, I AM JUST USING A DIFFERENT LAYOUT)
pwm = GPIO.PWM(11, 50) #Set PWM frequency to 50Hz for the Servo.
pwm.start(x)
and to change the PWM output

Code: Select all

pwm.ChangeDutyCycle(x)
I use pigpio's set_servo_pulsewidth to drive the servos
Is that a Python package?
Last edited by DibDibs on Sat Aug 13, 2016 7:50 pm, edited 2 times in total.

User avatar
mikronauts
Posts: 2823
Joined: Sat Jan 05, 2013 7:28 pm

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:49 pm

50Hz is correct

BUT

you need to send a 500-2500 us signal for servo position. Center is 1500us

Do yourself a favour, use joan's excellent pigpio library, it has servo commands.
DibDibs wrote:To generate the duty cycle, I am using this equation...
DutyCycle = PulseWidth*frequency
and I am using the RPi.GPIO package in python the set the PWM output.

the code looks like this...

Code: Select all

GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT) #SERVO PIN, PIN 11 (TRUST ME, THIS IS CORRECT, I AM JUST USING A DIFFERENT LAYOUT)
pwm = GPIO.PWM(11, 50) #Set PWM frequency to 50Hz for the Servo.
pwm.start(x)
and to change the PWM output

Code: Select all

pwm.ChangeDutyCycle(x)
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Grounding 6V servo?

Sat Aug 13, 2016 7:51 pm

mikronauts wrote:50Hz is correct

BUT

you need to send a 500-2500 us signal for servo position. Center is 1500us

Do yourself a favour, use joan's excellent pigpio library, it has servo commands.
Is it a built-in library, or can i use pip to install it or...???

User avatar
joan
Posts: 16214
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Grounding 6V servo?

Sat Aug 13, 2016 8:06 pm

Try the following.

sudo pigpiod

pigs s 27 1000
pigs s 27 1500
pigs s 27 2000

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Grounding 6V servo?

Sat Aug 13, 2016 8:12 pm

OK, I got it, do you have to start a daemon, coz Im getting an error!

User avatar
joan
Posts: 16214
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Grounding 6V servo?

Sat Aug 13, 2016 8:25 pm

DibDibs wrote:OK, I got it, do you have to start a daemon, coz Im getting an error!
Error?

DibDibs
Posts: 11
Joined: Fri Aug 12, 2016 11:24 pm
Location: Cumbria, United Kingdom

Re: Grounding 6V servo?

Sun Aug 14, 2016 1:37 pm

Never mind, I was getting the error because I didn't execute 'pigpiod'
It's all working fine now, thanks so much for all of your help :D

Return to “General discussion”