help with pic 12F509

Status
Not open for further replies.

crzy engineer

New Member
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.
 

Attachments

  • Deer feeder.jpg
    79.7 KB · Views: 3,002
What PIC part number? I can't quite make it out... Does it say 12F508/509?
 
Last edited:
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 and that should get you started.

Mike.
 
Yes I did. Guess I became too focused on the schematic and very curious about the normally closed push button switch (grin)...
 


Hey mike thanks for the info.

im guessing from what you wrote he made a mistake with the MCLR pin?
 
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?
 
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.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…