×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

communication using RS232.

communication using RS232.

communication using RS232.

(OP)
Hi..

Can any one send me a piece of coding how to communicate or send data to RS232 terminal? I am trying to communicate between a PIC and PC through RS 232. I know how to communicate through PIC if a data comes to RS 232 terminal but i need to send some data to RS232 from the PC program. I am using a QBASIC 4.5.

Thanks a lot.
Jaman

RE: communication using RS232.

(OP)
can anyone give me a reply?

RE: communication using RS232.

Here is your reply.

The answer has always been 42

RE: communication using RS232.

(OP)
The answer has always been 42

what type of answer this is..is it a reply or something else...sorry...i couldnt figure out..

RE: communication using RS232.

(OP)
thanks a lot..i will look into those...

RE: communication using RS232.

On the earlier GWBasic it was a matter of opening the com port as a channel and reading from it or writing to it. Don't know if I can find any code in the archives and even if it would be helpful to the version you are using.

Ed Fair
Give the wrong symptoms, get the wrong solutions.

RE: communication using RS232.

Start up qbasic, press <esc> and then press <shift>F1 to bring up the help.

Move the cursor to "Index" and press return

Press the "O" key, this takes you to the "O" section of help.

Move the cursor to "Open COM" to display the syntax of the command to open a comms port.

For example, To open a comms port at 300 baud, no parity, 8 bits, for Random access as file number 1, the syntax is:

open "com1:300,n,8" FOR RANDOM AS #1

Use the RB[n] and TB[n] options to set the size of the receive and transmit buffers.

Then consult the help on Input #filenumber, variable list to discover the syntax of how to read from the com port.

Hope that's enough to get you going.

The syntax doesn't look much different from the old gwbasic so far as I recall.

RE: communication using RS232.

(OP)
yes i have gone thorugh that i tried with the following code:

DIM b AS STRING * 1 '1 byte string (8 bits)

OPEN "COM1:19200,N,8,1,BIN,CD0,CS0,DS0,OP0,RS,TB2048,RB2048" FOR RANDOM AS #1
For i = 1 to 1000
b = CHR$(7)
PUT 1, , b
next i
CLOSE

the purpose of this code is to send 7 continuously to the rs232(as i have understand from help). But whenever i run the code it shiws me that "device is not connected". But i know that rs232 is connected as i can download a hex file to a PIC using rs232 and that thing works just fine. SO there should not be any problem with rs232. May be i am missing something.I am still trying to figure out but any help would be greatly apperitiated.

Thanks
Jaman

RE: communication using RS232.

(OP)
also eof function can be used but at first i want to just send a numeric 7(with 8 bits) to rs232.

RE: communication using RS232.

Are you trying to run this under XP or NT or Win2k?

RE: communication using RS232.

chr$(37)?

Ed Fair
Give the wrong symptoms, get the wrong solutions.

RE: communication using RS232.

(OP)
that is the way (chr$(7)) i think to input 7 as an unsigned byte value..may be i am wrong..if so than let me know...

I have searched some documentation and found that this might be a reason..i am running in windows xp and using an old version of QBASIC(4.5). I want to synchronize it with an other program bcz this program will be tied up with a control algorithm that i have written in QBASIC 4.5. For some reason i need to synchronize a value with the PIC and thats why i need to send a data to rs232 so that PIC can peak the data whenever it will get a byte to its rs232 terminal. I am trying this thing in home now with PIC but in my lab i am using windows 98. There is a snowstrom today and will give a try to run the same thing in lab pc. In the mean time if you have something to say, just throw a message.

I am really stacked on this issue.

Thanks
Arif
 

RE: communication using RS232.

chr$(7) is bell code if I recall.  10=lf 12=ff 13=cr
numeric is 30(0) to 39(9)
Has been a while, and the memory is going.
Try a:
for v=20 to 45:print chr$(v):next
to see what it puts out.

Ed Fair
Give the wrong symptoms, get the wrong solutions.

RE: communication using RS232.

Will XP allow a dos program to access the ports..... it was difficult & slow with NT.

RE: communication using RS232.

(OP)
DIM b AS STRING * 1
DIM i AS LONG, le AS LONG

line input "File name? "; file$

OPEN file$ FOR INPUT AS #1 'verify file exists
CLOSE
OPEN file$ FOR BINARY AS #1
OPEN "COM1:19200,N,8,1,BIN,CD0,CS0,DS0,OP0,RS,TB2048,RB2048" FOR RANDOM AS #2
le = LOF(1)
PRINT "Transfering:"; le; "bytes at baud rate 19200 to COM1"
FOR i = 1 TO le
GET 1, , b 'read from #1, the file
PUT 2, , b 'write to #2, the COM1
NEXT i
CLOSE
PRINT "Done transfering in binary mode."
SYSTEM

this can send a entire binary file to rs232. I tried this today and think its okay although i couldnt figure out the PIC response. But may be tomorrow..Although its true that XP was a problem. Thank you guys for all your help. I will try to keep in touch.

Thanks
Arif

RE: communication using RS232.

Ed 0-9 is CHR$(48) to CHR$(57) (30-39 is hex value) but since you used 10 for line feed,12 for FormFeed,etc. it is assumed you are using decimal values.


RE: communication using RS232.

You're right. I was pulling the stuff from different periods of time in the memory where I was using different values.  Was just attempting to get him of chr$(7) for the decimal value 7.

Ed Fair
Give the wrong symptoms, get the wrong solutions.

RE: communication using RS232.

(OP)
i tried to catch the byte through PIC but seems to me not working..one reason might be that QBASIC has max baud rate 9600 but in PIC and hyperterminal i am using 19200..i have to strict on this 19200 as i am also displaying the PIC data using rs232..that issue is major concern than this issue...so although it will send byte to rs232 PIC will not recover it due to unsynchronize baud rate...around 7 days work just vanished..i need to fix the PIC coding in an another way..but this option (sending data to PIC through hyperterminal) is probably the most accurate one...

Arif

RE: communication using RS232.

I haven't used qbasic enough to know, but is it an issue that qbasic restricts the 19,2 or because you get data overrun at greater than 9600?
The communication channel in qbasic should be able to handle anything that hyperterminal can use since they are basically the same thing. It is in the processing, what they do with it, that creates speed problems.
I didn't see any of the code but a friend reported that they had problems with gwbasic attempting communications at greater than 9600, I think with the channel filling up from the front before the back end moved it out.
In my experimenting with transferring stuff back and forth with another processor I used a terminal emulator that had data capture capabilities.  Don't recall what it was but you might want to try one.

Ed Fair
Give the wrong symptoms, get the wrong solutions.

RE: communication using RS232.

(OP)
i was out of this discussion for a while due to an exam..anyway..i think that is an issue...qbasic help told me that baud rate shouldnt be more than that value(9600)..i am not sure what i will do....i will try to make it an another way first..if i fail..than i have to again think about it...can u somehow remember what terminal emulator you used...i am using TERA TERM PRO..

RE: communication using RS232.

Don't recall what I used then, possibly Arnet's term since I've been using it for years, but you probably could capture it with Century Software's "Tiny Term" which has an evaluation download available from the web.

Ed Fair
Give the wrong symptoms, get the wrong solutions.

RE: communication using RS232.

(OP)
found TINY TERM..30 days trial..if found useful than will try to buy..thanks a lot for your help..

RE: communication using RS232.

HELLOOOOOOO EVERY BODY.
I HAVE A QBASIC PROGRAM THAT DEALS WITH A ROBOT THROUGH A
COM.
I WANT TO OPEN THIS PROGRAM  BY MIXING IT IN A C\C++
PROGRAM SO AS TO GET AN EXE FILE ,ANY BODY KNOWS HOW TO INTERFACE QBASIC WITH C\C++?
ANSR ME AT

OOO_OOOMK1983@YAHOO.COM

RE: communication using RS232.

OOOOOOMK1983:

1) Why not rewrite the program in c++?
2) ask your question in the c++ forum.
3) stop yelling (ALL CAPS)
4) start your own thread for your own questions. You'll get notified when someone answers that way

The answer is "42"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close