Is there a way to read the values on the ports simultaneously in binary because i want it to interface with an external ADC. I'm using 16F84A that's why.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
PORTA, PORTB, etc are all treated as variables. For example, if you need to copy the value of all of PORTB into a variable called Temp, you could use this line:
PORTB = Temp
Then you can check the individual bits of the Temp variable, or use the entire value.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if AN0 is @ 1V , RB0 is on
if AN0 is @ 2V , RB0 and RB1 are on
if AN0 is @ 3V , RB0 and RB1 and RB2 are on
if AN0 is @ 4V , RB0 and RB1 and RB2 and RB3 are on
if AN0 is @ 5V , RB0 and RB1 and RB2 and RB3 and RB4 are on
many thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Realize that reading an analog port will be represented by binary values. So depending on what your reference voltage you specify (default being the input voltage I think), the voltage is Vref/256 = voltage per bit. So with say a 5.1 voltage reference you get 5.1/256 = 20mv/bit.
Voltmeter = ReadAD(AN0)
If Voltemeter < 50 Then PortB = b'00000000'
If Voltmeter >= 50 AND Voltmeter < 100 then PortB = b'00000001'
If Voltmeter >= 100 AND Voltmeter < 150 then PortB = b'00000011'
If Voltmeter >= 150 AND Voltmeter < 200 then PortB = b'00000111'
If Voltmeter >= 200 AND Voltmeter < 250 then PortB = b'00001111'
If Voltmeter >= 250 then PortB = b'00011111'
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to read the values on the ports simultaneously in binary because i want it to interface with an external ADC. I'm using 16F84A that's why.
PORTA, PORTB, etc are all treated as variables. For example, if you need to copy the value of all of PORTB into a variable called Temp, you could use this line:
PORTB = Temp
Then you can check the individual bits of the Temp variable, or use the entire value.
Hi, can you tell me how can i do this :
if AN0 is @ 1V , RB0 is on
if AN0 is @ 2V , RB0 and RB1 are on
if AN0 is @ 3V , RB0 and RB1 and RB2 are on
if AN0 is @ 4V , RB0 and RB1 and RB2 and RB3 are on
if AN0 is @ 5V , RB0 and RB1 and RB2 and RB3 and RB4 are on
many thanks
Realize that reading an analog port will be represented by binary values. So depending on what your reference voltage you specify (default being the input voltage I think), the voltage is Vref/256 = voltage per bit. So with say a 5.1 voltage reference you get 5.1/256 = 20mv/bit.
Voltmeter = ReadAD(AN0)
If Voltemeter < 50 Then PortB = b'00000000'
If Voltmeter >= 50 AND Voltmeter < 100 then PortB = b'00000001'
If Voltmeter >= 100 AND Voltmeter < 150 then PortB = b'00000011'
If Voltmeter >= 150 AND Voltmeter < 200 then PortB = b'00000111'
If Voltmeter >= 200 AND Voltmeter < 250 then PortB = b'00001111'
If Voltmeter >= 250 then PortB = b'00011111'