Ir ao conteúdo
  • Cadastre-se

Gilberto Gozzi

Membro Júnior
  • Posts

    10
  • Cadastrado em

  • Última visita

Reputação

0
  1. olá Meus caros, antecipadamente obrigado pelas respostas, o circuito é o basico, com a diferença que nesse display ele requer uma tensão de -5V no VEE , para drivar (desculpe pelo drivar) o lcd , quanto ao software usei o exemplo da biblioteca do KS108 do arduino : Transcrita aqui e apenas adaptada para os o arduino Mega2560 /* * GLCDexample * * Basic test code for the Arduino KS0108 GLCD library. * This code exercises a range of graphic functions supported * by the library and is an example of its use. * It also gives an indication of performance, showing the * number of frames drawn per second. */ #include <ks0108.h> #include "Arial14.h" // proportional font #include "SystemFont5x7.h" // system font #include "ArduinoIcon.h" // bitmap unsigned long startMillis; unsigned int loops = 0; unsigned int iter = 0; void setup(){ delay(500); // allow time for LCD to reset GLCD.Init(NON_INVERTED); // initialise the library, non inverted writes pixels onto a clear screen GLCD.ClearScreen(); GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK); //draw the bitmap at the given x,y position GLCD.SelectFont(System5x7); // switch to fixed width system font countdown(5); GLCD.ClearScreen(); introScreen(); // show some intro stuff GLCD.ClearScreen(); } void introScreen(){ GLCD.SelectFont(Arial_14); // you can also make your own fonts, see playground for details GLCD.GotoXY(20, 2); GLCD.Puts("GLCD version "); GLCD.PrintNumber(GLCD_VERSION); GLCD.DrawRoundRect(16,0,99,18, 5, BLACK); // rounded rectangle around text area GLCD.SelectFont(System5x7); // switch to fixed width system font showCharacters(); countdown(5); } void showCharacters(){ byte line = 3; // start on the fourth line for(byte c = 32; c <=127; c++){ if( (c-32) % 20 == 0) GLCD.CursorTo(1,line++); // CursorTo is used for fixed width system font GLCD.PutChar(c); } } void drawSpinner(byte pos, byte x, byte y) { // this draws an object that appears to spin switch(pos % 8) { case 0 : GLCD.DrawLine( x, y-8, x, y+8, BLACK); break; case 1 : GLCD.DrawLine( x+3, y-7, x-3, y+7, BLACK); break; case 2 : GLCD.DrawLine( x+6, y-6, x-6, y+6, BLACK); break; case 3 : GLCD.DrawLine( x+7, y-3, x-7, y+3, BLACK); break; case 4 : GLCD.DrawLine( x+8, y, x-8, y, BLACK); break; case 5 : GLCD.DrawLine( x+7, y+3, x-7, y-3, BLACK); break; case 6 : GLCD.DrawLine( x+6, y+6, x-6, y-6, BLACK); break; case 7 : GLCD.DrawLine( x+3, y+7, x-3, y-7, BLACK); break; } } void countdown(int count){ while(count--){ // do countdown GLCD.CursorTo(0,1); // first column, second row (offset is from 0) GLCD.PutChar(count + '0'); delay(1000); } } void loop(){ // run over and over again iter = 0; startMillis = millis(); while( millis() - startMillis < 1000){ // loop for one second GLCD.DrawRect(0, 0, 64, 61, BLACK); // rectangle in left side of screen GLCD.DrawRoundRect(68, 0, 58, 61, 5, BLACK); // rounded rectangle around text area for(int i=0; i < 62; i += 4) GLCD.DrawLine(1,1,63,i, BLACK); // draw lines from upper left down right side of rectangle GLCD.DrawCircle(32,31,30,BLACK); // draw circle centered in the left side of screen GLCD.FillRect(92,40,16,16, WHITE); // clear previous spinner position drawSpinner(loops++,100,48); // draw new spinner position //GLCD.FillRect(24,txtLINE3,14,14, WHITE); // clear text area that will be drawn below GLCD.CursorTo(5,5); // locate curser for printing text GLCD.PrintNumber(++iter); // print current iteration at the current cursor position } // display number of iterations in one second GLCD.ClearScreen(); // clear the screen GLCD.CursorTo(14,2); // positon cursor GLCD.Puts("FPS= "); // print a text string GLCD.PrintNumber(iter); // print a number } #******************************************************************************************************************************************** #------------------------------------------------------------------------------------------------------------------------------------------------------------------ KS108.h : (arquivo da library ks108): /* ks0108_Arduino.h - Arduino library support for ks0108 and compatable graphic LCDs Copyright (c)2008 Michael Margolis All right reserved This is the configuration file for mapping Arduino (ATmega168) pins to the ks0108 Graphics LCD library */ #ifndef KS0108_CONFIG_H #define KS0108_CONFIG_H /*********************************************************/ /* Configuration for assigning LCD bits to Arduino Pins */ /*********************************************************/ /* Arduino pins used for Commands - these must be within the range of 30-37 */ #define CSEL1 33 // CS1 Bit // swap pin assignments with CSEL2 if left/right image is reversed #define CSEL2 34 // CS2 Bit #define R_W 35 // R/W Bit #define D_I 36 // D/I Bit #define EN 37 // EN Bit #define LCD_CMD_PORT PORTC // Command Output Register for pins 30-37 /* This version uses pins 22-29 for LCD Data */ /*******************************************************/ /* end of Arduino configuration */ /*******************************************************/ // these macros map pins to ports using the defines above // the following should not be changed unless you really know what your doing #define LCD_DATA_LOW_NBL A // port for low nibble: A=pins 22-25 #define LCD_DATA_HIGH_NBL A // port for high nibble: A=pins 26-29 // macros to fast write data to pins 30 - 37 #define fastWriteHigh(_pin) (PORTC |= 1 << ((7-(_pin -30)) & 0x07)) #define fastWriteLow(_pin) (PORTC &= ~(1 << ((7-(_pin -30)) & 0x07))) #endif na montagem do hardware não houve erro, pois usei um outro display de outro fabricante de 128x64 e funcionou corretamente, não sei se é incompatibilidade da biblioteca KS 108 ou se está queimado mesmo, não achei na internet ninguém que tivesse usado este modelo de display, apesar de ter sido amplamente vendido onde comprei na DABI da sta efigenia e até mesmo no mercado livre , pelo baixo preço da época
  2. Caros amigos , comprei esse lcd acima , nunca consegui faze-lo funcionar, não sei se por algum descuido queimei , por sinal os 2 que comprei , ou se as bibliotecas que usei com arduino não funcionan com este modelo, por favor , se alguem já escreveu qualquer codigo que tenha funcionado com esse display , tanto com arduino, pic , atmega , ou qualquer microcontrolador, o qual possa me enviar(ou indicar) um library e um codigo que funcione apenas para testar se ainda estão bons ou se jogo no lixo, ficarei muito grato, P.S.: que realmente alguem tenha testado com esse modelo e funconado, Grato
  3. Como usar attachInterrupt dentro de uma library , passando "interruptPin" e "função" dentro da libray , alterando uma variavel global ?
  4. Caros amigos , algum tempo atrás comprei está Bos... de display, até hoje não consegui faze-lo funcionar, a propósito , comprei dois , nenhum dos dois funcionam , já tentei com varias libraries e nada, não consigo saber se o display está ruim ou se são os tempos das libraries , ou comandos incompativeis, caso algum amigo aqui do forum já tenha usado esse display , ou em arduino ou em pic , ou qualquer outra coisa , e que tenha alguma rotina que funcione com esse display e possa me fornecer, para ver se jogo fora o display , ou nao, ficaria extremamente grato. Saúdações a todos
  5. Olá pessoal , deixe me palpitar quanto a essa questão, Gostaria de compartilhar com vocês a minha ultima experiencia: Fiquei louco com o MikroC, apesar de que estava bem acostumado com ele, comecei a ter problemas após um certo tamanho de programa, ai solicitei ajuda aqui no forum e o Luiz G. Barrio me ajudou dando uma dica da deficiência do mikroc em gerenciar o Bit de IRP acontece apenas na serie 16F, dai mudei para o PIC18F452 , pois bem só adiei a solução, mais 1/2 duzia de linhas e pau de novo , até pensei em mudar para atmega segundo sugestão do meu amigo aphawk , porém como já havia escrito 95 % do código achei mais fácil para esse meu projeto , mudar de compilador, após sofrer um pouco para aprender as diferenças entre um C e outro, com pouquíssimas conversões de sixtax portei meu programa para o CCS , fiquei plenamente satisfeito , acabaram se os travamentos . porém para os próximos projetos estou considerando a possibilidade de mudar para atmega apesar da minha dificuldade de ter que re-aprender o C para atmega e aprender o compilador do mesmo. Abraços (espero ter colaborado)
  6. Obrigado Luiz Gustavo, você me ajudou bastante, fico te devendo uma,,,vou adaptar pro pic 18F452 e recompilar , vamos ver no que da !!! Grande abraço Paulão, qualquer hora eu ligo e apareço, se você se lembra quando nos encontramos pela ultima vez , você me deu uma plaquinha do programador pra avr, porém não montei pois você ficou de me mandar o esquema a lista de materiais e o principal o "Firmware" prá eun gravar no avr !!! rsrrsrsrsrsr, eu ainda sou muito relutante tanto em programar em basic com com os avrs pois se me lembro bem são uma evolução da familia MSC51 da qual apesar de ainda ter alguns 8051,8749 etc aqui em casa (gosto de guardar velharias) , não tenho boas recordações daquele assembler maldito (KKKKK), aqui ainda tenho também alguns Z80 CPU, Z80 PIO , Z80 CTC, Z80 CIO, Z80 SIO-II, acho que vou acabar por montar um hardware com eles e voltar ao velho e bom : LD a,030 LD(HL),a EXX HL,DE heheh, lembra disso ???, um abraço
  7. Fala ai..... Paulão , beleza, com esta voce ????, é que saúdades do tk-82C, realmente , bons tempos aqueles em que não tinhamoa windows prá dar pau KKKKKK, manda um beijão prá Sandrinha, fala prá ela que qualquer hora eu ligo, é rapaz to quase me arrependendo de ter largado o asm viu...., como aqui não se ode meter a lenha nos fabricantes de compiladores, vou até ficar quieto !!!, Tô aguardando a resposta do Gustavo , se o problema é só com o PIC16 ou se eu mudar prô PIC18 vou ter o mesmo problema , ou se mudo de compilador,, já tentei usar outro compilador o CCS, o XC8 , mais cada um a sintax de acesso aos sfr são diferentes , a documentação é muito longa e não tão bem organizada prá quem tá começando no C como eu..., pelo menos esse é meu primeiro programinha em C, e não pisca só LED rsrsrsrsrrsrsr, vamos ver no que vai dar , um grande abraço..
  8. @LuizGBarrio ,, ajudou muito, meu programa esta ocupando após a compilação cerca de 25% da rom , provavélmente no fim do primeiro banco, o meu código não é grande , mas não tenho muita experiência em C, estou usando o PIC 16F887, vou copiar meu código abaixo para você ver que não é muito grande (pode até ser mau escrito KKK): , você saberia me dizer se esse problema ocorre somento com os P16 , se eu mudar pro PIC18F452 vou ter o mesmo problema ???, e se eu tentar mudar de compilador ???, qual outro você recomendaria ??? Um Abraço, Grato // Variaveis Rotary Encoder #################################################### static unsigned int QUAD1A, QUAD1A_OLD, QUAD1A_NEW, QUAD1B, QUAD1B_OLD, QUAD1B_NEW, QUAD1C; signed int count; unsigned char flag; PortBreset; // Variaveis Interrupção UART ################################################## static short rxflag=0 ; char rxchar; // Variable for storing the data from UART and array counter unsigned char rxarray[20]; // array to store the received charaters static unsigned char command[6] ; static short l ; int res ; void interrupt() { //#### Rotary encoder INTERRUPT ############################################### if(INTCON.RBIF) PortBreset = PORTB; //dummy read of PORTB to reset the mismatch condition { //if PortB change interrupt QUAD1A = PORTB.F1; // QUAD1B = PORTB.F2; // QUAD1C = PORTB.F0; QUAD1A_NEW = QUAD1A; QUAD1B_NEW = QUAD1B; if (QUAD1A_NEW + QUAD1B_NEW == 2) flag = 1; if ((flag == 1) & (QUAD1A_NEW + QUAD1B_NEW == 1)) { QUAD1A_OLD = QUAD1A_NEW; QUAD1B_OLD = QUAD1B_NEW; flag = 2; } if ((flag == 2) & (QUAD1A_NEW + QUAD1B_NEW == 0)) { if (QUAD1B_OLD == 1) {count++; flag = 3;} if (QUAD1A_OLD == 1) {count--; flag = 3;} } //###### End Encoder ########################################################## } INTCON.RBIF = 0; // clear RB flag INTCON.RBIE = 1; // enable on change interrupts //### END Rotary Encoder routine################################################ //##### UART Interrupt routine ############################################### if (PIR1.RCIF==1) { // test the interrupt for uart rx PIE1.RCIE = 0; //disable interrupt. rxchar = Uart1_Read(); rxarray[l] = rxchar; if (l >= 7) { l=0; rxflag=0; goto ret; } else if (rxarray[l] == 0x0d) { l++ ; rxarray[l]=00; rxflag = 1; res=strcpy(command,rxarray); goto Ret ; } l++; ret: ; // antes de sair limpar flag da int e re habilitar int PIE1.RCIE = 1; //enable interrupt. } //### End of UART INTERRUPT ################################################ } //### END OF INTERRUPT ROUTINES ############################################## // Lcd pinout settings sbit LCD_RS at RD0_bit; //RC4 sbit LCD_RW at RD1_bit; //RC5 Not defined sbit LCD_EN at RD2_bit; //RC6 sbit LCD_D7 at RD7_bit; sbit LCD_D6 at RD6_bit; sbit LCD_D5 at RD5_bit; sbit LCD_D4 at RD4_bit; // Pin direction sbit LCD_RS_Direction at TRISD0_bit; //TRISC4_bit sbit LCD_RW_Direction at TRISD1_bit; //TRISC5_bit sbit LCD_EN_Direction at TRISD2_bit; //TRISC6_bit sbit LCD_D7_Direction at TRISD7_bit; sbit LCD_D6_Direction at TRISD6_bit; sbit LCD_D5_Direction at TRISD5_bit; sbit LCD_D4_Direction at TRISD4_bit; unsigned char caller_id[] = "PU2TWU" ; //****************************************************************************** unsigned char comprimento_caller_id ; unsigned char x_position ; unsigned int short lcd_colum=20 ; void lcd_print_caller_id() { comprimento_caller_id = strlen(caller_id) ; x_position=lcd_colum-comprimento_caller_id ; x_position=x_position/2 ; x_position++ ; Lcd_Out(1,x_position,caller_id) ; } //############################################################################## unsigned long Vin ; unsigned int grau ; unsigned long temp ; static unsigned int destination ; unsigned int _degree=0 , _go ,x ,n ; static int direction ; unsigned char wsgrau[4] ; unsigned char wsencoder[4] ; unsigned char wsdestination[4] ; unsigned char strgrau[6] ; unsigned char strdestination[6] ; unsigned char strencoder[6] ; unsigned char offset={0x01} ; // mudar para posição fixa unsigned char cpygrau[4] ; unsigned char s_degree[4] ; unsigned char grau_symbol[2]={0xdf,0x00} ; unsigned short result ; unsigned short i=0,j=0,k,zz=0 ; static unsigned char degree_len ; // variaveis para debug //****************************************************************************** void main() { WPUB=0xff ; //OPTION_REG.B7 = 1 ; // pullups portb enable LCD_RW =0 ; TRISA=0x0f ; // ajustar conforme perifericos TRISB=0x07 ; TRISC=0xf9 ; TRISD=0 ; TRISE=0xff; PORTA=0 ; CM1CON0 = 0x00 ; CM2CON0 = 0x00 ; ADCON0 = 0x81; ADCON1 = 0xb0; ; ANSEL = 0x0d ; ANSELH = 0x00; IOCB = 0x07 ; INTCON.RBIF = 0; // Clear RB interrupt flag prior to enable INTCON.RBIE = 1; // enable on change interrupts INTCON.GIE = 1; // enable Global interrupts INTCON.PEIE = 1; PIE1.RCIE = 1; //enable interrupt. PORTC=0; PORTB=0; destination = 180 ; UART1_Init(9600) ; Lcd_Init() ; Lcd_Cmd(_LCD_CURSOR_OFF) ; Lcd_Cmd(_LCD_CLEAR) ; lcd_print_caller_id() ; delay_ms(500) ; count = 180 ; while(1) { Vin=Adc_Read(0) ; ; //*********************************************** temp=((Vin*360)/ 1023) ; grau=temp ; //****************************************************************************** WordToStr(grau,strgrau) ; j=3 ; for(i=5;i>=2;i--) { wsgrau[j]=strgrau ; j-- ; } result=strlen(wsgrau); i=0; while(i<=result) { if (wsgrau==0x20) { wsgrau=0x30 ; } i++ ; } Lcd_Out(2, 1, "POS:") ; x=0 ; while(x<=3) { cpygrau[x]=wsgrau[x]; x++; } Lcd_Out(2,offset+4,wsgrau) ; Lcd_Out(2,offset+7,grau_symbol) ; //Delay_ms(300) ; if (count > 360) { count = 360 ; } if (count < 0) { count = 0; // SET MAX COUNT AND MIN COUNT } WordToStr(destination,strdestination) ; Lcd_out(3,1,"Dest.:") ; j=3 ; for(i=5;i>=2;i--) { wsdestination[j]=strdestination ; j-- ; } lcd_out(3,7,wsdestination) ; Lcd_Out(3,10,grau_symbol) ; Lcd_Out(4, 1,"Local:") ; WordToStr(count,strencoder) ; j=3 ; for(i=5;i>=2;i--) { wsencoder[j]=strencoder ; j-- ; } Lcd_Out(4, 7, wsencoder) ; Lcd_Out(4,10,grau_symbol) ; // ENABLE_INTERRUPTS(global); // ENABLE_INTERRUPTS(INT_TIMER0); // SETUP_TIMER_0(RTCC_INTERNAL | RTCC_DIV_32); if (rxflag==1) { switch (command[0]) { case 'C': Uart1_Write_Text("AZ=") ; if (degree_len==1) { res = strcat(cpygrau, "00"); } if (degree_len==2) { res = strcat(cpygrau, "0"); } Uart1_Write_Text(cpygrau) ; Uart1_Write(0x0d) ; Uart1_Write(0x0a) ; break ; case 'M': j=0 ; i=1 ; while(i<=3) { s_degree[j]=command ; i++ ; j++ ; } s_degree[3]=0x00 ; n=0 ; for(i=0;s_degree>='0' && s_degree <='9';i++) n=10*n+(s_degree - '0') ; destination=n ; break; default: break ; } rxflag=0; l=0; command[0]=0x00; command[1]=0x00; command[2]=0x00; command[3]=0x00; command[4]=0x00; PIE1.RCIE = 1; //enable interrupt. } // if rx_flag if(QUAD1C==0) { destination=count ; } direction=grau; direction=direction - destination ; if((direction<0) && (direction <-4)) { PORTC.F2=1; PORTC.F1=0; } if((direction>0) && (direction > 4)) { PORTC.F1=1; PORTC.F2=0; } if(direction==0) {PORTC.F1=0 ;PORTC.F2=0;} // delay_ms(100); // <<<<<<<<<<<<<<<<<<<<<<<<<<----------------- detectei o problema quando quis acrescentar este delay aqui... } // end while } // Main
  9. Olá, a todos, pessoal estou desesperado, preciso da ajuda de alguém que seja fera em MikroC, pois estou com um problemão, e nem sei por onde achar a solução: escrevi um programa compilei sem erros, gravei , funcionando tudo ok, dai acrescentei uma linha besta como "delay_ms(100);" , dai compilei sem erros, porém o pic começou a resetar sozinho direto, dai descobri que qualquer linha de codigo a mais causava o mesmo problema, depois de uma semana sofrendo descobri que aumentando o nivel de otimização de 4 para 5 parou de resetar com a instrução do delay_ms(100); , porém ainda sim , quando acrescento mais codigo o problema volta a ocorrer, já revisei todo o meu código, e não achei nenhum problema, alguém tem alguma ideia do que possa ser ?? Grato..

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...