vb bs2 and psc!
Greetings all, I am having a problem with a simple little project I wonder if someone might have any thoughts on.
I am trying to send data from a vb app to my bs2, then relay this data to a psc. This is an adaptation of the simple "send data to a micon" tutorial at rentron. Here is the VB code, followed by the bs2 code.· I am using a joystick control that returns a large range, I have scaled it accordingly and have determined that servopos is a good value between 250-1250(using a label to see value realtime and by inserting a breakpoint and reading value)·this is after the mscomm output event, so I assume that the data was sent. So I guess the problem is in my bs2 code. Does anyone have any thoughts?, Thanks in advance!
edit*· I should note that in the mscomm.output event I am unable to wrap servopos with a chr$, I am not sure why but an error is raised when I do, could this be the problem, is the data the wrong "type" for the serin command on the bs2. I know that my psc is connected correctly because I can move the servos with simple bs2 code. THANKS AGAIN!
VB6.0 cod
BS-II code
·
Thanks again!
Post Edited (rounder) : 3/1/2005 3:34:16 AM GMT
I am trying to send data from a vb app to my bs2, then relay this data to a psc. This is an adaptation of the simple "send data to a micon" tutorial at rentron. Here is the VB code, followed by the bs2 code.· I am using a joystick control that returns a large range, I have scaled it accordingly and have determined that servopos is a good value between 250-1250(using a label to see value realtime and by inserting a breakpoint and reading value)·this is after the mscomm output event, so I assume that the data was sent. So I guess the problem is in my bs2 code. Does anyone have any thoughts?, Thanks in advance!
edit*· I should note that in the mscomm.output event I am unable to wrap servopos with a chr$, I am not sure why but an error is raised when I do, could this be the problem, is the data the wrong "type" for the serin command on the bs2. I know that my psc is connected correctly because I can move the servos with simple bs2 code. THANKS AGAIN!
VB6.0 cod
Option Explicit
Public Sub Form_Load()
JKJoystick1.TStart
Dim Pins As Long
For Pins = 0 To 15
cboPinNumber.AddItem CStr(Pins)
Next Pins
cboPinNumber.ListIndex = 0
optState(0).Value = True
MSComm1.CommPort = 1
MSComm1.Settings = "2400,N,8,1"
MSComm1.DTREnable = False
MSComm1.PortOpen = True
End Sub
Public Sub JKJoystick1_PosChange(NewX As Long, NewY As Long, NewThrottle As Long, NewRudder As Long)
Dim PinNumber As Long
Dim servopos As Long
servopos = ((NewX / 65.534 + 250))
PinNumber = cboPinNumber.ListIndex
MSComm1.Output = Chr$(255) & Chr$(PinNumber) & servopos
Label3.Caption = servopos
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
BS-II code
·
' {$STAMP BS2}
' {$PBASIC 2.5}
PinNumber VAR Byte
PinState VAR Word
ch VAR Byte
pw VAR Word
ra VAR Byte
sdat CON 15
baud CON 396
ra = 10
Main:
SERIN 16,16780,[noparse][[/noparse]WAIT(255),PinNumber,PinState]
SEROUT sdat, Baud+$8000,[noparse][[/noparse]"!SC", PinNumber, ra, PinState.LOWBYTE, PinState.HIGHBYTE, CR]
GOTO Main
Thanks again!
Post Edited (rounder) : 3/1/2005 3:34:16 AM GMT

Comments
VB 6.0 code
stamp code
' {$STAMP BS2} ' {$PBASIC 2.5} pos VAR Word ra VAR Byte sdat CON 15 baud CON 396 chan VAR Byte ra = 0 Main: SERIN 16,16780,[noparse][[/noparse]WAIT(255), chan, DEC pos] SEROUT sdat, Baud+$8000,[noparse][[/noparse]"!SC", chan, ra, pos.LOWBYTE, pos.HIGHBYTE, CR] GOTO MainPost Edited (rounder) : 3/1/2005 7:21:06 AM GMT