Haberler:

Foruma Resim Yükleme ve Boyut Sınırlaması ( ! )  https://bit.ly/2GMFb8H

Ana Menü

PIC18F452 VE Grafik LCD

Başlatan kostebek, 11 Şubat 2009, 22:17:05

kostebek

Merhaba arkadaşlar. Birtane 18f452 pic ve bir tane KS108 uyumlu grafik lcd ekranım var 128x64 lük.

Yahu simulasyonda çalışan kod normal devrede çalışmıyor. Sanırım birşeyler yanlış. PIC iç E portuna led bağladım istediğim gibi onlar yanıyor . PIC çalışıyor yani. ama LCD de hiçbişey yok.

KOD BU:

#include <18F452.h>

#use delay(clock=20000000)
//#define FAST_GLCD    // Try commenting this out to see the differences
#define GLCD_WIDTH   128

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HS                       //High speed Osc (> 4mhz)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOOSCSEN                 //Oscillator switching is disabled, main oscillator is source
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV27                   //Brownout reset at 2.7V
#FUSES NOPUT                    //No Power Up Timer
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOCPD                    //No EE protection
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads 
#FUSES CCP2B3 

#include "HDM64GS12.c"
#include "graphics.c"
#include "math.h"

void displayVoltage(int adc) {
   char voltage[9];
   sprintf(voltage, "%f", (float)adc * .01960784); // Converts adc to text
   voltage[4] = '\0';                              // Limit shown digits to 3
   glcd_rect(45, 18, 69, 25, YES, OFF);            // Clear the old voltage
   glcd_text57(45, 18, voltage, 1, ON);            // Write the new voltage
}

void main() {
   int1  warn = FALSE;
   int8  adc = 0, adc_old = 0;
   char  voltText[] = "Volts", warning[] = "Warning";
   float theta = 0;

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

   glcd_init(ON);                               // Must initialize the LCD
   glcd_rect(1, 5, 126, 15, NO, ON);            // Outline the bar
   glcd_text57(70, 18, voltText, 1, ON);        // Display "Volts"
   glcd_circle(30, 47, 10, NO, ON);             // Draw the clock circle

   for(;;) {
   
      output_e(0x02);
      
      adc = read_adc();                         // Read a value from the ADC
      displayVoltage(adc);                      // Display the reading
      adc = (adc > 249) ? 249 : adc;            // Keep the value 249 or less

      if(adc != adc_old) {
         glcd_rect(adc/2+1, 6, adc_old/2+1, 14, YES, OFF);  // Clears the old bar
         glcd_rect(1, 6, adc/2+1, 14, YES, ON);             // Draws a new bar
         adc_old = adc;                                     // Set old value to new

         if(adc > 200 && !warn) {                  // Check if over 4 volts
            glcd_rect(45, 38, 124, 55, YES, ON);   // Draw a filled black rectangle
            glcd_text57(47, 40, warning, 2, OFF);  // Write "Warning" on the LCD
            warn = TRUE; }
         else if(adc <=200 && warn) {
            glcd_rect(45, 37, 125, 55, YES, OFF);  // Draw a filled white rectangle
            warn = FALSE; }
      }

      // The following 3 lines make the clock hand spin around
      glcd_line(30, 47, 30+(int)(8*sin(theta)+.5), 47-(int)(8*cos(theta)+.5), OFF);
      theta = (theta > 5.9) ? 0 : (theta += .3);
      glcd_line(30, 47, 30+(int)(8*sin(theta)+.5), 47-(int)(8*cos(theta)+.5), ON);

      #ifdef FAST_GLCD
      glcd_update();
      #else
      delay_ms(100);    // Reduces flicker by allowing pixels to be on
                        // much longer than off
      #endif
   }
}


LCD nin herşeyi eyvallah ama VEE ye ne bağlayacağımı çözemedim bir türlü.

////  *18: Negative voltage is also connected to the 20k Ohm POT

böyle demiş. Diğer bağlantılar okey. Bunu direk - bağlayıncada da bişey olmuyor. POT a bağlayın demiş de nasıl bağlıcaz.

Teşekkürler

ahmet2004


kostebek

ahmet bey :)

Size ne desem azdır valla çalıştı ;)


Çok teşekkür ederim


fractal

bendekide glcd çalışmıyor.proteusta süper çalışıyor.pin ayarlarımda şöyle acabu bu pinlerdedemi bir sorun var...


#ifndef GLCD_CS1
#define GLCD_CS1     PIN_C2   // Chip Selection 1
#endif

#ifndef GLCD_CS2
#define GLCD_CS2     PIN_C3   // Chip Selection 2
#endif

#ifndef GLCD_DI
#define GLCD_DI      PIN_E0   // Data or Instruction input
#endif

#ifndef GLCD_RW
#define GLCD_RW      PIN_E1   // Read/Write
#endif

#ifndef GLCD_E
#define GLCD_E       PIN_E2   // Enable
#endif

#ifndef GLCD_RST
#define GLCD_RST     PIN_C0   // Reset
Restantum cogniscutur Quantum deligutur

berkay_yalan

hocam sema ve kodlarınızı paylasmanız mumkunmudur?

kostebek

Elbette mümkün. Zaten şuana kadar yaptığım her bişeyi neredeyse bu siteyle yaptım. Paylaşmak güzel şey :)







Bu da link:
http://rapidshare.com/files/197332160/GLCD_ORNEK.zip

http://rapidshare.com/files/197098911/GLCD_ORNEK.zip.html

Dosya içerisinde

*Proteus Simulasyonu

*CCS C kodu

*BMP resim

*BMP2ASM programı

mevcut

fractal

ben data kablolarını ters bağlamışım.teşekkürler.negatif karekter basma nasıldı?ccs c kullanıyorum.
Restantum cogniscutur Quantum deligutur

kostebek

glcd_text57(47, 40, warning, 1, OFF);


Buradaki OFF ters renk basar ;)

fractal

anlamadım.olmadı ekranda hiç bişey göstermiyor.
Restantum cogniscutur Quantum deligutur

kostebek

Şöyle

yazi[] = "SelamAleykum";
glcd_text57(47, 40, yazi, 1, OFF);

fractal

aynısını yapıyorum ama ekran da hiç bişey gözükmüyor.proteustada simülasyonda bişey yok.glc init on mu off yapıyorum.onda bi değişiklik oluyormu?

yukardaki resimde ekranda uyarı gözüküyorya onun gibi yapmak istiyorum.benim ekarn siyah beyaz.tüm ekran yazı hariç siyah yazı beyaz olması lazım ama olmuyor...
Restantum cogniscutur Quantum deligutur

fractal

tamam sorunu cözdüm ilk önce bar cizip onun içine yazının negatifini basmak gerekiyor.teşekkürler..
Restantum cogniscutur Quantum deligutur

kostebek

Aynen size bahsettikten sonra bende aynı şeyi düşündüm  ve baktım evet dediğiniz gibi oluyor


fractal

kostebek glcd de nasıl nasıl imlec yapıyorsun.?birde bu değişkenleri sprint f yapıp sonra gösterme işi bu tür şeyler program hafızasını cok yiyor.bu konuda ne yapılabilir?
Restantum cogniscutur Quantum deligutur

teknikelektronikci

köstebek hocam

rapid iptal olmuş dosyayi bir zahmet picproje.4shared e atabilirmisiniz ?
Ey Türk istikbalinin evlâdı! İşte, bu ahval ve şerâit içinde dahi, vazifen; Türk İstiklâl ve Cumhuriyetini kurtarmaktır! Muhtaç olduğun kudret, damarlarındaki asil kanda mevcuttur!