Shop OBEX P1 Docs P2 Docs Learn Events
How do one send ASCII characters using a serial ogject — Parallax Forums

How do one send ASCII characters using a serial ogject

SiriSiri Posts: 220
edited 2009-04-14 23:29 in Propeller 1
I am trying to communicate with a Thermocouple module(WTTCI-M - Data info attached) which uses ASCII charscters to communicate.
I tried using Full Duplex serial/FD serial - I was able to send and receive data but - the echoed back data is "garbled out stuff" not readable.
The indicator light on the Thermocouple blinks indicating on going communication.

Some help is greatly appriciated.

Here is the code I am using :

[noparse][[/noparse]code]:{VGA- display Themocouple Data}



CON
'Set clock speed to 80 MHz
_clkmode = xtal1 + pll16x 'Sets the clock speed to 80 MHz using a times 16 multiplier
_xinfreq = 5_000_000 'Crystal speed: 5 MHz


VAR
Byte Temp 'Declares variable for first byte of data from Thermocouple
Byte Temp1
Byte Temp2
Byte Temp3

OBJ

Text : "VGA_Text"
serial :"Extended_FDSerial"

PUB Start

serial.start(6,5,0,9600) ' Rx,Tx, Mode, Baud
text.start(16)

DisplaySerialData



PUB DisplaySerialData
repeat
serial.str(string("ATAJ"))
waitcnt((clkfreq/1000 * 100)+cnt)

Temp:=serial.RxTime(100)
'waitcnt((clkfreq/1000 * 100)+cnt)


Text.str(Temp)
waitcnt((clkfreq/1000 * 100)+cnt)


[noparse][[/noparse] /code]

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-14 15:21
    You wrote "Text.str(Temp)". That won't do what you want. It transmits a zero-terminated string given the address of the start of the string.

    You probably want to do "Text.tx(Temp)" which transmits the single character contained in "Temp".

    Note: If your "serial.RxTime" times out, you'll get a -1 value which will transmit as all one bits ($FF).
  • SiriSiri Posts: 220
    edited 2009-04-14 15:43
    Mike'
    Thanks for replying so fast

    But :

    "Text.tx(Temp)" does not compile - error message "expected a sub-routine)"
    Mike it does not time out - it keeps sending garbage to the screen.
    Thanks,

    Siri

    Post Edited (Siri) : 4/14/2009 5:04:09 PM GMT
  • Brian FairchildBrian Fairchild Posts: 549
    edited 2009-04-14 16:08
    Text.tx(Temp) is trying to send Temp to the VGA not the serial port.

    I'd really recommend you change the 'text' to something less confusing like 'vga'
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-14 16:54
    So in the file VGA_Text.spin

    there is a method "out"

    the documentation as comments inside the method says

    PUB out(c) | i, k
    
    '' Output a character
    ''
    ''     $00 = clear screen
    ''     $01 = home
    ''     $08 = backspace
    ''     $09 = tab (8 spaces per)
    ''     $0A = set X position (X follows)
    ''     $0B = set Y position (Y follows)
    ''     $0C = set color (color follows)
    ''     $0D = return
    ''  others = printable characters
    
    
    



    anyway to narrow down the problem:

    did you made tests using a PC as the masterdevice with the sensor ?

    The sensor creates +-12V as signal-levels are yiu using at least current-limiting resistor between sensor Tx and propeller Rx ?

    a better way would be to use the ciruit shown in the Propellerdatasheet with two transistors

    first test I would do is PC with a terminalprogram like PST.EXE.
    PST.EXE is ready for receiving data and then do a power on which makes the module send a "!"

    if this works STILL CONECTED TO THE PC try to send "RA" to test if you get a result of the connected sensor.

    If this works connect propeller to the PC and test if the PC can receive characters properly

    If all this works then connect the propeller to the sensor

    best regards

    Stefan

    Post Edited (StefanL38) : 4/14/2009 6:02:17 PM GMT
  • SiriSiri Posts: 220
    edited 2009-04-14 16:55
    Brian,

    I am sending "Temp" to the VGA port and not to the serial port.
    I do see the data in the VGA screen but it not readable it is suppose to be "ATAJ" - ehoed back and displayed on the VGS screen

    Thanks

    Siri
  • SiriSiri Posts: 220
    edited 2009-04-14 17:00
    Stefan,

    I am trying to display the contents of the variable"Temp" which is received via the serial port from the thermocouple module.
    I am not trying to just display characters.

    Thanks

    Stefan
  • SiriSiri Posts: 220
    edited 2009-04-14 19:08
    Stefan,

    Thank you very much.

    I used the thermocouple with the manufactures software and it worked well.The temperature was displyed on the computer screen.
    Where I had the problem was using the propeller to display it on a VGA screen.

    When I used as you suggested "Text.out" with the VGA_Text object - I was able to display the echoed commands as it is suppose to.
    Only thing I had to do was to add a carriage return to the commands to display the wright text.

    Thank you once again for your help.

    Siri
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-14 19:09
    Hello Siri,

    It is very clear to me that you want to communicate between propeller and sensor

    You didn't provided any information of what tests you have done and what works properly
    So the bug could be in several places

    - damaged Propeller-IO-pin because of connecting prop-IO-pin to +12V
    - inverted Tx and/or Rx line required


    I took a look into the datashet
    it says Note 1: All command strings sent to the data module should be preceded with the header character (see Table 1),

    and terminated with a carriage return. <

    All responses from the data module will also appear in this format.

    so therefore you have to send

      serial.str(string("ATAJ",13))
    
    



    best regards

    Stefan
  • SiriSiri Posts: 220
    edited 2009-04-14 23:29
    Stefan et al

    Thank you very much for your time. I am happy that people like you are there help us.

    Thaks to all of you who helped me to resolve my problem.

    Regards to you all,

    Siri
Sign In or Register to comment.