Quickbasic com1

loup garou

New Member
New here.....so Hi to everyone.

I programmed the 8M to output an analogue value 0-255 derived from an LDR.
The good news is it works.......I get an output displayed on the terminal set to 2400 baud, even works on hyperterminal and something I networked in XP. The bad news is I'm trying to look at the output using quickbasic and so far I've failed.

<CODE>
OPEN "COM1:2400,N,8" FOR INPUT AS #1
INPUT #1,VAR
PRINT VAR
CLOSE #1
<END CODE>

OK that was as near as I can come to a simple Quickbasic Program......
Where have I gone wrong.

I just need to get something off the ground in Quickbasic or GW then maybe VB6 and even .NET.

I'll take this one step at a time so Quickbasic for now would do just fine.
Pulling my hair out over this one. Thanks in advance John.

HELP PLEASE!!
 

eclectic

Moderator
John.

I can't help with the code, but, can possibly help with the marketing:

1. This area is for Finished projects.

2. Please re-post your question in the Main / Active Forum.

e
 

boriz

Senior Member
How about putting it in a loop. Something like…

Code:
OPEN "COM1:2400,N,8" FOR INPUT AS #1
do
    do
        i$=inkey$
        INPUT #1,VAR
    loop until (VAR>0) or (i$>””)
    PRINT VAR
loop until i$>””
CLOSE #1
 

LizzieB

Senior Member
Have you ever used that Quick Basic to access the serial port in XP? If it's the old Microsoft Quick Basic then AFAIK it won't work because that Basic can't access the serial port in any Windows after 9x.

If you like Basic but want one that works very well with current versions of windows* and allows you to use most windows functions then let me recommend Liberty Basic.

*Full Vista compatibility coming soon.
 

moxhamj

New Member
Re: "I just need to get something off the ground in Quickbasic or GW then maybe VB6 and even .NET."

Why not just go to .NET? Lots of things in the world of windows are not backwards compatible, especially serial ports. Indeed, almost every new version of basic has left out serial port drivers, till all the programmers jumped up and down and demanded they put them back in. .NET has serial port drivers (at last!) If you go from QB up to .NET, none of the code will port across each version anyway, as they insist on changing the syntax in every version. At least picaxe basic is stable *sigh*.

Plus, vb.net is free. See below for code examples.

http://www.instructables.com/id/Control-real-world-devices-with-your-PC/

PS - reckon QB is legacy? I'm coding at the moment in Micro-Soft Basic [capture from terminal]

A>mbasic
BASIC-80 Rev. 5.21
[CP/M Version]
Copyright 1977-1981 (C) by Microsoft
Created: 28-Jul-81
30776 Bytes free
Ok


Why? Because the above was done on a board that cost not much more than a 40X. MBASIC can talk to picaxes too - in fact it is much simpler than vb.net. And look at all those yummy Bytes Free!

Let me know if you have trouble understanding anything in that Instructable.
 

Marcwolf

Senior Member
Dr_Acula :- Yes - and I can hear the gears on your Babbage engine meshing from up here in Brisbane :>


Loup Garou - Visual Basic 6 is an easier alternative to QBasic. (and I have been programming in basic since 1974 :>) One can handle the interaction between a serial port and the application by using the MSComm control.

Unfortunately with Windows and DOS programs - the DOS runs in a very protected environment and that means that any access to the hardware is heavily controlled.

So the only way to work with any certainty on a Windows enviroment is to use a Windows language.

With dotNET - yes - it is free however your learning curve will be a LOT greater.

If you need to get hold of a copy of one of the older Windows basic's drop me a line.

Dave
 

hippy

Ex-Staff (retired)
The bad news is I'm trying to look at the output using quickbasic and so far I've failed ... Where have I gone wrong.
Hard to say as (1) I'm not familiar with quickbasic and (2) you don't say what the actual problem is; does it not compile, does it run but give an error, does it run but not print anything ?

You may need to open the COM1: port differently and you quite often have to override the RTS and other control lines or the program just hangs.

Which OS are you using ? Does it support serial port access from MS-DOS command line programs ?

Google is probably the best bet for general serial comms with microcontrollers and what works with another should work with the PICAXE. There are a number of postings in the forum showing how to do such comms in various languages.

You also need the PICAXE side working correctly. Ensure what you send is terminated with CR and LF and check it works using the Programming Editor Terminal function first.
 

SD2100

New Member
Try this, I wrote it in QuickBasic 4.0 and tested input from a 28x1, it will sit and wait for data and display it when it arrives or press any key to end the program.

Code:
    OPEN "COM1:2400,N,8,1,TB32,RB32,RS,OP,CD0,DS0" FOR RANDOM AS #1
    DO
        IF LOC(1) > 0 THEN
            DO
               PRINT ASC(INPUT$(1, 1))
            LOOP UNTIL LOC(1) = 0
        END IF
    LOOP WHILE INKEY$ = ""
    CLOSE #1
    END
 

loup garou

New Member
Thanks a million!!

I used to post on a totally unrelated forum and it used to tell me if someone had replied to one of my posts/threads. My heart sank a bit because I thought I had, had no interest.:( I know better now and have ticked that box.

Then :D My........... what a reply guys (gals included)
You all amaze me......

I need to give you all some feedback my thanks is overflowing.

In short I got a worker.....

Phil I looked at your code first and thought to myself that's a flyer and so I gave it a try typed it in exact. Sure enough values appeared on the screen.

eclectic............thank you for pointing out my error about posting in the wrong area. Double thanks to BeanieBots :) for puting my post in the right place...........I was in such a state over my little project I just wasn't thinking.

boriz.........I agree it all had to go in a loop but just one value at that point would have been heaven to me. So thanks. I don't know why but it's the top line that would prove to be the hardest and as it is was it wasn't going to work. I will explain later.

LizzieB....Thanks for the tip on windows versions....I went through hell with all of that when I was looking at the centronics port a few years ago. I got there in the end. So if anyone has woes. I read through a whole book and tried everything and only on the last page did it tell me I'd be wasting my time after windows 95/98.............got round it in VB6/XP back then.

This first toe in the water was with Windows 95 and Quickbasic 4.5 just to be safe. Windows 98 would give the same results I think for the centronics port.
"Liberty Basic" noted will try, thanks....
....but we are talking COM1 here so sorry to go all over the place.

Dr_Acula..........I'm hearing you.........MBASIC sounds interesting....
While I was down in the dumps I did try something in VB 2008 a free download and right up to date and what I wrote was simple but only runs for say a minute and then locks up. I will be sharing that prog with all later and maybe we all can get it to run perfect together.....cause that would be great.

Marcwolf.........I agree........I messed around in VB6 for a while and yes I have a copy around here and I may try something in that, but as you'll have just read..........VB2008 might just make it so easy it's unreal.....will post that code...later, but soon.

hippy.........Agreed I went through the same thought process as you and by now I've answered all those points you've raised..........which brings me right back in a circle to.........

Phil.........you are the main reason I've got a program up and running in Quickbasic. My main problem was opening the Comm port just right and this is where your code helped me so much. So I took that line and applied it to sort of my original way of doing things....more basic...and when I got a worker I pruned the top line down to the apsolute basics. So I've uploaded the dot bas file I made with quickbasic 4.5

I've also reproduced the bas file in text below.

CLS
OPEN "COM1:2400,N,8,1,CD0,DS0" FOR RANDOM AS #1
START : :
INPUT #1,R
LOCATE 15,40
PRINT R
IF INKEY$ = "" THEN GOTO START
CLOSE #1

Just a further note..... Phil when I ran your version I kept getting say 18,7,3,18,7,3,18,7,3 and over and over it would go not changing as I changed the input device which was an LDR. However with the prog above it runs sweet. I get 0-255 levels of light 250 infront of an open window 110 say in a lit room at night going all the way down to "0" with the lights out. It works well. Thank you very much for your help.

John
 

Attachments

Last edited:
Top