Sensing switch positions and transmitting status via serial port
Jerry Roach
Posts: 13
I am working on a project to sense 5 switch positions and report switch status to the host computer at least 6 times a second. There will be 2 systems running simultaneously so each stamp must have a unique identification to the host computer. I was thinking of using 3 of the I/O ports to create an address to ID each stamp with dip switches. And then have 5 I/O lines sense the switch positions in a continuous loop. Effectively sending a byte of data in a loop to the host computer to interpret. I have tested this with the debug terminal using the following:
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
DEBUG ? IN0
DEBUG ? IN1
DEBUG ? IN2
DEBUG ? IN3
DEBUG ? IN4
DEBUG ? IN5
DEBUG ? IN6
DEBUG ? IN7
LOOP
I don't understand how to do this by transmitting the information to the computer (Via RS232) where It can be received and interpreted by the computer monitoring the stamp provided switch positions in another application besides the stamp debug software. Can anyone give me some pointers with the code? I've study up on the SEROUT command, but I don’t know how to program and test the switch monitoring with this function.
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
DEBUG ? IN0
DEBUG ? IN1
DEBUG ? IN2
DEBUG ? IN3
DEBUG ? IN4
DEBUG ? IN5
DEBUG ? IN6
DEBUG ? IN7
LOOP
I don't understand how to do this by transmitting the information to the computer (Via RS232) where It can be received and interpreted by the computer monitoring the stamp provided switch positions in another application besides the stamp debug software. Can anyone give me some pointers with the code? I've study up on the SEROUT command, but I don’t know how to program and test the switch monitoring with this function.
Comments
You can easily create a program in Visual Basic.NET Express (which is free), by using the Serial Control.
Not sure if this is what you asked for.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
SEROUT 1,16468,[noparse][[/noparse]INL]
LOOP
But you could just use DEBUG...
DO
DEBUG DEC INL
PAUSE 100
LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
Aslo use port 16 as suggested , it is easy to debug.
Of course after you are done wiht your developent run you Stamps but stop the editor.
·
DO
DEBUG DEC INL
PAUSE 100
LOOP
But it is not sensing the the switch position in IN0. I no it works because it works on my previous program. Any thoughts? Also I changed DEC to SDEC.