Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Multiple inputs with PIC16F877

Status
Not open for further replies.

AUSTStudent

New Member
In my project, I am using sensors connected to PIC16F877. I have to get the readings from the sensors and display the value on the Computer (through parallel port). For example, I am using LM35 to display the temperature value on the PC (using Visual Basic). When I want to display, more than 1 sensor reading, it doesnot work. I want to use three ports for A/D conversion to display three different readings.



For synchronization between PC and PIC16F877, I am using control pins of parallel port. The temperature reading is displayed correctly on PC from the 3 ports. Since, sensors are not available now, I am using voltage less than 1.2V from the bread board to check, if synchronization is achieved or not. Along with the voltage from LM35, when I add any other voltage, I get the same reading of the temperature, i.e., the two ports are reading the same value, how is that possible, although I am putting 2 different voltage on AN0 and AN1???



I am programming using picbasic pro and the code is shown below.

***************************************************************************************************************

define ADC_BITS 10
define ADC_CLOCK 3
define ADC_SAMPLEUS 50


x var word 'ADC is made 10 bits for proper resolution of LM35

y var byte

a var word

b var byte

c var word

d var byte


TRISA=255
TRISB=0

TRISD = 255
ADCON1=%10010010
pause 500
loop:
if (portd.0 = 1) AND (portd.1 = 0) Then



ADCIN 0,x

y = x 'the last two bits will be discarded, but the reading for temperature is correct.
PortB = y
output PortB
pause 500

endif



if (portd.0 = 0) AND (portd.1 = 1) Then



ADCIN 1,a

b = a
PortB = b
output PortB
pause 500

endif



if (portd.0 = 1) AND (portd.1 = 1) Then



ADCIN 2,c

d = c
PortB = d
output PortB
pause 500

endif
goto loop

***************************************************************************************************************************


By proper programming in Visual basic, the control pins are changing, i.e., portd.0 and portd.1 is changing as 10, 01, 11. But, why is that the microcontroller is not reading multiple inputs separately??

Plz help

Thanx a lot...
 
Probably you trick the compiler when you use OUTPUT PORTB. OUTPUT is when you use a single I/O of a specific PORT, i.e. OUTPUT PORTB.1.
 
hi,
What operating system are you using on the PC, eg: Win XP etc.???

If its XP, do you have dll's that will enable the PC paraport control when using VB.?


EDIT: which pins on the PC paraport are you using.?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top