PIC Microcontroller Brownouts & Watchdog Resets - PWM5

Поделиться
HTML-код
  • Опубликовано: 17 окт 2024

Комментарии • 82

  • @romancharak3675
    @romancharak3675 5 лет назад

    Fascinating stuff, Julian ! Thank you so much. I've used the 12F683 in some of my projects - it's quite a nice microcontroller. Really looking forward to your solution. AND, I always learn something new from your videos.

  • @randomelectronicsanddispla1765
    @randomelectronicsanddispla1765 5 лет назад +5

    That doesn't sound like a good idea to me. The voltage regulator will drift with age, temperature, load,...
    It will need recalibrating regularly.
    Why not use a purpose built voltage reference?

  • @jonathancrossley6803
    @jonathancrossley6803 5 лет назад +1

    You don't need a switch at all; simply use the input voltage to enter the calibration routine and then to calibrate the unit:
    After manufacture power up the PWM5 with a sequence of 'unnatural' voltages e.g. 5V for 1s, 10V for 1s, 5V for 2s then finish on a voltage you would like to calibrate out e.g. 13.8V. Then use that measured ADC result and the error against the actual 13.8V to 'autocal' and set the calibration offset and store in EEPROM.

  • @Stuart-AJC
    @Stuart-AJC 5 лет назад +7

    Why not use a LM4040 Voltage Reference? It would be simpler than your solution I reckon. But as a software guy, rather than hardware, I do admire your version.

    • @staevobr
      @staevobr 5 лет назад

      Or a REF5050. Or any other stable, precise regulator...

  • @ledjohnnyboy
    @ledjohnnyboy 5 лет назад +6

    Hi Julian, I've found that these 5V linear regulators tend to drift considerably with time and temperature. This means calibration would have to be done somewhat often. Have you had a look at the TL431 adjustable precision reference IC? From my experimenting, a stable and 1% accurate voltage reference can be achieved easily (and cheaply).
    I'm working on a precise LDO to source considerable amounts of current as well. If you don't need to do that though, you can just wire the output of the TL431 to the ADC reference pin.

    • @JulianIlett
      @JulianIlett  5 лет назад +1

      Unfortunately, I've run out of pins on the 12F683. I suppose the uC could tolerate a slightly higher voltage on its Vref pin if Vdd were slightly less than 5V. Much testing would be needed.

    • @douro20
      @douro20 5 лет назад

      I wonder how stable an AMS1117 is.

    • @Majromax
      @Majromax 5 лет назад +1

      Looking at a schematic of the PWM5, it seems that one source of the pin scarcity is that you use two of the eight pins to manage the charge pump. If you added an external inverter you could manage the charge pump with a single pin; if you added a dedicated charge pump IC you could save two.
      Then, you'd be able to have a dedicated voltage reference on the chip, either as VREF for the PIC itself or for periodic re-calibration.

  • @SimpleElectronics
    @SimpleElectronics 5 лет назад +5

    Your videos make me want to PIC up Pic programming...

    • @benbaselet2026
      @benbaselet2026 5 лет назад +1

      His videos make me want to never go down that rabbit hole :D

    • @JulianIlett
      @JulianIlett  5 лет назад +2

      Do not fear the rabbit hole :)

    • @none0049
      @none0049 5 лет назад

      @@benbaselet2026 :) take the blue pill then :)

    • @NiHaoMike64
      @NiHaoMike64 5 лет назад

      @@none0049 STM32 is actually a very good option for someone wanting to upgrade from Arduino.

    • @benbaselet2026
      @benbaselet2026 5 лет назад

      @@none0049 Yes, esp32 might be it :)

  • @mad3635
    @mad3635 4 года назад

    hi j,,i have microchip pic16c74b .its program for an inverter ,is there away to MCLR it to power up or need to write code.

  • @steadyfield
    @steadyfield 5 лет назад

    You can use an external precise voltage reference for self-calibration after powered on.

  • @lucasc5622
    @lucasc5622 5 лет назад +1

    a cool project for JLC PCB, your own lithium battery charging / protection board based on the TP4056!

    • @massimookissed1023
      @massimookissed1023 5 лет назад

      You can get them prebuilt, with μUSB power connectors, at about 5 for a €$

    • @lucasc5622
      @lucasc5622 5 лет назад

      i know, but wheres the fun in that? julian could've bought any solar charge controller online, but he chose to make his own, because why not!

  • @mawoodmain
    @mawoodmain 5 лет назад +1

    Do pic micros not have band gap diodes to reference the ADC against? When ever I've used an ADC for low to medium applications the internal references have proven to be good enough eliminating the need for vcc ratiometric measurements. If you're working with things like thermistors in battery powered applications then ratiometric has a much better performance.

    • @mawoodmain
      @mawoodmain 5 лет назад +2

      Checked, that pic doesn't not have a reference but this 8 pin pic micro does PIC16F15313

    • @bibiricat
      @bibiricat 5 лет назад

      Some PICs do have a voltage reference of 1.024, 2048, 4096mV but not all of them.

    • @mawoodmain
      @mawoodmain 5 лет назад

      Pic is a pretty poor choice these days, they often have very few low functionality peripherals and are not as cheap as you'd imagine. Far East microcontrollers are often cheaper and have more rounded functionally, for example hdsc and paduk both make ranges of cortex m0+ micros some with specialised peripherals like 24bit ADCs while maintaining a very low price point.

  • @dilshankasthuriarachchi4737
    @dilshankasthuriarachchi4737 4 года назад

    Dear what is the compiler has been used here?

  • @duncanx99
    @duncanx99 5 лет назад

    Brilliant - simply brilliant, and so wonderfully complete.
    This has set me thinking, and the cat is standing by to be amazed...
    She won't be half as amazed as I will be, if I can do something similar with ATMega328!!!

  • @DrGreenGiant
    @DrGreenGiant 5 лет назад +1

    Button or shorting pins will mess up your conformal coating. Use a voltage reference???

    • @randomelectronicsanddispla1765
      @randomelectronicsanddispla1765 5 лет назад +1

      If you are worried about the conformal coating, red switches are a great solution.

    • @leestons
      @leestons 5 лет назад

      @@randomelectronicsanddispla1765 Will blue switches work too? :P

    • @urugulu1656
      @urugulu1656 5 лет назад

      @@randomelectronicsanddispla1765 maybe you mean reed switches?

  • @PetRatty
    @PetRatty 5 лет назад +1

    Julian, what about a ATmega328. didn't you do a video about measuring it's own supply voltage, it could calibrate itself. you could also do temperate compensation with the on die sensor, I'm sure you did a video on that also.

    • @urugulu1656
      @urugulu1656 5 лет назад +1

      oh fancy although the on board sensor is pretty darn bad. but maybe just good enough for the job

    • @motormadness9975
      @motormadness9975 5 лет назад +1

      the 328 is complete overkill for such a rudimentary application

    • @PetRatty
      @PetRatty 5 лет назад

      @@motormadness9975 Yes just a bit, like 100 times. just depends on what you have, maybe a ATtiny5 @£0.26 or PIC10F222 @£0.36, will do the same thing, i

    • @PetRatty
      @PetRatty 5 лет назад

      @@urugulu1656 +3c +-2c better than nothing and better than spending extra on components if it's build in. really depends on how much you want to spend

  • @azyfloof
    @azyfloof 5 лет назад

    That's some interesting software gymnastics! :)
    I have to wonder though what the point of this type of calibration is (for this particular use-case) given that the end user won't have access to the 5v supply anyway?
    You'd be better off hard-coding in a value, seeing as only you will be able to calibrate them, and that's even putting the natural drift of the regulator over time as it ages.

  • @urugulu1656
    @urugulu1656 5 лет назад

    instead of a button you can use the microcontroller to set these values. even dynamically. with some trickery the uC can sense its own vcc... a would recommend to not write the value to eeprom instantly and rather use the ram or some register to store the value and only write on power off and read on system boot. if you add a big enough cap across the supply rail you should have enough time to write to eeprom safely in tgese occasions.

  • @CTCTraining1
    @CTCTraining1 5 лет назад

    Julian, Isn't a switch going to be the weak point on the design? ... or are you thinking of something like a hall effect detector and use a magnet to make the adjustments?

    • @JulianIlett
      @JulianIlett  5 лет назад +1

      The switch will be used only during manufacture - then removed prior to the charge controller being sealed inside its casing.

    • @andymouse
      @andymouse 5 лет назад

      Nice idea, or just plain old reed switch.

  • @mahlapropyzm9180
    @mahlapropyzm9180 5 лет назад +3

    Instead of adding a button, why not just add pins or a socket to which a button can be attached? I doubt a button would survive long enough outdoors, even if potted/coated etc, to be used for more than one calibration.

  • @ciano5475
    @ciano5475 5 лет назад +1

    Why not use a PIC with an integrated voltage reference?

  • @markflack9191
    @markflack9191 5 лет назад

    Very interesting to see how the pic responds to these different events.

  • @RambozoClown
    @RambozoClown 5 лет назад

    I was really hoping you would have some novel way to do this without resorting to adding a button. I do like the comment about using a reed switch so it has a better chance at outdoor survival.

  • @apbosh1
    @apbosh1 5 лет назад

    Whats wrong with using a 28 turn pot as a voltage divider? instead of a fixed 5V Regulator.

    • @CTCTraining1
      @CTCTraining1 5 лет назад +1

      Useful trimpot commentary - forum.allaboutcircuits.com/threads/trimpot-reliability.113915/ tldr - lots of downsides

    • @TomStorey96
      @TomStorey96 5 лет назад +2

      Voltage will fluctuate proportionally with incoming voltage, which is not what you want for a voltage reference if youre going to use it to monitor the incoming voltage itself. You want it to be as stable and accurate as possible, and a regulator will provide a (relatively) fixed output voltage independent of the input voltage, at least until its dropout voltage.

    • @apbosh1
      @apbosh1 5 лет назад +1

      @@CTCTraining1 thanks for the link I had a read through.

    • @apbosh1
      @apbosh1 5 лет назад

      @@TomStorey96 I made a 12v battery capacity tester with an arduino basically sense voltage and run the load down to the cut off V . Cannot get it right! Ended up using 2 trim pots for voltage and current dividers and it worked great....until I put it on a different battery and it threw the readings out by about 0.5 v I would accept 0.1 ish. Is that a reasonable target without considering the many other variables of lead acid battery drop testing.

    • @pulesjet
      @pulesjet 5 лет назад

      Voltage would vary with battery voltage.

  • @theR6969
    @theR6969 5 лет назад +1

    I wish there was something like an electronic component that can do that job. can someone try to invent a "voltage reference" or something of that nature?? 🤔

    • @urugulu1656
      @urugulu1656 5 лет назад

      these are actual pieces of hardware already. they are around for ages.

    • @motormadness9975
      @motormadness9975 5 лет назад

      @@urugulu1656 well that flew right over your head

    • @urugulu1656
      @urugulu1656 5 лет назад

      @@motormadness9975 dont know what you mean by that but maybe theR6565 meant that sorta ironic...

  • @lezbriddon
    @lezbriddon 5 лет назад

    i used to use pic all the time, cant believe how they fell behind arduino and esp in the hobby world.

  • @flagpoleeip
    @flagpoleeip 5 лет назад

    How are you going to ensure that the reset button isn't pressed accidetally?

    • @JulianIlett
      @JulianIlett  5 лет назад

      It needn't be soldered in to calibrate the unit.

  • @massimookissed1023
    @massimookissed1023 5 лет назад

    Interesting.

  • @pulesjet
    @pulesjet 5 лет назад

    I would use the Forward Voltage Drop of a LED as your voltage Reference ? Sounds like that means would be more accurate then the one your using. A pile cheaper as well. My bet is the accuracy would be better then the seemingly low tolerances of those Voltage regulators. Using the LED looks like you could maintain a accuracy of like .08v over the LP2905's 0.15 tolerance. electronics.stackexchange.com/questions/77450/voltage-drop-assumption-on-diodes-leds-etc

    • @JulianIlett
      @JulianIlett  5 лет назад

      Like other diodes, forward voltage is probably temperature dependent.

    • @ciano5475
      @ciano5475 5 лет назад

      And for a LED, even the incident light is a factor.

    • @pulesjet
      @pulesjet 5 лет назад

      @@ciano5475 Encapsulate. Solved.

  • @cassiecarstens5184
    @cassiecarstens5184 5 лет назад

    Hi Julian. PIC & Atmel compiler: gcbasic.sourceforge.net/Typesetter/index.php/Home
    This "Great Cow Basic" compiler is great and FREE!

  • @Ncky
    @Ncky 5 лет назад +2

    Why program in asm when its 2k19 and u can do it in c

    • @ArjanvanVught
      @ArjanvanVught 5 лет назад

      And it will also remove those "GOTO's" ;-)

    • @JulianIlett
      @JulianIlett  5 лет назад +14

      I like to program the bare metal - C is for snowflakes ;)

    • @TomStorey96
      @TomStorey96 5 лет назад +5

      Why not? Assembly is fun, and its more of a challenge than C so it gets your brain working harder which is a good thing!
      Im currently working on a Z80 based project and writing that in assembly. But I also write C for other projects. Each language has a time and a place depending on what youre trying to achieve.

    • @johnstephenson2891
      @johnstephenson2891 5 лет назад

      @@JulianIlett At least it's not Mark 1 Autocode! lol

    • @johnstephenson2891
      @johnstephenson2891 5 лет назад +1

      @@JulianIlett "It was eventually realized that programming in assembly language required a great deal of intellectual effort." From Wiki!! lol

  • @Chriva
    @Chriva 5 лет назад

    Blinkenlights :)

  • @FutzWith
    @FutzWith 5 лет назад

    Maybe add a button lockout switch, to stop accidental pushes.