ascii via serial link

Tyro

Member
I want to send via the serial output a string of numbers. I am constrained by the hardware to only be able to use out0. I am using the sertxd command. The device is an 08M2.

symbol tripped = pin3

main:

pause 100
if tripped = 0 then goto main
pause 100
if tripped = 0 then goto main

let b1 = 1

sertxd(#b1)

goto main

The first portion is debounce code.

Manual 2 states:
The # symbol allows ASCII output. Therefore #b1, when b1 contains the data
126, will output the ascii characters “1” ”2” ”6” rather than the raw data 126.

The output however is read as "s". The measured binary output is 1 01110011

What am I doing wrong?
 

lbenson

Senior Member
Is your baud rate correct at 4800? If before "main" you put "sertxd("Started",cr,lf)", does that appear correctly?
 

Tyro

Member
The baud rate is correct. If I use what you suggested (sertxd("Started",cr,lf) on the picaxe terminal I see the words Started with an unprintable character and a carriage return but that is not what I want. I need to write a decimal number and transmit it as an ascii code. I am not adding the cr,lf at the moment so that it is easy for me to look at the output on a scope and decide what is happening.
 

BESQUEUT

Senior Member
01110011 is OK for lowercase character "s"
I suppose you measure the binary output : 1 01110011 with the scope.

If I use what you suggested (sertxd("Started",cr,lf) on the picaxe terminal I see the words Started with an unprintable character and a carriage return .
And nothing more ?

Did you putt "sertxd("Started",cr,lf)" before "main" as suggested by lbenson ?
Can you test same thing just before "sertxd(#b1)"

NB : b1 content the "one" value, so you expect to see an ASCII 49 character, IE "110001" on the scope
lf is enought ; you can ommit cr
 

Tyro

Member
I am measuring the ones and zeros with a digital scope. I did sertxd("Started",cr,lf) before the main and got "started" on the picaxe terminal.

I repeated sertxd("Started",cr,lf) just above sertxd(#b1).

On power up started gets printed. I press the button and started gets printed again followed a 1 below it. This is using the picaxe terminal. My equipment just reads junk and the digital signal still shows 's' as the third byte from the end instead of '1'

I will repeat, I want to write a decimal number and transmit it as an ascii character. I understood that #b1 would do this when b1 = 1.
 

lbenson

Senior Member
So with the PC connected to the picaxe with the programming cable, the Programming Editor terminal shows what you expect? But when you connect your equipment, you get something different?

This indicates that the picaxe is transmitting as anticipated. What is your equipment? Picaxe sertxd transmits "idle low"; many devices expect to receive "idle high", such as most usb/serial modules. What do you get if instead of sertxd, you use "serout 0, T4800_4,(#b1)"?
 

AllyCat

Senior Member
Hi,

I am measuring the ones and zeros with a digital scope.
If you're reading the bits on a 'scope, are you sure that you're reading them correctly (usually logic 0 = high and LS Bit is first)? I notice that 's' ($73 = 0111 0011) is '1' ($31 = 0011 0001) inverted and reversed.

Cheers, Alan.
 
Top