Shop OBEX P1 Docs P2 Docs Learn Events
a new try, communication between 2 propellers — Parallax Forums

a new try, communication between 2 propellers

nomadnomad Posts: 276
edited 2007-10-05 12:33 in Propeller 1
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
     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

  • hippyhippy Posts: 1,981
    edited 2007-10-02 11:53
    If you send anything other than ASCII digits then your validity check will fail when those characters are received -
        c := serial.rx-"0"
        IF c<0 OR c>9
    
    


    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.
  • nomadnomad Posts: 276
    edited 2007-10-02 15:35
    hi hippy
    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:
    if(c := ser.rxtime(500)) => 0 
          str := c
          text.out($0D)  ' 
          text.dec(str)
    
    


    thanks
    regards
    nomad
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-02 16:56
    Nomad, this is no explanation for anything...
  • nomadnomad Posts: 276
    edited 2007-10-03 07:02
    hi deSilva,
    please look on the german-forum
    regards
    nomad
  • nomadnomad Posts: 276
    edited 2007-10-05 12:33
    hi
    all problems OK
    all programms running correctly
    regards
    nomad
Sign In or Register to comment.