Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Coin Slot acceptor Timer using PIC16f84a

Status
Not open for further replies.

Axiash

Newbie level 1
Newbie level 1
Joined
Jul 12, 2019
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
20
Me and my classmates are doing our school project using PIC16f84A and a coin acceptor. The hardware is working fine and the components are already configured. The problem is with the code that we're using. The coin acceptor will accept a coin which corresponds into a timer(Ex. 1 coin = 1 minute timer, 5$ dollar coin = 5 minute timer). Here is a sample code of our C program


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
unsigned char count = 0;
unsigned char prevValue = LO;
 
 
while(1)
{
    switch (count){
        case 3:                 
            PORTB=0x01;   
//            asm ("Nop");
            DELAYtenMinute();
            count = 0x00;
            PORTB = 0x00;
            break;
        case 2:                 
            PORTB=0x01;
             
            DELAYfiveMinute();
            count = 0x00;
            PORTB = 0x00;
            break;
        case 1:                 
            PORTB=0x01;
            DELAYoneMinute();
            count = 0x00;
            PORTB = 0x00;
            break;



The DELAYMINUTE act as our timer and we already tried it in simulation(using MPBLAB X IDE). I would like to ask how can we be sure that pulse from the coin acceptor goes into variable count(which is used for switch case). Thank You!
 
Last edited by a moderator:

We can't answer that without knowing how the coin acceptor identifies the kind of coin inserted. It must produce some different signal depending on which coin was used and we need to find a way the software can recognize that so it can set the timer delay.

Commercial acceptors work in different ways but most seem to do it by producing a different number of short pulses for each different coin type.

Brian.
 

Hi

I'd use a counter variable with smaller granularity.
Maybe one second.
Add 60 seconds for every inserted coin.
As long as the counter value is not zero: switch ON the output and decrease the value every second.

Klaus
 

You are expecting that end user will insert only one coin and await for the end of the process, and only after this moment to add another one. Coding blocking inline as this is not the recommended way; you should create a variable to store the cumulated value of credits and then run the DELAY_xxxxx_Minute() at an endless loop, by decrementing the time correspondent of the remaining time. Consider split the code into dedicated functions at different layers, each one for input/middle/output stages of the system. The above function not to discard it completely, can be used with few modifications as the coin detector, just it.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top