• 車種別
  • パーツ
  • 整備手帳
  • ブログ
  • みんカラ+

toyspの愛車 [トヨタ プリウスα]

整備手帳

作業日:2013年10月27日

自作 タコメータ・・・・ 危険 真似しないでください

他の整備手帳を見る 他の整備手帳を見る

目的 修理・故障・メンテナンス
作業 DIY
難易度

中級

作業時間 6時間以内
1
タコメータが ないので 自作してみました。


PICは 難しくて 使えないので arduinoを こそこそと・・・・

シグナルは OBD2から から アナログでとって・・・・

2
シグナルは OBD2から とって

100msの間に何回 シグナルがあるか数えて

単に表示してます。

ど 下手な プログラムですが 一応 動いてます・・・


下に プログラムを 書いておきました・・・・・・

真似しないでください 危険です・・・

危険危険危険


OBD2からのシグナルピンは

 また 写真載せます。


ここです シグナル
3
//アナログシグナル
int sensorPin = 18 ; // select the input pin for the potentiometer

int sensorValue = 0; // variable to store the value coming from the sensor
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value


//表示LEDピン
int led[] ={14,12,11,10,9,8,7,6,5,4};//45678910111214
//回転数 境界数値 X100
int rpm[] ={10,15,20,25,30,35,40,45,50,60};//45678910111214
int real_rpm=0;
int real_rpm_old=0;
// the setup routine runs once when you press reset:
int buttonState = 0;


unsigned long time0;
unsigned long time1;
unsigned long time;



void setup() {
// initialize the digital pin as an output.
for (int i=0; i <= 9; i++){
pinMode(led[i], OUTPUT);
}
pinMode(sensorPin, INPUT);

digitalWrite(sensorPin, LOW);

open_led() ;
// Serial.begin(9600);
}
void open_led() {
for (int i=0; i <= 9; i++){
digitalWrite(led[i], HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led[i], LOW); // turn the LED on (HIGH is the voltage level)
//delay(100); // wait for a second
}

for (int i=9; i >= 0; i--){
digitalWrite(led[i], HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led[i], LOW); // turn the LED on (HIGH is the voltage level)
//delay(100); // wait for a second
}
delay(100);

for (int i=0; i <= 9; i++){
digitalWrite(led[i], HIGH); // turn the LED on (HIGH is the voltage level)
delay(100);
}
delay(500);
for (int i=0; i <= 9; i++){
digitalWrite(led[i], LOW); // turn the LED on (HIGH is the voltage level)
delay(100);

}


}



void loop() {
real_rpm=0;


buttonState = digitalRead(sensorPin);
// if( buttonState ==HIGH){
time0 = millis();

int count=0;
int v=1;

do
{
buttonState = digitalRead(sensorPin);

if (( buttonState ==LOW)*(v==1)){

v=0;
count++;

}

if (( buttonState ==HIGH)*(v==0)){

v=1;

}


time1 = millis();

time=time1-time0;

} while (time < 100);



real_rpm=6*count;// 1/100




// };

delay(2);

if (real_rpm_old-real_rpm>5){

// real_rpm=real_rpm_old-1;



}

//ノイズ処理 シグナルが接続されてないと ノイズになり 
// led[4]を 光らせる
if (real_rpm>200){

digitalWrite(led[4], HIGH);
delay(100);
real_rpm=0;



}
rpm_set( real_rpm);
real_rpm_old=real_rpm;
}
void rpm_set(int real_rpm) {
//count real_rpm
int led_no=10;
for (int i=9; i >=0; i--){

if (rpm[i]>real_rpm){

led_no=i;
}

}

led_on(led_no);




}
void led_on(int ii) {
for (int i=0; i <= ii-1; i++){
digitalWrite(led[i], HIGH); // turn the LED on (HIGH is the voltage level)
// delay(100); // wait for a second
}
for (int i=ii; i <= 9; i++){
digitalWrite(led[i], LOW); // turn the LED off by making the voltage LOW
// delay(100);
} // wait for a second
}
4
カバーなし
スピードメータ兼用 

int sensorPin = 18 ; //17 18// select the input pin for the potentiometer
int tipe_set_HIGH = 1;
int tipe_set_LOW = 0;
int led[] = {
14, 12, 11, 10, 9, 8, 7, 6, 5, 4
}; //45678910111214
int buttonState = 0;


int one_p_mm = 512;//mm
int sokuteijikan = 1000;//msec
int bunkatujikan = 100;
int cc = sokuteijikan / bunkatujikan;
int old_time_count = 0;

unsigned long time;
unsigned long timecount[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

unsigned long sokudo[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};


void setup() {
// initialize the digital pin as an output.
for (int i = 0; i <= 9; i++) {
pinMode(led[i], OUTPUT);
}
pinMode(sensorPin, INPUT);

digitalWrite(sensorPin, LOW);


pinMode( sensorPin , INPUT);
// digitalWrite( sensorPin , HIGH);

open_led() ;

}
void open_led() {
for (int i = 0; i <= 9; i++) {
digitalWrite(led[i], tipe_set_LOW );

}

for (int i = 0; i <= 9; i++) {
digitalWrite(led[i], tipe_set_HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led[i], tipe_set_LOW ); // turn the LED on (HIGH is the voltage level)
//delay(100); // wait for a second
}

for (int i = 9; i >= 0; i--) {
digitalWrite(led[i], tipe_set_HIGH ); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led[i], tipe_set_LOW ); // turn the LED on (HIGH is the voltage level)
// delay(100); // wait for a second
}
delay(100);

for (int i = 0; i <= 9; i++) {
digitalWrite(led[i], tipe_set_LOW); // turn the LED on (HIGH is the voltage level)
delay(100);
}
// delay(500);
for (int i = 0; i <= 9; i++) {
digitalWrite(led[i], tipe_set_HIGH); // turn the LED on (HIGH is the voltage level)

delay(100);
}
for (int i = 9; i >= 0; i--) {
digitalWrite(led[i], tipe_set_LOW); // turn the LED on (HIGH is the voltage level)

delay(100);
}


}

int v = 0;
void loop() {
time = (millis() % sokuteijikan);
int count = 0;
buttonState = digitalRead(sensorPin);

if (( buttonState == tipe_set_LOW) * (v == 1)) {
v = 0;
//count++;
for (int i = 0; i <= (cc - 1); i++) {
timecount[i] ++;
}
count = 1;
}

if (( buttonState == tipe_set_HIGH) * (v == 0)) {
v = 1;
}

if ( ( time / bunkatujikan) != old_time_count) {
sokudo[time / bunkatujikan] = timecount[ time / bunkatujikan] * one_p_mm * 36 / sokuteijikan ; //km/h
timecount[ time / bunkatujikan] = 0;
}

old_time_count = time / bunkatujikan;
int speed_he = 0;
for (int i = 0; i <= ( cc - 1); i++) {
speed_he = speed_he + sokudo[i];
}
speed_he = speed_he / cc;
led_on(speed_he / 160);

}

void led_on(int ii) {
if (ii > 11) {
ii = 10;
}


for (int i = 0; i <= ii - 1; i++) {
digitalWrite(led[i], tipe_set_HIGH); // turn the LED on (HIGH is the voltage level)
// delay(100); // wait for a second
}

if (ii <= 9) {
for (int i = ii; i <= 9; i++) {
digitalWrite(led[i], tipe_set_LOW); // turn the LED off by making the voltage LOW
// delay(100);
} // wait for a second

}

}
5
加速度メータを作ってみたいが
まず スピードメータを考えてみた
V=パルス回数/秒 *パルス1回の距離

直径 652.4mm
円周 2049.58mm

一回転あたりのパルス4とする

一回パルスあたりの移動距離
512.4mm/p

60Km/h 32.53Hz
6
スピードメータ 01



// these constants won't change:
const int inputPin = 17; // the pin that the potentiometer is attached to
const int ledCount = 10; // the number of LEDs in the bar graph

int ledPins[] = {
4, 5, 6, 7,8,9,10,11,12,14 }; // an array of pin numbers to which LEDs are attached



int sig_old=0;
int sig_now=0;
int sig_chenge=0;
int sig_count=0;
int check_count=2000;


void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}

pinMode( inputPin, INPUT);
pinMode(13, OUTPUT);


}


void loop() {
delay(1);

sig_old=sig_now;

sig_now = digitalRead(inputPin) ;
digitalWrite(13,sig_now);

if( sig_count>2000){
sig_count=2000;
check_count=2000;
}


if(sig_old!=sig_now){
sig_chenge=1;
check_count= sig_count;
sig_count=0;

}
else{
sig_chenge=0;
}
sig_count++;

//show_led(1844/check_count/35);
//show_led(1844/check_count/54);// 1memori 20k/h


//v=20*34/check_count km/h

//show_led((20*34/check_count)%10);
show_led(34/check_count);// 1memori 20k/h
// show_led(check_count/3);
// show_led(2000);

}
void show_led(int x) {

for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// if the array element's index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < x) {
digitalWrite(ledPins[thisLed], LOW);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], HIGH);
}
}
}



スピードメータ 02




// these constants won't change:
const int inputPin = 17; // the pin that the potentiometer is attached to
const int ledCount = 10; // the number of LEDs in the bar graph

int ledPins[] = {
4, 5, 6, 7, 8, 9, 10, 11, 12, 14
}; // an array of pin numbers to which LEDs are attached



int sig_old = 0;
int sig_now = 0;
int sig_chenge = 0;
int sig_count = 0;
int check_count = 2000;
long vv = 0;
long v_count = 0;

long V = 1;
unsigned long v_time = 150000;
unsigned long v_time0 = 0;


unsigned long time;

void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}

pinMode( inputPin, INPUT);
pinMode(13, OUTPUT);
time = micros();
v_time0 = time ;
// Serial.begin(9600);
}


void loop() {
delay(1);


// Serial.println(time);
sig_old = sig_now;

sig_now = digitalRead(inputPin) ;
digitalWrite(13, sig_now);

if ( sig_count > 2000) {
sig_count = 2000;
check_count = 2000;
V = 2000;
}


if (sig_old != sig_now) {
sig_chenge = 1;
check_count = sig_count;
sig_count = 0;


vv = vv + check_count;
v_count++;
v_time0 = micros() - time;
// Serial.println( v_time0);

if (v_time < v_time0) {
time = micros();
V = vv / v_count + 1;
vv = 0;

v_count=0;
}

}
else {
sig_chenge = 0;
}
sig_count++;

//show_led(1844/check_count/35);
//show_led(1844/check_count/54);// 1memori 20k/h


//v=20*34/check_count km/h
// show_led(( 34 / V) );

show_led((20 * 34 / V) % 10);
// show_led(34 / check_count); // 1memori 20k/h
// show_led(check_count/3);
// show_led(2000);

}
void show_led(int x) {

for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// if the array element's index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < x) {
digitalWrite(ledPins[thisLed], LOW);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], HIGH);
}
}
}

イイね!0件




関連コンテンツ

関連整備ピックアップ

クルーズコントロールスイッチ取付

難易度: ★★

ユピテルLS1100L取り付けと、セルスター直結配線DCコードの改造

難易度:

3Dクロームメッキ グリルカバーを修理から戻ってきたので再取付してみた。

難易度:

灯火の確認。

難易度:

D.A.D.ネックパッドの革張替え

難易度:

コルネット清掃整備

難易度:

関連リンク

この記事へのコメント

コメントはありません。

プロフィール

「名車 SVX に初心者マークの 強者現る!! http://cvw.jp/b/2021120/47791717/
何シテル?   06/20 12:56
トーイです。よろしくお願いします。
みんカラ新規会員登録

ユーザー内検索

リンク・クリップ

ヤマハ COX ボディダンパー 
カテゴリ:その他(カテゴリ未設定)
2014/06/20 23:53:51
エアコンパネル取り外し 
カテゴリ:その他(カテゴリ未設定)
2014/06/08 21:17:26
エアコンパネル解体 
カテゴリ:その他(カテゴリ未設定)
2014/06/08 21:14:48

愛車一覧

ヤマハ R1-Z ヤマハ R1-Z
復活 2スト 高燃費 高加速・・・・時代錯誤の バイク 転倒 注意
トヨタ プリウスα トヨタ プリウスα
トヨタ プリウスαに乗っています。 DIYでどこまでできるか・・・ リア ランプ ちょ ...
ヤマハ YSR50/80 ヤマハ YSR50/80
何かの勢いで ポチっとしてしまいました。 動くかどうかさえ不明
ダイハツ トールカスタム ダイハツ トールカスタム
本日納車 嫁 写真拒否のため 悪しからず... 20170625
ヘルプ利用規約サイトマップ

あなたの愛車、今いくら?

複数社の査定額を比較して愛車の最高額を調べよう!

あなたの愛車、今いくら?
メーカー
モデル
年式
走行距離(km)
© LY Corporation