Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools Display Modes
Old 13th January 2009, 11:36 PM   #1 (permalink)
Default help with pic 12F509

i am a tech at this company i work for and one of my engineers asked me to write a program from the schematic he provided me.

ok so this is my question... my first assignment was to write a code that would enable the pic to turn the motor on for 6 seconds when the switch is pressed then turn off to reserve power and again turn on when the swith is pressed again .

i presume it is a NC switch

can anyone help me out with this.
Attached Thumbnails
help with pic 12F509-deer-feeder.jpg  
crzy engineer is offline  
Old 13th January 2009, 11:56 PM   #2 (permalink)
Default

What PIC part number? I can't quite make it out... Does it say 12F508/509?

Last edited by Mike, K8LH; 13th January 2009 at 11:58 PM.
Mike, K8LH is offline  
Old 14th January 2009, 12:01 AM   #3 (permalink)
Default

Use a N.O. switch,like shown here as the RA3/MCLR buttonhttp://ww1.microchip.com/downloads/e...0Schematic.pdf
nickelflippr is offline  
Old 14th January 2009, 12:03 AM   #4 (permalink)
Default

The place to start is the template file you will find in C:\Program Files\Microchip\MPASM Suite\Template\Code called 12F509temp.asm. You will need to turn off the MCLR pin as your engineer has used it as the input pin. (change _MCLRE_ON to _MCLRE_OFF).

You will then need to read the datasheet to figure out how to turn on the weak pullup resistors and make GP4 an output. For the delay you can use the Pic Delay Generator and that should get you started.

Mike.
Pommie is offline  
Old 14th January 2009, 12:04 AM   #5 (permalink)
Default

Quote:
Originally Posted by Mike, K8LH View Post
What PIC part number? I can't quite make it out... Does it say 12F508/509?
I guess you missed the title.

Mike.
Pommie is offline  
Old 14th January 2009, 12:11 AM   #6 (permalink)
Default

Yes I did. Guess I became too focused on the schematic and very curious about the normally closed push button switch (grin)...
Mike, K8LH is offline  
Old 14th January 2009, 12:24 AM   #7 (permalink)
Default

Quote:
Originally Posted by Pommie View Post
The place to start is the template file you will find in C:\Program Files\Microchip\MPASM Suite\Template\Code called 12F509temp.asm. You will need to turn off the MCLR pin as your engineer has used it as the input pin. (change _MCLRE_ON to _MCLRE_OFF).

You will then need to read the datasheet to figure out how to turn on the weak pullup resistors and make GP4 an output. For the delay you can use the Pic Delay Generator and that should get you started.

Mike.

Hey mike thanks for the info.

im guessing from what you wrote he made a mistake with the MCLR pin?
crzy engineer is offline  
Old 14th January 2009, 12:39 AM   #8 (permalink)
Default

Quote:
Originally Posted by Mike, K8LH View Post
Yes I did. Guess I became too focused on the schematic and very curious about the normally closed push button switch (grin)...
is there anything wrong with the NC push button?
crzy engineer is offline  
Old 14th January 2009, 12:55 AM   #9 (permalink)
Default

Quote:
Originally Posted by nickelflippr View Post
Use a N.O. switch,like shown here as the RA3/MCLR buttonhttp://ww1.microchip.com/downloads/e...0Schematic.pdf
thanks for the suggestion nickel
crzy engineer is offline  
Old 14th January 2009, 12:55 AM   #10 (permalink)
Default

There is nothing wrong with using the MCLR pin. It is just unusual as it is normally used after all the other pins are allocated. The only thing wrong with the NC switch is that it will use (slightly) more current than a NO but as you have a motor in the circuit the extra amount is insignificant.

Mike.
Pommie is offline  
Old 14th January 2009, 01:02 AM   #11 (permalink)
Default

Quote:
Originally Posted by Pommie View Post
There is nothing wrong with using the MCLR pin. It is just unusual as it is normally used after all the other pins are allocated. The only thing wrong with the NC switch is that it will use (slightly) more current than a NO but as you have a motor in the circuit the extra amount is insignificant.

Mike.
ok i understand what you said. Im thinking he used it because that pin is only an input am i correct?
crzy engineer is offline  
Old 14th January 2009, 01:49 AM   #12 (permalink)
Default

Yes, it is input only but this suggests that the circuit will be extended to use the other pins. Also, with no MCLR pin and the internal oscillator, some (cheapo) programmers may not be able to reprogram the chip.

Mike.
Pommie is offline  
Old 14th January 2009, 12:40 PM   #13 (permalink)
Default

This guy has the best tutorials on PIC's

heres some for the 12F509.

http://http://www.gooligum.com.au/tut_baseline.html
Oblong is offline  
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Title Starter Forum Replies Latest
Needing help with delay times on a 12f509 Darkstar64 Micro Controllers 16 13th August 2008 11:59 PM



All times are GMT. The time now is 12:28 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker