a new try, communication between 2 propellers
nomad
Posts: 276
RE: a new try, communication between 2 propellers
hi
since 4 days, i have big troubles with this 2 spin-programms.
what i want is:
1) the slave transmit a value (LONG rxVal := 8)
2) the master receive the value and working with it (Long txVal should be 8)
for this 2 programms i make following changes:
- a gnd-line between the 2 props
after running: the result from master:
- code goes into "wrong" with IF c<0 OR c>9 output is: -48
now the questions:
on both programms
1) serial.start(rxpin,txpin,mode,baud)
- mode = %0000 = 0
- is this correct
2) on slave: (sender - transmit Datas)
- LONG txVal
- serial.dec(8) ' or txVal
- serial.tx(13) ' as CR
- are this statements correct
3) on master (Receiver)
- is this statement correct
- IF(c := serial.rxtime(500)) => 0 ' Wait up to 500ms for a character
- are the statements correct
4) i have tested the statement <values :=10*values +c>
- if c:= 8 , if have correct answer = text.dec(values) == 8
i dont know whats going wrong.
please help me.
regards
nomad
here the complete codes
hi
since 4 days, i have big troubles with this 2 spin-programms.
what i want is:
1) the slave transmit a value (LONG rxVal := 8)
2) the master receive the value and working with it (Long txVal should be 8)
for this 2 programms i make following changes:
- a gnd-line between the 2 props
after running: the result from master:
- code goes into "wrong" with IF c<0 OR c>9 output is: -48
now the questions:
on both programms
1) serial.start(rxpin,txpin,mode,baud)
- mode = %0000 = 0
- is this correct
2) on slave: (sender - transmit Datas)
- LONG txVal
- serial.dec(8) ' or txVal
- serial.tx(13) ' as CR
- are this statements correct
3) on master (Receiver)
- is this statement correct
- IF(c := serial.rxtime(500)) => 0 ' Wait up to 500ms for a character
- are the statements correct
REPEAT c := serial.rx-"0" ' statement: c:=rx-"0" not correct IF c<0 OR c>9 text.out($0D) text.str(string("Wrong c:" )) text.out($09) text.dec(c) QUIT values := 10*values +c text.out($0D) text.dec(values)
4) i have tested the statement <values :=10*values +c>
- if c:= 8 , if have correct answer = text.dec(values) == 8
i dont know whats going wrong.
please help me.
regards
nomad
here the complete codes
' master - reader - receiveData {******************************************************************************} OBJ serial : "FullDuplexSerial" ' Full Duplex Serial Controller text : "vga_text" ' Create vgaText-object CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 rxpin = 1 ' Receive on I/O pin 0 = red txpin = 0 ' Transmit on I/O pin 1 = black VAR LONG values PUB main | c text.start(16) text.str(string("Serial-InputTestMaster",13,10)) serial.start(rxpin,txpin,%0000,9600) '- rxpin,txpin,mode = 0, Baud = 9600 REPEAT IF(c := serial.rxtime(500)) => 0 ' Wait up to 500ms for a character values := 0 REPEAT c := serial.rx-"0" ' statement: c:=rx-"0" not correct IF c<0 OR c>9 text.out($0D) text.str(string("Wrong c:" )) text.out($09) text.dec(c) QUIT values := 10*values +c 'text.out($0D) 'text.dec(values) {************************************************************************} ' slave - Sender - transmitData {************************************************************************} CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 rxpin = 0 ' Receive on I/O pin 0 -> red -> to txpin txpin = 1 ' Transmit on I/O pin 1 -> black -> to rxpin ledon = 4 VAR LONG txVal ' transmit = 8 OBJ serial : "FullDuplexSerial" Pub Main txVal := 8 dira[noparse][[/noparse]ledon]~~ serial.start(rxpin,txpin,%0000, 9600) '- rxpin,txpin,mode,Baud REPEAT 5000 !outa[noparse][[/noparse]ledon] serial.dec(8) ' or txVal serial.tx(13) {************************************************************************}
Comments
If at failure the value is -48, as "0" has value 48, that means serial.rx returned a value of zero.
I would suggest getting the transmitter and receiver working separately with HyperTerm or some other terminal emulator before trying to get the two talking to each other. Having a 0V (GND) link between the two is essential.
I cannot help with the FullDuplexSerial object questions as I'm not fmiliar with it.
thanks for your answer.
in the meantime, the 2 programms are running and working
on the master its:
if input c := 8 (transmit from slave)
then output: is ascii <57> == decimal 8
i have changed the following statements:
thanks
regards
nomad
please look on the german-forum
regards
nomad
all problems OK
all programms running correctly
regards
nomad