+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 1
    Points: 18, Level: 1

    Join Date
    Jul 2019
    Posts
    1
    Helped
    0 / 0
    Points
    18
    Level
    1

    Coin Slot acceptor Timer using PIC16f84a

    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 bassa; 12th July 2019 at 05:17. Reason: add code tag

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 80,995, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,279
    Helped
    4433 / 4433
    Points
    80,995
    Level
    69

    Re: Coin Slot acceptor Timer using PIC16f84a

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 77,106, Level: 67
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,623
    Helped
    3560 / 3560
    Points
    77,106
    Level
    67

    Re: Coin Slot acceptor Timer using PIC16f84a

    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
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 29,579, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,840
    Helped
    1114 / 1114
    Points
    29,579
    Level
    41
    Blog Entries
    9

    Re: Coin Slot acceptor Timer using PIC16f84a

    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.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



--[[ ]]--