⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modpara.bas

📁 使用的是最小误差法的插补程序
💻 BAS
字号:
Attribute VB_Name = "modPara"
Public txt1 As Single                 '8个等级判断参数
Public txt2 As Single
Public txt3 As Single
Public txt4 As Single
Public txt5 As Single
Public txt6 As Single
Public txt7 As Single
Public txt8 As Single
Public speedPara As Single          '转数
Public stepAnglePara As String      '步进电机步距角(度/步)(0.36)
Public StepAngle As Single          '主轴步进角(度/步)
Public Steps As Integer             '步进电机步数
Public plus  As Single               '脉冲宽度
Public StopPlus  As Single           '判主轴启动后停止脉冲宽度
Public ParaPlus1 As Single          'plus1
Public Const pi = 3.14159265358979

Public UpPlus As Integer     '加速角度
Public DownPlus As Integer   '减速角度
Public AllPlus As Integer    '所有角度
Public Const DownRate = 25    '减速比

Public a1 As Single                  '加速度 (减速度=-a1)

Public f0 As Long               '启动脉冲频率(Hz)
Public f1 As Long               '匀速脉冲频率(Hz)

'从数据文件中读取数据至内存变量
Public Sub para_Read()

'读取等级判断数据
Open App.Path & "\Para.dat" For Input As #1
    Input #1, txt1
    Input #1, txt2
    Input #1, txt3
    Input #1, txt4
    Input #1, txt5
    Input #1, txt6
    Input #1, txt7
    Input #1, txt8
    Input #1, speedPara
    Input #1, stepAnglePara
    Input #1, StopPlus
    Input #1, ParaPlus1
    Input #1, USTimer
Close #1

    StepAngle = stepAnglePara / DownRate     '0.0144
    
    f1 = Int(speedPara * 360 / StepAngle)                    '计算匀速脉冲宽度
    f0 = Int(f1 / 10)
    a1 = (f1 - f0) / (UpPlus / StepAngle)

End Sub

'将内存变量写入数据文件中
Public Sub para_Write()
Open App.Path & "\Para.dat" For Output As #1

    Print #1, txt1             '将设置的参数写入文件para.dat
    Print #1, txt2
    Print #1, txt3
    Print #1, txt4
    Print #1, txt5
    Print #1, txt6
    Print #1, txt7
    Print #1, txt8
    Print #1, speedPara
    Print #1, stepAnglePara
    Print #1, StopPlus
    Print #1, ParaPlus1
    Print #1, USTimer
Close #1
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -