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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial communication port, QBasic Code for photobooth fundraiser?

Status
Not open for further replies.

011575

Programmer
Aug 6, 2006
3
US
So I am TRYING to help our local photographic museum,


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:


I downloaded quickBasic 4.5
from:

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:
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:

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? the bill collector can be set to receive short pulses 50 or standard 150ms on/off pulses, any recommendations?
 
I wonder what OS you have on your target machine. I'm afraid what Windows NT, Windows 2000 and Windows XP just don't allow QBasic talk to I/O ports directly.
You probably need DOS or Windows 95/98.
(btw qbasic is small enough to run from DOS bootable diskette)

hope this helps.
 
I am using Windows XP and I really need to run windows because my photobooth software was written in python.

Thanks for the potential tip/problem advice.
 
Note this is QBASIC and not QuickBasic code.
And you have tsh73's issue.
 
Here is my 2 cents worth ...

Since your application requires XP...

I suggest you use MS Access. Access can then display a GUI screen for your prompting. Then use VBA (plenty examples on the net) to read the COM1 port.

The data can we written to a text file (again simple examples on the net).

If needed you can use the API to launch other Windows applications, etc.

By using MS Access you can quickly create the interfaces you need..

I hope this gives you another alternative.

 
I know this is late...but it may server for "next" year's fundrasier.

in the code you posted, you didn't have cycle through the number of credits.

Also, you may want to write out some code to keep a seperate file as to how much money you sould have in the til. This will also server to let you know where your mistake lies; especially if it says you received a total of 5 bills and your "Credits" on the screen show 0 or 1.



--> It's a bird! It's a plane! No, it's an OS update patch! Ahh!! <--
 
Upstate Networks wanted $3800 to write this program for me. They estimated the work to be 60 hours, which is I think is 54 hours too much.

It would take me 60 hours, a good programmer should be able to do this fairly easily I would think?

Am I totally wrong?
 
Not necessarily. I think they said +/-60 hours because they will probably hire out the work and then have to test the code for your particular use/situation.

In the meantime, you can try out the code below. I noticed that you have a directory listing that did not meet the 8.3 specs. I reworked your code and modified it for a directory call FotoBox. See below.

Code:
'
' ------
' -- The code posted on their web site is incomplete (for both
' -- the QB and VB4 codes).  That's how they get you to acquire
' -- their services.
' -- To use the "saving of credits", create a folder in the root
' -- of your C drive called "FOTOBOX".  After that, you can try this.
' ------
' Hope this helps (HTH).
' -- MiggyD  ([URL unfurl="true"]www.tek-tips.com/viewthread.cfm?qid=1263352)[/URL]

' Activate communication port 1
OPEN "com1: 300, n, 8, 1, cd0, cs0, ds0, op0, rs, rb2048" FOR INPUT AS #11
' User-defined event
ON COM(1) GOSUB getbill
' Activate user-defined event
COM(1) ON

' Start Daily Bookkeeping
OPEN "c:\FotoBox\tally.txt" FOR APPEND AS #14
PRINT #14,
PRINT #14, "Activation Date: ";
PRINT #14, DATE$
PRINT #14, "Activation Time: ";
PRINT #14, TIME$

' Create temp workspace for current patron
OPEN "c:\FotoBox\credits.txt" FOR OUTPUT AS #10

' Main loop
Credit = 0
EOD = 0     'EOD = End Of Day (for when you close up shop)
DO
    COLOR 7, 0, 0
    CLS
    PRINT "       Please insert $1 BILLS FOR PHOTOS"
    PRINT
    PRINT " When you are done inserting all of your bills, press any key to continue..."
    OUT &H3F8, 1
    COLOR 31, 1, 1
    DO WHILE INKEY$ = ""
         LOCATE 5, 35
         PRINT "Credit: $"; Credit
         ' if ESC key is pressed then end program
         ' obviously you should modify this as needed
         [COLOR=red]' if this doesn't work right away, just hold
         ' down the escape key.[/color]
         IF INKEY$ = CHR$(27) THEN EOD = 1
    LOOP
    OUT &H3F8, 0
    ' Save number of credits incase of power failure
    PRINT #10, Credit
    ' Show how many photos allowed
    LOCATE 5, 35
    PRINT "Total Credit(s): $"; Credit
    PRINT #10, Credit
    [COLOR=green]'------
    '-- I guess that this must be the section
    '-- that will actually take the picture and
    '-- you'll probally have to remove credits
    '-- as well.
    '------[/color]
    REM DO WHILE INKEY$ = "": LOOP
    REM stop
    ' Reset credits to zero for the next patron.
    Credit = 0
LOOP WHILE EOD = 0
' Deactivate user-defined event
COM(1) OFF
' Close all OPENed I/O activities & terminate program
CLOSE 10, 11, 14
CLS
SYSTEM


getbill:
    COLOR 15, 1
    Credit = Credit + 1
RETURN

After you run the code, you can check out the FotoBox folder and see the TXT files.

Again, HTH.
--MiggyD

--> It's a bird! It's a plane! No, it's an OS update patch! Ahh!! <--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top