je cherche des exemples de montage si possible sur proteus pour un montage de potentiomètre, CAN (convertiseur analogique numérique), et un afficheur LCD.
je vous remercie d'avance...
-----
15/07/2007, 14h33
#2
invite9fe8593a
Date d'inscription
janvier 1970
Messages
2
Re : CAN et afficheur LCD
montage
code mikroC :
/*
* Project name:
ADC_on_LCD (Displaying ADC result on LCD)
* Copyright:
(c) Mikroelektronika, 2005.
* Description:
This code demonstrates how to use library function ADC_read, and library
procedures and functions for LCD display (4 bit interface).
* Test configuration:
MCU: PIC16F877A
Dev.Board: EasyPIC4
Oscillator: HS, 08.0000 MHz
Ext. Modules: LCD
SW: mikroC v5.0
* NOTES:
None.
*/
unsigned char ch;
unsigned int t;
char a[17], *tc;
long tlong;
void main() {
INTCON = 0; // disable all interrupts
LCD_Init(&PORTB); // initialize (4-bit interface connection)
LCD_Cmd(LCD_CURSOR_OFF); // send command to LCD (cursor off)
LCD_Cmd(LCD_CLEAR); // send command to LCD (clear LCD)
OPTION_REG = 0x80;
ADCON1 = 0x82; // configure VDD as Vref, and analog channels
TRISA = 0xFF; // designate porta as input
tc = "voltage:"; // assign text to string a
while (1) {
t = ADC_read(0); // get ADC value from 2nd channel
LCD_Out(2,1,tc); // print string a on LCD, 2nd row, 1st column
tlong = t * 5000; // use (int) multiplication instead of (long)
asm { // and fill the upper two bytes manually
MOVF STACK_2,W
MOVWF _tlong+2
MOVF STACK_3,W
MOVWF _tlong+3
}
t = tlong >> 10;
ch = t / 1000; // prepare value for diplay
LCD_Chr(2,9,48+ch); // write ASCII at 2nd row, 9th column
LCD_Chr_CP('.');