Shop OBEX P1 Docs P2 Docs Learn Events
Simple Serial and Using the data after — Parallax Forums

Simple Serial and Using the data after

TJHJTJHJ Posts: 243
edited 2008-05-27 22:33 in Propeller 1
So Im am transmitting from one prop chip to another, specifically from a proto bored to a uProp.

The problem arises that I cant seem to get a useable number on the side of the uProp.

So here is what I am doing.

It is one wire setup with the Proto Board sending and the uProp receiving.


So for Sending its basically doing this.
Ser.Tx(Number)




And on the receive side ive got it looking for two things, Im trying to get 2 sets of 4 numbers each.
Im trying to use -1 and -2 as my identifier for which set of data is coming through.
Repeat 
  Data := Ser.Rx
    if Data == -1
      Repeat r from 1 to 4
        EGT[noparse][[/noparse]r] := Ser.Rx
   if data == -2
     Repeat r from 1 to 4
        CHT[noparse][[/noparse]r] := Ser.rx




Then I use number to convert it to a string.

Oled.PutText(0,0,0,0,255,255,255, Num.Dec(EGT)) 'Print the value to the screen




Here is the issue. The value I get is strange. I get 00000000Number. Anyone know what I am doing wrong to get this error?

As always the help is greatly appreciated, and thank you for your time.
TJ

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-27 05:01
    Data will never be -1 or -2. The Ser.Rx routine returns a value from 0 to 255 only. Other problems include that you're using subscripts for EGT and CHT with values from 1 to 4 while a 4 byte array has subscripts from 0 to 3.
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-05-27 05:25
    Hello TJ,

    as your target is to display the numbers on a display. The numbers have to be translated anyway.

    I would take the Extended Full Duplex Serial-object from the obex to realize the datatransmission.

    obex.parallax.com/objects/31/


    This objects has methods for sending decimal values as a "string" and methods to receive a string
    receive a string like "5420" and transform it to the decimal VALUE 5420
    and much more predefined ready for use.

    It uses the FullDuplexSerial-object.
    My Opinion about the simple_serial-object is:
    it is simple CODED and has limitations in its use
    that make it difficult to USE

    The FullDuplexSerial-object is vice vera: it is complex CODED and easier to USE than simple-serial

    The Extended FullDuplexSerial uses FullDuplexSerial and adds more methods to it

    best regards

    Stefan

    Post Edited (StefanL38) : 5/27/2008 7:01:07 AM GMT
  • TJHJTJHJ Posts: 243
    edited 2008-05-27 19:27
    Awesome call on the extended serial object, but one question which mode should I use if I want it to be a one way one wire system? A little lost on this part.
    Thank you
    TJ
  • TJHJTJHJ Posts: 243
    edited 2008-05-27 22:33
    ok now Im just pounding my head at a wall, Ive got to be missing something basic, so here it what Im doing, as always thanks for all the help.

    Chip 1, TX Test Chip.



    Pub Main 
    ser.Start(9,8,2,9600) 
    Temp := String("33") 
    
    Repeat 
    
    
    ser.str(String("6")) 
    ser.str(String(","))
    


    The·uProp reciving side.


    PUB Gauge ''A display gauge and recoder 
    DELAY.Init(8_000_000) 
    OLED.InitOLED 
    OLED.CLS 
    Dira[noparse][[/noparse]18]~ 
    cognew(Getdata,@Stack1) 
    REPEAT 
     Print 
    
    
    Pub Getdata 
     ser.start(18,19,2,9600) 
     Repeat 
     Ser.rxstr(temp) 
     display := temp 
    
     
    Pub Print 
     oled.PutText (4,0,1, 255,255,0,Display) 
     oled.PutText (4,2,1, 255,255,0,num.dec(strsize(Display))) 
     Delay.PauseSec(2) 
     Oled.cls
    


    This puts on the screen "2 :22 :2 :2 :22 :2 :"
    and for the string size command 0000000014, I cant begin to explain why it has 8 zeros and then the lenght, Im assuming that its a 14 char string for some reason.

    Diferent numbers being tranmsitted result in different strings being shown, but always the same length in the StrSize command.
    For example 2 results in "N6NNNNNNN6NNNNN6"

    and if I use this code with out the comma to end it.

    Pub Main 
    ser.Start(9,8,2,9600) 
    Temp := String("33") 
    
    Repeat 
    
    
    ser.str(String("2"))
    

    I get "6666666666666" ·only 13·chars....




    ····


    I have·tired both the Tx,Rx Str as well as Tx,·Rx Dec and then convert it·to a string.

    At this point I'm so lost I dont know where I am anymore, So any help is always appreciated, and Thank you for your time to help.
    TJ
    ····
    Edit* The ser calls Extended_FDSerial.

    Post Edited (TJHJ) : 5/27/2008 10:42:15 PM GMT
Sign In or Register to comment.