Pic12f683, Trisio, High Z, A2d


Closed Thread
Results 1 to 10 of 10
  1. #1

    Default Pic12f683, Trisio, High Z, A2d

    Hello to all,

    I have a little problem on the 12F683. I want to get the pin GPIO.0 to switch from a LOW state (GND) to a High impedence state (High Z) and while in High Z take an anolog to digital conversion at GPIO.4.

    The problem with the current circuit and Code that i have (attached is a schematic and sample code) is that while in in the LOW State the A/D will be normal and read normal voltage. However, in the HIGH Z state the PIN GPIO.4 (or AN3) will jump to a HIGH state (i.e to VDD).

    Does anyone have any suggestions on how I can go about achieving this task? Maybe another way of switching from High Z to Gnd? Any help would be greatly appreciated.

    Sammple Code:

    'Define ADCIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    Define OSC 4 'define oscilator
    Volt VAR WORD
    main:
    TRISIO = %010000 'Set GPIO.0 as OUTPUT
    LOW GPIO.0 'GND STATE
    Pause 5000
    TRISIO = %010001 'Set GPIO.0 as input (HIGH Z State)
    pause 4000
    ADCIN 3, Volt
    if Volt >= 970 then loop
    pause 1000
    goto main

    loop:
    goto main
    END

    Schematic Attached:
    Thank You All!
    Attached Images Attached Images  

  2. #2
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Does the PIC have a common ground with the circuit you show in your diagram ?
    Keith

    www.diyha.co.uk
    www.kat5.tv

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Thumbs down Should have a closer look to your scheme ...

    A good question would be How much are Va and Vb ...

    probably more than the VDD supply of the pic ...


    gave you some idea for debugging your Pic batt charger ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4


    Did you find this post helpful? Yes | No

    Default

    well, i guess i missed that little detail in the schematic. I used the voltage from Vb to power the PIC (VDD) and also used the same common ground for Vss. I'm making a battery charger and basically i want to take the voltage measurement at Vb while there is no current going into the battery from the outside voltage source Va (i want to do this because the voltage of the battery increases while the current is going into the battery, however when the current is removed i can measure the voltage of the battery and it will be closer to the open voltage.)

    I hope this makes a little more sense.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Vb = 4v
    Va = 9v
    Ic = 280 mA (while in LOW state)
    Ic = 0.05 mA (while in High Z state)

    if this helps at all

  6. #6
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    You need to use an NPN transistor to drive R3 not the PIC.

    Because the PIC is powered from 4V the voltage on its pins cannot exceed 4.6v due to internal protection diodes. This means that even when in its hi-z state current will still be flowing via R3 which would explain why you stil have current flowing even when it is supposed to be off.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  7. #7
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Smile

    Keith is 100% correct. The base of Q2 would need to be at the same level as Va in order for it to switch off. 0.6v or more below Va would mean that it's biased on.
    You will find that in its current form Q2 is actually always on.

    Trent Jackson
    Last edited by T.Jackson; - 8th April 2007 at 15:07.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    I'll try that solution as soon as i can and get back to you to see if it worked out. but everything seems logical thanks.
    jose

  9. #9


    Did you find this post helpful? Yes | No

    Default

    The NPN Transistor driving R3 works fine. thank you all for your help it is greatly appreciated!

    jose

  10. #10
    Join Date
    Jul 2007
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    if you put a resistor on the battery for a short period you can decrease surface charge a lot and get an even more accurate reading (closer to actual charge held) on the battery

Similar Threads

  1. SERIN MIDI out of Synch?
    By jncortes in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th June 2009, 20:08
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. confused problem with interrupt in a working program
    By illuminator4 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th November 2008, 17:01
  4. sample code for M25P32
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th January 2007, 02:37
  5. Serin and TMR0
    By capitano in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th May 2006, 14:58

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