Square wave frequency input

This is a forum for discussing the development and testing of alpha MS2/Extra code. Documentation
(Runs on MS2 and Microsquirt)

Moderators: jsmcortina, muythaibxr

Post Reply
2002tiiguy
Helpful MS/Extra'er
Posts: 36
Joined: Wed Sep 14, 2016 3:05 pm

Square wave frequency input

Post by 2002tiiguy »

If i have a 5V square wave that i want to read the frequency of this square wave. can i configure the ms2 to read that frequency? if so, how? frequency is in the range of 0-300hz
slow_hemi6
Super MS/Extra'er
Posts: 4122
Joined: Fri May 07, 2004 3:33 am
Location: Australia

Re: Square wave frequency input

Post by slow_hemi6 »

Might be possible with a lm2917 frequency to voltage converter and connection to adc6 or adc7. What are you trying to monitor?
Find the Manuals up top under Quick links: Manuals. :RTFM:
Cheers Luke
2002tiiguy
Helpful MS/Extra'er
Posts: 36
Joined: Wed Sep 14, 2016 3:05 pm

Re: Square wave frequency input

Post by 2002tiiguy »

vss out of the back of the speedometer on my 89 e30, supposedly the signal coming out of the speedometer is a square wave. since the flex fuel sensor is also read based on frequency i should be able to read the speed signal
slow_hemi6
Super MS/Extra'er
Posts: 4122
Joined: Fri May 07, 2004 3:33 am
Location: Australia

Re: Square wave frequency input

Post by slow_hemi6 »

Specific code would need to be written for that and my guess is it would be this or flex but not both. MS2 only has so many timer resources available. I've noticed there is not much enthusiasm for new ms2extra code/features but good luck with it.
Find the Manuals up top under Quick links: Manuals. :RTFM:
Cheers Luke
nathaninwa
Super MS/Extra'er
Posts: 2638
Joined: Tue Sep 14, 2004 4:17 pm
Location: Aberdeen, Wa

Re: Square wave frequency input

Post by nathaninwa »

I'm not sure ms2 can do anything with the signal. Can a generic speedometer be created in TS to at least show speed maybe?
Volvo 940, 2jzge, MS3Pro, daily
240Z, 2JZ, MS3Pro boost control
slow_hemi6
Super MS/Extra'er
Posts: 4122
Joined: Fri May 07, 2004 3:33 am
Location: Australia

Re: Square wave frequency input

Post by slow_hemi6 »

Set up the way I said you can configure tuner studio to display with a custom gauge, you can datalog with a custom channel, you can use programmable outputs with raw adc values from adc6 or adc7.
Find the Manuals up top under Quick links: Manuals. :RTFM:
Cheers Luke
2002tiiguy
Helpful MS/Extra'er
Posts: 36
Joined: Wed Sep 14, 2016 3:05 pm

Re: Square wave frequency input

Post by 2002tiiguy »

ah, so adc6 and 7 are the spare adc's, i was really confused
2002tiiguy
Helpful MS/Extra'er
Posts: 36
Joined: Wed Sep 14, 2016 3:05 pm

Re: Square wave frequency input

Post by 2002tiiguy »

for the input values on the custom channel, what am i entering? can i just put the 0 and 300 hz in for point 1 and 2, or do i need to do something different?
slow_hemi6
Super MS/Extra'er
Posts: 4122
Joined: Fri May 07, 2004 3:33 am
Location: Australia

Re: Square wave frequency input

Post by slow_hemi6 »

Adc can only respond to voltage levels. They can not deal with a frequency. In order for a micro controller to deal with a frequency it must use a timer to do a compare of 1ON and 1OFF period to the time elapsed on the timer. This is mostly accomplished with an inbuilt timer module which saves greatly on processor resources. The timer module is already heavily utilized by MS2extra. The timer module also only works with certain input pins.
Find the Manuals up top under Quick links: Manuals. :RTFM:
Cheers Luke
grom_e30
Super MS/Extra'er
Posts: 4459
Joined: Thu Mar 08, 2012 12:44 pm
Location: UK

Re: Square wave frequency input

Post by grom_e30 »

the only way to achieve this is with a frequency to voltage converter so 0mph would be 0v and your max speed would be 5v then read the voltage with the megasquirt adc and you could calculate the speed based on the voltage the ecu is reading.
1990 bmw 320i daily driver with m20b25 ms3 sequential fuel, 380cc injectors, d585 coil near plug, home made cam sync, launch control, fan control, vss, homebrew egt logging what's next????
2002tiiguy
Helpful MS/Extra'er
Posts: 36
Joined: Wed Sep 14, 2016 3:05 pm

Re: Square wave frequency input

Post by 2002tiiguy »

so how does it read the flex fuel sensor?
jsmcortina
Site Admin
Posts: 39611
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: Square wave frequency input

Post by jsmcortina »

2002tiiguy wrote:so how does it read the flex fuel sensor?
It is very low frequency and it is sampled by polling the pin.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
2002tiiguy
Helpful MS/Extra'er
Posts: 36
Joined: Wed Sep 14, 2016 3:05 pm

Re: Square wave frequency input

Post by 2002tiiguy »

gotya, guess 300hz is just a little too high
Post Reply