pyrrhicpk wrote:
hi zenta,
just wanted to ask you about PWM/deg factor in the PEP setup sheet. Where are these values being used? are these being used as the servo limit values? if yes, then whats the significance in determining the PWM/deg factor?and can you plz elaborate me how have you implemented these values in the code?to me these seem some values being used in some conditional statements during the motion sequences.
thanks,
umar
Hi,
They are used to calculate the correct position. I believe I'm using the same method that are used in Visual SEQ. Here is the sub in PEP:
Code:
Sub CalculatePWM(LimitPWMRow As Integer, PWMFactorRow As Integer)
'Calculate the actual pwm value to each servo, uses PWM/deg factor from PEP sheet Setup
'Left front leg:
If TempCoxaDEG >= 0 Then
'calculate 0 deg to max deg PWM value:
TempCoxaPWM = Worksheets("Setup").Cells(LimitPWMRow, 3) + (TempCoxaDEG * Worksheets("Setup").Cells(PWMFactorRow, 3))
'Check MAX limit PWM value:
If TempCoxaPWM > Worksheets("Setup").Cells(LimitPWMRow, 4) Then
TempCoxaPWM = Worksheets("Setup").Cells(LimitPWMRow, 4)
End If
Else
'calculate <0 deg to min deg PWM value
TempCoxaPWM = Worksheets("Setup").Cells(LimitPWMRow, 3) - (TempCoxaDEG * Worksheets("Setup").Cells(PWMFactorRow, 2))
'Check MIN limit PWM value:
If TempCoxaPWM < Worksheets("Setup").Cells(LimitPWMRow, 2) Then
TempCoxaPWM = Worksheets("Setup").Cells(LimitPWMRow, 2)
End If
End If
If TempFemurDEG >= 0 Then
TempFemurPWM = Worksheets("Setup").Cells(LimitPWMRow, 6) + (TempFemurDEG * Worksheets("Setup").Cells(PWMFactorRow, 5))
'Check MAX limit PWM value:
If TempFemurPWM > Worksheets("Setup").Cells(LimitPWMRow, 7) Then
TempFemurPWM = Worksheets("Setup").Cells(LimitPWMRow, 7)
End If
Else
TempFemurPWM = Worksheets("Setup").Cells(LimitPWMRow, 6) - (TempFemurDEG * Worksheets("Setup").Cells(PWMFactorRow, 4))
'Check MIN limit PWM value:
If TempFemurPWM < Worksheets("Setup").Cells(LimitPWMRow, 5) Then
TempFemurPWM = Worksheets("Setup").Cells(LimitPWMRow, 5)
End If
End If
If TempTibiaDEG >= 0 Then
TempTibiaPWM = Worksheets("Setup").Cells(LimitPWMRow, 9) + (TempTibiaDEG * Worksheets("Setup").Cells(PWMFactorRow, 7))
'Check MAX limit PWM value:
If TempTibiaPWM > Worksheets("Setup").Cells(LimitPWMRow, 10) Then
TempTibiaPWM = Worksheets("Setup").Cells(LimitPWMRow, 10)
End If
Else
TempTibiaPWM = Worksheets("Setup").Cells(LimitPWMRow, 9) - (TempTibiaDEG * Worksheets("Setup").Cells(PWMFactorRow, 6))
'Check MIN limit PWM value:
If TempTibiaPWM < Worksheets("Setup").Cells(LimitPWMRow, 8) Then
TempTibiaPWM = Worksheets("Setup").Cells(LimitPWMRow, 8)
End If
End If
End Sub