Shop OBEX P1 Docs P2 Docs Learn Events
SerialCommunications Troubles — Parallax Forums

SerialCommunications Troubles

nomadnomad Posts: 276
edited 2009-04-20 21:18 in Propeller 1
Ref: SerialCommunications Troubles

hi,
i have a propeller professional Development Board aka PPDB
the board have a integrated RS232-Port and integrated blue LEDs
the board is running, all ok.
but i have some troubles with the serialCommunications.
what i can is:
send a string to my linux-box = no problem all is ok
what i will:

1) the board waiting for datas at RX
2) from the linux-box send a command (output = 1) as a string
= sendData = "1" is = ascci = 49
3) the board receive this datas,
if the datas are valid then the blue Led blinks
(in the future, the board control with this datas
the servos)

now the problems:
1) when i send "1" then receive the sometimes input (ascci 49) as
byte
== its possible that the receive DEC (1) not (ascci 49)????

2) i can't go this way: linux send, board receive and send back
this is in the moment not posible ???
timing-troubles

3) under windows with hyperterminal board send datas OK
4) if the board wait on incoming datas from hyperterminal
it's not run

it's the folowing stuff possible:
- 1) board wait for datas
- 2) linux send Datas to the board
- 3) board receive datas (not necessary)
- 4) if datas ok then led-blink (this is a must) for servos
- 5 goto 1

as attached files are : serialPropDevBoard111.spin
and the linux program : serialPropDevBoardxxx.spin ( *.cpp)

for any help tricks and tips i'm verry glad
Regards
nomad

here is the spin-code:
{
   serialPropDevBoard111.spin
   dd. 19.04.2009
******************************************************************************************
}
Con
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  Rx   = 31
  Tx   = 30
  baud = 9600

OBJ
   ' Ser : "FullDuplexSerial"
   Ser : "Extended_FDSerial"

Var
  byte input  '(from linux: 1)
  byte output '(to linux: 5 as Dec)   
   
Pub Start

  dira[noparse][[/noparse]0]~~   ' Pin05 set output leds  
  outa[noparse][[/noparse]0]~    ' Pin05 set low

  Ser.Start(Rx,Tx,0,baud)

  repeat 
     Ser.Start(Rx,Tx,0,baud)

     input:= Ser.RxTime(100)

     waitcnt(clkfreq / 10 + cnt)

     ' make leds blink
     'if input == 49
     '   !outa[noparse][[/noparse]0]

     ' some stuff to experiments
     Ser.str(string("5")) ' send string
     output := 5
     Ser.dec(input)        ' send 
     waitcnt(clkfreq / 10 + cnt)

{*************************************************}


Post Edited (nomad) : 4/19/2009 1:37:40 PM GMT

Comments

  • simonlsimonl Posts: 866
    edited 2009-04-19 14:42
    @nomad: I think you're getting these problems because you have "Ser.Start(Rx,Tx,0,baud)" inside your "repeat". Try removing that...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again wink.gif
    BTW: I type as I'm thinking, so please don't take any offence at my writing style smile.gif
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-19 15:06
    Hello Nomad,

    the codeline

      Ser.Start(Rx,Tx,0,baud)
    
    



    starts a new cog with the serial-driver (this is the FullDuplexSerial-object

    you have to call this only ONCE and BEFORE your repeat loop

    if call it over and over again. The cog that is running the serial driver stops and starts again and again
    The stop and start of the serial cog takes some time and in this time some bits can get lost that you want to receive

    best regards

    Stefan
  • nomadnomad Posts: 276
    edited 2009-04-19 15:57
    hi stefan and simonI,
    yesshes,
    THANKS, smhair.gif
    i'm stupid.
    excuse
    thanks for your answers
    regards
    nomad
  • simonlsimonl Posts: 866
    edited 2009-04-19 17:32
    Nah; not stupid - I often stare at code not seeing the obvious! Glad it's working now smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again wink.gif
    BTW: I type as I'm thinking, so please don't take any offence at my writing style smile.gif
  • nomadnomad Posts: 276
    edited 2009-04-20 07:14
    hi simon,
    i hope this, that the code now working.
    when i read your message here, in switzerland ist the time (sunday) evening at 19.00pm
    today (monday) i work with the new code, and i hope all is ok
    regards
    nomad
  • nomadnomad Posts: 276
    edited 2009-04-20 09:08
    hi simon and stefan,
    all stuff are running (send/receive) and the stuff with the blue LED is also OK
    thanks a lot
    regards
    nomad
  • simonlsimonl Posts: 866
    edited 2009-04-20 21:18
    Excellent! Well done smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again wink.gif
    BTW: I type as I'm thinking, so please don't take any offence at my writing style smile.gif
Sign In or Register to comment.