Shop OBEX P1 Docs P2 Docs Learn Events
Unable to display Serial data — Parallax Forums

Unable to display Serial data

SiriSiri Posts: 220
edited 2008-06-16 15:07 in Propeller 1
I am trying to display serial data sent from a serial device·to a 4 line serial LCD display(From Prallax).
I can display text using "serial_LCD" object but I am unable to display couple of bytes received from a serial device and captured to a variables(EX:Sdata1,Sdata2,Sdata3).

1.I tried using the Serial_LCD object with the command - [noparse][[/noparse]serial.putc(Sdata1)· - did not work
2.I tried using BS2 Functions with command - BS2.SEROUT.dec(pin,baud,mode,byte) - this did not work either- used the inverted and normal modes(1 and 0) - no luck
3.I tried the BS2 examples as in the uploaded code - did not work either

a.The LCD display is connected to pin 26 , Baud 9600- works well for text.
b.I am receiving the serial data via pin 30,31 at baud 9600,inverted signal
c.I have checked for matching- baud rates,modes,
d.I checked the receiveing serial signals - which I can display on VGA set-up and a TV set-up - using "VGA······ Object and TV_text objects from the object libraray.But unable to display the same serial signals on the LCD display.

I have attached a code I have used.

Some help will be greately appriciated.

Siri

P.S
··· Tried to upload file but was not able to do so - (Server problem)
·Here it is :

CON· ·_clockmode= xtall + pll16x
········ _xinfreq = 5_000_000

OBJ·· BS2 : "BS2_Functions"
········ Serial:"Extended_FDSerial
········ LCDText: "Serial_Lcd"

Var·· byte SData1,SData2,SData3

PUB· Main
····· Serial.start(31,30,0,9600)
····· LCDText.init(26,9600,4)

···· DisplayLCDText
···· GetSerialData

PUB DisplayLCDText

··· LCDText.backlight(false)
··· LCDText.cls
··· LCDText.home
··· LCDText.str(string("Heart Rate: "))
··· LCDText.gotoxy(0,3)
··· LCDText.str(string("Resp.Rate:"))

PUB GetSerialData

·· Repeat
···· LCDText.cls
···· SData1 := Serial.Rx
···· SData2 := SerialRx
···· SData3 := SerialRx
···· BS2.SEROUT_dec(26,SData1,9600,0,8)
···· LCDText.gotoxy(0,3)
···· BS2.SEROUT_dec(26,SData2,9600,08)

·I tried changing to different LCD·lines and I tried changing dec to char(BS2-command) and also tried the BS2 examples to display any serial data even substituting decimal numbers instead of Sdata1 and SData2 - just to see whether I can display decimal data - which are not even received via serial data capture.

Siri


·······



Post Edited (Siri) : 6/14/2008 9:01:45 PM GMT

Comments

  • RaymanRayman Posts: 14,233
    edited 2008-06-15 02:41
    Siri: I thought you had this fixed already!

    What is the format of the data you are receiving? If it ascii coded decimal, it probably takes a few bytes to represent a heartrate number.... If it's in binary format, you'll need to convert to decimal to display...

    Are you able to display the correct data on your VGA display? Can you post this code too?
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-06-15 08:37
    hello Siri,

    professional developers go ahead quickly because of their experience
    but: when ever a problem came across they will analyze the problem
    first step as you did by guessing hm it might be this and make a very quick test

    If this does not solve the problem they change their strategy to elimination of reasons.

    This means going back to a state where everything is clear. And then change or add one thing step by step
    looking what happens.

    Make a loop that sends defined values with BS2.SEROUT_dec to the LCD.
    If nothing happens on the display: Check what does the propeller send out

    Receive the data from the propeller with a PC-Terminalsoftware
    If the PC-Terminalsoftware receives the correct bytes you have narrowed down the problem
    to a problem about the LCD-receiving

    If the PC-Term-Software receive strange things you have narrowed down the problem
    to a "PropBlem" smile.gif) of BS2.SerOut_Dec

    best regards

    Stefan
  • SiriSiri Posts: 220
    edited 2008-06-15 17:06
    Rayman,
    You are right I had the problem solved - then the display was to a TV monitor,after that I tried with success porting the same data to
    a VGA monitor.
    Now I wan't to bring down the size of the display to a 4 line LCD.Which I thought from the previous experience would be a peice of cake, but
    not so.
    The LCD displays Text sent using"Serial_Lcd" object but I can't find any command that will send the contents of a variable to the LCD.
    Right now I am trying to send a variable - Ex.: Sdata:= 123 so it would print it on the Lcd screen ( with no reference to serial data) -
    I used the command : - using "Serial_Lcd" object initilized as - Serial :"Serial_Lcd"

    Serial.putc(Sdata) -- no response from the LCD
    Serial.str(string(" Heart Rate:")) -- prints on the Lcd screen with no problem.

    so I figure there is ? I am using the command in a wrong manner.

    ·Stefan,
    ·········· I have nothing else hooked to the prop now - except the Lcd display to pin 26.

    Thanks

    Siri

    Post Edited (Siri) : 6/15/2008 5:16:11 PM GMT
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-06-15 17:47
    I'm using the Parallax 4x20 Serial LCD to display mouse position, using the following code. Debug_Lcd is from the Object Library at the Parallax website.

    CON
    ··
    · _clkmode = xtal1 + pll16x·
    · _xinfreq = 5_000_000

    var
    · byte· X
    · byte· Y
    · byte· Temp1
    obj
    · LCD :· "Debug_Lcd"
    · Debug: "FullDuplexSerialPlus"
    · Mouse: "Mouse"

    Pub Main | value

    · value := LCD.init(0, 9600, 4)····· ' Return value of init. -1 is "True"
    · waitcnt(5_000_000 + cnt) 'Wait for 1000 ms
    · LCD.cls
    · LCD.gotoxy(0,3)
    · LCD.Str(String ("LCD init: "))
    · If value
    ··· LCD.Str (String ("Successful"))
    · Else
    ··· LCD.Str (String ("Failed··· "))
    · LCD.dec(value)
    · LCD.backlight(True)
    · LCD.gotoxy(0,0)
    · LCD.Str(String ("X position: "))
    · LCD.gotoxy(0,1)
    · LCD.Str(String ("Y position: "))
    · Mouse.Start(24,25)················ ' 25 is dpin, 24 is cpin
    · waitcnt(240_000_000 + cnt)
    · Temp1 := Mouse.present
    · LCD.gotoxy(0,2)
    · LCD.Str (String ("Mouse·· : "))
    · If Temp1
    ··· LCD.Str (String ("Present"))
    · Else
    ··· LCD.Str (String ("Not found"))

    · repeat
    ··· X := Mouse.abs_x
    ··· LCD.gotoxy(12,0)
    ··· LCD.dec(X)
    ··· Y := Mouse.abs_y
    ··· LCD.gotoxy(12,1)
    ··· LCD.dec(Y)··
    · LCD.backlight(False)
    · LCD.finalize
  • SiriSiri Posts: 220
    edited 2008-06-15 19:15
    Rayman/stefan/sylvie

    I have solved the issue of displaying serial data on the LCD.

    The problem was : I was using 2 serial objects initialized using the dame pin(26) which was connected to the LCD. I also used
    "FullDuplexSerial: command = serial.dec to display the variable.

    Now I am using both the serial objects in one program - but I have to stop one of them to use the other and re-initialize to the same
    pin(26).
    Both objects function well as long as they stopped/re-initilized prior to using them.

    Thanks to all you patient guys who listen to us and helping

    Siri
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-06-15 20:14
    Hello Siri,

    the LCD is a serial device just receiving serial data. The LCD doesn't care at all how the bitbanging is created
    as long as all parameters are fitting. The main thing about the LCD-object is to provide commands
    like Cls Gotxy etc. These methods use the method putc and putc uses method tx which is the same name as in
    the Extended_FD_Serial-object.

    Could you attach your code to a posting ?
    I would like to take a look inside.
    I think it will be quite easy to add the methods of the LCD-object to Extended_FD_Serial
    or modify the LCD-object that it uses Extended_FD_Serial instead of simple_serial

    Then you can use ONE object without starting/stopping two of them all the time

    best regards

    Stefan
  • SiriSiri Posts: 220
    edited 2008-06-16 15:07
    Stefan,

    I am at work now and I will post the code for you to see - when I get home.

    Thanks again,

    Siri

    Back Home now - Here is the Code:

    { Propeller LCD serial data Display "ONLY" - 06/15/08 }

    CON

    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000



    OBJ Serial : "FullDuplexSerial"
    Lcd :"Serial_Lcd"

    VAR
    Byte SData1,SData2,SData3 'Variables for serial data


    PUB Main
    Lcd.init(26,9600,4)
    Serial.start(30,31,1,9600)

    LcdTextDisplay
    DisplaySerialData


    PUB LcdTextDisplay

    Lcd.cls
    Lcd.home
    Lcd.str(string("Heart Rate:"))
    Lcd.gotoxy(0,1)
    Lcd.str(string("Oxygen Sat:"))
    Lcd.gotoxy(0,2)
    Lcd.str(string("Status :"))


    PUB DisplaySerialData

    Lcd.finalize

    Repeat
    SData1 := Serial.Rx 'Receives data from serial device
    SData2 := Serial.Rx
    SData3 := Serial.Rx
    Serial.stop 'stop "FullDuplexSerial initialized to Pins 30&31

    Serial.start(0,26,1,9600) ' re-initilize to connect to P26 to send data to Lcd

    Serial.Tx(139) 'move cursor to Rt. to display "SData1"
    Serial.dec(SData1)
    Serial.Tx(159) 'move cursor to next line and position - SData2
    Serial.dec(SData2)
    Serial.Tx(179) 'move cursor to next line and postion - SData3
    Serial.dec(SData3)


    Siri

    Post Edited (Siri) : 6/16/2008 7:17:50 PM GMT
Sign In or Register to comment.