While building the Inmoov hands, I got 5 servos to drive the fingers, and they will be controlled by an Arduino using the Adafruit 12 bit PWM shield. All info for the shield is here:
https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield
As the shield drives the servo with PWM instead of the Arduino servo.write() function, I needed a way to determine the MIN/MAX PWM of all my servos. Never had any experience of PWM calibration, so I went to see if Google could help.
Excellent article from Jeremy:
https://create.arduino.cc/projecthub/jeremy-lindsay/calibrating-my-servos-fa27ce
Video demo from Youtube:
Their ideas and approach are brilliant but I do not have a "pot" right now and I do not want to spend hours writing and debugging a Python UI. Here is how I understand it, basically all I need to do is to find
- A minimal PWM that moves the servo from the initial position
- A maximum PWM that moves the servo to it the maximum range
- I wanted an Arduino to do above for me semi-automatically
I have only a push-button module with me right now, I know how unbelievable it is, so had to work around that. The code logic is very simple:
- Define an initial PWM ~70 (Googles says most of the servo PWM starts from 100 but mine somehow moves at 79)
- Drive the servo with this PWM when the push button is pressed, and display the value in Arduino Serial Monitor
- Program to increase the PWM by 5, then repeat the loop till your servo moves(This is your Potential MIN PWM)
- To fine-tune the PWM, Set the initial PWM = "Potential MIN PWM - 10", and change the increment from 5 to 1, then repeat the test
For example, with the initial PWM set at 70 but the servo only started to move at 85, we know the "Potential MIN PWM" is between 81 and 85. So we set the initial value as 80 and cycle through with increment 1, this way we know the exact value for SERVOMIN. I hope this makes sense to you.
The same goes for finding the MAX, start with the MIN, set increment to 20 until you hit a point where the servo no longer moves, this will be your "Potential MAX". Set the starting PWM to ("Potential MAX" - 30) and a smaller increment, go with "1" if you don't mind pushing the button 30 times as I did. You will then find your SERVOMAX.
With the SERVOMIN and SERVOMAX identified, you can then load the Adafruit example from here:
https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library
To make the servo movement easier to see, attach a servo horn with a piece of tape or a paper clip. Note, in my code, the push button is connected to Pin 9.
Comments
Please log in or sign up to comment.