How to set analog pin to output 5V?


Closed Thread
Results 1 to 5 of 5
  1. #1
    james's Avatar
    james Guest

    Default How to set analog pin to output 5V?

    Is there a way to output 5V from an alalog port pin withput setting it to digital (it seems I am restricted to pinA.0 if I am to desire only 1 analog pin as digital and the rest as analog)?

    Thanks

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    PIC's cannot output from pins that have been set to Analog. You must look in the A/D Converter section and/or in the Comparator section of the Datasheet and set the pins Digital if you want to Output from any pin.

    You can of course have dual purpose pins... use them for output, then switch them to input later in the program. Fo that you will need to think carefully about your circuit design so that your outputs and inputs don't interfere with each other.

    However, there is one EXCEPTION (not all PICs have the hardware installed or able to have it connected to an external pin, so not all PICs are capable of doing this) where you can have 'psuedo-analog output (there's the clue) out of one otherwise analog configured pin... can anyone else figure it? I'll give you the answer tomorrow if nobody else has guessed it between now and then.

  3. #3
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    out of one otherwise analog configured pin... can anyone else figure it?

    A PWM situation?
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  4. #4
    james's Avatar
    james Guest


    Did you find this post helpful? Yes | No

    Default

    Yes, I know about the converse, changing duty cycle to obtain a desired output using an RC filter, it was the digital to analog I was interested in. And unfortunatedly, I am limited to a specific pin (A.0) if I am in need of only 1 analog output.
    In a configuration table a port pin can be configured for Vref+ and Vref-. If I have configured for an internal Vref (5V), will that set the pin to 5V?

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Actually PWM is not Analog but Digital. if you freeze any instant in time, it's either ON, or OFF. There's no 'in-between' as with Analog. Further, you can't have PWM fall out of an Analog configured pin. Lastly, Microchip doesn't multiplex the Hardware CCP with the Analog ports anyway.

    James, I think you're pretty much between a rock and a hard place on this one... you could experiment and see if...

    TRISA.0=0
    Loop:
    Toggle PortA.0
    Pause 1000
    Goto Loop

    would work, despite it previously being configured Analog. Put a meter on RA0 and see if it's switching On/Off. If it is, you're in business, if it's not, then....

    Finally, the answer to yesterday's exception... How can I have a 'pseudo-analogue' output falling out of an otherwise configured Analogue (input) pin?

    Some PICs (like the 16F628 and others), have an internal programmable Voltage Reference Module (VRef). VRef can be strapped to a physical PIC pin (RA2 on a 16F628 if my memory serves me right), and whatever voltage you program VRef to be, that's the voltage that will appear on an ANALOG configured INPUT pin. So that's how you get an ANALOG voltage, appearing on an ANALOG pin, previously configured for INPUT.

    Now I said 'pseudo-Analog' because VRef has pretty coarse steps between it's Vmin and Vmax, but nevertheless it's still a lot more versatile than Digitals two states.

    Melanie

Similar Threads

  1. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts