My PIC 18F14K22 Desulferator

Discussion in 'The Projects Forum' started by ozarkshermit, Feb 18, 2015.

  1. ozarkshermit

    Thread Starter New Member

    Feb 7, 2009
    7
    1
    Howdy all:

    Just thought I'd post my progress on this . . .

    First

    I'd like to thank others who posted on previous (old) threads, especially Sgt Wookie
    I used parts of his posted schematic in my design.


    Here is my project to date:

    I'm using a 18F14K22 Pic, using the 16 MHz internal oscillator, programmed using " PicBasic Pro".

    A little over 5K of code so far, just about done. Not even approaching the 16K available on the PIC.

    Here is the "Preamble" to the code, minimal description -

    Please excuse the "all Caps". I copied this from my program, that's how it is there . .


    '********************************************************
    '* Name : DESULF 15 FEB.BAS *
    '* Author : Ken Stuempges *
    '* Date : 1/12/15 *
    '* Version : 1.0 *
    '* Notes : THIS WILL BE USED TO PULSE THE DESULFERATOR *
    '* A 18F14K22 PIC RUNNING AT 16 MHZ INTERNAL OSCILLATOR
    '
    ' THE FET USED IS AN IRF640 - - 17 AMPS AT 200 VOLTS
    ' MAXIMUM CASE TEMPERATURE IS ~ 300 DEGREES F
    ' THE CASE TEMPERATURE WILL BE LIMITED TO ~ 115 DEGREES F
    ' THAT WILL STILL ALLOW ALMOST 16 AMP DRAIN CURRENT
    ' **** THIS TEMPERATURE MIGHT BE ADJUSTED AFTER ACTUAL TESTS CONDUCTED *****
    ' A LM34 IS USED TO MONITOR THE FET CASE TEMPERATURE
    ' A LED WILL BLINK TO SHOW ACTIVIY.
    '
    ' THE VARIABLE "OFF TIME" IS ACTUALLY THE PULSE REPITION RATE, RATHER THAN FREQUENCY
    '
    ' THE UPPER TEMPERATURE LIMIT OF THE FET IS PROGRAMMED FOR 115 DEGREES
    ' IF THAT TEMPERATURE IS REACHED, THE OFF TIME WILL BE INCREASED
    ' AND PULSE WIDTH WILL BE DECREASED
    ' AS THE TEMPERATURE FALLS, THE OFF TIME WILL BE DECREASED
    ' AND PULSE WIDTH WILL GRADUALLY BE INCREASED
    '
    ' AVERAGING ROUTINES ARE USED FOR BOTH THE FET TEMPERATURE AND BATTERY VOLTAGE
    ' THIS WILL STABILIZE THE VALUES AND PREVENT DISPLAY JITTER AND ERRATIC RESULTS
    '
    ' 16 READINGS ARE MADE, AND THEN SORTED HIGH TO LOW.
    ' THE FOUR HIGHEST AND FOUR LOWEST VALUES ARE DISCARDED
    ' THE REMAINING EIGHT ARE TOTALED, THEN DIVIDED BY EIGHT
    ' THESE ROUTINES WERE POSTED ON THE PBP WEBSITE.
    '
    ' THE DEFAULT PULSE WIDTH IS 50 MICROSECONDS
    ' THE DEFAULT OFF TIME IS 1000 MICROSECONDS
    '
    ' ONE TOGGLE SWITCH IS USED TO ENABLE/DISABLE THE DeDENDRITING FUNCTION
    ' ANOTHER TOGGLE SWITCH IS USED TO CONNECT 5 VOLTS TO THE PIC
    ' RECOMMEND HAVING THAT SWITCH OPEN WHEN THE BATTERY IS FIRST CONNECTED
    '
    '
    ' THREE PUSHBUTTONS ARE USED TO ADJUST THE PULSE WIDTH
    ' "ADJUST" "MORE" "LESS"
    '
    ' PRESS AND HOLD ADJUST UNTIL "ADJUST PULSE WIDTH "
    ' " MORE OR LESS" IS DISPLAYED
    '
    ' ****** IMMEDIATELY RELEASE THE BUTTON ******
    ' - - - THEN - - -
    ' EITHER WAIT IF NO ADJUSTMENT IS WANTED, - OR -
    '
    ' PRESS AND HOLD EITHER "MORE" OR "LESS" AND THE PULSE TIME WILL CHANGE
    ' AFTER THE NEW PULSE WIDTH IS ATTAINED, RELEASE THE BUTTON AND WAIT UNTIL
    '
    ' "PULSE IS ADJUSTED"
    ' "PULSE = XX MICRO-SECONDS"

    ' THEN THE DISPLAY WILL READ "ADJUST OFF TIME ?"
    ' "MORE OR LESS"
    '
    ' PRESS MORE TO INCREASE, PRESS LESS TO DECREASE
    ' THE STEPS ARE IN 10 MICROSECOND INCREMENTS
    '
    ' IF NO CHANGE IS DESIRED, JUST WAIT, AND THE DISPLAY WILL RESET
    '
    '##### THE FET IS OFF DURING THE TIME ANY ADJUSTMENTS ARE BEING MADE ####
    '
    ' ANALOG INPUTS ON PORTA.0, A.1, AND A.2 ARE PROVIDED FOR -
    ' BATTERY VOLTAGE, AND FET TEMPERATURE, SO FAR
    '
    '****************************************************************

    Timer0 is used to interrupt the main (short) program, to turn the FET on for the desired pulse width, and set the desired off-time.
    The Off-Time is actually the pulse repition rate (time between pulses).
    Pulse Width is programmable in 1 micro-second steps; the Off time is programmable in 10 microsecond steps.

    The FET temperature is monitored using a LM34 temperature sensor, and automatically adjust pulse width and/or frequency as needed .

    A seperate, small voltmeter (7 segment, 0 to 99V) will be used to display the peak voltage as measured at the board

    I have a DeDendriter FET, to short the battery for 100 microseconds, every 5 minutes or so - this time cycle might change.
    A toggle switch enables the code that pulses the DeDendriter FET, and disables the pulser during this brief time.

    The battery voltage is constantly monitored.

    A 4 line by 20 character LCD displays the following:

    FET Temperature in degrees F
    Pulse Width in micro-seconds
    Off-Time in microseconds
    Battery Voltage, to tenths of a volt

    All of the code is written and tested, connected to a 12V lawn mower battery , with the exception of the DeDendriting pulse and adjustments for FET temperature.

    I etched my circuit board, which has become a "first prototype" because I added some features. A new circuit board has been etched and drilled,
    but not populated yet.
    Solder Wick was soldered to the foil on the first board to provide lower resistance in critical current paths. I will do the same on the new board.

    I will be providing a schematic later, along with some photos of various waveforms taken on my digital scope.
    The schematic is practically identical to the 555 circuit, only using a PIC instead, plus the other features.

    Here is a list of the major components used:

    18F14K22 PIC
    1 MH Inductor : Mouser # 542-2324-V-RC
    220 MicroH Inductor : Mouser # 542-2316-V-RC (5.8 Amp)
    Pulsing FET : IRL640 - 17A 200V
    DeDendriting FET : IRFB 3307 - 120A 75V
    Diode: Mouser # 512-FFPF 10UP60STU Ultra Fast 10A 600V
    Caps (4) : Mouser # 140-RXJ101M1HBK1016P - 50 Mf, 100V

    Presently testing using a LCD and Pushbuttons on one of my prototyping boards.

    I am measuring a whopping 71 volts peak at the board (using my FLUKE DMM) - Not sure what it will be across the battery terminals.
    I have some cable from an inverter, at least 8 gage, and very flexible, that will be used to connect the board to the battery.
    This is being developed using an old riding mower 12V battery I am trying to recover.

    NOW, after all this, I have a question:

    Since I will be connecting an analog input to the PIC onto the Battery terminals, I think that a Ferrite Bead will be needed
    in the sense lines to supress the high voltage spikes. I have a couple on order, to use if needed.

    Any thoughts on this?

    More later
    Ken
     
  2. ozarkshermit

    Thread Starter New Member

    Feb 7, 2009
    7
    1
    Here are some updates:

    The new circuit board is completed, and fully tested. It does not include the solder wick on the back, as far as I can tell it made no difference.

    The Peak Voltage option has been eliminated. It is no longer on the schematic, but does remain on the circuit board.

    A ferrite bead was added to the voltage sense wire, and a 0.1 Uf decoupling Cap was also added to the an analog input.
    The voltage spikes at the analog input have been completely eliminated.

    The DeDendriting FET is now on the circuit board, and shorts the battery for 100 micro-seconds once every 5 minutes.
    It is enabled using a toggle switch (Might not want it all the time)

    A toggle switch was added to enable the power to the 5V regulator on the PIC side.

    An "activity" LED blinks once a second.

    Additional features are provided for in the future:

    1. Enable an external charger when the battery voltage falls to a low level.
    2. Enable an external Dis-charger (probably a power resistor or light bulb)

    Attached is the Schematic (using Express SCH), and photos of the Circuit Board top and bottom.

    Also included is a pix of my prototyping LCD display connected to the circuit board while pulsing the battery.
    That display has been invaluable in many earlier projects.

    I have a large number of waveform photos from my digital scope, showing various aspects, but they are kind of fuzzy, readable but fuzzy.
    If I can I will take some better pix, if not will follow up later with some uploads of them.
    Also have a couple of pix showing the pulse width and off times on my SALEAE Logic Analyzer.

    So far So Good

    Ken
     
  3. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,979
    744
    Nice design, just wondered if your using the pwm on the chip, as i couldn't find any source files from microchip to get my 18Fk422 to work?
     
  4. ozarkshermit

    Thread Starter New Member

    Feb 7, 2009
    7
    1
    Thanks Dave

    I'm not using PWM - - started out with that (using PICBasicPro), but was unable to
    accomplish the independent resolution of both pulse width and off time that I wanted.

    The way I do this is as follows:

    Timer 0 runs in the background, the interrupt frequency is determined by changing
    the TIMERH and TIMERL pre-load values, thereby changing the Off Time.

    All that happens during interrupt is the Pulsing FET is turned on for the programmed pulse width time,
    then reload the TIMERH and TIMERL variables with the programmed values.

    A variable is used for Pulse Width time in micro-seconds.

    I plan on posting a couple of screen shots using my SALEAE Logic analyzer, to show the pulse
    width and off times. It clearly shows the resolution to be less than a microsecond for each.

    The push button routines allow changing the variable for pulse width in one micro-second steps,
    as well as changing the Timer Interrupt pre-load values in 20 microsecond steps.

    Hope that helps

    Ken
     
    Dodgydave likes this.
Loading...