PIC18F4620 Multi-Coin Slot Interfacing - Need Help

Status
Not open for further replies.

emerhidalgo

Newbie level 3
Joined
Nov 16, 2011
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
Good Morning Sir/Madam

I need some help with regards to this... Kindly help me please...

I made a counter program and circuit for the multi-coinslot with the following objectives

1. Count the pulse the output pulse of the coinslot

this was the schematic that I made which was now in an actual simulator



Here's the code written in MikroC Pro:

Code:
void main() {
  int counter = 0;
     //ADCON1 |= 1;
      //CMCON |= 7;
  TRISB = 0;
  PORTB = 0;
  while(1){
  if (PORTB.F2 == 1){
  counter++;
               if (counter==1){
               PORTB.F0 = 1;
               delay_ms(5000);
               }
               else if (counter>=2){
               PORTB.F1 = 1;
               delay_ms(5000);
               }
               delay_ms(5);
               
  }
}
}

The code objective was to turn on a LED whenever the counter increments itself by using the trigger PORTB.F2
On my assumption it will turn ON PORTB.F2 at a very fast time interval so I wrote this code just to see if it will works but unfortunately it doesn't

Am I missing something important?

Here's the document of the multi-coinslot that I used.
**broken link removed**

Here's the part list
- PIC18F4620
- Multi-Coin Slot Model: 623
- Crystal Oscillator 20MGHz
 

Attachments

  • attachment.rar
    114.1 KB · Views: 83
Last edited:

Thanks taroot I will try that and revert back to you asap...
 

Thanks dude, I'm a little confused about the logic...

I think I should use an Interrupt for this one coz I don't think that I can read the pulse by using the above code.

This is my new code.




I put the counter pin of the multicoinslot to RX pin of the MCU...
I managed to get a blinking led result. F0 = 1 F1 = 1 F0 and F1 = 0, but I haven't inserted a coin yet. Jeez! Im so confused..

btw can you read interrupt in PORTB.F2?
 

Use External interrupt (PORTB) to count the coin pulse. when you insert a coin you will get interrupt and use counter with it.
void interrupt() {

if(INT0IF_bit) { // Rising Edge
INT0IF_bit = 0;
counter++;
}
 
Thanks for helping us out taroot... I really appreciate your help... but unfortunately I can't try that solution right now... I'm working on a different project this week... I'll let you know if the solution works when I'm done Thanks a lot dude.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…