QBASIC to PICAXE

picaxester

Senior Member
I'm trying to interface a PICAXE to PC useing qbasic. The problem is I'm an idiot :(
Can someone help me, please :)


eric
 

hippy

Ex-Staff (retired)
On the PICAXE side you need to get familiar with SERIN and SEROUT, and on the QBasic side you need to get familiar with OPEN, PRINT, LOC, INPUT$, INKEY$ and a few other functions.

This is a simple terminal program written in PowerBasic which should also be compatible with QBasic, but might need a few minor changes. Whatever the PICAXE sends gets displayed on the screen, everything typed gets sent to the PICAXE. Press the Esc key to terminate.

http://homepage.ntlworld.com/the.happy.hippy/picaxe/terminal.txt

Check Google for information on QBasic serial port programming and QBasic interfacing with Basic Stamp.
 

picaxester

Senior Member
Thanks, it works!
I'll just play around with your code until I understand it :)
It will be nice to make .EXEs that interface with external PICAXE devices.


eric
 

moxhamj

New Member
You know, with all the posts about interfacing using vb6 and vb.net, it seems good old qbasic may present a simpler answer. Qbasic programs compile into a simple self contained .exe - no weird .dll or .ocx files that have to be registered and then get unregistered later by another program.

But any version of basic can do a shell of an exe.

Does qbasic still work with xp/vista on the serial port?
 

lbenson

Senior Member
EDITED: QBasic works in XP.

This is less than definitive, but I just got "Device Timeout" when trying Hippy's code from XP. I have two USB to serial cables on my laptop, with 3-wire picaxe programming cables on header pins. I breadboarded crossover links for the two headers, and fired up a copy of hyperterminal on Com1 and Com7--2400,N,8,1, no handshaking. I could then type in either terminal and the text would appear in the other. I then hauled out qbasic, unused for a decade, and put in Hippy's program, removing the "RS,CS,DS,CD". But I get a timeout, so maybe XP is not allowing access. I don't really know enough to test further, but will be happy to try suggestions. This would be useful.

EDITED: Putting back in the "RS,CS,DS,CD" from Hippy's code made it work in XP.



Edited by - lbenson on 11/03/2007 15:13:12
 

lbenson

Senior Member
Well, I misunderstood what the "RS,CS,DS,CD" were doing. I put them back in, and it works--what I type in the DOS window appears in the hyperterminal window.
 

hippy

Ex-Staff (retired)
<i>Well, I misunderstood what the &quot;RS,CS,DS,CD&quot; were doing. I put them back in, and it works </i>

Don't ask me; I just cut-and-paste from one program to another :)

To be honest, I'm not sure which have to be there and which don't ( I do just cut-and-paste ). Without some of the options, the PC waits for CTS etc to be asserted which is the &quot;device timeout error&quot;, because PICAXE 3-wire comms doesn't use CTS etc.

<i>what I type in the DOS window appears in the hyperterminal window. </i>

Excellent news. On 98SE I had problems trying to do the same between two instances in separate MS-DOS Prompt windows. Had to keep clicking on one then the other to have the comms flow.

Also, under 98SE at least, once a COM port has been opened in MS-DOS it cannot be used again under Windows until the MS-DOS Prompt window is closed.
 

moxhamj

New Member
Re Hippy &quot;Also, under 98SE at least, once a COM port has been opened in MS-DOS it cannot be used again under Windows until the MS-DOS Prompt window is closed.&quot;

If you right click on the .exe file up comes a properties menu. In the 'program' tab is a check box &quot;Close on exit&quot;.

I've just dusted off Qbasic - free download at <A href='http://www.qbcafe.net/' Target=_Blank>External Web Link</a>. Unzip to whatever directory (eg c:\qbasic), then double click on the QB shortcut. I got an error message about not being able to find files, so right click on QB, and in properties/program, change the Cmd line to C:\qbasic\QB.EXE and the Working to C:\qbasic\.

If you compile by going Run/Make Exe, and create it without brun, it creates a standalone .exe. Any VB/C# program can then do a shell of an .exe. For example, a VB.net program can save a text file, and then shell a .exe to send that file to a picaxe. Another .exe can collect data from the picaxe and put it in a text file.

This can future-proof VB from making serial comms impossible to use.
 

picaxester

Senior Member
Here is a crappy qbasic program that makes a graph:

OPEN &quot;COM1:4800,N,8,1,RS,CS,DS,CD&quot; FOR RANDOM AS #1
SCREEN 12
CLS

y = 0

FOR x = 0 TO 256
PSET (x, y), 10
NEXT x

y = 256

FOR x = 0 TO 256
PSET (x, y), 10
NEXT x

y = 128

FOR x = 0 TO 256
PSET (x, y), 10
NEXT x

x = 0

FOR y = 0 TO 256
PSET (x, y), 10
NEXT y

x = 256

FOR y = 0 TO 256
PSET (x, y), 10
NEXT y

y = 0
x = 0

DO WHILE INKEY$ = &quot;&quot;
IF LOC(1) &gt; 0 THEN c$ = INPUT$(1, #1): z = ASC(c$): x = x + 1: y = 255: y = y - z: PSET (x, y), 4
LOOP

CLOSE #1
END


Just start it up and then use the PICAXE &quot;SERTXD&quot; command to send data to it.
Hit the print screen botton on your key board to copy it to the clip board and then use paint (or whatever) to paste and save it.


eric

Edited by - picaxester on 12/03/2007 19:38:36
 

picaxester

Senior Member
Useing &quot;PSET (x, y), 4&quot; in the loop will only draw single pixels but I would like them to be linked by a line. I tryed to use the DRAW cammand but had no luck.
Help please :)


eric
 

manuka

Senior Member
Mmm- I've just recalled from the text era back in the early -mid 90s,that only <b> QBasic 4.5 </b> had the inbuilt .exe compiler. This little goodie was missing from the more popular <b>Quick Basic </b> Stan
 

moxhamj

New Member
Correct. The website link I provided above is for QB 4.5 and the compiler works. I've forgotten how snappy and fast a compiled QB program is - a pleasure to use and very useful for those background jobs that don't need a graphic interface.
 

hippy

Ex-Staff (retired)
QuickBasic 7.1 ( more properly PDS 7.1 ) is I recall faster than QB4.5, and the free/shareware FirstBasic from PowerBasic.com even quicker ( put &quot;$EVENT OFF&quot; at the top ).

Another interesting option is VB-DOS 1.0 - Got the terminal code shown earlier working under that ( Win98SE ), but as a Console App ( as per QB ) not as a Windowed App.
 

lbenson

Senior Member
QB 4.5--gee, I had qbasic 1.1 on my system, no wonder I couldn't find the &quot;Create EXE&quot; option.
 

Dippy

Moderator
I had VB for DOS. I just threw it out recently.
Now that was a clunker. Probably worth something on Antiques Road Show.
 

jodicalhon

New Member
The Count quothe:

<i>I got an error message about not being able to find files... </i>

So did I.

<i>...so right click on QB, and in properties/program, change the Cmd line to C:\qbasic\QB.EXE and the Working to C:\qbasic\. </i>

Thanks, Your Bloodthirstyness, you're a genius!

I was opening a command line and running it from there (which works), but I'm now having a much more pleasant QB experience.

Cheers.

Edited by - Jo C on 14/03/2007 11:23:34
 

slurp

Senior Member
following this thread I started to poke about a bit, found <i>Just Basic </i> here http://www.justbasic.com/ <A href='http://www.justbasic.com/' Target=_Blank>External Web Link</a>

seems to be a nice straight forward package...

regards,
colin
 
Top