My Cart:

0 item(s) - £0.00
You have no items in your shopping cart.


Trim A Continuous Rotation Servo With Code

In this quick tutorial, we are going to cover how to trim a continuous rotation servo with code. We will be writing our code in Microsoft's MakeCode Editor for the BBC microbit. 2589_additional_3_feetech_fs90r_360_degree_continuous_rotation_servo_wheel If you ever rushed a robotics build and completed the construction before remembering to trim your servos then this tutorial is for you! It's easy to do and you'll never have to completely dismantle a project just to turn a trim screw a fraction of a turn again! This tutorial also covers 360-degree continuous servos that don't have a trimpot on the base.

We Used:


Trim A Continuous Rotation Servo With Code:

trim-a-continuous-rotation-servo-with-code-microbit-trim-870 The above image is of the underside of two continuous rotation servos, the screws that you can see are used to trim the servo. When a servo hasn't been trimmed it may start to rotate in one direction or the other when it is powered and receiving the signal telling it to stop, either 1.5ms or 90 degrees. trim-a-continuous-rotation-servo-with-code-microbit-870 Ordinarily, you would send the stop signal (1.5ms or 90 degrees) to the servo with a line of code and use a screwdriver to adjust the screw (trimpot) until the servo stops turning, but if your servo is buried inside a project this may be impossible, hence the need to trim it with code. trim-a-continuous-rotation-servo-with-code-microbit-code-870 We can do this easily by adjusting the 90 value by plus or minus one until we make the servo stop moving. In the example above, I went from 90 to 93 and determined that the effect was getting worse and not better so I went backwards from 90 to 83 and the servo stopped moving. Thus, whenever I want the servo to come to a full stop, the value will be 83 and not 90.

The Kitronik Way:

Kitronik has created a number of custom servo control blocks to make it easier to create code for our products. The blocks are now a part of the MakeCode editor and can be added using the add package option. trim-a-continuous-rotation-servo-with-code-microbit-package-870 To the top of the editor is the Cog icon, when you click on this select Add Package from the menu and a dialogue box will appear. Type Kitronik into the space provided and press enter, choose the kitronik-servo-light box and our servo control blocks will be added to the menu. trim-a-continuous-rotation-servo-with-code-microbit-stop-870 The Stop block above does exactly what it says on the tin. Regardless of whether your servo is trimmed or not this block will stop it. Rather than sending a pulse of 1.5ms or an angle of 90 the Stop block actually disconnects the PWM. No PWM signal=no movement.

← Previous Post Next Post →

Leave a Reply