2016-03-27 00:16 kanzure has joined #qi-hardware 2016-03-27 00:18 kanzure has quit [Changing host] 2016-03-27 00:18 kanzure has joined #qi-hardware 2016-03-27 03:40 DocScrutinizer05 has quit [Disconnected by services] 2016-03-27 03:40 DocScrutinizer05 has joined #qi-hardware 2016-03-27 04:18 GeorgeHahn has quit [Read error: Connection reset by peer] 2016-03-27 04:54 doomlord has joined #qi-hardware 2016-03-27 04:56 DocScrutinizer05: discussion of the time-keeping circuits: http://lists.en.qi-hardware.com/pipermail/discussion/2016-March/011020.html 2016-03-27 05:00 sb0 has quit [Quit: Leaving] 2016-03-27 05:35 sb0 has joined #qi-hardware 2016-03-27 07:23 doomlord has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…] 2016-03-27 08:07 doomlord has joined #qi-hardware 2016-03-27 08:10 wildlander has joined #qi-hardware 2016-03-27 08:27 doomlord has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…] 2016-03-27 08:30 doomlord has joined #qi-hardware 2016-03-27 08:36 sandeepkr__ has joined #qi-hardware 2016-03-27 11:04 doomlord has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…] 2016-03-27 11:41 k 2016-03-27 11:42 btw did you notice the similarities between the FET in 4 and an "ideal diode" 2016-03-27 11:42 ? 2016-03-27 11:43 yes, there's a bit of that there 2016-03-27 11:49 doomlord has joined #qi-hardware 2016-03-27 11:49 I just wonder what's the ABSMAX for the sMCU 2016-03-27 11:49 particularly regarding voltage on any pin vs VCC 2016-03-27 11:51 my final design recommendation is: ADC/GPIO[1] - 3M3 - C1 - GND; [1] - schottky - VCC 2016-03-27 11:53 the leakage current on ADC/GPIO is basically negligible resp no problem to probe for, after power return 2016-03-27 11:53 simply charge again until C1 full, then switch to discharge and probe voltage 2016-03-27 11:55 the temperature and thus leakage of the chip won't change in the timespan from battery change aka discharge, over probing residual charge on C1 after power return, to probing leakage after fully charging C1 after residual charge probing 2016-03-27 11:59 doomlord has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…] 2016-03-27 12:03 for 1uA@3V3 leakage current you got an equiv Z of 3M3, what a coincidence ;-) 2016-03-27 12:04 so your ADC would still probe with a multiplier of 0.5, which is easy to determine after you charged C1 to VCC, *after* probing residual charge after batt swap 2016-03-27 12:06 and 0.5 "prescaler" also leaves still enough precision in ADC 2016-03-27 12:06 s/precision/resolution/ 2016-03-27 12:06 DocScrutinizer05 meant: "and 0.5 "prescaler" also leaves still enough resolution in ADC" 2016-03-27 12:07 it's just one bit less 2016-03-27 12:09 you could even get quarter-bit or even 1/8 bit resolution by polling at high speed and determinin time for first 1digit decrement vs time between 1st and 2nd 1bit decrement 2016-03-27 12:10 you even can *completely* eliminate prescaler effects of GPIO leakage, by doing a PWM beween charge and discharge to keep C1 voltage steady 2016-03-27 12:11 your C1 voltage is exactly Vcc * PWM ratio 2016-03-27 12:13 how much better than this could any other design get? 2016-03-27 12:14 doomlord has joined #qi-hardware 2016-03-27 12:15 (and how much simpler, BOM wise and to evaluate) 2016-03-27 12:16 wpwrak: ^^^ 2016-03-27 12:21 doomlord has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…] 2016-03-27 12:21 ((*completely* eliminate)) not only prescaler effects but also any nonlinearities in ADC 2016-03-27 12:21 only thing you can't completely eliminate but only mitigate with PWM is ADC noise 2016-03-27 12:25 doomlord has joined #qi-hardware 2016-03-27 12:27 to be precise: s/Vcc/Vio/g 2016-03-27 12:29 even when Vcc doesn't rapidly drop to 0V, it's still a given that the whole circuit is in a quasi static state without any variables, after MCU stopped working. So it should be highly repeatable 2016-03-27 12:30 IOW discharge is still predictable (by calibration) 2016-03-27 12:31 factory side calibration 2016-03-27 12:31 the ADC is 16 bit. so i can make many ADC effects (not quite all, e.g., not non-linearity) vanish into bits that hold no useful value anyway ;-) 2016-03-27 12:31 you do a test series discharge time vs capacitor voltage, create a tab and that should be good enough 2016-03-27 12:32 (pre 2016-03-27 12:32 at least for precision in the sub-second range during 60s 2016-03-27 12:33 dictable) dunno. there are elements that may develop their own life before i can fully "neutralize" them. e.g., the OLED. 2016-03-27 12:33 how long will that take? 1s, or less? 2016-03-27 12:33 that's what i don't know :) 2016-03-27 12:34 no matter if 1s or less, the effect on timing is negligible 2016-03-27 12:34 definitely can't be larger than 1s of error 2016-03-27 12:34 same for glitches 2016-03-27 12:36 before trying to eliminate dirt effects, we need to consider if they matter at all 2016-03-27 12:37 otherwise the cure will be much worse than the disease 2016-03-27 12:40 if system leakage is in the order of 5 uA and we have about 50 uF of caps on the rail, a drop by 1 V would take 10 s 2016-03-27 12:41 fine 2016-03-27 12:42 and what are the variables in all this? 2016-03-27 12:42 I mean, the variables you can't determine even at runtime 2016-03-27 12:42 or even control at runtime 2016-03-27 12:43 the MCU loses sight of things around 1.71 V, realistically much earlier, since we want to clean up and close shop as soon as we go significantly below 3.3 V 2016-03-27 12:43 fine 2016-03-27 12:43 then system is in a very well defined state from that moment 2016-03-27 12:43 the only vatiable I see is temperature 2016-03-27 12:44 component variations, component state. e.g., the OLED has its own DC-DC converter that can keep things alive for a while 2016-03-27 12:45 so what? those won't change over lifetime of a particular device much 2016-03-27 12:45 you control component state 2016-03-27 12:46 that's the whole purpose of "closing shop" 2016-03-27 12:47 if factory side (R&D) calibration isn't sufficient, user needs to do a onetime calibration for the device (if you don't want to do this at factory for each device) 2016-03-27 12:47 not necessarily. e.g., i don't really know what's going on inside the OLED, and i eventually lose the ability to communicate with it. i can still command a reset, though, but i don't know how that affects residual charges and the things they drive 2016-03-27 12:48 you can however instruct the display to switch on or off all pixels, as long as shop not closed yet 2016-03-27 12:48 mmh. lemme check ... 2016-03-27 12:48 which I am pretty sure has identical effect on component state on all the OLEDs you ship 2016-03-27 12:50 there's no HRNG in OLED that creates massive uncertainties in component behavior 2016-03-27 12:51 when one OLED acts in a particular way once, it will do twice under same (history of) conditions, and other identical OLED components will as well 2016-03-27 12:52 there is a "quick" display off command. in fact, there are two, with not very clearly spelled out differences 2016-03-27 12:52 if there are massive fluctuations between components of same bin, you need per-device calibration to cope with those 2016-03-27 12:53 otherwise one time R&D 'calibration' will do 2016-03-27 12:55 tbh I'd rather power on all consumers to pull Vcc to GND as fast as possible 2016-03-27 12:55 of course, the more we clean up, the lower the leakage. so we're increasing that slope 2016-03-27 12:55 yes, exactly ;-) 2016-03-27 12:55 have some 100 uF anti-charge cap somewhere ;-) 2016-03-27 12:57 doomlord has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…] 2016-03-27 12:58 there are a number of nonlinear components like PTCs ;-) But honestly I'd not worry too much about all this, I'm pretty sure you can pull Vcc to GND in less than a second 2016-03-27 12:58 or at least to a steady state of maybe 1V5 above GND 2016-03-27 12:59 and you can do this very reproducibly 2016-03-27 12:59 irrespective of any random effects based on history of the component behavior (aka commands issued before) 2016-03-27 13:00 as I said, there's no HRNG in any of your components that would have massive impact on their behavior on power down 2016-03-27 13:01 only variable is temperature, yet to get evaluated if it matters at all 2016-03-27 13:04 you don't need a HRNG. it's enough if there is something that can be in different internal states you don't control. that's what i'm worried about. 2016-03-27 13:04 particularly system behavior from 1V5 down to 0V on Vcc is pretty reproducible 2016-03-27 13:04 and i can't actually test such things before having a number of devices 2016-03-27 13:05 you hardly have *any* devices with different internal stages after receiving same sequence of commands 2016-03-27 13:05 hence i prefer a "safe" design that itsn't at risk of needing a redesign at that point 2016-03-27 13:06 you don't need several devices, random different internal stages are a problem of *one* device 2016-03-27 13:07 i don't really have time for elaborate transitions. e.g., the OLED has transitions that are specified to take some 100 ms. i can't risk waiting for such things. 2016-03-27 13:07 which you can test right away. and designing for a 100% safe circuit no matter which possible nasty properties components might have is not possible 2016-03-27 13:08 huh? don't you know in which state the OLED is, before as well as after such transition? 2016-03-27 13:08 isn't that deterministic? 2016-03-27 13:08 (test right away) naw, there are several new components in the new design for which no prototype exists yet 2016-03-27 13:09 I just can tell you you're massively overengineering this 2016-03-27 13:10 if time is SOOOOO important, add a cmos clock and a goldcap 2016-03-27 13:10 i know the "high-level" state before and i know the state after. what happens in the middle, duh. inside the high-level state, there are internal sub-states that are hidden from me. 2016-03-27 13:10 heh ;-) 2016-03-27 13:12 may not be so difficult to be able to support page 3 (diode) and page 4 (fet) design in the same circuit, with a minor placement change 2016-03-27 13:13 both add more complications than they solve 2016-03-27 13:13 so you don't like the diode anymore ? 2016-03-27 13:14 my final design recommendation is: ADC/GPIO[1] - 3M3 - C1 - GND; [1] - schottky - VCC 2016-03-27 13:15 page 3 is pretty much that, except that i add a lower R between C1 and ADC/GPIO 2016-03-27 13:15 [2016-03-27 Sun 13:49:10] I just wonder what's the ABSMAX for the sMCU - particularly regarding voltage on any pin vs VCC (when Vcc = 0V and capacitor 3V) 2016-03-27 13:16 and no, your design is massively different in that respect to mine 2016-03-27 13:16 okay, that's a fair point 2016-03-27 13:17 the absmax is the usual vdd + 0.3 V but there is no clamping diode. so i don't quite know what happens. 2016-03-27 13:18 @ occasional lurkes: Vdd is another synonymous name for Vcc 2016-03-27 13:18 what really worries me in your design is the huge resistance amplifying even the tiniest GPIO leakage 2016-03-27 13:20 well, i guess i could always raise C1 to 47 uF or such :) 2016-03-27 13:20 as I elaborated you got the precision of a 1bit delta-slope converter ( precision of your timebase) for ADC when you do that PWM pattern I suggested. Completely irrespective of any leahage current however large or small 2016-03-27 13:21 well, actually the precision limit is the noise and resolution of the ADC, but *not* any prescaler formed by resistors and leakage current 2016-03-27 13:23 when you switch 8PWM) between 25% charging via R from Vcc and 75% discharging via R to GND and that keeps your voltage staedy, then you know your capacitor has exactly 25% of Vcc resp Vio 2016-03-27 13:23 s/8/(/ 2016-03-27 13:23 DocScrutinizer05 meant: "when you switch (PWM) between 25% charging via R from Vcc and 75% discharging via R to GND and that keeps your voltage staedy, then you know your capacitor has exactly 25% of Vcc resp Vio" 2016-03-27 13:24 i don't see how PWM would help with measuring. charging/discharging is not a problem, since we have low impedance anyway 2016-03-27 13:24 see above 2016-03-27 13:24 my final design recommendation is: ADC/GPIO[1] - 3M3 - C1 - GND; [1] - schottky - VCC 2016-03-27 13:25 3 components, one GPIO 2016-03-27 13:26 capacitor voltage probable to 0.1% precision almost irrespective to size of R 2016-03-27 13:27 no overvoltage issues at GPIO (when Vdd = 0V). Immune tio glitches 2016-03-27 13:28 yes, it still has the 'problem' of Vdd not falling to 0V for 20s, but we discussed that thoroughly during last 30min, it can get taken care of by software design 2016-03-27 13:28 by fast discharge as well as R&D or factory (per unit) calibration 2016-03-27 13:30 one particular OLED won't suddently start to behave randomly differnet, when you propperly "initialize" it during shutdown 2016-03-27 13:31 when there are N different states the component can be in, and you can't transition fast between them, all you need to do is to know the current state and apply the according calibration 2016-03-27 13:31 there is no HRNG 2016-03-27 13:32 your circuit is mostly deterministic 2016-03-27 13:33 (see above) hmm, that would help with the part of the error that is because of component variation. i wouldn't help with error due to chip temperature. i wonder if we can do such precise temperature compensation. after all, the possible V difference would be basically the whole measurement range, with the leakage current going through 3.3 MOhm. 2016-03-27 13:33 you know the state it's in so you can predict how it behaves 2016-03-27 13:33 you still didn't grok the PWM thing? 2016-03-27 13:34 i think i get the PWM thing: you charge to a well-known voltage, then measure, and thus calculate the leakage current 2016-03-27 13:35 sandeepkr__ has quit [Read error: Connection reset by peer] 2016-03-27 13:35 when you switch (PWM) between 25% charging via R from Vcc and 75% discharging via R to GND and that keeps your voltage staedy, then you know your capacitor has exactly 25% of Vcc resp Vio - capacitor voltage probable to 0.1% precision almost irrespective to size of R and leakage current 2016-03-27 13:35 no 2016-03-27 13:36 I do PWM charge/discharge to keep the ADC at a steady level that was the value when first probing the voltage of C1 2016-03-27 13:36 sandeepkr__ has joined #qi-hardware 2016-03-27 13:36 leakage current: irrelevant doesn't show up in equation 2016-03-27 13:37 same for size of R 2016-03-27 13:37 how does a PWM with fixed ratio hold an arbitrary initial voltage ? 2016-03-27 13:38 PWM= 42.4711%, so voltage on C = Vio/Vcc * 42.4711% 2016-03-27 13:38 sure. but how does this help with _measuring_ ? 2016-03-27 13:39 the trick is to adjust the PWM so it has same average voltage as C 2016-03-27 13:39 doomlord has joined #qi-hardware 2016-03-27 13:39 you're talking about a second RC circuit, for the PWM ? 2016-03-27 13:39 no 2016-03-27 13:41 with a given capacitor voltage (to probe) of 42.4711%, you first get a ADC that results in value 12345, then you start with a PWM of 50% (you can optimize by guessing the needed PWM from 12345) and watch the ADC. It will go up to 12350 or whatever, so you know your 50% are too high and you turn it down to 45% 2016-03-27 13:42 redu until your ADC again shows 12345 and your PWM vill be 42.4711% 2016-03-27 13:42 redo even 2016-03-27 13:42 ah, i see. so 2 (or more) measurements 2016-03-27 13:42 all percentages of voltage with respect to Vio/Vdd 2016-03-27 13:43 yes, multiple measurements 2016-03-27 13:43 temperature may still be an issue. if the MCU is actively moving things around, that may change the chip temperature a little. and since we're extremely temperature-sensitive there, ... 2016-03-27 13:44 but okay, that could probably be compensated, too 2016-03-27 13:44 the only variables determining precision are: the *relative* precision of ADC (noise and resolution), Vdd and your timer for PWM 2016-03-27 13:44 e.g., meas(temp), meas(Vc1), meas(temp), then do the PWM routing, also all the while measuring the temperature 2016-03-27 13:45 s/routing/routine/ 2016-03-27 13:45 how much could temperature change during 2 minutes? also where is temperature realyl coming in here. For sure not for probing, probbaly for Vcc discharge though 2016-03-27 13:48 sure for probing. don't forget that it can go up to 1 uA over a 100 C range. so that's about 1% of the measurement range for each C, assuming the change is linear 2016-03-27 13:49 hmm? 2016-03-27 13:49 we'll be trying to measure differences < 1% of the range 2016-03-27 13:49 so? 2016-03-27 13:49 range = [0, 3.3 V]. 1 uA * 3.3 MOhm = 3.3 V, 100% of the range 2016-03-27 13:50 you're confused :-) 2016-03-27 13:50 so even slight temp changes can throw us off 2016-03-27 13:50 no, leakage current doesn't show up in the equation 2016-03-27 13:50 max leakage is 25 nA at 25 C and 1 uA "over full temp range", i.e., at 125 C 2016-03-27 13:50 this "meter" is completely immune to leakage current 2016-03-27 13:51 but only if you're assuming constant leakage 2016-03-27 13:51 yes 2016-03-27 13:51 what i'm saying is that it changes 2016-03-27 13:51 during measuring period 2016-03-27 13:51 which is <1s 2016-03-27 13:52 I don't see how temperature could change during this period of time 2016-03-27 13:54 maybe it helps ro check wikipedia for sigma-delta ADC 2016-03-27 13:55 hmm, i get about 0.7 C, assuming we draw ~2 mA on average. that would be okay. 2016-03-27 13:56 this is a modified sigma-delta scheme 2016-03-27 13:57 i understand the process, my concern is the effect of leakage changing during the process. but it seems that the change would be relatively small. 2016-03-27 13:57 https://en.wikipedia.org/wiki/File:Fig._1b.svg 2016-03-27 13:59 you can bet on the effect being too small to calculate it without help of an electronic calculator ;-) 2016-03-27 14:00 it will be serveral magnitudes lower than your demanded precision of 1% 2016-03-27 14:01 _several_ 2016-03-27 14:06 i get about 1 C = 1%, so, zero magnitudes :) still, that's already 2016-03-27 14:08 how's the chance for the low power chip to heat up 1°C during less than 1s, in a semi-steady state 2 or 3 seconds after power up 2016-03-27 14:09 your stability of Vdd is a more concerning issue regarding ADC precision 2016-03-27 14:10 after all we use Vdd as reference voltage here, all the time 2016-03-27 14:12 dunno if your ADC has an internal stabilized refernce voltage so you could use ADC to determine actual voltage of Vio 2016-03-27 14:13 Vcc should be pretty stable, and when we ramp down, we already assume we fall rapidly, right ? :) i'd set the low voltage interrupt close to 3.3 V, so te MCU reacts within some 10% of the range. 2016-03-27 14:14 and yes, the ADC has a bandgap reference, too 2016-03-27 14:14 they pretty much all do nowadays ;-) 2016-03-27 14:15 so you can probe the real voltage during charging, while same time pulling ADC/GPIO high and probing it 2016-03-27 14:15 and you also can probe the real low voltage on ADC/GPIO = L 2016-03-27 14:17 now you have a very precise Vhigh and Vlow and a very precise PWM timing, you're set 2016-03-27 14:20 your capacitor voltage is Vlow + PWM% * (Vhigh - VLOW) 2016-03-27 14:20 which for 100% PWM = Vhigh ;-) 2016-03-27 14:20 aka charging 2016-03-27 14:23 Vlow (i.e., ADC = 0 V) will be close enough to GND, even if we go for the full 16 bit resolution :) 1 uA * 100 Ohm ~ 2 * 3.3 V >> 16 ;-) 2016-03-27 14:24 (10 or 12 bit probably makes more sense) 2016-03-27 14:25 well, you have a load current through discharging, via the 3M3, so your Vlow might be higher than 0V00 2016-03-27 14:25 yes, by up to 3.3 V / 3.3 MOhm = 1 uA :) 2016-03-27 14:25 actually it depends on Vcapacitor too 2016-03-27 14:26 aaah ok 2016-03-27 14:26 yes, right 2016-03-27 14:44 Vcc stability during ramp-down is no problem, after all you're either in charging mode and the slight variation in Vcc will be less than a glitch for this circuit, or you already entered discharging mode where Vcc doesn't matter at all 2016-03-27 14:46 we also have one 'problem' with this circuit: charging takes as long as discharging, so the recovery window after power return is rather long. No two battery swaps in sequence 2016-03-27 14:47 well, can get mitigated in software 2016-03-27 14:49 actually you just need to write history (with timestamps) to storage, to have the complete picture and do the "right thing" 2016-03-27 14:51 histroy can get deleted as soon as capacitor is supposedly recharged to 100% after a few minutes of charging time 2016-03-27 15:08 dandon has quit [Ping timeout: 260 seconds] 2016-03-27 16:38 sb0 has quit [Ping timeout: 244 seconds] 2016-03-27 16:50 sb0 has joined #qi-hardware 2016-03-27 16:57 fdcx has quit [Remote host closed the connection] 2016-03-27 17:01 fdcx has joined #qi-hardware 2016-03-27 17:06 fdcx has quit [Ping timeout: 260 seconds] 2016-03-27 18:20 *************** Announce :) 2016-03-27 18:20 New CHT hackbase subseason CHT4-D, MAY/JUNE 2016 @ http://next.totalism.org 2016-03-27 18:20 Would be awesome if some of you guys make it 2016-03-27 18:20 sandeepkr_ has joined #qi-hardware 2016-03-27 18:23 sandeepkr__ has quit [Ping timeout: 244 seconds] 2016-03-27 19:15 would love to, but seems too much of a dealbraker for my ordinary daywork tasks 2016-03-27 19:20 MistahDarcy has quit [Ping timeout: 252 seconds] 2016-03-27 19:20 dcht00: what the hell is that event anyway? 2016-03-27 19:20 I don't get it 2016-03-27 19:21 did you try to read from "Start here" ? 2016-03-27 19:22 ohhh 2016-03-27 19:22 nope 2016-03-27 19:23 dcht00: wow that's really interesting 2016-03-27 19:24 whitequark thanks - refresh site, i tried to make Context stand out more 2016-03-27 19:24 dcht00: hmmmm i would be interetsted to at least visit 2016-03-27 19:24 a few days? 2016-03-27 19:24 it's basically hacking in wild canary islands nature ....... on stuff that makes you not die / more comfortable :) 2016-03-27 19:25 awesome, all info you need should be on the pad, pls let me know if anything else is unclear 2016-03-27 19:30 dcht00: visa info? I need spanish visa, right? 2016-03-27 19:31 whitequark where are you based / nationality? 2016-03-27 19:31 russian 2016-03-27 19:31 live in hong kong though 2016-03-27 19:31 holy shit the tickets are worth a small fortune 2016-03-27 19:31 oh, i have no clue tbh ... i think russians do need a visa for Spain, yeah ... sorry about that 2016-03-27 19:32 the whole idea is to have it in Canary Islands which is very cheap and easy to come for EU people 2016-03-27 19:32 Hong Kong is quite a stretch 2016-03-27 19:32 $1827 and 44 hours one way 2016-03-27 19:32 you'd probably make it easier to Hillhacks in India ....... check http://totalism.org/calendar 2016-03-27 19:32 another awesome event 2016-03-27 19:33 .... I'll pass, a 44 hour flight is too much of a torture itself to pay that much for it lol 2016-03-27 19:39 44h honestly? 2016-03-27 19:40 I had a 12h to Teipei from Germany 2016-03-27 19:40 ok I had a 14h trip from germany to Gomera 2016-03-27 19:40 this still makes no more than 28h even from HK 2016-03-27 19:41 also the trip Germany - TPE was a 800EUR iirc 2016-03-27 19:41 Germany - Gomera was 300 2016-03-27 19:42 twoway 2016-03-27 19:43 hmm, TPE- Germany twoway might actually be USD 1800 then 2016-03-27 19:43 anyway, recheck, it sounds like you didn't find the best offer / flight yet 2016-03-27 19:47 dcht00: I studied the CHT website a few months ago already, thus I knew what it's all about 2016-03-27 19:47 :-) 2016-03-27 19:47 kudos 2016-03-27 20:08 wildlander has quit [Ping timeout: 264 seconds] 2016-03-27 20:34 DocScrutinizer05: the others are even more stupidly epxensive and not much shorter 2016-03-27 20:39 DocScrutinizer05: how do you like this one ? https://defuse.ca/b/Get2nVONkfdFVqQaFEkHQc 2016-03-27 20:49 whitequark: a wild search HKG-LPA, suggests ~USD 1k (in argentina) with 25h10 + 20h15, with KLM and AF. may 5, june 1. (since this seems to be a month-long event ?) 2016-03-27 20:51 then you just need a boat to make it to lanzarote :) 2016-03-27 20:54 hm, then my search engine fucked up 2016-03-27 21:01 wpwrak: I'm fixing the code 2016-03-27 21:02 rather, the algo, I'm prolly fscking up the code ;-) 2016-03-27 21:04 whitequark: maybe don't search from your iphone ;-) 2016-03-27 21:04 DocScrutinizer05 good to see we have friends everywhere :) 2016-03-27 21:04 if you send an email saying hi at a random time that'd make my day 2016-03-27 21:05 wpwrak: I don't have an iphone, nor did I search from a smartphone... 2016-03-27 21:06 whitequark: hehe ;) i was referring to iphone users sometimes getting shown more expensive offers than the rest of humanity 2016-03-27 21:06 quick search from me: 2016-03-27 21:07 12h + 1200€ to go from Hong Kong to Germany 2016-03-27 21:07 ahhhh, I had no idea 2016-03-27 21:07 DocScrutinizer05: (algo) i used a simple one to illustrate the concept. in real life, there would be more non-linear components, but factoring them in would just make it harder to see the basic idea 2016-03-27 21:07 from there it's another 5h to Lanzarote, with some layover 2016-03-27 21:08 the basic idea needs fixing 2016-03-27 21:08 but ....... I honestly wouldn't encourage you to spend 3 grand to travel here :) 2016-03-27 21:08 donations of 1% of that are very welcome though 2016-03-27 21:08 :) 2016-03-27 21:13 whitequark: it's lanzarote that makes it expensive. to las palmas it's about 1/2 of hkg-lanzarote 2016-03-27 21:14 mhrm 2016-03-27 21:14 (didn't try to vary dates. maybe that would change it, too) 2016-03-27 21:22 but it;s probably best to fly to gran canaria, then make the last hop with a local LCC, or maybe a ferry if that's common there. the local organizers should know 2016-03-27 21:23 the usual travel sites sometimes don't even list the LCCs, so you miss the most efficient routes 2016-03-27 21:25 wpwrak: http://paste.opensuse.org/86669840 2016-03-27 21:26 err linwe 19 is wrong 2016-03-27 21:27 duty = ADC_RANGE / adc_0 * 100 2016-03-27 21:28 btw, argentina just grew some 1.7 million km^2 ;-) http://buenosairesherald.com/article/211476/foreign-ministry-to-unveil-argentinas-continental-shelf-limits-on-monday- 2016-03-27 21:30 wpwrak: this code is still full of bugs and mess, but it demonstrates the idea 2016-03-27 21:30 no "* 100%" in c-ish syntax ;-) 2016-03-27 21:31 huh? 2016-03-27 21:32 that's very slow convergence. mine tries to converge much faster. that's especially imporant considering that also PWM goes through 3.3 V, so it may take a lot of time to change Vc1. 2016-03-27 21:32 ??? 2016-03-27 21:33 yours doesn't converge any way, it's a one time calculation that tries to figure leakage current 2016-03-27 21:33 dandon has joined #qi-hardware 2016-03-27 21:33 anyway, in think the main idea is to adjust C1 through PWM and then measure what we got. whether we then operate with deltas or stepwise approximation, is a second order problem 2016-03-27 21:34 no, the idea is to NOT adjust C1 and keep it at a given ADC value instead. Finmd the PWM duty that matches this condition 2016-03-27 21:35 well, a bit like euler's method :) 2016-03-27 21:35 a bit like sigma-delta ADC 2016-03-27 21:35 but you do adjust C1 2016-03-27 21:35 delta-sigma? 2016-03-27 21:36 only temporarily until it changes one tick on ADC so I know if PWM is too high or too low. Then I immediately resore it to its original voltage 2016-03-27 21:37 actually NOISE_THRESHOLD = 2 ticks 2016-03-27 21:38 C1's voltage is meant to keep constant (+-2 ticks) during complete PWM-ADC 2016-03-27 21:39 while PWM gets adjusted so it keeps C1 voltage at that ADC level for long time (NUM_SAMPLES = 20) 2016-03-27 21:39 you can make NUM_SAMPLES = 2000 if you like 2016-03-27 21:43 ooh, and that code for sure is no C syntax, rather a tad pythony 2016-03-27 21:47 only temporarily until it changes one tick on ADC <(abs(adc_t - adc_0) > NOISE_THRESHOLD) ; line25> so I know if PWM is too high or too low <(adc_t - adc_0) >0; line28> 2016-03-27 21:48 Then I immediately restore it to its original voltage 2016-03-27 21:49 lines 31, 36 are >> // adjust duty TODO: short hack, optimize!<< and actually need optimization 2016-03-27 21:50 there Euler comes in 2016-03-27 21:50 N +- N/2 +- N/4... 2016-03-27 21:51 those duty++ and duty-- should be outside the loops, right ? 2016-03-27 21:51 no 2016-03-27 21:52 not really, I kept them inside the loops since duty needs the more adjustment the longer recovery takes 2016-03-27 21:52 might overshoot though 2016-03-27 21:53 you could keep them outside the loops too 2016-03-27 21:54 but ideally you find some sort of Euler, based on i counter in 22-25 2016-03-27 21:54 the 22-25 loop will iterate the longer, the closer duty is to the target 2016-03-27 21:55 so for higher i, the duty adjustment should be lower 2016-03-27 21:56 duty++ and -- are really just meant symbolic 2016-03-27 21:57 yeah, you'd probably want some t++ and then duty += f(t) or such 2016-03-27 21:57 ((will iterate the longer...)) when it iterates > NUM_SAMPLES times, duty is considered perfect 2016-03-27 21:57 yes 2016-03-27 21:57 oops is it t? 2016-03-27 21:57 no it's i, line 21 2016-03-27 21:57 t for the time you "correct" 2016-03-27 21:57 a new variable 2016-03-27 21:58 DANG!!! 2016-03-27 21:58 25: until ((i++ > NUM_SAMPLES) or (abs(adc_t - adc_0) > NOISE_THRESHOLD)) 2016-03-27 21:58 since duty is measured in adc counts, while the correction loops count in loop counts 2016-03-27 21:59 (i++) hehe :) 2016-03-27 21:59 duty is measured in percent 2016-03-27 21:59 line 6 2016-03-27 21:59 i just used a float ;-) 2016-03-27 21:59 you prolly want to make that ppm 2016-03-27 22:00 polly some obscure implementation-dependent unit :) 2016-03-27 22:00 nah, it's a plain simple integer, see line6 2016-03-27 22:01 and line3 2016-03-27 22:02 make line6 usleep(100000 - pw) or whatever you like 2016-03-27 22:02 it determines range of duty and frequency of PWM 2016-03-27 22:02 sure, in the end it's an integer. everything is :) 2016-03-27 22:03 this one reasonably is a 12 to 16bit integrer, unsigned 2016-03-27 22:04 it doesn't make sense to have it higher precision than your ADC can do and actually does 2016-03-27 22:05 you also can't feed a real to usleep 2016-03-27 22:08 i have my own timekeeping anyway. well, i do happen to have a function called usleep ... 2016-03-27 22:11 http://paste.opensuse.org/94860912 2016-03-27 22:17 http://paste.opensuse.org/80816228 even 2016-03-27 22:18 usleep(MAXPWM) is the frequency (actually period) of your PWM signal 2016-03-27 22:20 if you need higher resolution (higher MAXPWM) and same time higher PWM frequency, you should divide all parameters to usleep() by a constant factor 2016-03-27 22:27 MistahDarcy has joined #qi-hardware 2016-03-27 22:27 one more bug smashed: http://paste.opensuse.org/20517572 2016-03-27 22:27 now I actually should add (C) GPL2 J.R. to this 2016-03-27 22:28 the shorter the code, the better ;-) 2016-03-27 22:32 OHMY 2016-03-27 22:33 s/ (adc_t - adc_0) >0) / (adc_t > adc_0) / 2016-03-27 22:34 wpwrak: ^^^ 2016-03-27 22:36 yeah :) 2016-03-27 22:36 i just c-ified it 2016-03-27 22:36 highly welcome 2016-03-27 22:37 it's crap, syntax wise 2016-03-27 22:37 https://defuse.ca/b/0iPMvsYL0SlBmXqeRyxtC6 2016-03-27 22:37 heck, I wrote my last c code some maybe 6 years ago 2016-03-27 22:38 mmh. two small bugs 2016-03-27 22:39 // sample Vc1 + Ileak(t0) * R1, sounds odd 2016-03-27 22:39 well, maybe it's actually correct, however puzzling# 2016-03-27 22:41 add "Vadc =" ? 2016-03-27 22:41 or what is the puzzling bit ? 2016-03-27 22:43 the equation is puzzling me 2016-03-27 22:44 yes, it's actually correct 2016-03-27 22:44 I'd write "sample relative Vc1" 2016-03-27 22:44 stop 2016-03-27 22:44 making it sample Vadc = Vc1 + Ileak(t0) * R1 2016-03-27 22:45 it's a tad out of scope how Ileak calculates Vadc here 2016-03-27 22:45 else i need to define what a "relative Vc1" is 2016-03-27 22:45 now you need to define what Ileak is ;-) 2016-03-27 22:45 oh, didn't i talk enough about leakage current before ? :) 2016-03-27 22:45 here yes ;-D 2016-03-27 22:45 lol 2016-03-27 22:45 in the mail, too ;-) 2016-03-27 22:45 aah ok 2016-03-27 22:46 well nevermind 2016-03-27 22:46 I'm ore worried about INCREMENT 2016-03-27 22:46 and heck, another bug 2016-03-27 22:48 http://paste.opensuse.org/58706276 fixed 2016-03-27 22:48 (took the pwm adj out of the loop) 2016-03-27 22:48 posted: http://lists.en.qi-hardware.com/pipermail/discussion/2016-March/011021.html 2016-03-27 22:49 you also might actually want to probe for (and use) V3_3 instead of using a constant 2016-03-27 22:49 line6 2016-03-27 22:49 and line30 2016-03-27 22:50 the rest looks good to me 2016-03-27 22:51 it's not real code. 3.3 is just 3.3 V :) 2016-03-27 22:51 s/do pulse(100);/do pulse(1.0);/ 2016-03-27 22:52 yes, but 3.3V is not warranted 2016-03-27 22:52 this is actually Vio_h 2016-03-27 22:52 yes, fixed in the post 2016-03-27 22:53 sure. but Vio_h(I very tiny) is Vcc is 3.3 V 2016-03-27 22:53 else something is broken :) 2016-03-27 22:53 for me INCREMENT is (NUM_SAMPLES - i) 2016-03-27 22:54 for you it's SAMPLES - i 2016-03-27 22:54 err 2016-03-27 22:54 SAMPLES/i ? 2016-03-27 22:55 a real 0<=duty<=1 is really messy to handle 2016-03-27 22:55 i think one would want to calculate the quanta that went into or out of C1 2016-03-27 22:56 duty +- i/SAMPLES, now that looks correct 2016-03-27 22:57 probably more complicated. but i'm too lazy to do the math now :) 2016-03-27 22:57 me too ;-) 2016-03-27 22:58 and with a little luck there may be a simple direct temperature correction that works just as well, and we don't need all this ;-) 2016-03-27 23:00 During all this, we read back Vc1 with the ADC (which is affected by leakage) AND COMPARE IT TO INITIALLY READ VALUE. If the values read back stay long enough AT INITIAL VALUE within the expected noise bounds, our duty cycle matches the correct Vc1 voltage 2016-03-27 23:01 something like Ileak = 25 nA * max(1, tempC - 25) * (3.3 / 2 - real_Vc1); // or such 2016-03-27 23:01 it's already posted :) let's see if anyone has questions 2016-03-27 23:02 s/ For faster convergence, INCREMENT should be a function of the time it took to pull Vc1 back to the original value./ For faster convergence, INCREMENT should be a function of the time it took to pull Vc1 AWAY FROM THE original value./ 2016-03-27 23:03 that may be easier, indeed. i was thinking of some f(t, duty) 2016-03-27 23:03 http://paste.opensuse.org/58706276 2016-03-27 23:03 but again, one would have to do the math. not sure if duty really disappears if you use i 2016-03-27 23:04 sorry? 2016-03-27 23:04 lost me on the second half 2016-03-27 23:05 i'm not sure if it's just a function of "i", or if it would still be a function of i and "duty" 2016-03-27 23:05 duty += i/SAMPLES 2016-03-27 23:05 resp -= 2016-03-27 23:06 as i said, too lazy to do the math :) 2016-03-27 23:06 s$ INCREMENT $ i/SAMPLES $ 2016-03-27 23:07 s$ INCREMENT $ (i/SAMPLES / 4) $ 2016-03-27 23:07 or whatever factor works best 2016-03-27 23:08 it's just an optimization, you can spend weeks to optimize the optimization, or just go 'Meh!' 2016-03-27 23:08 it just should converge 2016-03-27 23:09 too high feedback and you get oscillation 2016-03-27 23:16 anyway, time to search the eggs ;-) 2016-03-27 23:34 (oscillation) yes, and the thing needs some more timeouts anyway, right now, it could easily loop somewhere forever 2016-03-27 23:58 arossdotme has joined #qi-hardware 2016-03-27 23:59 Ornotermes has quit [Ping timeout: 276 seconds]