Shop OBEX P1 Docs P2 Docs Learn Events
Simple RPM detection? — Parallax Forums

Simple RPM detection?

eagletalontimeagletalontim Posts: 1,399
edited 2008-06-19 06:51 in General Discussion
Is there any simple way to read an RPM signal from a cam angle sensor for a 4 cylinder? I am hoping to be able to hook up the RPM signal wire to the SX chip and be able to use the RPM's to change certain variables in my existing program or call functions at a preset RPM. I have read up on the COUNT and PULSIN commands, but I am lost when it comes to math like this. I have no idea how to measure the frequency of what is coming from the RPM signal wire on the car. I can hook up a meter to the wire and it will show about 1v at idle and about 3v to 4v at 5k rpm +, but if I hook a transistor and a relay to it, it hums when I rev it up instead of latch. I just basically need a function that will read the signal and output the proper RPM into a variable that i can use in other parts of my existing program. Thanks for the help in advance!

Comments

  • VelocitVelocit Posts: 119
    edited 2008-06-17 21:05
    It all depends on the specific CAS and its principals of operation. What car are you dealing with specifically? If the CAS is a hall-effect sensor or some type of optical sensor, chances are the output will be a series of 5V or 12V pulses depending on the orientation of the camshaft. On my car, the CAS is a hall effect sensor and the magnet attached to the camshaft has four regions: a 105* N region; a 105* S region; a 75* N region; and a 75* S region -- in that order. Whenever a N region is under the sensor, the signal is high; 5V in this case. If you just need to know RPM, as opposed to actual camshaft orientation, you would have to search for the same transition between regions, every rotation, and count them per unit of time; i.e. how many times the 105*N to 105*S transition is made every 100ms.

    This task might be a little tricky if you're new to programming or computer math. A better solution would be to find an RPM signal wire. Many PCM's use the crank angle sensor and camshaft position sensor as inputs, then calculate the RPM and output an RPM signal to the stock tachometer in the gauge cluster. These signals are much more straightforward and easy to read as they don't have any information about orientation encoded in them. You could very easily use the COUNT command in this case, though the results depend a lot on the specific car and how the PCM outputs the RPM signal.

    When you attach a voltmeter to the CAS signal wire, you're only seeing an averaged reading of the pulses since they're being output faster than the meter can react and faster than your eyes could possibly see without an oscilloscope. The same goes for the transistor/relay combination you proposed: the pulses are being output much faster than the switching frequency of the relay (usually around 150Hz or less). In this case the relay armature is simply floating between its two positions since it's being forced to operate on such a high frequency. Remember, in any four stroke engine, the camshaft rotates twice as fast as the crankshaft.

    If possible, I recommend finding a technical information manual for your car (usually sold with or similarly to the factory service manual [noparse][[/noparse]FSM], from your dealer). This manual should have all relevant information including RPM signal wires and format.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Paul
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-06-17 21:43
    I have found the RPM signal wire which is a 5v output max. So far, this is what I have :

    RPM_signal VAR RB.4
    RPM VAR Byte
    COUNT RPM_signal, 30, RPM
    IF RPM < 1 THEN
    RC = %00110000
    ELSEIF RPM = 1 THEN
    RC = %01101110
    ELSEIF RPM = 2 THEN
    RC = %01111010
    ELSEIF RPM = 3 THEN
    RC = %00110011
    ENDIF

    I actually need to get it to read to the thousands. I just need a variable to be equal to the exact value + - 100 RPM so I can use it in other areas of my program. The program I have shown above will display a 1 if it is under 1000, 2 if it is under 2000, a 3 if it is under 3000 and so on. I need it to read at least 500 RPM increments. The only problem I have now is that as I rev up the engine, the numbers will bounce back and forth when it reaches a close value for the next digit to be displayed. I have no way of showing what RPM would be equal to while the engine is revving up.
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-06-17 22:30
    ok, I found a hertz to RPM equation, but now i have no idea how to use it in the program.

    RPM (n) = (Hertz X 120) / Rotor Poles

    If I am not mistaken, my car has 4 poles. How would I use the COUNT command to insert the proper hertz for the equation?
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-06-17 23:13
    ok, i got it [noparse]:)[/noparse]
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-06-18 13:46
    Hey Bean, how accurate is your 32 bit RPM code at 10,000 RPM?
  • BeanBean Posts: 8,129
    edited 2008-06-18 14:42
    Can you provide a link to the code ?
    What clock speed will the SX be running at ?

    10,000 RPM is only 167 pulses per second (times pulses per revolution). Pretty tame numbers.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Uhhhm, that was on fire when I got here...

    www.iElectronicDesigns.com

    ·
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-06-18 16:25
    it is set to 4000000 I am using the exact code you posted on the RPM reading topic. I can't remember the link [noparse]:([/noparse]
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-06-18 21:31
    another thing....if the RPM signal wire is not hooked up in the car, is there anyway to detect that and not run that function? I ran into a problem where if it is not hooked up, the RPM variable changes alot and caused conflict in other areas of my code.
  • VelocitVelocit Posts: 119
    edited 2008-06-19 02:01
    If the COUNT command returns zero, then tell your program to disregard any further calculations that rely on RPM. A result of zero can only mean that the wire is disconnected or the car is off.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Paul
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-06-19 02:05
    i am no longer using the count command though. I am using the PULSIN with a pin set to input schmitt. It is reading high and low pulses. I am thinking it is picking up radio pulses when disconnected. I need a more reliable way to detect if it is disconnected.
  • VelocitVelocit Posts: 119
    edited 2008-06-19 02:10
    Put a pull-down resistor on the pin and see if that helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Paul
  • eagletalontimeagletalontim Posts: 1,399
    edited 2008-06-19 03:06
    I did and the function stopped working or would continue to loop through it so it basically locked up the chip till I reset it.
Sign In or Register to comment.