clemen2
01-20-2006, 09:33 AM
Hi
·
I am having trouble with my ping))) sensor when using the extra RS-232 connection on the PDB (with BS2px stamp).· My goal is to send the distance data to a VB 6 program.· The Ping sensor works fine when using the programming RS-232 and the debug window.· My stamp program and VB can exchange data without a problem through the extra RS232 connection (thanks to an excellent Nuts and Volts article #89, September 2002).· But when I try to use the extra RS232 connection and the Ping))) together the VB program does not receive the correct distances just a bunch of ascii 9’s or 10’s.
·
Here is the program that fails to work properly:
·
'{$STAMP BS2px}
' {$PORT COM1}
' {$PBASIC 2.5}
·
Ping··········· PIN···· 8
·
·
RX············· CON···· 9······················ ' receive (from PC)
TX············· CON···· 10······················ ' transmit (to PC)
RTS············ CON···· 11····················· ' Request To Send (from PC)
CTS············ CON···· 12······················ ' Clear To Send (to PC)
Trigger········ CON···· 13
Scale·········· CON···· $0CD··················· ' raw x 0.80 = uS
RawToCm ········CON···· 2257··················· ' 1 / 29.034 (with **)
Baud··········· CON···· 396···················· 'N9600 for BS2px
IsHigh········· CON···· 1······················ ' for PULSOUT
'IsLow·········· CON···· 0
·
i·············· VAR···· Word
rawDist· ·······VAR···· Word··················· ' raw measurement
cm············· VAR···· Word
·
Main:
SERIN RX, Baud, [WAIT("p")]
·
FOR i = 1 TO 300
· PULSOUT Ping, Trigger························ ' activate sensor
· PULSIN· Ping, 1, rawDist················ ' measure echo pulse
· rawDist = rawDist */ Scale··················· ' convert to uS
· rawDist = rawDist / 2························ ' remove return trip
· Cm = rawDist ** RawToCm
· PAUSE 10
· 'Cm.LOWBYTE = 121
· 'Cm.HIGHBYTE = 122
· SEROUT TX\RTS, Baud, [Cm.LOWBYTE,Cm.HIGHBYTE]
NEXT
GOTO Main
END
·
· Note that if I remove comment ticks from lines ·'Cm.LOWBYTE = 121 and 'Cm.HIGHBYTE = 122, VB correctly receives the 121 and 122 data (300 pairs) without hitch.
·
Any ideas?
Cliff
·
I am having trouble with my ping))) sensor when using the extra RS-232 connection on the PDB (with BS2px stamp).· My goal is to send the distance data to a VB 6 program.· The Ping sensor works fine when using the programming RS-232 and the debug window.· My stamp program and VB can exchange data without a problem through the extra RS232 connection (thanks to an excellent Nuts and Volts article #89, September 2002).· But when I try to use the extra RS232 connection and the Ping))) together the VB program does not receive the correct distances just a bunch of ascii 9’s or 10’s.
·
Here is the program that fails to work properly:
·
'{$STAMP BS2px}
' {$PORT COM1}
' {$PBASIC 2.5}
·
Ping··········· PIN···· 8
·
·
RX············· CON···· 9······················ ' receive (from PC)
TX············· CON···· 10······················ ' transmit (to PC)
RTS············ CON···· 11····················· ' Request To Send (from PC)
CTS············ CON···· 12······················ ' Clear To Send (to PC)
Trigger········ CON···· 13
Scale·········· CON···· $0CD··················· ' raw x 0.80 = uS
RawToCm ········CON···· 2257··················· ' 1 / 29.034 (with **)
Baud··········· CON···· 396···················· 'N9600 for BS2px
IsHigh········· CON···· 1······················ ' for PULSOUT
'IsLow·········· CON···· 0
·
i·············· VAR···· Word
rawDist· ·······VAR···· Word··················· ' raw measurement
cm············· VAR···· Word
·
Main:
SERIN RX, Baud, [WAIT("p")]
·
FOR i = 1 TO 300
· PULSOUT Ping, Trigger························ ' activate sensor
· PULSIN· Ping, 1, rawDist················ ' measure echo pulse
· rawDist = rawDist */ Scale··················· ' convert to uS
· rawDist = rawDist / 2························ ' remove return trip
· Cm = rawDist ** RawToCm
· PAUSE 10
· 'Cm.LOWBYTE = 121
· 'Cm.HIGHBYTE = 122
· SEROUT TX\RTS, Baud, [Cm.LOWBYTE,Cm.HIGHBYTE]
NEXT
GOTO Main
END
·
· Note that if I remove comment ticks from lines ·'Cm.LOWBYTE = 121 and 'Cm.HIGHBYTE = 122, VB correctly receives the 121 and 122 data (300 pairs) without hitch.
·
Any ideas?
Cliff