วันพฤหัสบดีที่ 20 พฤษภาคม พ.ศ. 2553

ห่างหายไปนาน


ห่างหายไปนานไม่ได้ update กับเขาสักที ที่หายไปนานก็ไม่ใช่อะไรครับ ไปเรียน cal3 อยู่ วิชาสุดท้ายแล้ว ในที่สุดก็จะจบแล้ว ดีใจจังเลย ว่าแต่จบไปแล้ว ต้องรอทำงานอีก เง้อ!!! จบช้าก็แบบนี้แหล่ะ ก็คนเรียนไม่เก่งเนอะ ไม่มีใครช่วยเราได้นอกจากตัวเราเอง วันนี้ว่างๆ (รึเปล่า) พอดีที่ร้าน www.vt-recycle.com ที่เปิดขายของ ยังไม่มีเครื่องวัดรอบมอเตอร์ เพื่อใช้ทดสอบมอเตอร์ เลยไม่รู้รอบมอเตอร์ ก็เลยทำใว้ใช้สักหน่อย แต่ยังไม่มีภาค input นะ แค่วงจรคร่าวๆ ส่วนโค๊ดก็เอามาจากตัวอย่างของ CCS ไปดูกานเลย

ป.ล. ใครผ่านมาผ่านไปก็ช่วยอุดหนุนหน่อยนะครับ เป็นทุนในการพัฒนาโปรเจกต่างๆ อิอิ ....

/**
#include <16f877a.h>
#fuses HS,NOWDT,NOLVP
#use delay(clock=20000000) //one instruction=0.2us
//#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7)
#bit t1_overflow=0x0C.0

#include
// #bit t1_overflow=0xF9E.0 (PIC18, Reminder)

void main() {
int cycles8, cycles;
int32 freq;
long freqc_high;
long freqc_low;

lcd_init();
lcd_putc("\f");

while (TRUE) {
cycles8=0;
cycles=0;
freqc_high=0;
t1_overflow=0;
set_timer1(0);
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
/* ___ wait one second ___ */
while (cycles!=0xFF) { //true=3, false=4
cycles8=0; //1 cycle
//start inner loop
while (cycles8!=0xFF) { //true=3, false=4
if (t1_overflow)//true=2,false=3 //----|
{t1_overflow=0;freqc_high++;}//6 cycles // |
else // |-- 8 cycles
{delay_cycles(5);} //----|
delay_cycles(62); //x62
cycles8++; //1
///2 cycles to jump to top
//math: end inner loop
//math: total inner loop=((3+8+x+1+2)*255 + 4)*255
//math: if x=62.87781 then inner loops takes 5mil instructions
//math: if x=62 then inner loop takes 4942920, have to fill 57080 cycles
}
delay_cycles(216); //y
cycles++; ///1 cycle
///2 cylces to jump to top
//math: outer=(3+1+y+1+2)*255+4=57080
//math: y=(57080-4)/255)-(3+1+0+0+1+2)
//math: if y=216.827450980392156862745098039216 then outer loop cylces is 57080
//math: if y=216 then outer loop cycles is off by 211 cycles. z=211
}
delay_cycles(211); //z
/* ___ end waiting 1 second ___ */
setup_timer_1(T1_DISABLED); //turn of counter to prevent corruption while grabbing value
if (t1_overflow) //check one last time for overflow
freqc_high++;
freqc_low=get_timer1(); //get timer1 value as the least sign. 16bits of freq counter
freq=make32(freqc_high,freqc_low); //use new make32 function to join lsb and msb
lcd_gotoxy(1,1);
printf(lcd_putc,"Frequency Counter");
lcd_gotoxy(1,2);
printf(lcd_putc," F = %LU Hz\r\n",(freq/3)+1); //and print frequency

}
}
**/

วันพฤหัสบดีที่ 13 พฤษภาคม พ.ศ. 2553

ใกล้จบแล้ว

อีกไม่นานเกรดจะออกแล้วววววววว ดีใจจัง มาแจกวงจรดีกว่า