Acidmods
AcidMods Resources ----- ( These are helpful tools for modding ) => Pic Programmers and Programs => Topic started by: Hippijoebob on June 23, 2011, 04:23:00 PM
-
I need help with programming my pic12f863 in C. I am using CCS's C Compiler through MPLAB witha PICKit 2. The question I have is how do i have the rapid fire started and then pulsed through the triggers and then stopping when you stop pulling the trigger. Would a flowchart like this work
Check for input using while function thats equal to 1 -> output high for 1 ms -> start 1 ms delay loop already in program for as many times as specified -> back to top
While this general idea work? I hopw you can understand what I mean Thanks
-
You are best off setting up a timer interrupt for your pulse timing, say 1ms, then setup software counters for the speed.
For basic RF you don't need to read the triggers ever, just switch the pin between tristated and, high for matrix (needs a 330ohm resistor between the trigger and the PIC) or low for CG (no resistor needed), this will mean you only get RF when the trigger is pulled.
So,
Interrupt
Decrement counter -> counter equals 0? -YES> Reload Counter and flip the pin state -> Return
-NO> Return
Main Program
Here you can do things like read buttons for mode changes etc
A good place to look at code structure is Hazer's BMU codes (can be found here on AM, just search), they are written in ASM however even if you do not know asm the comments are very informative.
-
Thanks for the reply. You kinda said what I thought and confirmed it. Thanks again.