計測用車いすの開発
〜プログラムの詳細とダウンロード〜

Sub Calc_Encoder()
'
'************************************************
' エンコーダ信号の処理(12ビット→整数(0-4095))
'************************************************
'
For i = 0 To DataNum
  Encoder(0, i) = Encoder_raw(0, i) '0-255(下位8ビット)
  Encoder(1, i) = Encoder_raw(1, i) '0-255(下位8ビット)
  If Encoder_raw(2, i) >= 128 Then
    Encoder(1, i) = Encoder(1, i) + 2048
    Encoder_raw(2, i) = Encoder_raw(2, i) - 128
  End If
  If Encoder_raw(2, i) >= 64 Then
    Encoder(1, i) = Encoder(1, i) + 1024
    Encoder_raw(2, i) = Encoder_raw(2, i) - 64
  End If
  If Encoder_raw(2, i) >= 32 Then
    Encoder(1, i) = Encoder(1, i) + 512
    Encoder_raw(2, i) = Encoder_raw(2, i) - 32
  End If
  If Encoder_raw(2, i) >= 16 Then
    Encoder(1, i) = Encoder(1, i) + 256
    Encoder_raw(2, i) = Encoder_raw(2, i) - 16
  End If
  If Encoder_raw(2, i) >= 8 Then
    Encoder(0, i) = Encoder(0, i) + 2048
    Encoder_raw(2, i) = Encoder_raw(2, i) - 8
  End If
  If Encoder_raw(2, i) >= 4 Then
    Encoder(0, i) = Encoder(0, i) + 1024
    Encoder_raw(2, i) = Encoder_raw(2, i) - 4
  End If
  If Encoder_raw(2, i) >= 2 Then
    Encoder(0, i) = Encoder(0, i) + 512
    Encoder_raw(2, i) = Encoder_raw(2, i) - 2
  End If
  If Encoder_raw(2, i) >= 1 Then
    Encoder(0, i) = Encoder(0, i) + 256
    Encoder_raw(2, i) = Encoder_raw(2, i) - 1
  End If
Next i
'
End Sub

[ Wheelchair Home Page ] [ Wheelchair Measuring System ]
このページに関するお問い合わせはkhirata@nmri.go.jpまでお願いします