PIC Vietnam

Go Back   PIC Vietnam > *06201046*

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Bài Trong Ngày Vi điều khiển

Conversation Between *06201046* and phamhtruong82
Showing Visitor Messages 1 to 2 of 2
  1. phamhtruong82
    11-12-2012 12:07 AM
    phamhtruong82
  2. phamhtruong82
    11-12-2012 12:06 AM
    phamhtruong82
    chao moi người !! xin giúp đỡ mình đang làm đồ án chương trinh chạy mô phỏng ok, nhưng nạp vào ic thực tế thì chân ccp1 không thể điều khiển được và lúc nào cũng ở mức 1. xin mọi ng giúp đỡ vì cũng xắp hết hạn nộp bài rồi đây là code mình dùng l293b.
    #include<16f877a.h>
    //No Watch Dog Timer
    #FUSES NOWDT
    #FUSES XT
    #FUSES NOPUT
    #FUSES NOPROTECT
    #FUSES NODEBUG
    #FUSES NOBROWNOUT
    #FUSES NOLVP
    #FUSES NOCPD
    #FUSES NOWRT
    #USE DELAY(CLOCK=10000000)
    #use fast_io(b)
    #byte portb=0x6
    int16 duty=0;

    void main()
    {

    setup_ccp1(CCP_PWM);//khoi tao bo pwm1
    setup_timer_2(T2_div_by_16,154,1);//tao xung 1ms
    set_pwm1_duty(duty);
    while(true)
    {
    if(!bit_test(portb,0))//che do quay thuan
    {
    output_bit( pin_c3 , 1 );
    output_bit( pin_c4 , 0 );
    duty=0;
    set_pwm1_duty(duty);
    delay_ms(1000);
    goto next;

    }

    if(!bit_test(portb,1))//che do quay nghich
    {
    output_bit( pin_c3 , 0 );
    output_bit( pin_c4 , 1 );
    duty=0;
    set_pwm1_duty(duty);
    delay_ms(1000);
    goto next;

    }
    next:


    if(!bit_test(portb,4))//che do off
    {
    output_bit( pin_c3 , 0 );
    output_bit( pin_c4 , 0 );
    set_pwm1_duty(0);

    }
    while(!bit_test(portb,3))//che do tang toc
    {delay_ms(1000);
    duty=duty < 600 ? duty +10 : 600;
    delay_ms(20);
    set_pwm1_duty(duty);
    break;
    }
    while(!bit_test(portb,2))//che do giam toc
    {
    duty=duty >0 ? duty - 10 : 0;
    delay_ms(20);
    set_pwm1_duty(duty);
    break;
    }

    }


    }

Múi giờ GMT. Hiện tại là 11:19 PM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam