I am having a problem with running the code for a large servo Here and I am using the DF15RSMG 360 Degree Motor (20kg).
I am using a RPi Zero W and a UPS hat.
When plugged in and the code is run the servo spins continuously and doesn’t stop even when, stop, is hit. I have to unplug the battery and plug it back in. If I don’t hit stop and unplug the battery and plug it back it will still continue to spin I am happy to provide a video if it helps. I have adjusted the parameters that the servo operates around.
Any ideas I am willing to try!!!
I thought that’s what 360º servos did. I may be wrong but I was under the impression they cannot be positioned like a normal servo but continuously rotate and so can be used as a reversible motor. Some descriptions state that they can be speed controlled in both directions about centre by controlling the pulse width as you would with positioning. I purchased one once to have a fiddle and found speed control anything but positive. There was some very minor speed variations about the centre position but once the pulse got a few microseconds away from centre the servo just travelled at full speed. Any control is non existent. This would make sense really as when a servo gets a pulse change for a new position it would travel to that position at full speed give or take acceleration and deceleration.
Edit: Just had a look at the link. That tutorial says “standard” servo. If you used such a servo you would probably find that sample bit of code may work.
What you’ve got is definitely a servo motor if it is the part that you linked earlier, that was the SER0035 that we supply?
Looking at your code, there’s no point at which the servo is forced to change direction. And it may be that it’s not reaching that position within the two-second delay before the PWM duty cycle changes and it is told to keep rotating, try running this on your Pi instead, should make it sweep back and forth repeatedly:
from gpiozero import AngularServo
from time import sleep
servo = AngularServo(18, min_angle=0, max_angle=360, min_pulse_width=0.0004, max_pulse_width=0.00255)
for x in range(0, 360):
servo.angle = x
for x in range(360, 0, -1):
servo.angle = x
This is actually a servo that can be positioned anywhere within a 360º circle. Is that what you are saying? Surely 0º and 360º are the same position. How would it differentiate between the two unless 0º is set as start at switch on which could be anywhere in the circle.
Just had a look at DFRobot web page re this unit and there seem to be a couple of conflicting statements. One directly below the other would you believe.
Using the Arduino servo library, you could drive this servo motor easily.To reduce the consumption of your microcontroller, this servo has a lock function for the pulse detection. So driving it to a target position just requires one PPM controlling signal.
Quote 2 NOTE : This Servo Motor is not a servo which allows you control position or speed, but it is actually a motor with servo appearance, and you can control its rotating direction. You could use servo.h to make the adjustment.
What do you make of this. Your comments would be interesting as I have not had a great deal of experience with servos
Would you also read my first reply to this post. Your comments re speed control would be appreciated. I originally purchased this 360º servo as a possible solution to “creeping” small motors very slowly which “H” bridge systems applying PWM to chip enable are reluctant to do. I was unable to get any meaningful speed control and I believe that once a pulse is changed from centre position (1500µsec) it will run at full speed searching for the new position which it never finds.
That’s correct, 0º and 360º are the same position on this motor, although it’s continuos rotation, so you can go from 350º to 10º by rotating clockwise or anticlockwise through the reflex or acute angle between those bearings (assuming clockwise is positive from the side it is being viewed from )
And the 0º or origin for this motor is pre-set, if you send it a PWM with a given duty-cycle on the signal pin that matches it will always home to the same position.
Yes, I’m fairly sure that Owen may have confused this with another motor we supply that is not a servo, but is designed to look like one (I’m not going to link it here as it will likely just cause more confusion), although this is certainly a stepper motor. I grabbed one from stock and ran a demo script on a Pi to be sure. DC Motors and DC servo motors have similarities, but they are very different. The Pi Hut explains this quite well:
Servo.h is a library (essentially just a whole series of functions in C++) so with an Arduino or similar board you can send the appropriate positions and servo motor specs to a function, and it will handle setting the pins to the appropriate voltage, duty-cycle, etc to make your motor behave the way that you would like more easily. It does not however, allow for a standard brushed-DC motor to act like a DC servo motor, it’s purely just functions to simplify the use of run-of-the-mill servos such as the one Caleb has.
Once @Caleb161865 tries running the modified script I provided, we’ll discuss further other methods to make this servo move to the positions that you would like using the GPIO of the Pi.
The 2 conflicting quotes I included come from the DF Robot web page that comes up when I search the servo depicted on the Core page that Caleb links in his opening paragraph. Nothing to do with what Owen posted. So I think it is fair to assume this is the one Core stock. All the numbers match.
They not only contradict each other but are directly one above the other, in other words following.
Maybe it wasn’t english I learned at school all those years ago.
Did you have any thoughts on so called speed control. There are a few questions I would like to ask so maybe I could start another topic. I need to do a few experiments first.
And you can get our latest projects and tips straight away by following us on: