Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

[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. :)
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
At what frequency the counter increments and how ?
 

pwb87

Newbie level 3
Joined
Apr 24, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
38
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?
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
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.
 

pwb87

Newbie level 3
Joined
Apr 24, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
38
I see. This counter would increment (and reset) within the code.
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,366
Helped
4,727
Reputation
9,469
Reaction score
4,495
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,589
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.
 

ernpao

Advanced Member level 4
Joined
Sep 16, 2010
Messages
100
Helped
26
Reputation
52
Reaction score
24
Trophy points
1,298
Activity points
2,043
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).
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
Can you use PIC12F683 for the project ? I can help you with the code. I am working on the code. Will soon post it.
 

pwb87

Newbie level 3
Joined
Apr 24, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
38
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.
 

hobbyckts

Advanced Member level 1
Joined
Mar 12, 2015
Messages
481
Helped
88
Reputation
176
Reaction score
85
Trophy points
28
Activity points
2,457
PICKIT2 usb Can program your controller
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top