Industrial scales (pic18f4550). It sends data in rs232 and it displays them on a lcd

03/09/2013 18:28

Hi again.

In this project, i have cerated an industrial scales. It is managed by a pic18f4550 and its main features are:

- It is able to weigh until 5100Kg

- It sends the weight in to a serial rs232.

- It displays the weight on a two lines lcd. 

This project uses the Lcm324 gauge. It works with 2mV/V step, for this reason, i have to use the LM324 integrated in order to amplify the low signal that comes from the gauge.

The varaiable resistor emule the gauge´s signal from 0v to 0.02V

The complete code is:

#include <18f4550.h>

#device adc=10

#FUSES XT, NOWDT

#use delay(clock=4000000)

#include

#use rs232(baud=9600, xmit=pin_c6, rcv=pin_c7, bits=8, parity=N)

float v,p;

#int_AD

void serial_isr()

{

printf("Peso= %04.2fKg",p);

delay_ms(500);

}

void main()

{

int16 t;

setup_adc_ports(AN0);

setup_adc(ADC_CLOCK_INTERNAL);

lcd_init();

enable_interrupts(global);

enable_interrupts(int_AD);

 while (true)

 {

 set_adc_channel(0);

 delay_us(20);

 t=read_adc();

 v=(5.0*t)/1024.0;

 p=((v*5100)/2)-410.88;

 printf(lcd_putc,"\fPeso= %04.2fkg",p);

 delay_ms(500);

 }

}