SERIN SEROUT terminal echo program

RogerTango

Senior Member
I tried writing a silly echo program to gain more familiarization with serial comms.

I used pin 0 just like the programmer, if I loop a serout only the text comes across Hyperterm no problems.

However if I do a serin and check for <> "" then go to the sub to output, I only get garbage on the screen.

Am I making a mistake using the same pin for SERIN and SEROUT? I tried using a pause also... didnt help.

What do I need to make a simple echo on the AXE please?

Thanks,
Andrew
 

RogerTango

Senior Member
I see now, I cannot use Pin0 for serin.

So I rewrote it to use serrxd and sertxd (might as well get familiar with both), however no text is being printed.

When I do a loop using

main;
sertxd("Hello World",cr,lf)
goto main

Nothing comes up on my terminal, and I have it set to 4800.

Im lost at this point, Ive spent 30 minutes trying to get it to work, without help I give up. Google has just confused me at this stage of the game.

BTW, 14M is being used.

Andrew
 

RogerTango

Senior Member
Okay, I went back and checked a few things, I have sertxd working when I push a button.

However, now I am not sure, does serrxd behave the same as serin, where as it must wait for data and no interrupts are processed until said is true?

I have not yet been able (as far as I can tell) receive data from HyperTerm on the AXE and echo it back. Should I pick a particular protocol, like VT100? This is slightly elusive to me.

Thanks-
Andrew
 

Jeremy Leach

Senior Member
I've never tried to echo from hyperterminal - is the serrxd immediately after the sertxd in your code then? And how much delay is built into the echo in hyperterminal? If none, then I guess it's possible that the serrxd command isn't executed in time to catch the echo??
 

RogerTango

Senior Member
I tried it with no dealy (in code) and with 20ms delay, nothing ever worked.

It _appears_ that serrxd is "not supported"?? The more I read the docs & Hippy's website, the more confused I am on this particular command.

Andrew
 

Jeremy Leach

Senior Member
I don't think there should be confusion here really Andrew. With any command you should refer to manual 2 "Basic commands summary" and see if the command is relevant to your picaxe type. I've never used Serrxd, but as the manual says it's via the serial input programming pin and 4800 baud if your picaxe is running at 4MHz.

When I say delay, I mean delay in Hyperterminal. Because I've never used echo, I don't even know if you can add a delay. But you are sertxd out from picaxe to hyperterm, and echoing back (maybe after a delay) from hyperterm to picaxe serrxd. All I'm saying is that maybe it echos the data back to the picaxe so rapidly that the picaxe hasn't managed to execute the serrxd in time. I really don't know though ...just guessing.
 

Technical

Technical Support
Staff member
Code:
main:
serrxd b1
sertxd (b1)
goto main
Do not use Hyperterminal and the programming editor at the same time as you will get a COM port clash. To start with simply use the terminal function within the programming editor itself (PICAXE>Terminal menu).
Type a character at the bottom of the terminal screen and click 'send'.

After you download this program you will have 'disconnect'-ed your PICAXE-14M from any other new program download. You will therefore have to do a battery 'hard-reset' to download a new program (see the manual for more details).
 

RogerTango

Senior Member
Thank you for your additional information, however these details has already become evident in my experimenting.

The code you just outlined is a duplicate of what I had programmed last night, cut & dry echo. I used the term in the PICAXE programmer also, no echo.

Does the serrxd look at pin0 (or whatever the programmer pin is)?
sertxd works fine without changing anything, right out the chip to the PC.

Thanks-
Andrew
 

moxhamj

New Member
Yes it can be done http://www.instructables.com/id/Control-real-world-devices-with-your-PC/

Lots of tricks. Like as technical says, you only have one com port so you have to remember whether it is hyperterm using it or the download program. Almost worth having two PCs while you debug it.

You have to get the N or T right. You have to get the circuit right on your particular picaxe input pin - replicate the 10k/22k circuit on another pin, or use a max232 (but watch the inversion). Output can be directly from another pin to the PC.

If it can talk to vb.net it can talk to hyperterminal.

vt100 doesn't matter - vt100 just adds commands so the cursor can move around the screen (useful when you are running wordstar on a remote board).

Do it in stages. Hyperterminal at 2400 baud, 8 bits, 1 stop bit, no parity and flow control=none.

Simple loopback device - a D9 pin with pins 2 and 3 joined. I have used mine many times.

Hyperterminal, single character to a picaxe, and get the picaxe to light a led when it gets that character.

Watch which port hyperterminal defaults to. Mine defaults to com2 and it needs to use com1. I saved that as a session, then went and found the little .ht setup file, and put a shortcut to that on the desktop. Now hyperterminal starts with all the settings as they should be.

Then new code, picaxe sends a single character every second and see if it appears on hyperterminal.

Try at 2400 first, then raise the baud rate later.

Absolute simplest serin code will be:
serin 3,N2400,b0

Absolute simplest serout code will be:
serout 0,N2400,(b0)

Pins don't really matter. I used 3 for input and 0 for output on an 08M.

And that is deliberately going to pin0, because this is the same pin as the feedback pin from the picaxe to the picaxe program editor - but you would never need to worry about that because the picaxe editor is shut down and you are now using hyperterminal instead. Right? (I made that mistake about 20x when writing that instructable *grin*)
 
Last edited:
Top