Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - septhai

#9
ในรถที่เป็น 12โวลต์หรือ24โวลต์ แปลงมาเป็น 5โวลต์ ควรเลือกใช้แบบไหนดีกว่ากันครับ
1.ระหว่าง แหล่งจ่ายไปในรถยนต์ สวิชชิ่ง(LM2576-5.0) กับ เรกูเรต(ตระกูล7805)
2.เดิมผมใช้ LM2576-5.0 อยู่ ถ้าจะเปลี่ยนมาเป็น BP5277-50(http://www.es.co.th/detail.asp?Prod=017601599) มันจะมีข้อดีข้อเสียต่างกันอย่างไรบ้างครับ(วงจรผมกินไฟประมาณ 0.1Amp)
3.ถ้าใช้ BP5277-50 ต้องต่อ C ที่ Vinและ Vout เพิ่มด้วยไหมครับ
ขอบคุณครับ
#11
พอดีดูราคาที่จีนมันถูกมากครับ
ATmega128 ที่จีน(aliexpress) กับที่ ES มันเหมือนกันไหมครับ
ซื้อมาจากจีนแล้วมันจะมีปัญหาไหมครับ
เคยซื้อ LM2575 มาใช้งานได้แต่ไม่ทนเลยเหมือน Spec ไม่ได้ เลยกลัวมันเป็นของปลอมหรือหลุด Spec ครับ
ขอบคุณครับ
#12
ได้แล้วครับผมเพิ่ม อินเตอร์รัป ไทม์เมอร์ ลงไปครับ ลืมบอกไปว่าผมเปลี่ยนมาใช้ Mega64 นะครับ
ขอบคุณพี่ RoLRoR และ moonoi มากครับ :)


ISR (TIMER0_OVF_vect)
{
   if (inDex++ > 10)
   {
      display_led (1);
      inDex = 0;
   }   
}
//------------------------------------------------------------------------//
void init_timmer0 (void)
{
   TCCR0 = (1 << CS02) | (0 << CS01) | (1 << CS00);
}
//------------------------------------------------------------------------//



// อันนี้เพิ่มในMain โปรแกรมครับ
init_timmer0 ();
TIMSK = (1 << TOIE0);
sei ();
#13
รบกวนสอบถามโปรแกรม 7Segment ครับ
คือพอมันแสดงผมได้ตามปรกติแต่7Segment มันจะกระพริบ ถ้าหากเพิ่ม delay_ms(200) หรือโปรแกรมอื่นๆลงไปครับ พอจะมีคำแนะนำไหมครับ





/******************************************************************************
* Workfile    : LAB_7Segments_02.c
* Purpose     : 7-Segments LED
* Copyright   : appsofttech co.,ltd.
* Author      : Prajin Palangsantikul
* Email       : prajin@appsofttech.com
* Compiler    : AVR Studio/WINAVR
* Target      : ATmega16
* Other Files :
* Ref         :
******************************************************************************/

/****************************************************************** Includes */
#include <avr/io.h>         // AVR device-specific IO definitions
#include <compat/deprecated.h>  // Deprecated items
#include <stdio.h>          // Standard Input/Output

#define F_CPU 16000000UL         // 8 MHz
#include <util/delay.h>         // header file implement simple delay loops


/********************************************************************** Note */
// PORT Px connect to 7-Segments
// PORTA -> 7-Segments
// PORTB -> digit of 7-Segments (PB0-PB4)

#define DSP_DATA_POUT       PORTA       // DSPx enable (DIGIT PORT)
#define DSP_DATA_DDR      DDRA

#define LED_DATA_POUT      PORTF         // LED Display (DATA_PORT)
#define LED_DATA_DDR      DDRF


/********************************************************** Global variables */
const unsigned char num_led[17] = {
               0xC0, 0xF9, 0xA4, 0xB0, 0x99,  //0,1,2,3,4
                    0x92, 0x82, 0xF8, 0x80, 0x90,  //5,6,7,8,9
                    0x77, 0x7C, 0x39, 0x5E, 0x79,  //A,b,C,d,E
                    0x71, 0x80                     //F,.
                    };               

unsigned char num[4];      // buffer number led

      
/***************************************************************** delay_ms */
void delay_ms(uint16_t i)
{
    for (;i > 0; i--)
        _delay_ms(1);
}

/*************************************************************** display_led */
void display_led(unsigned int dly)
{
    int i;

    for (i=0;i<dly;i++) {
        DSP_DATA_POUT = 0x07;           // 0b0111 (DSP1 enable active)
        LED_DATA_POUT = ~(num_led[num[0]]);         
        _delay_ms(2);

      DSP_DATA_POUT = 0x0B;           // 0b1011 (DSP2 enable active)
        LED_DATA_POUT = ~(num_led[num[1]]);
        _delay_ms(2);

      DSP_DATA_POUT = 0x0D;           // 0b1101 (DSP3 enable active)
        LED_DATA_POUT = ~(num_led[num[2]]);
        _delay_ms(2);

      DSP_DATA_POUT = 0x0E;           // 0b1110 (DSP4 enable active)
        LED_DATA_POUT = ~(num_led[num[3]]);
        _delay_ms(2);
    }
}

/************************************************************ Main Functions */
int main(void)
{       
   unsigned int count=0;

    LED_DATA_DDR = 0xFF;      // PORTB All output
    DSP_DATA_DDR = 0x0F;       // PORT PA0-PA3 Output   

   num[3] = 0;
   num[2] = 0;
   num[1] = 0;
   num[0] = 0;

    while (1) {
                              
      display_led(100);

        if (count++ >= 9999)
            count = 0;

       num[3] = (count/1000);
       num[2] = (count%1000)/100;
       num[1] = ((count%1000)%100)/10;
        num[0] = ((count%1000)%100)%10;
      
      _delay_ms(200);
    }

   return 0;
}
#14
Quote from: JENG on August 27, 2015, 01:41:08 PM
1.ทำได้คับ แต่เปลืองทรัพยากรณ์โดยใช่เหตุ
2.ทำได้คับ ดีกว่าข้อ1 จะ pwm โดย interrupt หรือ h/w pwm ได้ทั้งนั้น
ตัวอย่างเรื่อง pwm มีมากมายใน google คับ
ขอบคุณครับ จะลองตามขัอสอง หากไม่ได้ก็คงต้องตามขัอหนึ่งครับ
#15


รบกวนสอบถามเรื่อง การปรับความสว่างจอ LCD โดย Atmega64
ผมใช้ Winavr ครับ
1. ผมต้องการให้สามารถปรับความสว่างของจอ LCD เป็น 2 Step โดย Active Backlight1 เป็นระดับหนึ่ง Active Backlight2 เป็นอีกระดับหนึ่ง โดยสลับกับ ON/OFF มันทำได้ไหมครับ ถ้าได้มันจะเกิดผลเสียตามมาทีหลังหรือไม่ครับ เช่น จะทำให้ Port MCU เสียไหมครับ เป็นต้น

2. ถ้าข้อหนึ่งไม่ได้หรือไม่ควรใช้ ทราบมาว่าอาจต้องใช้ PWM ไม่ทราบว่าต้องใช้ขาไหนครับ และพอจะมีตัวอย่าง โปรแกรมบ้างไหมครับ

ขอบคุณมากครับ
#16
ขอบคุณมากครับ ทุกๆคำตอบ