Hi,
You could take a look at my PEP ver 2.02 sheet and the VB code I’m running in the background. Take a look at the sheet called “Setup” and the code in the SSC32com module (check the CalculatePWM sub).
Hi,
You could take a look at my PEP ver 2.02 sheet and the VB code I’m running in the background. Take a look at the sheet called “Setup” and the code in the SSC32com module (check the CalculatePWM sub).
Thank you but i couldnt understand what you suggested.
Im having a hard time converting Degrees to servo positions " P1500 "
Here’s the code im having trouble with:
Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click
Dim Xb As Double
Dim Zb As Double
Dim Q As Double
Dim P1 As Double
Dim P2 As Double
X = txtboxX.Text
Z = txtboxZ.Text
Xb = (X - L3 * Math.Cos(P)) / (2 * L1)
Zb = (Z - H - L3 * Math.Sin(P)) / (2 * L2)
Q = Math.Sqrt(1 / (Xb ^ 2 + Zb ^ 2) - 1)
P1 = Math.Atan2(Zb + Q * Xb, Xb - Q * Zb) * 180 / Pi
P2 = Math.Atan2(Zb - Q * Xb, Xb + Q * Zb) * 180 / Pi
Dim T1 As Double = P1 - 90 ' Sholder degrees
Dim T2 As Double = P2 - T1 ' elbow degrees
Dim T3 As Double = P - P2 ' wrist degrees
txtboxT1.Text = T1
txtboxT2.Text = T2
txtboxT3.Text = T3
'Elbow(movement)
Dim positionE As Double
positionE = (T2 * 8.1944444) + 1475 ' Here's where im have trouble
SerialPort1.Write("#2 " & ("P" & positionE) & "T2000" + Chr(13))
Sleep (1000)
'Sholder movement
Dim positionS As Double
positionS = (T1 * 11.111111111111111) + 1500 ' this one works fine
SerialPort1.Write("#1 " & ("P" & positionS) & "T2000" + Chr(13))
txtresult.Text = positionE ' displays the degrees in txtresult
'Wrist movement
Dim positionW As Double
positionW = (T3 * 11.111111111111111) + 1500
SerialPort1.Write("#3 " & ("P" & positionW) & "T2000" + Chr(13))
End Sub
Is there any way i can do the conversion??
Thanx for your help
Oh and Fish, the shoulder is working fine as it should.
Sorry about that, I meant to ask if the elbow was 30° off.
Any ideas from the code i`ve posted??
Hi,
Can you explain how you determined the 8,194444 factor? I guess the 1475 is a 0 deg offset. What kind of servo are you using for this joint? Can you explain more of what result you get that are wrong.
I’d say the 8.1944444 needs to be the same 11.11111 as the other servo (unless the servo has modified or is not typical).
ive change it to 11.11111 . Ok i
ve made a program in visual basic , i have for inputs x and z positions and then the program calculates the inverse kinematics and moves all the servos exept the base (not yet) to the position let say 30,15 put is not very accurate.
You really need to provide enough information for some one to actually help you. Maybe some images showing the positions you are able to achieve and the values that make the arm move there. Saying “not very accurate” isn’t really providing much detail as to the problem you are having.
For increased accuracy you could use the same method used in the Visual SEQ and the method I used for PEP. Calibrate the servo with the center position (0 deg) and the max and min positions, use the actual angle values and pwm values. You’ll see that (max pwm - center pwm)/“max deg value” won’t give the exact result as (center pwm - min pwm)/“min deg value”. Then use these two results for calculating the actual pwm value for angle values.