intercommunications between 2 ProtoBoard with rs232
nomad
Posts: 276
RE: intercommunications between 2 ProtoBoard with rs232
hi,
for my project, i work on a intercommunications between 2 protoboards
with the FullDuplexSerial-Object, without rs232-hardware, only with
2 cables (rx,tx).
- the master have a vga_text-Object for output.
- the slave have a led on/off - stuff (control for running)
i think, my 2 spin-programms working correctly.
but i have a problem with the transmitting a decimal-value
(x := 1000) from the slave to the master.
what i want:
1) transmit decimal-values from the slave to the master
2) master receive this value and working with this value.
please give me some tips for this problem
thanks
regards
nomad
hi,
for my project, i work on a intercommunications between 2 protoboards
with the FullDuplexSerial-Object, without rs232-hardware, only with
2 cables (rx,tx).
- the master have a vga_text-Object for output.
- the slave have a led on/off - stuff (control for running)
i think, my 2 spin-programms working correctly.
but i have a problem with the transmitting a decimal-value
(x := 1000) from the slave to the master.
what i want:
1) transmit decimal-values from the slave to the master
2) master receive this value and working with this value.
please give me some tips for this problem
thanks
regards
nomad
{******************************************************************************
rs232TestMaster_vgaOut_1.spin
******************************************************************************}
OBJ
ExtSerial : "FullDuplexSerial" ' Full Duplex Serial Controller
text : "vga_text" ' Create vgaText-object
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
serRecv = 1 ' Receive on I/O pin 0 = red
serXmit = 0 ' Transmit on I/O pin 1 = black
VAR
BYTE str
PUB main | c
text.start(16)
text.str(string("Serial-InputTest",13,10))
ExtSerial.start(serRecv,serXmit,%0000,9600) ' 9600 Baud
repeat
'text.str(string("repeat",13,10))
if(c := ExtSerial.rxtime(500)) => 0 ' Wait up to 500ms for a character
'text.str(string(" Received",13,10))
str := c
text.out($0D) '
text.dec(str)
waitcnt(30_000_000 + cnt)
case c
"0".."9": ' do something with a digit
"A".."Z","a".."z": ' do something with a letter
'13: ' ok, here's a return
' 8: ' backspace key
{***************************************************************************
rs232Test_slave_1.spin
-----------------------
***************************************************************************}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
serRecv = 0 ' Receive on I/O pin 0
serXmit = 1 ' Transmit on I/O pin 1
ledon = 4
VAR
BYTE sendbyte
OBJ
ExtSerial : "FullDuplexSerial"
Pub Test1
dira[noparse][[/noparse]ledon]~~
ExtSerial.start(0, 1, 2, 9600) '- rxpin,txpin,mode,Baud
' -1 = receive = read (rxpin)
' 0 = transmission = write (txpin)
' - depends on your set up
sendbyte := 125
repeat 1000 ' repeat 5 times
!outa[noparse][[/noparse]ledon]
'ExtSerial.tx(sendbyte)
ExtSerial.str(string("123",13)) ' old ("A",13,10)) ' \r = for linux carridge return
'waitcnt(100_000_000 + cnt) 'wait a length of time
{********************************************************************************************}

Comments
ExtSeria.dec(var) should work for what you are trying to do..
Oldbit
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buttons . . . check. Dials . . . check. Switches . . . check. Little colored lights . . . check.
— Calvin, of 'Calvin and Hobbes.
thanks for the tip.
regards
nomad
Best you collect all characters (upto the stop condition, e.g. 13) in a vector, add a zero byte.
and let NUMBERS.fromString(..) do the dirty work
thanks for the tip
today (sunday) i testing the whole stuff
regards
nomad