-
Search Results
-
Topic: About Proteus print out
I have proteus software but I can’t to print out or save this one
I tried to interface load cell with instrument amp with PIC18F458 and display the result on glcd , i wrote code on mikro c but it is showing errors and i’m unable sort out those errors…please help..will this program work on for proteus simulation ?
Int Digital_Value; Double t; Char table[17]={0,1,2,3,0,4,5,6,0,7,8,9,0,10,0,11,0}; Char txt[4] ; Char volt1[13]; Unsigned float tint,tint1,tint2,tint3,tint4,tint5,tint6,tint7,tint8,tint9; Unsigned float tint10; Unsigned float slope,weight,tavgfloat; // t must be defined as float or int Unsigned char var1, var2, Kp, Kp1,i; Unsigned int tavg,tavg1; Char attempts=0; Void main() { GLCD_Init (&PORTC,0,1,2,3,4,5,&PORTD); Glcd_Set_Font(FontSystem5x8, 5, 8, 32); Glcd_Fill(0); // Clear screen Usart_Init(2400); INTCON = 0; Keypad_init(&PORTB) ; GLCD_Write_Text("RCOEM",1,1,1); GLCD_Write_Text("WEIGHT:",1,11,1); OPTION_REG = 0x80; ADCON1 = 1; // configure AN3 Vref+, and Vref - as Vss TRISA = 0b110110; // 0 means input while (1) { while(!keypad_Read()) { delay_ms(10); for(i=0;i<10;i++) { Digital_Value = ADC_read(0); // get ADC value 8 bit =255 t=2.823*Digital_Value/1023.0; t=(t-0.658)/1.362; // becomes x (weight) tint=t*1000; tint10=tint9; tint9=tint8; tint8=tint7; tint7=tint6; tint6=tint5; tint5=tint4; tint4=tint3; tint3=tint2; tint2=tint1; tint1=tint; delay_us(200); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ if (Usart_Data_Ready()) // If data is received { b = Usart_Read(); // Read the received data Usart_Write(b); // Send data via USART } //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ } tavg=(tint+tint1+tint2+tint3+tint4+tint5+tint6+tint7+tint8+tint9)/10; tavg1=tavg%10; tavg=tavg-tavg1; if (tavg1>=0 && tavg1<=5) tavg1=2; if (tavg1>=6 && tavg1<=9) tavg1=7; tavg=tavg+tavg1; tavgfloat=tavg/1000.0; //#################################################### Weight = tavgfloat; // y = ax + b // ##### eleminate exponential term ################# if(weight<1.0) { weight=weight*1000; if(weight<2.01) {weight=1.001;} floattostr(weight,volt1); volt1[8]='g'; volt1[9]='m'; volt1[10]=' '; } else { floattostr(weight,volt1); volt1[8]='k'; volt1[9]='g'; volt1[10]=' '; } GLCD_Write_Text(volt1,1,21,1); //y,x Delay_ms(500) ; //########################################## } while(!keypad_Read()); //wait for key 1 press Delay_ms(10); //debounce time kp=keypad_Released(); //wait for release var1=kp; //store var1 into kp var1 =table[kp] ; ByteToStr(var1,txt); GLCD_Write_Text(txt,20,30,1); Delay_ms(100); } }Topic: PWM by pic 16F877A
Hey guys,
I am using 16F877A to output PWM, increasing and decreasing it via two push buttons its based on the code used in DC Motor Speed Control using PWM with PIC Microcontroller in MikroC but the problem is that after a certain PWM value the PWM will not decrease and I have also added a switch with instantly makes duty value zero but it also doesn’t work after a certain pwm value and I have tried it on Proteus as well as with leds in real life but they give the same result. Only way it goes low is to keep pressing the UP button then some how it come down to a low value then other two switches start working and I then can switch it pwm off. Don’t know whats wrong.
Here is the code:-
{ adc = ADC_Read(1); // Get 10-bit results of AD conversion rpm_temp = adc * 2; //converting analog value to rpm WordToStr(rpm_temp, speed_out); //converting integer to string to disply on LCD Lcd_Out(2,9,speed_out);//Write speed in 2st row 6th col Delay_ms(100); if (RD0_bit ==0 && duty<250) //if button on RD0 pressed { Delay_ms(100); duty = duty + 10; //increment current_duty PWM1_Set_Duty(duty); //Change the duty cycle } if (RD1_bit ==0 && duty >0) //button on RD1 pressed { Delay_ms(100); duty = duty - 10; //decrement duty PWM1_Set_Duty(duty); } if (RD2_bit ==0 && duty >0) //button on RD2 pressed { Delay_ms(100); duty = 0; //reset duty PWM1_Set_Duty(duty); }I want to display data read from UART on 16×2 LCD with MikroC compiler & PIC16F877A microcontroller …
In my program I am sending data through USART terminal of MikroC, it is receiving correctly on virtual terminal in Proteus but not displaying on LCD.
Please check the code written in MikroCsbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit; sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit; sbit LCD_D7 at RB5_bit; sbit LCD_RS_direction at TRISB0_bit; sbit LCD_EN_direction at TRISB1_bit; sbit LCD_D4_direction at TRISB2_bit; sbit LCD_D5_direction at TRISB3_bit; sbit LCD_D6_direction at TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit; char gps; void main() { Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"log"); Lcd_Out(2,1,"lat"); UART1_Init(9600); here: if (UART1_Data_Ready() == 1) { // if data is received gps = UART1_Read(); delay_ms(100); } Lcd_Out(1,6,gps); Delay_ms(2000); goto here; }I’m trying send data to the PIC using the Terminal Window on Proteus, but something is wrong and I don’t understand why. I attached the Proteus project and *.HEX.
The PIC is 16F628a.
#define _XTAL_FREQ 8000000 #define RS RB0 #define EN RB3 #define D4 RB4 #define D5 RB5 #define D6 RB6 #define D7 RB7 #include <xc.h> #include "lcd.h" #include "uart.h" #pragma config FOSC = INTOSCCLK // Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD) #pragma config BOREN = ON // Brown-out Detect Enable bit (BOD enabled) #pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) void main() { TRISB = 0b000000110; TRISA0 = 0; Lcd_Init(); Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String("WAITING..."); UART_Init(9600); UART_Write_Text("Terminal is running!"); while(1) { if(UART_Data_Ready()) { Lcd_Clear(); RA0 = 1; Lcd_Write_String(UART_Read_Text); __delay_ms(1000); } } }The UART.h and LCD.h from https://electrosome.com/lcd-pic-mplab-xc8/ and https://electrosome.com/uart-pic-microcontroller-mplab-xc8/
Somebody know why the code is not working?
