Notifications
Clear all

futaba s3003 shutdown question

9 Posts
4 Users
7 Likes
429 Views
(@brianros)
Member
Joined: 11 months ago
Posts: 1
Topic starter  

Hi everyone my name is Brian and i m a hobbyist from Argentina, first post here! I really love the youtube content, i m very new to electronics and programming so please have patience.

 

I m building a robotic arm and i m using different servos for the joints. I wrote a small routine for testing my servos with a raspberry pi pico in micropython, i m trying to do the following, start at mid range, swipe back and forth, and dissable the servo. It works as intended, except when i try to disengage the servo after the swipes by setting the duty cycle to 0, but it stays locked in the last position, and some values around 0, but the servo goes to the end of its range when i do that, i also tried setting it to above 12% duty cycle, but it also just stays locked in place at its last position.

The most annoying part is that the servo stays locked even if i stop the program, i need to turn off my external power supply (i built the atx psu from the youtube video!). I m worried if i forget to power off my psu the servo will end up overheating and burning by holding its position indefititely, is that a valid concern?

 

Thanks in advance!

Here s my code:

from machine import Pin, PWM
import utime

servo = PWM(Pin(0))

servo.freq(50)
def test_360 (servo):
servo.duty_u16(2240)
print("waiting")
utime.sleep(5)
servo.duty_u16(0)
print("waiting")
utime.sleep(5)

def test_180(min = 1250, max = 8200, test = servo):
   avg = int((min+max)/2)
   servo.duty_u16(avg)
   for a in range (avg,max,200):
      servo.duty_u16(a)
      print("duty", a)
      utime.sleep(0.05)
   for a in range (max,min,-200):
      servo.duty_u16(a)
      print("duty", a)
      utime.sleep(0.05)
   for a in range (min,avg,200):
     servo.duty_u16(a)
     print("duty", a)
     utime.sleep(0.05)
   servo.duty_u16(0)

 

 

while True:

test_180()
break

This topic was modified 9 months ago 3 times by brianros

   
Quote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Posted by: @brianros

but it stays locked in the last position, and some values around 0, but the servo goes to the end of its range when i do that, i also tried setting it to above 12% duty cycle, but it also just stays locked in place at its last position.

I'm not proficient with Python, and it doesn't seem to follow my traditional upbringing.  😆 However, I don't think the problem is with your code.  I believe you may not be familiar with the workings of common servos.

I'm also unclear on you explanation above.  First, you say, "it stays locked in the last position" and then you say, "it goes to the end of its range."  These two sentences contradict each other... to me at least.

Anyway...

Servos when powered must be continuously tickled with frequency to stay in one location.  This from the Internet:

For a servo motor capable of a range up to 180, the values will be 1000 microseconds = 0 degrees, 1500 microseconds = 90 degrees, and 2000 microseconds = 180 degrees. Depending on the servo motor you are using, you may notice a difference.

The fact that you thought you were disabling it by setting to zero duty cycle is simply telling it to go to the 0 degrees stop.  

The only way to disable a servo, is to de-power it... remove the power.  Usually this is a big problem, as you'll have to add some circuitry... a relay or a mosfet.  The normal way is to keep it at the last position is simply keep feeding it the last PWM setting where you want it to stay.

I hope this helps.

VBR,

Inq

 

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@brianros @inq I agree with everything Inq says, but why a servo? Why not a stepper motor? It may be the stepper is more able to do what you want, especially since the servo is not able to do some at least of what you want. Food for thought.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

Posted by: @brianros

I m worried if i forget to power off my psu the servo will end up overheating and burning by holding its position indefititely, is that a valid concern?

Not a worry as indicated by @inq.  But a quick look at your code, it may be as you want it, but don't forget the duty cycle as set in the pmw class method of .duty_u16 is a number between 0 and 65535.  I see in your function test_180 sets a max number of 8200, a seemingly minuscule max duty cycle.  

And if posting code click on the <> in the menu bar and plop your code in the pop up screen to save our eyes getting boggled, it hard to read python code where indents are part of the code when you just use a single space to show your indents. 😉 

ps. you can choose to do a servo.deinit() in your code to turn off the pmw on your pin.

This post was modified 9 months ago by byron

   
Ron and Inq reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

Posted by: @byron

Not a worry as indicated by @inq.

I knew you'd come to the rescue if it actually was in that stuff you call code. 😋 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@inq I think their brains are wired differently than ours. I would rather see well-written assembler code than Python or hard-core C++. I am 100% positive that there is some cognitive difference between old fashioned close to the iron coders and modern-day OOP types, but maybe I am just old.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
Inq reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

@zander, I think old dogs can be trained too.  If I'm not mistaken, @byron is in our age group and he was able to learn it.  However, I am concerned about the number of empty neurons I have left that are dying off with age versus the amount of information I want to learn.  I have to be choosey.  😋 🤣 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

@zander @inq.

I'm in my mid 70's so maybe just a young whippersnapper, at least of Ron 😀  

In the early 1970 I was employed as a C programmer, though the skills got very rusty when I took up this electronics hobby malarky when I retired in 2013.  In retirement I started off with C programming on Arduino's (and learned C++ too to a competent newbie level) but I got a raspberry pi and thought I would give python a go.   I can program in both, though my C is getting decidedly rusty again since micropython came out and I've not done a C or C++ project for about 4 years.  

Apart from mucking about with sensors and the like attached to microcontroller I also find I so a fair bit of GUI and database stuff on my PC and rpi and certainly for this I much prefer to code in python.  I find I actually enjoy programming in python whereas if I now have to code in C I would think of it as being a bit of a drudge to get something done (like a need to squeeze some more speed).  Very soon I think we may hear some whoops of joy when @inq realises how python works and the joy of instant programming without the need to compile and the pleasure of trying out some quick coding test with the python REPL. 😎   As for Ron liking assembler code, well bah humbug to that, I think I would prefer to do train spotting or maybe a little light head banging. 😀  


   
Inq and Lee G reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6988
 

@byron I would kill to be in my mid 70's again. I officially retired in 2004 although for a while I was still talking to prospective clients and making it known I was still looking but after a couple of projects fell through I was never again a paid for work programmer/analyst/bottle washer.

I never used C++ professionally, it simply was not available on the hardware platforms I was using. My most used language was PL/I or PL1 second most K&R C third most 360 Assembler. At the hobby level, I was very active in Turbo Pascal (President of the Toronto User Group) and a lot of miscellaneous C, C++, Pascal, and Macro Asm PC versions.

While I am at it, I never heard of Kirchoff's law, just Ohm's law. I don't remember if we studied transistors in HS, but I did learn the very basic stuff on 2N170 NPN and 2N107 PNP. I see these are now part of the Transistor Museum! I used to 'aquire' the transistors and build a simple AM radio in a fountain pen that I sold for $5 to fellow students. In today's dollar, that's $55.

Enough confessions, back to work.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
byron reacted
ReplyQuote