4cyl engine rev limiter
I just bought the "what is a microcontroller?" kit from radio shack and just got done with the manual it came with and I have a basic understanding of how it works and its programing.
I dug around and found a guy that made a RPM detector using a hall sensor, and some programing.
Well- I replaced the hall sensor with the primary of my ignition coil on my 4cylinder engine, and halfed the detection time from 1000, to 500 and it displays the RPMs in the debug.
Well- I want to set a rev-limiter program to it.
I kinda know how to do it, but dont fully understand how to write the "if, than"
basically, if RPM's exceed 3000 turn pin 14 high which would then turn a mosfet of relay on to turn the ignition coil off and slow the engine down, also, if RPMs are less than 3000 leave pin 14 low.
you get me?
here is the program I have now.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
SpeedIn PIN 15 'Receive Input from Hall Sensor
'
[noparse][[/noparse] Constants ]
Capture CON 500 ' Num of msec to listen for input
'
[noparse][[/noparse] Variables ]
rpm VAR Word ' value to hold the RPM of the engine
pulses VAR Word ' input pulses from Engine
'
[noparse][[/noparse] Initialization ]
pulses = 0
DO
COUNT SpeedIn, Capture, Pulses
rpm = (Pulses * 60)
DEBUG CR, "Pulses = ", DEC pulses
DEBUG CR, "RPM = ", DEC rpm, CR,CR
LOOP
END
I dug around and found a guy that made a RPM detector using a hall sensor, and some programing.
Well- I replaced the hall sensor with the primary of my ignition coil on my 4cylinder engine, and halfed the detection time from 1000, to 500 and it displays the RPMs in the debug.
Well- I want to set a rev-limiter program to it.
I kinda know how to do it, but dont fully understand how to write the "if, than"
basically, if RPM's exceed 3000 turn pin 14 high which would then turn a mosfet of relay on to turn the ignition coil off and slow the engine down, also, if RPMs are less than 3000 leave pin 14 low.
you get me?
here is the program I have now.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
SpeedIn PIN 15 'Receive Input from Hall Sensor
'
[noparse][[/noparse] Constants ]
Capture CON 500 ' Num of msec to listen for input
'
[noparse][[/noparse] Variables ]
rpm VAR Word ' value to hold the RPM of the engine
pulses VAR Word ' input pulses from Engine
'
[noparse][[/noparse] Initialization ]
pulses = 0
DO
COUNT SpeedIn, Capture, Pulses
rpm = (Pulses * 60)
DEBUG CR, "Pulses = ", DEC pulses
DEBUG CR, "RPM = ", DEC rpm, CR,CR
LOOP
END
Comments
but there is an endif statement.
any ideas?
this is what I have so far
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
SpeedIn PIN 15 'Receive Input from Hall Sensor
'
[noparse][[/noparse] Constants ]
Capture CON 125 ' Num of msec to listen for input
'
[noparse][[/noparse] Variables ]
rpm VAR Word ' value to hold the RPM of the engine
pulses VAR Word ' input pulses from Engine
'
[noparse][[/noparse] Initialization ]
pulses = 0
DO
COUNT SpeedIn, Capture, Pulses
rpm = (Pulses * 60)
DEBUG CR, "Pulses = ", DEC pulses
DEBUG CR, "RPM = ", DEC rpm * 4, CR,CR
LOOP
DO
DEBUG ? rpm
IF (rpm = > 1300) THEN
HIGH 14
IF (rpm = < 1300) THEN
LOW 14
ENDIF
changing the second·IF to an ELSEIF should fix that problem, you have 2 IF's only 1 ENDIF
where you have your·DO LOOP will not allow your IF THEN statements to run
you also have a DO without LOOP
you can also remove the = sign from one of your IF statements depending on what you want 14 to be when·rpm is = to 1300
Hope this helps
···· Brad
pulses = 0
DO
COUNT SpeedIn, Capture, Pulses
rpm = (Pulses * 60)
DEBUG CR, "Pulses = ", DEC pulses
DEBUG CR, "RPM = ", DEC rpm * 4, CR,CR
LOOP····<<<·· at this point your program will go back up to the DO statement bypassing all code below this line
DO···· <<<·· DO without LOOP
DEBUG ? rpm
IF (rpm = > 1300) THEN···· <<<·· remove = if you intend 14·to be·LOW when rpm is = 1300
HIGH 14
IF (rpm = < 1300) THEN···· <<<·· change to ELSEIF (rpm = < 1300) THEN·· also remove = if you intend·14
LOW 14···························································································· ·to·be HIGH when rpm is = 1300
ENDIF
LOOP···· <<<·· putting LOOP here will allow your IF THEN statements to run
Post Edited (Brad_H) : 4/27/2008 10:16:57 AM GMT
Car ignition systems don't quite work like that... a production quality rev limiter would probably intercept the signal to the ignition coil and output a signal corresponding to the maximum set RPM once the threshold is crossed. Given the relatively slow reaction time of relays, your method is likely to either shut the engine off or cause backfire. There are a whole lot of things that can go wrong and seriously damage your car's engine so be very careful with this project!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Paul
its like it doesn't know what it should be doing in the ifthan statement.
here's what I have so far
DEBUG ? rpm
IF (rpm = 720) THEN <<< I often change the number to something it usually displays as my RPM, or change the = to a >
HIGH 10
ELSEIF (rpm < 1300) THEN <<< same thing here, and yet no output on pin 10
LOW 10
ENDIF
LOOP
just got it to work, it seems that the stamp cannot read the RPM, but it can however read the pulses. So in other words- it can monitor its input on pin 15 which is what im using as the pulse input- but it cannon monitor an equation that it performed.
here's the entire program for a 4cyl engine with a rev-limit LED on pin 10.
Ill revise this in an hour or so and rewire my car so I can incorporate a rev limiter.
videos will come as well >=D
>>>>>>>>>>>>>><<<<<<<<<<<<>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<,
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
SpeedIn PIN 15 'Receive Input from Hall Sensor
'
[noparse][[/noparse] Constants ]
Capture CON 125 ' Num of msec to listen for input
'
[noparse][[/noparse] Variables ]
rpm VAR Word ' value to hold the RPM of the engine
pulses VAR Word ' input pulses from Engine
'
[noparse][[/noparse] Initialization ]
pulses = 0
DO
COUNT SpeedIn, Capture, Pulses
rpm = (Pulses * 60)
DEBUG CR, "Pulses = ", DEC pulses
DEBUG CR, "RPM = ", DEC rpm * 4, CR,CR
'<<< DO without LOOP
DEBUG ? pulses
IF pulses > 5 THEN
HIGH 10
ELSEIF pulses < 5 THEN
LOW 10
ENDIF
LOOP