Jallist Archive Jul 2005

Re: Code for 'timing' pulse inputs on one pin of PIC12F683

From: Shawn Standfast <sstandfast(at)yahoo.com>
Date: 05 Jul 2005 03:47:49 -0700 (PDT)

Check out my webpage for the OBD II controller (work
in progress) 
http://www.geocities.com/sstandfast
 .  It
deals with a Variable Pulse Width scheme that is not
exactally the same as what you are doing but very
similar.  You are on the right track with starting and
stoping timers for the pulses.  In the case of timing
pulses, fast reaction times are necessary for starting
and stoping the timers therefore I suggest using an
interrupt on change pin for your data input.  Im not
sure if your PIC of choice has this feature or not. 
But that is my two cents worth of advice.

Shawn

--- rjos_killarney  wrote:

> Hi group Guru's!
> 
> I have a little project that I'm putting together
> using the PIC
> 12F683 chip.
> I have the 12F683 data sheet and the JAL manual plus
> many references 
> to Jal files that might be useful.  BUT after
> several days of trying 
> to work out possible Jal code solutions to do what I
> want with my 
> proposed circuit - my mind has suddenly shut down -
> GONE GAH, GAH - 
> too many late nights so my partner keeps telling
> me!!
> 
> Anyway to outline what my circuit is:
> 
> * 12F683 with stable external 20Mhz clock in (on
> GP5/CLKIN - pin 2);
> * a digital i/p on GP4/T1G (pin 3) [rcv-in];
> * a digital o/p on GP0 (pin 7) [shiftout data];
> * a digital o/p on GP1 (pin 6) [shiftout clk];
> * a digital o/p on GP2 (pin 5) [LED drive - Hi=on,
> Lo=off];
> * digital i/p on GP3 (pin 4) - not yet used.
> 
> I've decided to use an external 20Mhz xtal derived
> clock - provides
> an 200ns instruction cycle time.
> 
> Now what I'm trying to do is receive a 6 x pulse
> signal on GP4/T1G 
> (pin 3):
>   eg.. -> start -> data1 -> data2 -> data3 -> data4
> -> stop -> idle
> 
> * pin 3 (GP4/T1G) quiescent state (idle) = Hi;
> * receive a signal in on pin 3 (GP4/T1G) comprising
> -
> 	{note - all pulses timed from beginning of
> 'period'}
> 	** start pulse = 15us (Lo), 15us (Hi)	[period > 30us]
> 	** data pulse1 (see a. below),		[period = 60us]
> 	** data pulse2 (see b. below),		[period = 60us]
> 	** data pulse3 (see a. below),		[period = 60us]
> 	** data pulse4 (see b. below),		[period = 60us]
> 	** stop pulse = 15us (Hi), 15us (Lo)	[period > 30us]
> * on finish receiving - return to 'idle'.
> 
>   a. pulse Hi - either 12us, 22us, 32us
> 	total 'period' = 60us;
> 
>   b. pulse Hi - either 12us, 18us, 24us, 30us, 36us,
> 42us, 48us, 52us
> 	total 'period' = 60us;
> 
> For timing:
> 
> 1. to set the 'period' - maybe use - Timer0 with
> prescaler (scaling 
> factor TBD), internal clock {Fosc/4 = 200ns},
> interrupt on overflow;
> 
> 2. to 'time' the pulses (on T1G - pin 3) - use
> Timer1 (maybe with 
> prescaler - scaling factor TBD), internal clock
> (Fosc/4 = 200ns), 
> interrupt on overflow;
> 
> 3. depending on the 'timed' length of the data1,
> data2, data3, data4 
> pulses - on interrupt a subroutine will be called to
> further process 
> the results.
> 
> My problem is - my mind is a blank as to how to
> 'code' the above in 
> Jal.
> 
> Any of you Jal guru's out there like to help out
> with some code - or 
> maybe give me some pointers / guidance PLEASE.
> 
> Any assistance will be MUCH APPRECIATED.
> 
> 
> 
> 


Seiz System Engineering AbelCam AbelCam WebCam Software for Windows