VisualBasic variables
davide
Posts: 2
Hi everybody!
I'm new in Basic stamp programming. I've read all what I found about serial communications between VisualBasic and Basic Stamp but I didn't find what I'm looking for.
With Visual Basic Express sending values through the serial is easy. With SERIN command is easy reading the values. My problem is the "conversion". I'd like to send an integer from 0 to 200, read it with SERIN, subract 100 and send the pulse to the servo.
I succeeded in sending the values but they're not what I expected. I didn't understand what's happening. Can anybody help me?
Which kind of variable must I set in VB? Dec16, dec4, byte,...? And which kind of variable must I set in Pbasic?
Thanks a lot
I'm new in Basic stamp programming. I've read all what I found about serial communications between VisualBasic and Basic Stamp but I didn't find what I'm looking for.
With Visual Basic Express sending values through the serial is easy. With SERIN command is easy reading the values. My problem is the "conversion". I'd like to send an integer from 0 to 200, read it with SERIN, subract 100 and send the pulse to the servo.
I succeeded in sending the values but they're not what I expected. I didn't understand what's happening. Can anybody help me?
Which kind of variable must I set in VB? Dec16, dec4, byte,...? And which kind of variable must I set in Pbasic?
Thanks a lot
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
··· Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
······· If Timer1.Enabled = False Then
··········· SerialPort1.Open()
··········· Timer1.Enabled = True
······· Else
··········· Timer1.Enabled = False
··········· SerialPort1.Close()
······· End If
··· End Sub
··· Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
······· Dim vel As Int16
······· vel = VScrollBar1.Value
······· SerialPort1.Write(vel)
··· End Sub
End Class
And this is the pbasic code:
' {$PBASIC 2.5}
DEBUG "start"
pi VAR Word
DO
··· SERIN 16,16780, [noparse][[/noparse]DEC4 pi]
··· PULSOUT 13,750-(pi-100)
··· PULSOUT 12,750+(pi-100)
LOOP
END
The effect is very strange and absolutely unpredictable. The scrollbar goes from 0 to 100. I know (or I suppose) that it's only a problem in reading the values...