Hi,
for a project I need to use the MG966R servo. I have tried to use the servo library which I have successfully used with the KY66 micro servo and the PC9685 pwm board.
in the below example I have on channel 0 e 1 two functional KY66 following a potentiometer input and the MG966R on the channel #2.
I am assuming (and maybe that is the mistake that I can use the same MIN and MAX pulse width and frequency for the MG966R..
Does anyone have experience with this servo?
thanks!
for a project I need to use the MG966R servo. I have tried to use the servo library which I have successfully used with the KY66 micro servo and the PC9685 pwm board.
in the below example I have on channel 0 e 1 two functional KY66 following a potentiometer input and the MG966R on the channel #2.
I am assuming (and maybe that is the mistake that I can use the same MIN and MAX pulse width and frequency for the MG966R..
Does anyone have experience with this servo?
thanks!
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Public servo1 As Servo
Public pinservo As Pin
Public Timer1 As Timer
Public potentiometer As Pin
Public driver As Adafruit_PWMServoDriver
Public const MIN_PULSE_WIDTH As Long = 80
Public const MAX_PULSE_WIDTH As Long = 620
Public const FREQUENCY As Long = 50
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
potentiometer.Initialize(potentiometer.A0,potentiometer.AnalogRead)
driver.Initialize(0x40)
driver.SetPWMFreq(FREQUENCY)
AddLooper("IntPot")
End Sub
Sub IntPot
Dim ServoPos As Int
ServoPos = MapRange(potentiometer.AnalogRead,0,1023,0,179)
driver.SetPWM(0,0,convert2angle(ServoPos)) ' KY66 working
driver.SetPWM(1,0,convert2angle(ServoPos)) 'KY66 working'
driver.SetPWM(2,0,convert2angle(ServoPos)) 'MG966R NOT working
Log("pot:",potentiometer.AnalogRead)
Log("ServoCmd:",ServoPos)
End Sub
Sub convert2angle (myang As Int) As Int
Dim pulse As Int
pulse =MapRange(myang,0,180,MIN_PULSE_WIDTH,MAX_PULSE_WIDTH)
Return pulse
End Sub