can u explain what are this ports 0, 1, 2, 3 to connect the different sensors please
wp100 said:Hi,
I assume you are talking about using the 16F690 chip on the starter board.
If so then you will probably be best connecting your 4 sensors to PortC 0,1,2 & 3
These can be used for Analogue or Digital, depending on how you configure them
RA0,RA1 and RA3 are used by the Pickit2 to program the chip, so to keep things simple its better to keep them free for programing.
Are you aware that you can buy different grades of the LM35 - typically the CA and D types which have different accuracy specifications.
i ask u which datasheet indicates about that
i need some help regarding the program for this LM35 sensor as well please can u help me
#include <pic.h>
/* cADC - Display the PICkit Pot Input Value on the built in LEDs
This program samples the voltage on RA0 using the ADC and Displays the
value on the 8 LEDs using "cLEDDisp 2" as a base.
myke predko
04.10.03
*/
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT \
& UNPROTECT & BORDIS & IESODIS & FCMDIS);
int i, j;
int ADCState = 0; // Keep Track of ADC Operation
int ADCValue = 0;
int Dlay = 63; // LED Time on Delay Variable
const char PORTAValue[8] = {0b010000, 0b100000, 0b010000, 0b000100,
0b100000, 0b000100, 0b000100, 0b000010};
const char TRISAValue[8] = {0b001111, 0b001111, 0b101011, 0b101011,
0b011011, 0b011011, 0b111001, 0b111001};
const char NOTPORTA[8] = {0, 0, 0, 0, 0, 0, 0, 0};
main()
{
PORTA = 0;
CMCON0 = 7; // Turn off Comparators
ANSEL = 1; // Just RA0 is an Analog Input
ADCON0 = 0b00000001; // Turn on the ADC
// Bit 7 - Left Justified Sample
// Bit 6 - Use VDD
// Bit 4:2 - Channel 0
// Bit 1 - Do not Start
// Bit 0 - Turn on ADC
ADCON1 = 0b00010000; // Selemct the Clock as Fosc/8
while(1 == 1) // Loop Forever
{
for (i = 0; i < 8; i++ )
{ // Loop through Each of the 8 LEDS
for (j = 0; j < Dlay; j++); // Display "On" Delay Loop
if ((ADCValue & (1 << i)) == 0)
PORTA = NOTPORTA[i];
else
PORTA = PORTAValue[i];
TRISA = TRISAValue[i];
} // rof
switch (ADCState) // ADC State Machine
{
case 0: // Finished, Start Next Sample
GODONE = 1;
ADCState++;
break;
case 1: // Wait for ADC to complete
if (!GODONE)
ADCState++; // Sample Finished
break;
case 2: // Save Sample Value in "ADCValue"
ADCValue = ADRESH;
ADCState = 0;
break;
} // hctiws
} // elihw
} // End cADC
Build C:\Users\masood\Desktop\Code Examples\cADC\cADC.c for device 16F690
Using driver C:\Program Files\HI-TECH Software\PICC\9.80\bin\picc.exe
Make: The target "C:\Users\masood\Desktop\Code Examples\cADC\cADC.p1" is out of date.
Executing: "C:\Program Files\HI-TECH Software\PICC\9.80\bin\picc.exe" --pass1 "C:\Users\masood\Desktop\Code Examples\cADC\cADC.c" -q --chip=16F690 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [192] C:\Users\masood\Desktop\Code Examples\cADC\cADC.c; 30.1 undefined identifier "CMCON0"
********** Build failed! **********
i am unable to fix it
2/3)the output as led's are connected to PORTC 0-3
Clean: Deleting intermediary and output files.
Clean Warning: File "C:\Users\masood\Desktop\Code Examples\cADC\cADC.p1" doesn't exist.
Clean: Done.
Build C:\Users\masood\Desktop\Code Examples\cADC\cADC.c for device 16F690
Using driver C:\Program Files\HI-TECH Software\PICC\9.80\bin\picc.exe
Executing: "C:\Program Files\HI-TECH Software\PICC\9.80\bin\picc.exe" --pass1 "C:\Users\masood\Desktop\Code Examples\cADC\cADC.c" -q --chip=16F690 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Executing: "C:\Program Files\HI-TECH Software\PICC\9.80\bin\picc.exe" -ocADC.c.cof -mcADC.c.map --summary=default --output=default cADC.p1 --chip=16F690 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Licensed for evaluation purposes only.
This licence will expire on Mon, 11 Oct 2010.
HI-TECH C Compiler for PIC10/12/16 MCUs (PRO Mode) V9.80
Copyright (C) 2010 Microchip Technology Inc.
Memory Summary:
Program space used A0h ( 160) of 1000h words ( 3.9%)
Data space used Fh ( 15) of 100h bytes ( 5.9%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Configuration bits used 1h ( 1) of 1h word (100.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
Loaded C:\Users\masood\Desktop\Code Examples\cADC\cADC.c.cof.
********** Build successful! **********
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?