Menu

ADC

Help
2008-03-01
2013-05-30
  • Nobody/Anonymous

    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.

     
    • Hugh Considine

      Hugh Considine - 2008-03-08

      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.

       
      • Nobody/Anonymous

        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

         
    • kent_twt4

      kent_twt4 - 2008-04-21

      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'

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.