Author Topic: PIC12F675 COUNTER  (Read 1393 times)

0 Members and 1 Guest are viewing this topic.

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
PIC12F675 COUNTER
« on: March 25, 2017, 04:10:12 am »
Good afternoon everyone.
last week I asked for help getting a counter to display to a LCD.
This week I  need more help, also with a counter but for different reasons.

I am building a module that mount on top of our coffee maker.
one of those ones that takes PODS or CAPSULES.

The bin for holding the used capsules can only hold 18 or 19 capsules.
with 19 I have trouble getting it out.

I bought an 8pin development board and it came with a PIC12F675 preloaded with a simple flasher that flashed the 2 LEDs at the same time. Could have made the demo a little more interesting.

The board has
LED1 on GP0
LED2 on GP1
KEY1 on GP2
RESET on GP3
ADC on GP4
KEY2 on Gp5


I have done my program using the same IO configurations.
My code is attached below.

The problem is that LED2 is on all of the time.
If I press RESET LED1 comes on for a brief moment then goes out.
The counter has no effect, it should count to 6 then turn on the led.
I thought this might be the 200ms delay I have to test the unit,  but when I change the delay to 2000ms I.e. 2 sec
LED1 stays on for about 7 seconds. "by counting to myself."

I REM'd out the entire counter section which left  LED1 & Led2 both set to a low level,
however It Didn't Work.
Both LEDS are on all the time and when I press RESET Both of the LEDs dim to aprox 1/2 brightness until I release the reset.

I think the problem could be the way I have named the pins.

Any help  Would be appreciated.
my code has only one file. COFFEE MAIN.c


 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: PIC12F675 COUNTER
« Reply #1 on: March 25, 2017, 07:58:08 am »
You need to look at the hardware and work out how the LEDs are connected, you explicitly set LED2 to 0 and it lights, that suggests the LED is connected to 5V and the PIC is sinking current, not sourcing.

Try changing LED2=0; to LED2=1; and see if the LED goes off.

Once you've worked out the hardware then you can work on the program logic as you don't ever change the state of LED2 anywhere in the attached code after that line.

I suspect the key switches are similarly connected and raise the input pin to 1 when pressed so it'll always be a zero while the switch isn't pressed, making your counter run forever unless you push the switch.

 

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: PIC12F675 COUNTER
« Reply #2 on: March 25, 2017, 09:35:28 am »
Cjay
your right.
I found some bits missing from the code and have added it in.

The LEDs are wired to be  on  when low which is not how I would do it.
I may have to build my own development board for these chips.

The main problem however was about 4 lines missing at the top of
void main(void)
I had just found the problem whilst getting ready for dinner so I didn't have time to update/edit this feed.

edit...
an updated version is below

Thank you
BILL.
« Last Edit: March 25, 2017, 12:24:22 pm by neko efecktz »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf