Serial communication port, Code for photobooth fundraiser?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
rolland_elliott
Newbie
Posts: 3
Joined: Sun Aug 06, 2006 7:33 pm

Serial communication port, Code for photobooth fundraiser?

Post by rolland_elliott »

So I am TRYING to help our local photographic museum,

http://www.lightfactory.org/exhibitions/index.htm

with a little fundraiser for their self portrait exhibition starting a mere 13 days from now.

They want to have a photobooth as a fundraiser, which is easy enough for me to supply, I am a professional photographer who has a photobooth.

However they want to have it act as an automatic vending machine.

I have bought a program that controls my photobooth, but the vending section of code is not yet complete.

All I need to do is have my dollar bill acceptor write a number "1" to a text or dat file so the program can know how many dollars have been inserted. As more dollars are inserted the machine simply adds the numbers up. Two dollars would write the number 2 to the text file. Sounds easy enough?

The manufacturer of the bill acceptor has posted free qbasic code on their website:

http://www.upstatenetworks.com/kiosk/

I downloaded quickBasic 4.5
from:
http://qbnz.com/pages/downloads/software/

Extract it and there is a file called QB.exe that runs quickbasic.

Next I created a *.bas file in the same directory that Qbasic is located in and called it money.bas using the following code

Code: Select all

OPEN "com1: 300, n, 8, 1,cd0,cs0,ds0,op0,rs,rb2048" FOR INPUT AS #1 

OPEN "c:\photoboof\credits.txt FOR OUTPUT AS #2 

PRINT #2, 0 

CLOSE #2 

OPEN "c:\photoboof\credits.txt" FOR OUTPUT AS #2 

delay = 0 

  
COLOR 15, 1, 1 

CLS 

PRINT "       Please insert $1 BILLS FOR PHOTOS" 

PRINT 

PRINT " When you are done inserting all of your bills, press any key to continue..." 

LOCATE 5, 35 

PRINT "Credit: $"; credit 

ON COM(1) GOSUB getbill 

COM(1) ON 

credit = 0 

  

OUT &H3F8, 1 

DO WHILE INKEY$ = "" 

LOOP 

  

OUT &H3F8, 0 

REM PRINT "Total Credit: "; credit 

PRINT #2, credit 

CLOSE 

REM DO WHILE INKEY$ = "": LOOP 

REM stop 

SYSTEM 

  

getbill: 

REM PRINT HEX$(ASC(INPUT$(1, 1))) 

credit = credit + 1 

LOCATE 5, 35 

PRINT "Credit: $"; credit 

RETURN 


Now I opened up the QB.exe program and open up the money.bas file in it.
Hit F5 and the program should runs.

I am attatching my serial based Bill Acceptor, model. # coinco ba30b to my computer using this device:
http://www.upstatenetworks.com/kiosk/

Note the Bill Acceptor will NOT function until you run the above quickbasic program which activates the com port and sets the voltage correctly to activate the bill acceptor.

The major issue is I have three of these bill acceptors and two adapter cables and the machines simply do not give the customer a credit when money is inserted. I think it changed the credit file from 0 to 1, once the very first time I tried it, but never since and I have tried this on 3 different PC's.

I am beginning to think something is wrong with the serial com comamnds in my source code? any recommendations?
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

I notice a few things that stand out for me in this source code.

First, DOS only supports 8 character filenames, so your C:\photoboof\credits.txt won't work. You need to change the directory name to have less than 8 characters.

Second, in the line that contains this line of code:

Code: Select all

OPEN "c:\photoboof\credits.txt FOR OUTPUT AS #2 
there are no closing quotes for the file name, which should be located right after the .txt.

Third, the program terminates after the user presses the button, making the computer return to the shell it was called from (a DOS window, DOS prompt, etc.) This might be a problem if the program is running as a public terminal.

Forth, QuickBASIC 4.5 is technically not legal for download off of QBNZ, but Microsoft hasn't supported QuickBASIC for more than a decade. QBASIC 1.1 is the only truly legal one to download. It's available from QBNZ too.

Fifth, the site says "QBASIC" source code, not QuickBASIC source code. Although they are almost the same thing, you should probably use the same interpreter that they use.

Sixth, the lines that contain

Code: Select all

ON COM(1) GOSUB getbill 

COM(1) ON 
I believe are in the wrong order, since you are activating the COM port after the event trapper. Try switching the order.

Also, not having this device available to us hinders all progress we could possibly make. However, assuming that the correct parameters were sent to the COM port, the source code seems pretty straight forward.

Post any success/failure stories :)


Try this code. Has the minor fixes that I described above. Use QBASIC instead of QuickBASIC.

Code: Select all

OPEN "com1: 300, n, 8, 1,cd0,cs0,ds0,op0,rs,rb2048" FOR INPUT AS #1 

OPEN "c:\photos\credits.txt" FOR OUTPUT AS #2 

PRINT #2, 0 

CLOSE #2 

OPEN "c:\photos\credits.txt" FOR OUTPUT AS #2 

delay = 0 

COLOR 15, 1, 1 

CLS 

PRINT "       Please insert $1 BILLS FOR PHOTOS" 

PRINT 

PRINT " When you are done inserting all of your bills, press any key to continue..." 

LOCATE 5, 35 

PRINT "Credit: $"; credit 

COM(1) ON

ON COM(1) GOSUB getbill 

credit = 0 

  

OUT &H3F8, 1 

DO WHILE INKEY$ = "" 

LOOP 

  

OUT &H3F8, 0 

REM PRINT "Total Credit: "; credit 

PRINT #2, credit 

CLOSE 

REM DO WHILE INKEY$ = "": LOOP 

REM stop 

SYSTEM 

  

getbill: 

REM PRINT HEX$(ASC(INPUT$(1, 1))) 

credit = credit + 1 

LOCATE 5, 35 

PRINT "Credit: $"; credit 

RETURN 
rolland_elliott
Newbie
Posts: 3
Joined: Sun Aug 06, 2006 7:33 pm

thank you for the response, but no luck

Post by rolland_elliott »

Thank you for the response, but no luck so far.

I copied your code into a new *.BAS file and ran it and the screen never changed at all to reflect a dollar was inserted into my bill collector. I'm pretty sure my hardware works right.

I read on another forum:
http://www.tek-tips.com/viewthread.cfm? ... 966&page=1

that Windows XP doesn't allow for low level com communicaitons? Any truth to this. Perhaps this is why the code is not working?
If I bought a newer verison like QuickBasic 7.1 would that help?

Thanks again for all the trouble shooting!
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

Yeah, DOS and Windows XP don't mix. If I were you, I would try the Visual BASIC code that they gave on the site. Try using that.

To other peeps: Isn't there probably a FB equivalent to this code? ;-)
rolland_elliott
Newbie
Posts: 3
Joined: Sun Aug 06, 2006 7:33 pm

thanks again, no dice on win 98 machine either

Post by rolland_elliott »

IN an act of despiration I booted up windows 98 on an older laptop.

For some reason your code does not turn on my bill acceptor.
From what I know the bill acceptor needs power from the serial port which must be activated from the PC. It is the 4th pin on the serial cable and is known as DTR.

I know a bit about BASIC. I know nothing about visual basic. I went and posted the VB code on three forums and no one has been able to give me a way to run it. From my understanding, the VB code isn't capable of being run indepently as a standalone program and must be integrated into the photobooth program, something not doable since I do not have the source code for that program.

Anyways, maybe I am wrong in my diagnosis. Thanks again.
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

As I have no knowledge of this, I will pitch in on something I do know. DOS can be emulated very well with DOSbox, you may want to give it a try on your XP show.

Link:
http://dosbox.sourceforge.net/news.php?show_news=1
Image
Post Reply