Mesa 7i96 to spindle FWD/REV control
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 23297
- Thank you received: 4938
21 May 2021 18:30 #209774
by andypugh
Replied by andypugh on topic Mesa 7i96 to spindle FWD/REV control
I have VBA code that does it in Excel. Let me go to the other computer...
Function INTERPXY(Optional ZValues As Range, Optional X As Double, Optional Y As Double, Optional Xaxis As Range, Optional Yaxis As Range) As Double
Dim Xmax, Xmin, Ymax, Ymin, Ystart, q1 As Integer
Dim V, V1, V2, V3, V4 As Double
Dim dx, dy As Double
If Xaxis Is Nothing Then Set Xaxis = ZValues.Resize(RowSize:=1).Offset(RowOffset:=-1)
If Yaxis Is Nothing Then Set Yaxis = ZValues.Resize(ColumnSize:=1).Offset(ColumnOffset:=-1)
' Find X bracket
Xmax = 0
Xmin = 1
Do
Xmax = Xmax + 1
If X >= Xaxis(1, Xmax).Value Then Xmin = Xmax
Loop Until Xmax >= Xaxis.Count Or Xaxis(1, Xmax).Value >= X
' Find Y bracket
Ymin = 1
Ymax = 0
Do
Ymax = Ymax + 1
If Y >= Yaxis(Ymax, 1).Value Then Ymin = Ymax
Loop Until Ymax >= Yaxis.Count Or Yaxis(Ymax, 1).Value >= Y
' Set 4 corner values
' V1 V2
' V3 V4
V1 = ZValues(Ymin, Xmin).Value
V2 = ZValues(Ymin, Xmax).Value
V4 = ZValues(Ymax, Xmax).Value
V3 = ZValues(Ymax, Xmin).Value
If Xmax <> Xmin Then
dx = (X - Xaxis(1, Xmin).Value) / (Xaxis(1, Xmax).Value - Xaxis(1, Xmin).Value)
Else
dx = 0
End If
If Ymax <> Ymin Then
dy = (Y - Yaxis(Ymin, 1).Value) / (Yaxis(Ymax, 1).Value - Yaxis(Ymin, 1).Value)
Else
dy = 0
End If
INTERPXY = (1 - dx) * (1 - dy) * V1 + dx * (1 - dy) * V2 + (1 - dx) * dy * V3 + dx * dy * V4
End Function
The following user(s) said Thank You: mhd325ic
Please Log in or Create an account to join the conversation.
- mhd325ic
- Offline
- New Member
-
Less
More
- Posts: 19
- Thank you received: 3
23 May 2021 11:19 #209888
by mhd325ic
Replied by mhd325ic on topic Mesa 7i96 to spindle FWD/REV control
Thanks Andy, This helps a lot!
Please Log in or Create an account to join the conversation.
Moderators: PCW, jmelson
Time to create page: 0.112 seconds