How do one send ASCII characters using a serial ogject
Siri
Posts: 220
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]
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]
pdf
225K
Comments
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).
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
I'd really recommend you change the 'text' to something less confusing like 'vga'
there is a method "out"
the documentation as comments inside the method says
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
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
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
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
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
best regards
Stefan
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