ServoBlade Feature Request

I’m having a problem with servoblade where because my servos are being fed a constant PWM signal, they are constantly straining to perfectly center themselves. this means the slightest touch or pressure or movement causes them to complain loudly. Because of the tolerances of my saber, this is near constant.

is there a way to add a version of servoblade that only sends pwm signals briefly on ignition and retraction?

That’s kind of a weird behavior for a servo.
It shouldn’t be too difficult to turn off the servo signal if it hasn’t changed for a bit I think.

Are you willing to add it yourself? Or are you saying that it shouldn’t be hard for me to do?

I can do it, but I don’t want to make any promises about when I’ll do it.
If you know a little C++, you might be able to do it yourself, and I can help.

I’ve done a lot of beginner esque electronics projects in C++ and I’m open to giving it a try. I’m most confused about the file structure of proffieOS, where is the part where it actually sends the signal? I know it’s generated in leds.h, but that’s about as much as I know.

Honestly, I might just benefit from a rough outline of how you would reccomed executing something like this.

So, the actual output signal is generated by a hardware timer. A timer is just a counter that increments at some specific frequency, and when it reaches value A, the GPIO goes high , and it when it reaches value B it resets the counter back to zero, and the GPIO goes low.

Most of the timer stuff is encapculated by pwm_pin.h, you shouldn’t need to make any changes there, but you may need to look at it to see what it does.

The rest happens in simple_blade.h, which is responsible for taking the value(s) computed by the style and calling the functions in pwm_pin.h to actually tell the timer what the values of A and B are.

Now, basically what we’re going to have to is to check if the value has changed in the set() function, and if it has, we should do something like: last_change_ = millis();

In loop() we would add some code that turns the blade off if millis() - last_change_ is greater than some value, like maybe 100ms.

We also need some code that powers the blade on again when a change occurs, but it’s not clear if that shoud happen in set() or loop().

All of this should be only be done for servos, so we should create a new templated class which inherits from Simple_Blade, and overide the functions we need and then use that in ServiBladePtr.

Hope this helps. :slight_smile:

1 Like