フィルターのクリア

currently i working on plotting a graph of rpm sensor on matlab but unfortunately when i run the plotting coding in Matlab it was failed.It said 'Warning: Unsuccessful read: Matching failure in format.' please help me,i dont know what is the problem

2 ビュー (過去 30 日間)
volatile int rpmcount = 0;
int rpm = 0;
unsigned long lastmillis = 0;
void setup(){
Serial.begin(9600);
attachInterrupt(0, rpm_car, FALLING);//interrupt cero (0) is on pin two(2).
}
void loop(){
if (millis() - lastmillis == 1000){ //Uptade every one second, this will be equal to reading frecuency (Hz).
detachInterrupt(0); //Disable interrupt when calculating
rpm = rpmcount * 60; // Convert frecuency to RPM, note: this works for one interruption per full rotation. For two interrups per full rotation use rpmcount * 30.
Serial.print("RPM =\t"); //print the word "RPM" and tab.
Serial.print(rpm); // print the rpm value.
Serial.print("\t Hz=\t"); //print the word "Hz".
Serial.println(rpmcount); //print revolutions per second or Hz. And print new line or enter.
rpmcount = 0; // Restart the RPM counter
lastmillis = millis(); // Uptade lasmillis
attachInterrupt(0, rpm_car, FALLING); //enable interrupt
}
}
void rpm_car(){ // this code will be executed every time the interrupt 0 (pin2) gets low.
rpmcount++;
}

回答 (2 件)

Image Analyst
Image Analyst 2014 年 11 月 11 日
This is C or Java code, not MATLAB code. Use MATLAB instead.
  4 件のコメント
melisa samad
melisa samad 2018 年 2 月 10 日
Hi, Nazrin Zaini. do you know how to code the speed at matlab?
Walter Roberson
Walter Roberson 2018 年 6 月 3 日
You have the Arduino sending "RPM =" and "Hz=" but your MATLAB code is expecting only numeric values.

サインインしてコメントする。


Osama Yassin
Osama Yassin 2018 年 6 月 3 日
Hi, Nazrin Zaini .. did get the solution about attachInterrupt function in matlab?

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by