|
|
ŸÄÚ¹ÌÅÍ ¿¬±¸ µÎ¹ø°..
|
|
±è¿µÀÏ
|
2012-05-10 11:35:00, Á¶È¸ : 5,878, Ãßõ : 675 |
|
1. ¾ÕÀü ŸÄÚ¹ÌÅÍ ½ÇÇè¿¡¼ ½Ç¿ëÀûÀÎ Á¤È®¼ºÀ» È®ÀÎÇßÀ¸¹Ç·Î À̹ø¿¡´Â ½ÇÁ¦·Î
¼¾¼·ÎºÎÅÍ ½ÅÈ£¸¦ Àоî¿À´Â ½ÇÇèÀ» Çß½À´Ï´Ù.
°£ÀÌ ÃøÁ¤±â¸¦ ¸¸µé°í µå¸±¿¡ Ç÷¡±×¸¦ ´Þ¾Ò½À´Ï´Ù. ½ÇÁ¦·Î ÇÇÄÚÁî ²¿¸®³¯°³ Å©±â
·Î Å×ÀÌÇÁ ÆøÀ» À߶ó ºÙÀΰÍÀÔ´Ï´Ù. ÀÌ°ÍÀÌ ÀÎ½ÄµÇ¸é ¿Ø¸¸ÇÑ ÇÁ·ÓÀº ´Ù ÀνĵǰÚÁö¿ä.
2. ½ÇÇèÇÑ °á°ú Àú¼Ó¿¡¼´Â ÀνÄÇÏÁö¸¸ °í¼ÓȸÀü¿¡¼´Â ÀνÄÀ» ÇÏÁö ¸øÇß½À´Ï´Ù.
ÀÌ ¼¾¼ ȸ·Î´Â ºûÀÌ °¡·ÁÁö¸é Ãâ·ÂÀÌ high°¡ ³ª¿À°Ô²û ±¸¼ºÇÑ °ÍÀÔ´Ï´Ù.
±×·±µ¥ ½ºÄÚÇÁ·Î ÆÄÇüÀ» È®ÀÎÇغ¸¸é Àú¼Ó¿¡¼´Â low/high ½ÅÈ£°¡ È®½ÇÈ÷ ±¸ºÐµÇ´Âµ¥
°í¼ÓÀ¸·Î ¿Ã¸±¼ö·Ï ÆÄÇüÆø¸¸ ª¾ÆÁö´Â°ÍÀÌ ¾Æ´Ï¶ó highÀü¾Ðµµ ä »ó½ÂÇϱâ Àü¿¡ ÇÏ°ÇÏ´Â
ÀÛÀº Åé´ÏÆÄ Çü½ÄÀ» ¶ç´Â°Ô º¸¿´½À´Ï´Ù.
3. NPN TRÇÑ°³°ú ÀúÇ× ¸î°³¸¦ Á¶ÇÕÇÏ¿© À̸®Àú¸® ÀúÇ×°ªÀ» ¹Ù²ã°¡¸ç Å×½ºÆ®ÇÑ ÃÖÁ¾È¸·ÎÀÔ´Ï´Ù.
¹¹ TRÁõÆøÀ» Àß ¸ô¶ó¼ ±×³É ¸¶±¸ÀâÀÌ·Î ÀúÇ׹ٲ㰡¸ç ÁÁÀº °á°ú³ª¿Ã¶§±îÁö º¯°æÇغ»°Ì´Ï´Ù.
µýÁöÁ» °É¾îÁÖ¼¼¿ä.
4. ÆÄÇüÀÌ ±×·±´ë·Î ¸¸Á·½º·´½À´Ï´Ù. µå¸±ÀÇ ÃÖ´ë RPMÀº 2830Àε¥ Ç÷¡±× 3°³ ºÙ¿©³õÀ¸´Ï±î
´ë·« 8500 RPMÀÇ °ªÀÌ ³ª¿É´Ï´Ù. ÀÌÁ¤µµ ¼Óµµ¸é ¼ÒÇü,°æ·®±âüÀÇ ÇÁ·ÎÆç·¯ ÀνĿëÀ¸·Î´Â
ÃæºÐÇÑ ½ºÆÑÀ̶ó°í »ý°¢ÇÕ´Ï´Ù.
´ÙÀ½¿¡´Â ¹Ý»çÇüÀ¸·Î ±¸¼ºÇؾ߰ڽÀ´Ï´Ù. °üÅëÇüÀº ¾Æ¹«·¡µµ ½Ç¿ëÀûÀÌÁö ¸øÇÏ´Ù°í »ý°¢ÇÕ´Ï´Ù.
ȸ·Îµµµµ ¾ø´Âµ¥ ¼Ò½º°¡ ÇÊ¿äÇÒ¶õ°¡¸¸Àº ±×³É Äڵ常 º¸¼Åµµ ´ë·« ȸ·Î¸¦ ¾î¶»°Ô ±¸¼ºÇß´ÂÁö
°¨ ÀâÀ¸½Ç°Ì´Ï´Ù.
display´Â ´ë·« 0.5Ãʸ¶´Ù Çѹø¾¿ÀÌ°í, RPMÃøÁ¤Àº ÀÌÀü DISPLAY ½ÃÁ¡ºÎÅÍ µé¾î¿Â ÆÞ½º½Ã°£µé ´©Àû
°ª¿¡ ¼ÀÇøµ Ƚ¼ö·Î ³ª´«, Àüü ¼ÀÇøµÀÇ Æò±Õ°ªÀÌ µÇ°Ú½À´Ï´Ù. 0.5Ãʵ¿¾È 20°³ µé¾î¿À¸é
20°³ÀÇ Æò±Õ°ªÀ» ÃëÇÑ´Ù´Â °ÅÁÒ.
//**********************************************************
// Tachometer
// LCD display version.
//------------------------------------------------
//
// Date : 2012 05. 10.
// Programed by youngil.kim
//**********************************************************
#define F_CPU 16000000UL // 16 MHz
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "Mymega16.h"
volatile unsigned char dsp_count, ovf_count;
volatile unsigned int flag, sample_count;
volatile unsigned long count16_sum;
//--------------[ flag ]--------------
#define DSP 0
#define LOWRPM 1
#define SAMPLE 100
// ¿ÜºÎ ÀÎÅÍ·´Æ® 󸮷çƾ
ISR (INT0_vect) {
if (sample_count < SAMPLE) {
count16_sum += ((unsigned long)ovf_count * 65536);
count16_sum += TCNT1;
TCNT1=0;
ovf_count=0;
sample_count++;
}
}
// ÃÊ´ç 61ȸ È£ÃâµÈ´Ù.
ISR(TIMER0_OVF_vect ) {
if (dsp_count > 30) {
sbi(flag, DSP); // ´ë·« 0.5Ãʸ¶´Ù display°»½Å.
dsp_count = 0;
}
else dsp_count++;
// if (chkbit(PORTB,0)) cbi(PORTB, 0); // ÆÞ½º Á¦³Ê·¹ÀÌÅÍ.
// else sbi(PORTB, 0);
}
ISR(TIMER1_OVF_vect ) {
ovf_count++;
}
int main (void) {
unsigned char i;
unsigned int temp;
//---------[ Æ÷Æ®¼³Á¤ ]------------------
// ³»ºÎ pull-up »ç¿ë¾ÈÇÔ.
sbi(MCUCR, PUD);
DDRD = 0xFB;
DDRA = 0xF2;
DDRB = 0xFF;
//---------[ ŸÀ̸Ó0 ¼³Á¤ ]--------------
sbi(TCCR0, CS12); // 1024ºÐÁÖ, displayÁֱ⠼³Á¤¿ë.
cbi(TCCR0, CS11);
sbi(TCCR0, CS10);
//---------[ ŸÀ̸Ó1 ¼³Á¤ ]--------------
cbi(TCCR1B, CS12); // 64ºÐÁÖ, ÆÞ½ºÆø ÃøÁ¤¿ë.
sbi(TCCR1B, CS11);
sbi(TCCR1B, CS10);
cbi(TCCR1B, WGM13); // normal mode.
cbi(TCCR1B, WGM12);
cbi(TCCR1A, WGM11);
cbi(TCCR1A, WGM10);
//---------[ INT0 ¼³Á¤ ]------------------
sbi (GICR, INT0); // ¿ÜºÎ ÀÎÅÍ·´Æ® Enable.
sbi (MCUCR, ISC01);
cbi (MCUCR, ISC00); // falling edge detect type.
//---------[ LCD ÃʱâÈ ]--------------
LCD_initialize();
locate (0,0);
LCD_puts("_RPM Meter_");
for(i=0;i<10;i++) _delay_ms(100);
//---------[ º¯¼öÃʱâÈ ]------------------
clear_lcd();
locate (0, 0);
LCD_puts("RPM:");
TCNT1 = 0;
TCNT0 = 0;
sbi(TIMSK, TOIE0);
sbi(TIMSK, TOIE1);
sei(); // interrupt ½ÃÀÛ.
//---------[ ¸ÞÀÎ ]--------------
for(;;) {
if(chkbit(flag, DSP) != 0) {
cbi(flag, DSP);
// displayó¸®
temp = 0;
locate(0,4);
if (sample_count > 1) {
count16_sum = count16_sum / sample_count;
temp = 15000000 / count16_sum;
LCD_num9999(temp);
}
else {
LCD_puts("<200");
}
count16_sum = 0;
sample_count = 0;
ovf_count = 0;
}
}
}
|
|
|
|
|
À¸¹Ì ¾Æ±îºì Mega16...
±×·¸°Ô ÄÄÆÄÀÏÇÏ°í ³ª¸é ¸î¹ÙÀÌÆ®³ª µÇ³ª¿ä? |
2012-05-10 21:06:56 |
|
|
°³¹ßÀº ÀÌ°Å·Î ÇÏ°í, ½ÇÀü¿¡´Â mega48·Î °¡¾ß°ÚÁö¿ä. 2220 byteÀÔ´Ï´Ù. |
2012-05-10 22:21:48
|
|