PIC Vietnam

Go Back   PIC Vietnam > Thành Viên

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

hopeman hopeman is offline

Đệ tử 6 túi

Visitor Messages

Showing Visitor Messages 11 to 17 of 17
  1. hoahongxanh18
    27-11-2013 05:45 PM
    hoahongxanh18
    Tải tai zalo cho dien thoai cam ung android. Hay đến với thế giới màu sắc trong tai game kim cuong nào! Hiện tại có rất nhiều game mới ra mắt nhưng tai game pikachu vẫn rất được yêu thích. Hãy đến với đường đua rực lửa trong tai game dua xe hay tải game thien dia quyet cho dien thoai iphone, ipad
  2. ngocha265199
    27-11-2013 03:52 PM
    ngocha265199
    Sự phát triển của thế giới di động hiện nay cũng kéo theo sự bùng nổ của các game giải trí hấp dẫn như tai game dot kich cho điện thoại, tai game dot kich miễn phí cho mobile, hay game vui nhộn, cực hot mà hiện đang được rất nhiều bạn trẻ chơi đó là tai game avatar cho mobile, tai game avatar về máy, tai game avatar miễn phí cho di động. Games hấp dẫn đang chờ đón các bạn đó ^^
  3. ngaymuamua
    22-11-2013 04:13 PM
    ngaymuamua
    Cách tai facebook phiên bản tiếng việt- facebook mobile - wap tai facebook ve dien thoai mobile phiên bản mới nhất - tai facebook cho dien thoai-tai facebook ve dien thoai- Hướng dẫn tai facebook ve dien thoai java, đăng kí facebook trên iphone, facebook là gì ?
  4. cunmeo
    06-11-2013 12:33 PM
    cunmeo
    Game dành cho các bạn TEEN nè, tha hồ xả streess sau những giời học và làm việc căng thẳng nhétai game audition, tai game co tuong, tai game gunny, tai ola, trên trang tai game vui mien phi
  5. xinhxinh
    16-10-2013 02:38 PM
    xinhxinh
    Trang tai game ai la trieu phu mien phi rất hay. Nhanh tay tai game ai la trieu phu cho dien thoai iphone, ipad về máy nào. Đừng bỏ lỡ cơ hội tai game angry birds--tai game angry birds mien phi--game angry birds mien phi về máy nha bạn. Và thật là thú vị với ola ken cho dien thoai iphone, ipad--tai ola ken mien phi
    Nhanh tay ta ola ken mien phi về máy ngay hôm nay nha bạn.
  6. chanhtho_1991
    27-09-2012 04:07 PM
    chanhtho_1991
    anh ơi. anh cho em địa chỉ mail để em dễ liên lạc. địa chỉ mail của em là: chanhtho1991@gmail.com
  7. chanhtho_1991
    27-09-2012 04:04 PM
    chanhtho_1991
    chào anh. em la sinh viên năm 2. em đang nguyên cứu về pic16f887.em dang nguyên cứu về phần mền ccs4 viết cho pic, trong đó có 2 ví dụ về hệ thống CAN mà em không biết làm sao mô phỏng để chạy chương trình viết sẵn vì em ko biết gì về CAN hết, anh giúp em vẽ mạch mô phỏng như chương trinh giúp em với. em ko biết những con trong mạch CAN, anh gửi qua mail giúp em với, địa chỉ: chanhtho1991@gmail.com
    /////////////////////////////////////////////////////////////////////////
    //// EX_CAN_CCS_A.C ////
    //// ////
    //// Example of CCS's CAN library, using the PIC18Fxx8. This ////
    //// example was tested with and written for the CCS CAN Prototype ////
    //// board. ////
    //// ////
    //// The CCS CAN Prototype board has four CAN nodes that communicate ////
    //// to each other. Node A is the 18F458 with it's internal CAN ////
    //// peripheral, Node B is a PIC16F87x connected to an external ////
    //// MCP2510 CAN peripheral, and Node C and Node D are both MCP250xx ////
    //// stand-alone CAN I/O expanders. This example is the firmware ////
    //// for Node A. ////
    //// ////
    //// Every two seconds this firmware sends out a command to node B ////
    //// to change it's leds (CAN ID 0x202) ////
    //// ////
    //// Upon change of the A/D reading, a value of 0-9 is sent to ////
    //// Node D which is displayed on the 8-seg LCD (CAN ID 0x400) ////
    //// ////
    //// Pressing the Node A button sends a request to Node B (CAN ID ////
    //// 0x201) for Node B's A/D reading, which Node B will respond ////
    //// with a CAN message with it's A/D reading (with CAN ID 0x201). ////
    //// Also, pressing the Node A button will change the LEDs on Node ////
    //// C (CAN ID 0x300) ////
    //// ////
    //// Pressing Node C's buttons will cause Node A's buttons to change ////
    //// (Node C transmits button changes with CAN ID 0x303) ////
    //// ////
    //// Using a serial port, you can examine all the CAN traffic as ////
    //// seen by the 18xxx8. ////
    //// ////
    //// For more documentation on the CCS CAN library, see can-18xxx8.c ////
    //// ////
    //// Jumpers: ////
    //// PCH pin C7 to RS232 RX, pin C6 to RS232 TX ////
    //// ////
    //// This example will work with the PCH compiler. ////
    /////////////////////////////////////////////////////////////////////////
    //// ////
    //// Baud rate settings to use to connect to the CCS CAN Prototype ////
    //// board at 20Mhz: ////
    //// ////
    //// Baud Rate Prescalar: 4 ////
    //// Propagation Segment: 3xTq ////
    //// Phase Segment 1: 6xTq ////
    //// Phase Segment 2: 6xTq ////
    //// Synchronized Jump Width: 1xTq ////
    //// Sample Rate: 1x ////
    //// Wakeup Filter: Off ////
    //// ////
    /////////////////////////////////////////////////////////////////////////
    //// ////
    //// Node C and D are seperate stand-alone MCP250xx CAN I/O ////
    //// expanders. The CCS CAN Prototype board has these chips already ////
    //// programmed correctly. However, if you wish to program your own ////
    //// to work with this example, then use the provided .HEX files ////
    //// a programmer capable of programming these chips. Or, make a ////
    //// a new HEX file with these properties: ////
    //// ////
    //// NODE C: Set RX ID mask and buffers to receive ID 0x3**. (The ** ////
    //// means make the least signifcant 8bits no-care in the mask). ////
    //// Set TX1 buffer to ID 0x301, TX2 buffer to ID 0x302, TX3 buffer ////
    //// to ID 0x303. Set GP0 to analog (and enable the A/D). Set GP1, ////
    //// GP2 and GP3 to OUTPUT. Set GP4, GP5 and GP6 as INPUT with edge ////
    //// trigger enable. Leave OPTREG2 clear, disable PWM1 and PWM2, ////
    //// and disable scheduled transmission. Also, see the baud rate ////
    //// settings above. ////
    //// ////
    //// NODE D: Set RX ID mask and buffers to receive ID 0x4**. (The ** ////
    //// means make the least signifcant 8bits no-care in the mask). ////
    //// Set TX1 buffer to ID 0x401, TX2 buffer to ID 0x402, TX3 buffer ////
    //// to ID 0x403. Configure all ports as OUTPUT. Leave OPTREG2 ////
    //// clear, disable PWM1 and PWM2, and disable scheduled ////
    //// transmission. Also, see the baud rate settings above. ////
    //// ////
    /////////////////////////////////////////////////////////////////////////
    //// (C) Copyright 1996,2003 Custom Computer Services ////
    //// This source code may only be used by licensed users of the CCS ////
    //// C compiler. This source code may only be distributed to other ////
    //// licensed users of the CCS C compiler. No other use, ////
    //// reproduction or distribution is permitted without written ////
    //// permission. Derivative programs created using this software ////
    //// in object code form are not restricted in any way. ////
    /////////////////////////////////////////////////////////////////////////

    #include <18F458.h>
    #fuses HS,NOPROTECT,NOLVP,NOWDT
    #use delay(clock=20000000)
    #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

    #define CAN_DO_DEBUG TRUE

    #include <can-18xxx8.c>

    #define PIN_LED1 PIN_A5
    #define PIN_LED2 PIN_B5
    #define PIN_LED3 PIN_B4

    #define LED1_HIGH output_low(PIN_LED1)
    #define LED1_LOW output_high(PIN_LED1)
    #define LED2_HIGH output_low(PIN_LED2)
    #define LED2_LOW output_high(PIN_LED2)
    #define LED3_HIGH output_low(PIN_LED3)
    #define LED3_LOW output_high(PIN_LED3)

    #define BUTTON PIN_A4

    #define BUTTON_PRESSED !input(BUTTON)

    int16 ms;

    const char lcd_seg[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x1 0}; //0 for on, 1 for off

    #int_timer2
    void isr_timer2(void) {
    ms++; //keep a running timer that increments every milli-second
    }

    #define ASK_FOR_ID_AD_B 0x201 //ask for AD info from CAN port B
    #define SET_LED_ID_B 0x202 //set LEDs for CAN port B
    #define RESPOND_TO_LED_C_ID 0x303
    #define WRITE_REGISTER_C_ID 0x300
    #define WRITE_REGISTER_D_ID 0x400

    void main() {
    int b_leds=0;
    int c_leds=1;
    int a_leds=0;
    struct rx_stat rxstat;
    int32 rx_id;
    int buffer[8];
    int rx_len;

    int last_lcd_output=0xFF;
    int i,curr_lcd_output;

    setup_port_a(RA0_ANALOG);
    setup_adc(ADC_CLOCK_INTERNAL);
    set_adc_channel(0);

    for(i=0;i<8;i++) {
    buffer[i]=0;
    }

    LED1_HIGH;
    LED2_HIGH;
    LED3_HIGH;
    printf("\r\n\r\nCCS CAN EXAMPLE\r\n");
    delay_ms(1000);
    LED1_LOW;
    LED2_LOW;
    LED3_LOW;

    setup_timer_2(T2_DIV_BY_4,79,16); //setup up timer2 to interrupt every 1ms if using 20Mhz clock

    can_init();

    enable_interrupts(INT_TIMER2);
    enable_interrupts(GLOBAL);

    printf("\r\nRunning...");

    while(TRUE)
    {
    if ( can_kbhit() )
    {
    printf("\r\n");
    if(can_getd(rx_id, &buffer[0], rx_len, rxstat)) {
    if (rx_id == ASK_FOR_ID_AD_B) {
    printf("Channel B AD: %X\r\n",buffer[0]);
    }
    else if (rx_id == RESPOND_TO_LED_C_ID) { //node C is an mcp250x0 which sends out a message upon edge detection on IO
    printf("Chaning LEDs\r\n"); //in_data[0]=iointfl, in_data[1]=gpio
    a_leds=~(buffer[1]);
    if (bit_test(a_leds,4)) {LED1_HIGH;} else {LED1_LOW;}
    if (bit_test(a_leds,5)) {LED2_HIGH;} else {LED2_LOW;}
    if (bit_test(a_leds,6)) {LED3_HIGH;} else {LED3_LOW;}
    }
    }
    }

    if ( can_tbe() && (ms > 2000)) //every two seconds, send new data if transmit buffer is empty
    {
    ms=0;

    //change leds on port b
    printf("\r\n\r\nSet LEDs on Port B to %U",b_leds);
    can_putd(SET_LED_ID_B, &b_leds, 1, 1, 1, 0);
    b_leds++;
    if (b_leds > 7) {b_leds=0;}
    }

    if (BUTTON_PRESSED) {
    while (BUTTON_PRESSED) {}
    delay_ms(200);

    //ask for AD on port B
    printf("\r\n\r\nAsking for A/D reading on Port B...");
    can_putd(ASK_FOR_ID_AD_B, 0, 1, 1, 1, 1);

    //change LEDs on port C
    buffer[0]=0x1E; //addr of gplat on 25050
    buffer[1]=0x0E; //mask
    buffer[2]=~(c_leds << 1); //new gplat values
    printf("\r\nIncrementing LED on Port C");
    can_putd(WRITE_REGISTER_C_ID, &buffer[0], 3, 1, 1, 0);
    c_leds++;
    if (c_leds > 7) {c_leds=0;}
    }

    //change lcd segment on port d
    i=read_adc();
    curr_lcd_output=i/26; //scale to 0-9
    if (curr_lcd_output != last_lcd_output) {
    last_lcd_output=curr_lcd_output;
    printf("\r\nChanging 8-seg LCD on D to current A/D reading (%X, %X)",i,curr_lcd_output);
    buffer[0]=0x1E; //addr of gplat
    buffer[1]=0x7F; //mask
    buffer[2]=lcd_seg[curr_lcd_output]; //new gplat values
    can_putd(WRITE_REGISTER_D_ID, &buffer[0], 3, 1, 1, 0);
    }
    }
    }

About Me

  • Signature
    mạch nạp - kit phát triển - linh kiện điện tử www.PNLabvn.com

Statistics

Tổng số bai
Visitor Messages
General Information
  • Lần cuối: 31-08-2011 10:57 AM
  • Tham gia ngày: 02-07-2007
  • Ðã giới thiệu: 1

Múi giờ GMT. Hiện tại là 11:22 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