Hi
I managed to control servos in VB6 to my needs, however i would like to read analogue inputs from the ports into VB6.
How do i go about doing this?
Hi
I managed to control servos in VB6 to my needs, however i would like to read analogue inputs from the ports into VB6.
How do i go about doing this?
Hello.
What are you using to control your servos?
- Amanda
Apologies
i am using a Mini Maestro 12ch
Hello.
To read the analog voltage on a Maestro channel that is configured as an input, you can use the Get Position serial command. Please note that the values measured will range from 0 (representing 0V) to 1023 (representing 5V). More information about this command can be found in the “Serial Servo Commands” section of the Maestro controller’s user’s guide, which can be found under the “Resources” tab of its product page.
-Brandon
To get values in VB6 to integer as mV
(Ive left out the comm port stuff, I dont use MScomm)
Dim voltVal As Integer ' input values
Dim voltCommand(3) As Byte ' output command
Dim StrData As String * 2 ' input string
voltCommand(0) = 170 'start byte
voltCommand(1) = 10 'Device ID
voltCommand(2) = 16 'Command number &H10
voltCommand(3) = 0 'servo 1
'Send voltCommand byte array command over comm port
' When com port input buffer is filled put it in to StrData
' then put values into volt integer array
'low bit + hight bit = value
voltVal = Asc(Mid(StrData, 1, 1)) + (256 * Asc(Mid(StrData, 2, 1)))
'express as volts to text box
'5000 mV / 1023 units for Mv (/ 1000 to get volts to 2 decimal places)
Me.txtVolt.Item.Text = FormatNumber((voltVal * (5000 / 1023)) / 1000, 2)