Electoday 2025

ไมโครคอนโทรลเลอร์ => AVR and Arduino => Topic started by: pong19021 on February 15, 2013, 10:15:57 AM

Title: ใครมี code วัด RMP ขอหน่อยครับ
Post by: pong19021 on February 15, 2013, 10:15:57 AM
ใครมี code วัด RPM ขอหน่อยครับ ของอะไรก็ได้ครับ PIC AVR ARM
Title: Re: ใครมี code วัด RMP ขอหน่อยครับ
Post by: firmware.c on February 15, 2013, 11:07:55 AM
Motor ชนิดไหนครับใช้ encoder แบบไหน
Title: Re: ใครมี code วัด RMP ขอหน่อยครับ
Post by: pong19021 on February 15, 2013, 11:27:35 AM
MOtor CPU ครับ
Title: Re: ใครมี code วัด RMP ขอหน่อยครับ
Post by: nont_peet on February 15, 2013, 02:11:25 PM
http://www.themakersworkbench.com/content/tutorial/reading-pc-fan-rpm-arduino (http://www.themakersworkbench.com/content/tutorial/reading-pc-fan-rpm-arduino)

by google  ;D
Title: Re: ใครมี code วัด RMP ขอหน่อยครับ
Post by: jojoe on February 19, 2013, 02:40:44 PM
http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/

ถ้าใช้ Arduino ดูตามลิงค์ เลยครับ มันเป็นการอ่านความถี่ ถ้าอ่านความถี่จาก encoder เราต้องรู้ก่อนว่า มันหมุนไป 1 รอบ ให้ พัลส์กี่ลูก
เพื่อที่จะได้เอาคำนวน เป็นความเร็วรอบ

               S=(F x 60) / P
                           
โดย
S=ความเร็วรอบต่อนาที
F=ความถี่ (Hz)
P=จำนวนสัญญาณพัลส์ต่อรอบ

#include <FreqCounter.h>
int P= 100;
void setup() {
  Serial.begin(57600);                    // connect to the serial port
  Serial.println("Frequency Counter");
}

long int frq;
Void loop() {

FreqCounter::f_comp= 8;             // Set compensation to 12
FreqCounter::start(100);            // Start counting with gatetime of 100ms
while (FreqCounter::f_ready == 0)         // wait until counter ready

frq=FreqCounter::f_freq;            // read result
Serial.println((frq*60)/P);                // print result
delay(20);
}

ลองดูนะครับ
intput เข้า pin 5 ของ Arduino นะครับ
Title: Re: ใครมี code วัด RMP ขอหน่อยครับ
Post by: pong19021 on February 20, 2013, 06:16:08 AM
ขอบคุณมากครับได้แล้วครับ