Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Simple RPM Switch

Status
Not open for further replies.

thekyguy11

New Member
Hi, I'm working on a project that needs an RPM switch. I've seen a few idea's searching around on google, but I'm looking for the most simple way to build an RPM switch to send a high/low signal to my pic. It would need to switch at roughly 350rpm (I'll have to adjust this once I try it) so the pic knows when the engine is running, versus when it is off. The pic controls starting, so I can't just use the oil pressure switch, etc as an input instead. Thanks

Kyle
 
Last edited:
See "Speed Switch" circuit on page 8 of the data sheet for the LM2907/LM2917: **broken link removed**

Added:
Because of the built in zener voltage-regulator, the LM2917 would be better for an automotive environment.

Ken
 
Last edited:
because I can't count on the oil pressure switch opens when the oil pressure is above 20psi, the engine can easily reach this pressure without even starting. Especially if it has just been ran and is restarted.
 
I think Ubergeeek63 means to directly interface the RPM sensor output pulses to a PIC input, and have the PIC measure the pulse period or frequency to determine when the RPM>350.

Ken
 
o, Id love to do it that way, but I don't know how. It would be awesome if you could explain what components I would need (if any). and I wrote the code with swordfish basic compiler, so if you by any chance know how to write the code for that, it would be great!
 
I might be thinking too simply, but can't you put the sensor (switch) in series with a DC supply and a capacitor, diode and another capacitor. Then connect the PIC across the last capacitor?
 

Attachments

  • thingy1.JPG
    thingy1.JPG
    12 KB · Views: 545
I might be thinking too simply, but can't you put the sensor (switch) in series with a DC supply and a capacitor, diode and another capacitor. Then connect the PIC across the last capacitor?
right idea but indeed oversimplified.

a pull down resister after the switch, an RC filter before the PIC pins to take out any extranious noise and diode clamps to the PIC rails and a software frequency counter.


Dan
 
Last edited:
I'm such a newb, can someone draw that setup for me? I really appreciate it. Also, maybe I'm missing something, but what is the switch for?
 
I get this that the value 350RPM value isn't absolute, you just want to know if the motor is revolving or not. For that you could use a supervisor ic with 8 legs. Check out watchdog timers and MCU-reset ic's. They have the timer you need. If the motor is too slow or stops, the "dog" is not fed and it "barks".
**broken link removed**
 
i don't have the software convenient... the switch is actually the sensor. it might be a magnetic reed, it might be a hall. The chances are it is 0-12V from an engine sensor. I honestly would not know and it could vary from engine to engine though manufacturers will tend to do it the same at least for a year or so till better parts are available.

Dan
 
ahhh, I wasn't thinking of it that way. So, in my case, that would represent the existing crankshaft position sensor. I was just planning on splicing into the signal wire that the ecu uses for an RPM input signal, thats why i didn't think about the sensor. So, if I'm splicing into the RPM input wire to the car's ECU, what hardware would I need between that connection and the PIC pin?
 
ahhh, I wasn't thinking of it that way. So, in my case, that would represent the existing crankshaft position sensor. I was just planning on splicing into the signal wire that the ecu uses for an RPM input signal, thats why i didn't think about the sensor. So, if I'm splicing into the RPM input wire to the car's ECU, what hardware would I need between that connection and the PIC pin?
as i said, most likely just filtering and clamping. one to prevent noise from false triggering the software and the other to protect the PIC.
 
I really appreciate the help. However, when you say filtering and clamping, I get the general idea, but I have no clue what components I would use to accomplish this. I would really appreciate somebody showing me exactly what I need... or point me in the direction of where I can learn about this.
 
You would probably just need a resistor and capacitor but the values would depend on the signal that's available.

As for using a pic to detect the RPM, 6 Revs/Second (360RPM) could be detected by starting a timer every time a pulse is detected, if the timer times out the speed is too low, if another pulse comes along then you compare the timer to a preset amount, too high and the speed is too low. I don't have time right now but I could have a go at detecting this on my Junebug, possibly tomorrow.

Mike.
 
I managed to have a play with this today.

Here is Swordfish code for the Junebug that will light LED 6 if the pulses arriving on B0 represent a speed exceeding 360 RPM.
Code:
Device = 18F1320
Clock = 8 // 8MHz clock
Config OSC = INTIO2, WDT = OFF, LVP = OFF

Const RPM=360
Const CyclesPerMin = 8 * 1000000 /4 * 60
Const Period = CyclesPerMin/RPM/8

Dim NOT_RBPU As INTCON2.7
Dim TMR1IE As PIE1.0
Dim TMR1IF As PIR1.0
Dim INT0IE As INTCON.4
Dim INT0IF As INTCON.1
Dim TMR1 As TMR1L.AsWord        

//global variables
Dim Running As Bit

//interrupt routine
Interrupt MyInt()
    If INT0IF=1 Then                //recieved pulse
        If TMR1IF=1 Then            //has timer overflowed
            Running=0               //yes so not running
        ElseIf(TMR1<Period) Then    //if less than period
            Running=1               //then speed greater than 360RPM
        Else
            Running=0               //otherwise - not running
        EndIf
        TMR1=0                      //reset the timer
        INT0IF=0                    //clear the flags
        TMR1IF=0
     EndIf
End Interrupt

//main code starts here

OSCCON = $72            // select 8MHz internal clock
NOT_RBPU=0              //WPUs on port B
ADCON1=$70
T1CON = %10110001       //pre=8
INT0IE=1
Enable(MyInt)           //set interrupt going
TRISA=$fe               //Setup LEDs
PORTA=1
TRISB=$ff

While true
    DelayMS(1)
    If Running=1 Then
        TRISA.7 = 0     //LED 6 on
    Else
        TRISA.7 = 1
    EndIf    
Wend

End

You can vary the variable RPM to fit your requirements but it can't be less than 240 without modifying the code. It will also need modifying if you use a faster clock speed than 8MHz.

Have fun.

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top