Thanks for the encouragement. Here's my first attempt at making something other than just thinking about it. I realize there is a lot wrong with this. Just please be gentle with me. I know I don't have a clue what I'm doing, but I want to try. Assume a 16f877 for now.
(And how do I put it in a scrollable window like I see in other posts?)
DEFINE ADC_BITS 8 'Number of bits in ADCIN result
DEFINE ADC_CLOCK 3 'ADC clock source (rc = 3) ***WHAT IS THIS?
Define CLOCK_FREQUENCY = 20
DEFINE ADC_SAMPLEUS 50 'ADC sampling time in microseconds
DEFINE OSC 20 'Oscillator speed in MHz
TRISA = %11111111 ' Set PORTA to all input
TRISB = %00000000 'Set Port B to all outputs
ADCON1 = 2 ' PORTA is analog '****Is this necessary?
sensor var porta.0
coil var portb.0
delay var byte 'Set variable "delay" as one byte
ON INTERRUPT GOTO spark: ' When hall effect is sensed, go make a spark
INTCON = %10010000 ' Enable RB0 interrupt ***I don't know what value goes here to make it listen to porta.0..???**
loop:
ADCIN 0, delay ' Read channel 0 to the variable "delay"
ADCON ?? 'Convert it to decimal???
delay = delay * 2 'A multiplier to make the ADC input result in
'something meaningful in microseconds(2-510us)
coil=0
goto loop:
spark:
DISABLE ' Disable interrupts in handler
pauseus delay ' This delay retards the spark
while dwell=1 coil=1 ' This turns on current to the coil while the
' hall effect is sensed
RESUME ' Return to main program
ENABLE ' Enable interrupts after handler
Goto loop: 'I don't know why I put this here - not needed right?
end
I'm embarrased to even post this considering the expertise here, but I want to learn and most importantly, I want it to work.
Thanks,
Bookmarks