MPLAB IDE vs MICROc for temperature control system

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

MPLAB IDE vs MICROc for temperature control system

Postby nadeeraanuar » Thu May 14, 2015 1:12 am

hello and good day everyone. I am doing m microcontroller project bu using MPLAB. Unfortunately, the coding that I found is in microC. is there any way to convert the coding from micro c to mplab? If there is. can any of teach me? Im using PIC16F877A and LM35 . for now, this is the coding in micro c:

CODE: SELECT_ALL_CODE
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;

unsigned long ADRead;
unsigned int vDisp[3];
unsigned char Display[7];
     
void main()
{
  PORTA = 0;
  TRISA = 0X01;
  PORTB = 0;
  TRISB = 0;
  LCD_Init();
  LCD_Cmd(_LCD_CURSOR_OFF);
  LCD_Cmd(_LCD_CLEAR);
  LCD_Out(1, 1, "Temp:");
  //Display = "+125 'C";
  Display[4] = 39; //'
  Display[5]= 'C';
  ADCON1 = 0x0E;
  ADC_Init();
  while (1)
  {
    ADRead = (ADC_Get_Sample(0) * 500) >> 10;
    vDisp[0] = ADRead / 100;
    vDisp[1] = (ADRead / 10) % 10;
    vDisp[2] = ADRead % 10;
    Display[1] = vDisp[0] + 48;
    Display[2] = vDisp[1] + 48;
    Display[3] = vDisp[2] + 48;
    LCD_Chr(1, 8, Display[0]);
    LCD_Chr(1, 9, Display[1]);
    LCD_Chr(1, 10, Display[2]);
    LCD_Chr(1, 11, Display[3]);
    LCD_Chr(1, 12, Display[4]);
    LCD_Chr(1, 13, Display[5]);
    //LCD_Out(1, 8, ); // 'Show temperature
    delay_ms(200); //200ms delay for waiting
  }
}
nadeeraanuar
Freshie
 
Posts: 7
Joined: Tue Apr 22, 2014 9:08 pm

Re: MPLAB IDE vs MICROc for temperature control system

Postby Idris » Thu May 14, 2015 9:44 am

Hi nadeeraanuar,

You can refer to DIY kit "Temperature Control System Using LM35". Click at the attachment tab and there have sample code, schematic, component list and etc. The sample code is for PIC16F876A, but it is compatible with PIC16F877A, you just need to change the device in Project.

Try and understand the code first.

Thanks.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: MPLAB IDE vs MICROc for temperature control system

Postby nadeeraanuar » Fri May 15, 2015 1:43 am

okay thank you.
one more question is, is it possible for me to combine coding.
for example I am doing temperature controlled water system.
so I combined my coding of ldr and led with the coding of temperature sensor.
is there any rules or condition in order for me to combine them because it seems like only the ldr and led part is working.
nadeeraanuar
Freshie
 
Posts: 7
Joined: Tue Apr 22, 2014 9:08 pm

Re: MPLAB IDE vs MICROc for temperature control system

Postby Idris » Fri May 15, 2015 10:46 am

Yes it is possible. You need to really understand your project flow, then 'translate' it into program.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: MPLAB IDE vs MICROc for temperature control system

Postby nadeeraanuar » Fri May 15, 2015 10:57 am

yes. my project now is 70% working. only the lcd didnt display the temperature value.
thank you for helping
nadeeraanuar
Freshie
 
Posts: 7
Joined: Tue Apr 22, 2014 9:08 pm

Re: MPLAB IDE vs MICROc for temperature control system

Postby ober » Fri May 15, 2015 5:39 pm

nadeeraanuar WROTE:okay thank you.
one more question is, is it possible for me to combine coding.
for example I am doing temperature controlled water system.
so I combined my coding of ldr and led with the coding of temperature sensor.
is there any rules or condition in order for me to combine them because it seems like only the ldr and led part is working.

Yes, there is translator, human :)
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 4 guests

cron