EB500, I can send data but cant recieve?
Hey, So I got myself an EB500 and Ive been using it for about a week now. I can send data to it so that it moves forward, left, right,backward. What I cant get it to do·is send data. Heres my configuration:
Computer-COM3 Outgoing
··············COM4 Incoming
BS2 code:
' {$STAMP BS2}
' {$PBASIC 2.5}
dir VAR Byte
pulseCount VAR Byte
x VAR Byte
x=83
DO
SEROUT 1,84,[noparse][[/noparse]"TX",10,DEC 82,10]
SERIN 0,84,[noparse][[/noparse]WAIT("!"),DEC3 dir]
timeout:
IF (dir=1) THEN
FOR pulseCount = 0 TO 50
PULSOUT 13,650
PULSOUT 12,850
NEXT
ENDIF
IF (dir=2) THEN
FOR pulseCount = 0 TO 50
PULSOUT 13,850
PULSOUT 12,650
NEXT
ENDIF
IF (dir=3) THEN
FOR pulseCount = 0 TO 50
PULSOUT 13,850
PULSOUT 12,850
NEXT
ENDIF
IF (dir=4) THEN
FOR pulseCount = 0 TO 50
PULSOUT 13,650
PULSOUT 12,650
NEXT
ENDIF
RETURN
LOOP
and it is recieved by the vb code i wrote
·
Computer-COM3 Outgoing
··············COM4 Incoming
BS2 code:
' {$STAMP BS2}
' {$PBASIC 2.5}
dir VAR Byte
pulseCount VAR Byte
x VAR Byte
x=83
DO
SEROUT 1,84,[noparse][[/noparse]"TX",10,DEC 82,10]
SERIN 0,84,[noparse][[/noparse]WAIT("!"),DEC3 dir]
timeout:
IF (dir=1) THEN
FOR pulseCount = 0 TO 50
PULSOUT 13,650
PULSOUT 12,850
NEXT
ENDIF
IF (dir=2) THEN
FOR pulseCount = 0 TO 50
PULSOUT 13,850
PULSOUT 12,650
NEXT
ENDIF
IF (dir=3) THEN
FOR pulseCount = 0 TO 50
PULSOUT 13,850
PULSOUT 12,850
NEXT
ENDIF
IF (dir=4) THEN
FOR pulseCount = 0 TO 50
PULSOUT 13,650
PULSOUT 12,650
NEXT
ENDIF
RETURN
LOOP
and it is recieved by the vb code i wrote
·
Comments
The RETURN will probably make your Stamp reset because there's no saved return address.
BS2 code:
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
SEROUT 1,84,[noparse][[/noparse]"TX",10,DEC 82,10]
LOOP
and my vb code:
Public Class Form1
Dim in_data As String
Dim sData As Byte
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.Open()
CheckForIllegalCrossThreadCalls = False
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Do
in_data = SerialPort1.ReadLine()
Loop Until in_data = "TX"
in_data = SerialPort1.ReadLine()
TextBox1.Text = in_data
SerialPort1.ReadExisting()
End Sub
End Class
Serial port is on COM4 with the rest default settings.
The light on the EB500 is not on like it is when I have it wait to get data.
‘{$STAMP BS2}
bData VAR BYTE
‘Wait for the eb500 radio to be ready
PAUSE 1000
Main:
SERIN 0,84,[noparse][[/noparse]STR bData\1]
DEBUG STR bData\1
GOTO Main
I try to send a letter or w/e by typing in the COM3 debug terminal and the program hangs, and the TX light just stays on and then the program crashes. Is something horribly wrong here???
Some suggestions:
There is a pin on the EB500 which goes high when the unit connects. In the sample code you will see that the code waits for this pin to go high before proceeding. Just waiting usually works, but if the computer is busy it can take a little longer. If the LED isn't lit, you aren't connected.
Try using hyperterminal. There is a complete code example in the docs. That way you can find out if you have the EB500 wired and configured correctly. I don't know VB well enough to say if your code there is ok, but if hyperterm gets the data, it is prolly a VB issue.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Have fun!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
·· For future reference please post new or clarified information in follow-ups.· These types of bumps messages (usually deleted) don't offer anything new to members reading the thread and therefore if they had nothing to offer before, it is unlikely that will change.· If you're not getting replies you may need to provide additional information or at the very least, the results of what you have tried since your last post.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering