Search Results - microcontroller

Home Forums Search Search Results for 'microcontroller'

Viewing 15 results - 91 through 105 (of 127 total)
  • Author
    Search Results
  • #10480
    tasos17
    Participant

    I need some help and input for my project.

    I have made one voltmeter / ammeter using a pic microcontroller and one robot controller brain (that can talk). The first part works perfectly and I will test the second one coming days.

    If it works I will move to the next stage that is to have the results from the first one transferred to the the second one which will spell them, so I will have visual (2×16 display) and audio from the robot brain.

    Can I use UART communication for that ?

    If so, can I use USB to UART TTL converter using PL2303HX for that ?

    Thanks in advance.

    sahu
    Participant

    With reference to the article Interfacing HC-SR04 Ultrasonic Distance Sensor with PIC Microcontroller, I am trying to change the microcontroller to PIC 16F676.

    #define _XTAL_FREQ 8000000
    
    #define RS RC5
    #define EN RC4
    #define D4 RC0
    #define D5 RC1
    #define D6 RC2
    #define D7 RC3
    
    //#include <xc.h>
    #include <htc.h>
    
    #include "lcd.h";
    #include <pic16f676.h>
    
    // BEGIN CONFIG
    #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
    #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled)
    #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
    #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
    //#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
    #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
    //#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
    #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
    //END CONFIG
    
    void delayMs(int x);
    
    void main()
    {
      int a;
    
      TRISA = 0b00010001; //RA0 as Input PIN (ECHO)
      TRISC = 0x00; // LCD Pins as Output
    
      Lcd_Init();
    
      Lcd_Set_Cursor(1,1);
      Lcd_Write_String("Developed By");
      Lcd_Set_Cursor(2,1);
      Lcd_Write_String("electroSome");
    
      delayMs(3000);
      Lcd_Clear();
    
      T1CON = 0x10; //Initialize Timer Module
    
      while(1)
      {
        TMR1H = 0; //Sets the Initial Value of Timer
        TMR1L = 0; //Sets the Initial Value of Timer
    
        RA0 = 1; //TRIGGER HIGH
        __delay_us(10); //10uS Delay
        RA0 = 0; //TRIGGER LOW
    
        while(!RA1); //Waiting for Echo
        TMR1ON = 1; //Timer Starts
        while(RA1); //Waiting for Echo goes LOW
        TMR1ON = 0; //Timer Stops
    
        a = (TMR1L | (TMR1H<<8)); //Reads Timer Value
        a = a/58.82; //Converts Time to Distance
        a = a + 1;   //Distance Calibration
        if(a>=2 && a<=400) //Check whether the result is valid or not
        {
          Lcd_Clear();
          Lcd_Set_Cursor(1,1);
          Lcd_Write_String("Distance = ");
    
          Lcd_Set_Cursor(1,14);
          Lcd_Write_Char(a%10 + 48);
    
          a = a/10;
          Lcd_Set_Cursor(1,13);
          Lcd_Write_Char(a%10 + 48);
    
          a = a/10;
          Lcd_Set_Cursor(1,12);
          Lcd_Write_Char(a%10 + 48);
    
          Lcd_Set_Cursor(1,15);
          Lcd_Write_String("cm");
        }
        else
        {
          Lcd_Clear();
          Lcd_Set_Cursor(2,1);
          Lcd_Write_String("Out of Range");
        }
        delayMs(400);
      }
    }
    /************************************************************/
    
    void delayMs(int x)
    {
      int i;
      for (x ;x>0;x--)
      {
        for (i=0;i<=110;i++);
      }
    }

    I am using Hi-Tech C compiler and getting following errors.

    Error [1347] ; 0. can’t find 0x21 words (0x21 withtotal) for psect “text142” in segment “CODE” (largest unused contiguous range 0x1E)
    Error [1347] ; 0. can’t find 0x12 words (0x12 withtotal) for psect “text140” in segment “CODE” (largest unused contiguous range 0x7)
    Error [1347] ; 0. can’t find 0xF words (0xf withtotal) for psect “text144” in segment “CODE” (largest unused contiguous range 0x7)

    #10408
    #10277
    sahu
    Participant

    How to display floating point values on LCD ? I am using MPLAB XC8 LCD Library.

    #10227
    nitin ahuja
    Participant

    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 MikroC

    sbit 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; 
      }
    
    #10165
    Ivan
    Participant

    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?

    #10164
    Ligo George
    Keymaster

    Hello, It seems like you converted our program in the article Interfacing HC-SR04 with PIC Microcontroller to CCS C.

    In that tutorial I used prescaler : 2, so you should use :

    setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);

    and you should change a-4 to a in printf().

    Please check the above program after making these changes and let me know whether it works or not. If it works, I can include it too in that article such that it will help others too.

    #10070
    Ivan
    Participant

    Hi everyone.

    I saw the Interfacing LCD with PIC Microcontroller – MPLAB XC8 on electroSome and I did the circuit. It works fine! But I’m wondering. Is there a way to create custom character?

    #9975

    How to connect more than 2 serial devices to an ARM microcontroller?
    or how to use a single serial port of a microcontroller for 2 devices?

    #9817
    Ligo George
    Keymaster

    Can you explain the problem in detail ? What happens when you operate 2 servo motors simultaneously ?
    It might be the problem of your power supply. Make sure that your power supply can provide enough current to operate 2 servo motors simultaneously.
    It is better to use separate power supplies for PIC and Servo Motors OR you should use proper filtering capacitors, otherwise ripples produced by the servo motor will reset the PIC Microcontroller.

    #9373
    Ligo George
    Keymaster

    As shown in the error message, please check your target. It might be the problem of your pic microcontroller. Try replacing it with a new one. Check whether the ICSP circuit is correct or not.

    #9355
    Ligo George
    Keymaster

    You may use Microchip’s IO port expanding IC’s MCP23017 or MCP23S17.
    Following link may help you :
    Increasing IO Ports PIC Microcontroller
    You can expand output pins by using D-Latches or Shift Registers
    Expanding Output Pins PIC Microcontroller

    #9328
    Ligo George
    Keymaster

    Hope the following link will help you.
    Generating PWM with PIC Microcontroller

    #9276
    Ligo George
    Keymaster

    Crystal Oscillators will provide the necessary clock for the operation of microcontrollers.
    Microcontrollers works on the basis of clock. Microcontrollers use common data bus for data transmission between different parts. Each peripherals and registers communicate each other by time division multiplexing. This is achieved though clock.
    For example, to store data from a particular memory location to register A,
    Clock 1 : Provides Location Address To Memory
    Clock 2 : Provides Read Control Signal to Memory, which places data in the data bus
    Clock 3 : Provides Clock to Register A, to store data available in the data bus.
    This is only an example for understanding the working, actual process may differ for different microcontrollers.

    #8886
    biswaIITH
    Participant

    Hello LIGO..u are doing a great job..i am a newbie in microcontroller and i must confess this site helped me tremendously..i am trying to generate PWM pulses for certain applications..But PWM frequency is 100kHz..can i use the code available on this website  https://electrosome.com/pwm-pic-microcontroller/ i am using PIC16F876A micro..THAnk u in advance

Viewing 15 results - 91 through 105 (of 127 total)
>