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.

[PIC] Issues with Simple PIC Project

Status
Not open for further replies.

pwb87

Newbie level 3
Joined
Apr 24, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
38
Hello everybody. I am a newcomer to the world of pic microcontrollers.
Needless to say, I'm pretty inexperienced with coding, and was wondering if any kind souls could take a stab at this, and I could learn from what you come up with. I am using a PIC16F88, Here's what needs to happen:
Set pin 6 as input 1, set pin 10 as output 1, set pin 11 as output 2

When input 1 goes high, look at a counter, if counter is less than 10, do routine 1. If counter is equal to 10, do routine 2

routine 1:
Turn on output 1
when input 1 goes low, wait 5 seconds, then turn output 1 low
increment counter 1

routine 2:
Turn on output 2 for 2 seconds, then turn off
Turn on output 1
when input 1 goes low, wait 5 seconds, then turn output 1 low
reset counter

That's it. Any help would be greatly appreciated. :)
 

At what frequency the counter increments and how ?
 

The frequency of the counter would be pretty low. It would probably only increment once a minuet or so. That would depend directly on how often the input goes high, which is arbitrary. I'm not sure what you mean by "how". The code would increment the counter at the end of routine 1?
 

How means if you press a button to increment the counter or you feed some pulses on T0CKI pin or is it a software counter which increments in the code itself with a delay.
 

I see. This counter would increment (and reset) within the code.
 

Easy, but what language do you want the code in and what clock frequency does the 16F88 run at? Knowing the speed is necessary to work out the 5 second delay timing.

Brian.
 

Just to be clear, the 'counter' variable is incremented by routine 1 (which is only called when the input goes from low to high and the counter variable is less than 10) as it was asked 'how' the counter is incremented.

It would also help if you mentioned what compiler you are using or will be using. Have you tried writing the code yet? It seems like you already have the logic/flow planned out.

The ff are common for both routine 1 and routine 2:
-Turn on output 1
-when input 1 goes low, wait 5 seconds, then turn output 1 low

Which means they will be executed no matter which routine you call so you can bring them outside of routine 1 and 2

What exactly will this be used for? People might also be able to give suggestions and improve the logic/flow of your program if you shared what the project is supposed to do (i.e. what the 2 ouputs will drive, why the counter?, why is the timing such)

Also, since your program seems to depend on the change of state of your input pin i recommend you use the INT interrupt of your pic (if it has it).
 

Can you use PIC12F683 for the project ? I can help you with the code. I am working on the code. Will soon post it.
 

I was thinking about using mikroC compiler, unless anyone would recommend anything else.
@betwitx: Clock Speed would be 4Mhz
@ernpao: You are absolutly correct about bringing them outside of both routines.
I bought a PICDEM lab to learn the the basics, but I have found the setup to be pretty difficult.
I have played with extremely simple stuff on arduinos before (blinking an led), but I have not taken a stab at this yet.
The purpose of this program is to turn on a vacuum (output 1), and activate a filer cleaning blow-back (output 2) only every 10 times the vacuum runs. This is for my dad's woodshop.
I guess I could try it with a PIC12F683, but I would have to get one, and I also not sure if the PICkit 2 USB can program one of those. It can definitly do a PIC16F88.
 

PICKIT2 usb Can program your controller
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top