Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format of data out of serial port

Status
Not open for further replies.

RandyVSP

Technical User
Apr 18, 2003
44
US
I have a program working, to send a single charactor out the serial port under QBASIC. I send the charactor, then wait, then if no response is found in the rx buffer, I send again, max of three tries, then onto next charactor.

My loop is simply "for adres = 1 to 10"
then the variable adres is used as :
"print #1,adres"

Im using this to output a address for a microchip polling project.

My question is simply this : when I do the above loop and Print # 1 function, what is the format of that variable? Is is ASCII, hex, binary or what???? My guess is ASCII, and that would be 7 bits, and the port is setup for 9600, 8 bits, no parity, and 1 stop bit.

Anyone been into this before??

Randy McKenzie
 
Printing the ascii character into an 8 bit character cell, which can be considered hex or binary as those are reprentations of the character you are dealing with.
With your code you are getting a terminator after the character you are sending.

Sounds suspiciously like homework, but for the moment will let it excape the flag. But somebody else may take offense.

Ed Fair
Give the wrong symptoms, get the wrong solutions.
 
Actually this is for a Amateur radio project Im working on. What is the added bit, making the 7 bit ASCII into 8 bit?? I desire a binary 8 bit unit....can QBASIC send binary instead of ASCII???? Or do I convert from ASCII to binary using the CHR$ stuff? Been along time since my BASIC class in High School.....

The desired goal is to have eventually numerous addressable PICS, each monitoring various items, connected via a RS485 network, polled by a master PC.

Been a LONG time since I had homework.....

Randy McKenzie
Actual age : 35, but sometimes feel 65, but wife says I act like 5......
 
7bit ascii is simply chr$(0) - chr$(127)
8bit is chr$(0) - chr$(255)

when you send info to a serial port you send the chr$(#) or
equiv. Qbasic (or QuickBasic) or any other programming language together with the operating system will take care of sending the bits (serial ports receive/send 1 bit at a time).

Some of the control codes (chr$(1)-chr$(29)) are typically
used to tell the receiver you are through sending. This is
part of (but certainly not all of) what is known as "handshake". (BTW even chr$(0) is used making up what is known as an ASCIIZ string (null terminator).

there are lots of examples of sending info over a serial port. You might look at allbasiccode.com or QB45.com

FYI it's been a lot longer for me (since i've had homework).
LOL
 
Wouldn't consider the terminator as handshake. Printing as shown you would get the character plus a 0Dh and an 0ah, otherwise known as carraige return and linefeed.
You probably would want to suppress those with the semicolon.
And I assume that you would build in some time delay for checking the return code, since the earliest you could get a valid one would be 2 character cell widths after you wrote to the data register, which can be a while after you do a print statement.
To get around the variable delay of the print statement you might want to consider the poke/peek pair.

Ed Fair
Give the wrong symptoms, get the wrong solutions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top