Avatar for ChristianW

ChristianW

Member since Nov 2016 • Last active Nov 2019
  • 13 conversations
  • 100 comments

German IT developer who found his long lost love for electronics and connected devices...

Most recent activity

  • in Electronics
    Avatar for ChristianW

    @allObjects thanks for the clarification.
    Actually it's not for a motorized vehicle but for a velomobile - a fully faired three wheeled recumbent. Because there is no dynamo you need a battery to power lights, indicators and horn.
    And if that goes down on longer trips you are busted, so I'd like to know how much is left and how much I currently draw.
    Because it is easy to do I'd also like to measure speed, cadence and distance - and store them in an EEPROM (see other thread). And the best time to store is when the battery is pulled.

  • in Electronics
    Avatar for ChristianW

    Thanks for the suggestion, I'll change the resistor setup tomorrow to be on the safer side.
    No voltages above 12,6 V (LiPo 3S) - and no charging while in circuit possible.
    So that should simplify things a bit...

  • in Electronics
    Avatar for ChristianW

    Not quite.
    The 12V pulls the pin high, but the (external) diode shortens that to 3,3V.
    I just measured the voltage to be about 3.8V on the pin.
    Do you think this is still an issue?

    For pulldown (in case of power loss) I used the internal resistor via pinMode()

    As with the flickering this may have been cause by wrongly wired MOSFETs or a shortage between 3,3V and 5V PIN.
    Prototyping got a bit messy lately... ;-)

  • in Electronics
    Avatar for ChristianW

    PS: Without BLE connection and LED off it is even 9 seconds feedback on the LCD!

  • in Electronics
    Avatar for ChristianW

    I just wired it up.
    Used a 10k resistor to pull D7 against Vin (about 12,5 V from my fully charged LiPo).
    Capacitor is a 1000uF / 25V.

    Strange thing: The display flickers and blacks out rhythmically while D7 is not configured.

    I used this script to test powerdown detection:

    function onInit() {
    
      pinMode( D7, "input_pulldown" );
    
      setWatch(function(e) {
        //LED.set();
        console.log( "power out" );
        var t=0;
        setInterval(function() {
          console.log( "t=", t++ );
        }, 1000 );
      }, D7, { edge: "falling"});
    }
    

    It gives me about 6 seconds console feedback before dying with the LED off:

    power out
    t= 0
    t= 1
    t= 2
    t= 3
    t= 4
    t= 5
    t= 6
    

    With LED set immediately after power down it is only two seconds (still enough for some cleanup probably).

    So basically it seems to work.

    @Gordon: is it normal that it behaves strange when certain pins are used as inputs bot not configured yet?

  • in Electronics
    Avatar for ChristianW

    Thanks, @AkosLukacs.

    I was considering the CR2032 backup, but was scared to mess with two inputs.
    Thanks for sorting that our.

    Actually it would be enough to have some cycles left for a EEPROM write, so a powercap or elko could just do.
    What about another pulldown between Din and GND?
    EDIT: I just found input_pulldown in the pinMode() documentation. That would do the trick, wouldn't it?

    It would be nice to use a setWatch() instead of polling external hardware.
    Maybe I'll give t a try later...

    The NRF52LL reference looks interesting, too. Did not know about it.
    Thanks.

  • in Electronics
    Avatar for ChristianW

    I am using a Pixl.js for a bike (velomobile) computer project.
    It should monitor the onboard LiPo battery with 11.1 V and is also driven by it.

    In case off immediate power loss (battery is dying or just disconnected) there should be a triggered routine to save some current data to flash.

    I was considering this:
    Battery power is monitored by an INA226.
    So one way is to regularly poll and detect an undervoltage.
    But this is slow and could only work for a slowly dying battery - no sudden disconnect.

    So another idea is this:
    Put a capacitor parallel to the Vin Pins to gain some time after power loss.
    Put a diode in front so the capacitor only feeds the Pixl, nothing outside.
    Wire the feeding current (before the doide) with a resistor (~10k) to a digital input.
    Put another small diode between 3,3 V and the input so the voltage will not rise above 3,3 V. (Maybe a Z-diode of about 3,3 V between GND and the input would be better?)
    As soon as the outside voltage drops, the pin will change to low and trigger a watch set on that pin.

    Will that work?
    Anyone tried something similar or has a better idea?

    Some ASCII Art sketch for clarification:

    Din  O---+--[R]----+
             |         |
             V diode   |
             -         |
             |         |
    3v3  O---+         |
                diode  |
    Vin  O---+---|<----+-------------O 
            +|                       + LiPo
            === capacitor
             |                       - LiPo
    GND  O---+-----------------------O
    
Actions