Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am making an internet cafe software that is coin-operated. I want my program to detect 5 volt signal coming from a coin detector in every insertion of coin. However, I've been searching in google trying to find sample codes to do this but to no avail. Pinchange event doesn't do the trick since the wire that carries the signal is always connected to a serial port pin and pinchange event is always happening even without inserting a coin in the coin slot. I want to detect only the 5 volt signal that the coin detector sends to serial port in every insertion of coin. Please help me on this.

Thank you and best regards.
Posted

surely that depends on the definition of
Quote:
the 5 volt signal that the coin detector sends to serial port in every insertion of coin
- I think you'd be better off going from analogue to digital anyway and dealing with the digital state change
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 14-Apr-15 20:12pm    
Good point, a 5.
—SA
Member 11592606 14-Apr-15 20:27pm    
Yes if only digital coin detectors are available here, but sadly they are not. I know this is possible because somebody already made something like this using the pin 2 of the serial port connected to coin signal wire. In fact, I bought one code from them but their support sucks.
Garth J Lancaster 14-Apr-15 21:20pm    
Im not saying get a digital coin detector - Im saying convert your serial 'analogue' output from the detector you already have to something easier to use - a digital input (in effect what you want is 0 = no coin and 1 = a coin) if we arnt worried about the value of the coin itself - so it may as well be a 'token'



you say they are using pin 2 of a serial connector ? ok, on a DB-9 that's 'receive data', yes ?


so, if they have somehow connected pin 2 to the detector, what values would you expect to read (as bytes) from your serial connection ? lets take a punt here - 0 would mean no coin - but anything inbetween 1 and 255 (as a byte) could be a coin - I say could because on the scant information shown, its really 0 = no coin, anything other than 0 has to be logic '1', a coin ? the problem is, without a proper a-d unit in there, how can you tell ?

If you're really going to persist with this serial 5v, then, in VB.Net run a loop 'forever', read from the serial connection, and see what byte value you get back for a coin vs no coin - I suspect you'll need to use a lot lower level control of the serial port though to get meaningful results
Member 11592606 14-Apr-15 22:10pm    
This is the website of the existing software like this -- http://www.gensansale.com/threads/bs-coin-slot-machine-software-pc-timer.16933/.

I did not expect this is very hard to do.
[no name] 14-Apr-15 23:39pm    
This discussion is going around in circles because you are not being clear with your question. Have you purchased this device and software?
The serial port doesn't expose any "voltage measurement" hardware at all. You cannot directly "detect 5 volts" as you put it.

The port does expose the presence of a change in state on the pins. If the voltage falls below a threshold voltage, the pin goes low and your code sees it as a logic low, or 0. If the voltage rises above the threshold voltage, the pin goes high, or 1.

What that threshold voltage is is determined by the exact specs of your serial port. Some work on 3 volts and tolerate 5 volts, some only on 5 volts.

If what you describe is the only "documentation" you have, chances are good this is not a real serial device and you're not going to get a byte to read on the port with normal read and write methods. You're probably going to only get a change of state on a pin, in which case, you'll probably be polling for the state of whatever pin you've connected the device to.
 
Share this answer
 
Comments
Member 11592606 15-Apr-15 3:20am    
Can you please give me sample code on how to detect when the pin goes high or low? I'm learning VB.net only through online tutorials and not had attended formal schooling in programming. Thank you.
Dave Kreskowiak 15-Apr-15 9:31am    
I don't have to as someone already has.
Member 11592606 15-Apr-15 19:56pm    
Does a serial port pin go HIGH when voltage rises up to 5+ volts and go LOW otherwise?
Dave Kreskowiak 15-Apr-15 20:06pm    
Considering there are only 2 states that the pin can be in, wouldn't it be easier to just try it and see what happens?
 
Share this answer
 
Comments
Member 11592606 15-Apr-15 19:53pm    
Thank you sir. I'll try this at home later.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900