need help for measuring two freq at same time


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Location
    Mumbai-INDIA
    Posts
    22

    Talking need help for measuring two freq at same time

    Hi,

    I am hobbyst, I want to measure two frequencies between 10hz to 500hz at same time on two different pins, ie measure two frequencies within same time base of 1000 mili sec . I tried "Count" but I cold not measure two inputs within same 1000ms. Is there a better way to do it?, any example code would help me lot.

    I am using 16f73 @4mhz. Actually I am trying to measures pulses coming from my motor bikes spark plug, I have condtioned and converted pules picked up from spark plug and converted to TTL level. Other frequency input is coming from speed sensor.

    These Pulses from spark plug are erratic, Does anybody have any circuit for getting reliable reading using PIC?.

    Thanks in advance

    regards
    mahesh
    VU2IIA

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    you could try using the "change on portb" interrupt. put both of the inputs on port b and then any change will trigger the interrupt. You could set up the interrupt handler to figure out which one has changed and using a timer and a bit of maths, work out both frequencies.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    This is like super-crude... but it'll kinda work as a starting point...
    Code:
    	InputA var PortB.0
    	InputB var PortB.1
    	LED var PortB.4
    
    	Temp var Byte
    	ToggleA var Temp.0
    	ToggleB var Temp.1
    
    	CounterA var WORD
    	InputACount var WORD
    	InputBCount var WORD
    
    	TRISB=%00001111	
    
    Start:
    	'
    	'	Get Ready
    	'	---------
    	ToggleA=0
    	ToggleB=0
    	InputACount=0
    	InputBCount=0
    	High LED		' We're Ready...
    	'
    	'	Start Count
    	'	-----------	
    	For CounterA=0 to 3999
    		If (InputA=0 and ToggleA=0) then ToggleA=1
    		If (InputA=1 and ToggleA=1) then
    			InputACount=InputACount+1
    			ToggleA=0
    			endif
    		If (InputB=0 and ToggleB=0) then ToggleB=1
    		If (InputB=1 and ToggleB=1) then
    			InputBCount=InputBCount+1
    			ToggleB=0
    			endif
    		PauseUS 250
    		Next CounterA
    	'
    	'	Stop Count
    	'	----------
    	Low LED
    	LCDOut $FE,1,"A=",#InputACount,"Hz"
    	LCDOut $FE,$C0,"B=",#InputBCount,"Hz"
    	Goto Start		' Loop forever
    Yes, of course there are limitations... you'll have to trim PauseUS so that the For/Next Loop is exactly 1 second long... so put a scope on the LED pin... another limitation is that your Pulse must be wider than about 270uS so you may need some external circuitry... another is that probably 3.5kHz is a practical maximum count... but go play...

  4. #4
    Join Date
    Mar 2007
    Location
    Mumbai-INDIA
    Posts
    22


    Did you find this post helpful? Yes | No

    Smile

    Hi Melanie & kamikaze47,

    First of all New year Greetings to you. Thanks for replying and giving me helping hand.

    Actually 2 Months back I purchased Cheap 100cc new motorcycle, which doesnt have RPM meter, so I wanted to make RPM meter and Speedometer for my bike. I am getting RPM signals from Spark plug and and Speedometer signal from hall sensor, which is just few hundred hz per seconds, but problem was how to measure both signals at same time.

    Melanie, I will try your code, I will try not to bother you and use my small brain to its max.

    Thank you once again,

    regards
    Mahesh-VU2IIA
    my hobby page, if you have time to see.
    http://www.vu2iia.bravehost.com/

Similar Threads

  1. I don't understand this code!
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 13th February 2008, 02:55
  2. Measuring time
    By AugustoPedrone in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th July 2007, 23:46
  3. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  4. Alarm Time
    By Santana in forum Code Examples
    Replies: 1
    Last Post: - 8th December 2006, 13:58
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14:24

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts