Another question about 12F675


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579

    Default Another question about 12F675

    Hi everybody !
    I intend to use ADC(AN3) of 12F675 and using VRef . My question is : pin 6-GP1 must be connected to VDD ?
    I post my code. Thanks in advance !
    Code:
    @ DEVICE PIC12F675, intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, bod_off
    
    DEFINE OSC  4
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    
    CMCON = 7
    OPTION_REG  = %10000110
    TRISIO      = %00011110			'if 1 then GPIO=input ; if 0 then GPIO=output
    ANSEL       = %00011000
    ADCON0      = %10001101
    
    ..............
    	adcin 3, read_volt
      	read_volt=read_voltage * 5000
      	read_volt=div32 1023

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Datasheet:

    bit 6 VCFG: Voltage Reference bit
    1 = VREF pin
    0 = VDD


    So you have to change your
    Code:
    ADCON0      = %10001101
    to
    Code:
    ADCON0      = %11001101
    AND connect Vref pin to your separate voltage source (since you want to use Vref pin, you should have a voltage source other than Vdd).
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    Thank You for such fast reply!
    So :
    If I connect pin 6 to VDD - it's correct ADCON0= %10001101.
    In this case, this code
    Code:
    adcin 3, read_volt
      	read_volt=read_voltage * 5000
      	read_volt=div32 1023
    it's correct ? It's possible to read so at AN3 the voltage between 0 and 5 volts(VDD)?
    I need to read maximum 1 volt...
    Some explanations: I intend to use ADC of 12F675 like "over-current detector" for one electrical motor. The montage is used in autovehicle,where, I think, it's spikes of voltage and I search the way to avoid PIC dammge.
    Attached Images Attached Images  
    Last edited by fratello; - 24th August 2010 at 14:40.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Thingie %1:
    If you need to measure max. 1Volt, then you may want to have a 1V voltage source connected to Vref Pin. Something like " LM185-1.2/LM285-1.2/LM385-1.2
    Micropower Voltage Reference Diode" or" LM4121 1.25V Precision Micropower Low Dropout Voltage Reference". Not 1V though.
    But, if you set ADC module with Vref pin and connect Vref pin to Vdd, you simply waste a pin. You do not have to use Vref in such case;
    bit 6 VCFG: Voltage Reference bit
    1 = VREF pin
    0 = VDD

    If you set it as "0 = VDD" then you do not need to connect Vref pin to Vdd. You can use GP1 for other purposes.

    Thingie %10:
    May I recommend that you use comparator module of this PIC for "over load" dedection & protecton?
    It will be much quicker.
    You can set your comparator module to a level where you want the protection take action.
    Last edited by sayzer; - 24th August 2010 at 15:31.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    Thanks, again !
    On first "boot" (when I power up for the first time the montage) I read the over-load current ( about 300 mV) and I store the value into eeprom. Next time, I read the current and if this is > value memorised, then I stop the motor. This works fine , but, time to time, the PIC is dammaged. I use for power LM 2931AZ5, with 100uF and 100nF .I really don't understand why this...so I think maybe it's something wrong with this pin (6). Thank You for support !

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