Umm help with an idea (servo control)

so where do you guys (or gals) think a good starting point would be

also to be brutally honest this is probably going to end up being my first time writing non G-code script

i have also noticed that there is what appears to be a plugin example/skeleton at https://github.com/OctoPrint/Plugin-Examples

do you think this would be a good first step?

Each of us has provided some helpful material. Why don't you sort through those, get a better understanding and then make a choice based upon what you might be able to do.

To me, it sounds like a Python script or service which runs, accepts inputs and can act upon those inputs. So it might hear "CW 3", interpret that into "turn clockwise 3 degrees" or "turn clockwise for 3/10 seconds" or whatever and then send the correct command to the GPIO pin to make that happen. And then once you have something like that, then consider working on the plugin side of this.

Or, build the whole thing as a plugin if you'd like.

yeah that actually makes sense to me, the only real downside is that i only have one Raspberry pi to do this on, being my octoprint pi

aside from that i very much like your idea

also looking at my CNC G-Code cheat sheet, M3 looks like a good candidate to test this with as M3 controls spindle (drill bit) speed and has no immediate use on a printer

First things, first: read. That's how all of us got good at this eventually.

  • Get comfortable creating a Python script which you can run from the command line.
  • Get comfortable creating a shell script which you can run from the command line.
  • Get comfortable with remoting into your Pi using either ssh or PuTTY.

M3 is a gcode command which your printer board will interpret. You don't want your printer board to interpret this unless you connect the servo to that. You're looking for Pi-side if you want to connect it to the Pi itself. Check out the Gcode Systems Command plugin I mentioned earlier.

ok will do

ok so as much as i am embarrassed to say so, i have no python knowledge whatsoever, and all the online tutorials that i've looked at so far are getting me nowhere as they all assume that i have had some history with python before although i do not

Neither did any of us before we started :slight_smile: What you're trying to do can be done by a beginner, of that I am very confident. The script will be quite small and very frustrating for you to develop (like bang you head on the table frustrating). However, it will be EXTREMELY satisfying once it works, and it may open a new world up for you. Enjoy the trip!

1 Like

oddly enough ive had some time on Scratch.mit.edu and i'm tempted to do a sanity check with it

so later on if i end up getting lost, i could possibly use it as a frame of reference

so i've been working on the sanity check on scratch and it is at a point where i feel comfortable sharing it with the public so feel free to check it out. feel free to give it some constructive criticism

https://scratch.mit.edu/projects/355106013/

now its a matter of translating that into python (after learning how to), and possibly turning that into a plugin

yeah now that i am thinking about it, i am thinking that it might be easier to jump the gun and just make it into a plugin

and if you are curious as to why i want to try to make it as a plugin, i hope to be able to share it with the public so people can experiment with it and come up with their own ideas

so my question now is, is there a pre-made empty plugin that i could use, as well how to translate the sanity check into said plugin (all i'd really need at the moment is how to format this)

1 Like

soo i had a breakthrough, just because i can, i tried out wiring my servo according for the pins for the led strip for this plugin i had wired the control pin to the pin for the red led and it somewhat works.

since it works off of a "slider" value that controls the duty cycle with a range of 0-(0%) to 255(100%) and servos pick up, up to ~20% duty cycles so now its a matter of controlling this

I had also found out that the tiny servo that I had used has a self-destruct mode at about 40% as the servo thinks it can go up to about 270° with a working range of 180° as well that the same thing sort of happens with 0° but for whatever reason not 1°

Honestly losing the fine tuning ability by nearly breaking a few gears of a servo doesn't really matter to me as I have 3 extras to play with and it has been now ranked my "testing" servo

1 Like

In the developing a plugin... growing up section I think is instructions on how to use cookiecutter to start off the simple framework for your plugin. That's what I use to start.

1 Like

Oh? Might have to give that a try

going back to the breakthrough, I just remembered that on the plugin there is three (or four if you want white) control pins in use so I could have that plugin power the servos

So now I'm curious as to what can I use to increment the values on command between two angles per motor that I can possibly change later on

Hmm does octolaspe have something already

I used the PCA9685 to control 6 servo's from a PI for my wordclock. It is connected to the I2C bus. This servo can easily drive up to 16 servos. The original design for the chip is to generate PWM signals, e.g. used for dimming LEDS. With the correct parameters it generates the pulse length for upto 16 servos: between 1 and 2ms for 90degree or 0.5 to 2.5 ms if you have a 180degree servos. There are many tutorials for this and the Pi. The point is: there is an octoprint plugin that controls a light strip from GCODE M150 and a PCA9685, that should be easily modifiable to react to GCODE and (additionally) operate servo's.

1 Like

So I know it's been a while on this one, but I recently worked with a budding new plugin developer and he has been able to get 2 9g servos controlled via OctoPrint to move a raspicam on a gimble. He will be submitting the plugin in the very near future to the plugin repository, and it's called Easy Servo, so keep an eye out.