親愛的愛將沒有轉速表,
油表又從沒正常工作過,
所以就把它的位置拿來做轉速表了。
一般的轉速表是接到CDI的脈動線圈上抓取轉速訊號,
但不想大費周章拆車只為了找出這條線,
而檔車的火星塞就正在引擎的側邊,
因此直接使用霍爾元件去感應火星塞的點火訊號,
就可以抓到引擎的轉速。
使用示波器可以看出霍爾元件感應火星塞時所輸出的波形,
線性的霍爾元件在沒有磁場的狀況下輸出1/2Vcc的電壓,
這樣的電壓已經高於單晶片的閾值電壓,
因此需要使用電壓比較器來抓出脈波。
使用可變電阻來調整閾值電壓。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
Servo indicator; | |
unsigned long start; | |
unsigned long length; | |
int rpm; | |
long rpma; | |
int out; | |
void setup (){ | |
pinMode(7,INPUT); | |
pinMode(8,OUTPUT); | |
indicator.attach(8); | |
indicator.writeMicroseconds(670); //10000rpm | |
delay(550); | |
indicator.writeMicroseconds(2340); //0rpm | |
delay(550); | |
} | |
void loop (){ | |
while(!spike()); //wait for LOW signal | |
while(spike())start=micros(); //start at the falling edge of HIGH signal | |
while(!spike()); //wait for LOW signal | |
while(spike())length=micros()-start; //end at the falling edge of HIGH signal | |
if(length>6000&&length<100000){ //T=6000us equal 10000rpm; T=100000us equal 600rpm | |
rpm=60000000/length; //rpm=(1sec/T)*60=60000000(us)/T(us) | |
} | |
rpma=rpma*3+rpm; //averaging filter | |
rpma=rpma/4; | |
out=rpma/10; //accuracy=10rpm | |
indicator.writeMicroseconds(map(out,0,1000,2340,670)); | |
} | |
boolean spike(){ | |
return (PIND>>7);//read signal input | |
} |
Arduino mini pro
ss49e hall sensor
LP339n
Servo
Regulator
others
----------------------
HALL EFFECT SENSING AND APPLICATION
SS49e Hall effect sensor
LP339n Voltage comparator