#avr | Logs for 2016-05-28

Back
[04:45:36] <superware> hi liwakura :)
[04:50:26] <superware> can someone please help me out? I'm trying to drive a DMX512 device with an ATmega328P since yesterday. I'm running at 16MHz, I have a MAX485 with RO not connected, RE and DE to VCC, DI to ATmega PD1 (TXD), A to DMX device D+ and B to D-, and the code (USART interrupt driven): http://pastebin.com/vGU3UQrj
[04:52:02] <anton02> is it possible to have a passive band pass filter with narrow passband and where the pass band is a plateau
[04:52:06] <anton02> my narrow I mean 1khz
[04:52:33] <anton02> and by passive I mean no op-amps. It can have BJTs though if that helps
[05:17:43] <Jan-> hihi avr people :)
[06:35:10] <julius> hi
[06:35:13] <julius> anybody got some time to look over my "switch a 12v water pump with a atmega" question? http://electronics.stackexchange.com/questions/236865/switching-a-12v-2-5w-pump-with-a-atmega-relay
[06:38:59] <Jan-> Relay?
[06:39:41] <NicoHood> I added an ATOMIC_BLOCK(ATOMIC_RESTORESTATE) to my code instead of the SREG manual trick. But this adds 12 more bytes of flash to my code. Is there any reason why to use the atomic block anyways?
[06:39:48] <NicoHood> talking about this part in my commit: https://github.com/NicoHood/IRLremote/commit/0710e35e309e279ad69786ef754088eeb2a505a8#diff-1eee0fe39daec0c873bdcc9353abcdd1L42
[07:15:48] <kre10s_> julius, Why not use an n channel mosfet to switch the pump current directly?
[07:17:36] <kre10s_> all you need is an n channel mosfet and a pull down resistor. The pull down resistor goes between the gate and ground. the source is connected to ground, and the drain is connected to the pumps negative terminal. 12v feeds the pumps positive terminal.
[07:18:51] <kre10s_> the pull down resistor is needed to prevent the gate from wandering around during reset or when the IO driving the mosfet is High-Z.
[07:21:42] <kre10s_> When selecting a mosfet all you need to make sure, is that it has an acceptable on resistance at the driving voltage (~5V in your case). That it will turn off (have high resistance) at the IO's low level. and will support the instantaneous current of ~2A to get the pump started.
[07:26:47] <Jan-> kre10s_: isn't there a chance that inductive effects from the motor could affect the FET
[07:26:52] <Jan-> high voltage transients and so on?
[07:29:19] <kre10s_> nah... Its not like It's a high power pump. But I'm reading now in the Bedienungsanleitung that the pump is 12V/50Hz. you will need an h-bridge to run it off of DC.
[07:31:13] <kre10s_> The wall adapter supplied with the pump probably produces 12V AC. If building an H-bridge is too complex for you using a relay is your best option.
[07:32:26] <Jan-> relay is way simpler
[07:32:35] <Jan-> H bridge is simple in theory but making them work is a bit of a mare
[07:32:36] <kre10s_> Yes. Either way I would still use a mosfet to drive the relay, and place a diode across the relay coil.
[07:33:21] <Jan-> that's what I would do
[07:33:26] <Jan-> keep it simple
[07:34:36] <kre10s_> You can buy complete H-bridge chips from say, infineon that require almost no external components and can drive you pump directly.
[07:34:55] <Jan-> Or you could use a $2 relay :)
[07:34:59] <Jan-> I dunno.
[07:35:11] <Jan-> If you're going to be switching this pump a lot, a solid state solution might be best.
[07:35:20] <Jan-> Otherwise, eh. I'd go for the relay.
[07:35:40] <julius> kre10s_, also a good idea
[07:38:39] * Jan- and phil are going out for lunch
[07:38:40] <Jan-> mmm thai
[07:45:31] <julius> kre10s_, got a mosfet there that can do 3,7mOhm at 10v. with a 2a stall current for the pump, would that mean a wort case power loss of: u = r*i = 0.00037 Ohm * 2A = 0.00074v p = u*i = 0.00074*2A = 0.00148W ~1.5mW?
[07:47:04] <kre10s_> whats the mosfet product code?
[07:49:21] <julius> aot240l
[07:50:23] <kre10s_> D: that thing is like 4.6 EURO!
[07:51:53] <julius> its from china
[07:52:05] <julius> it wasnt that expensive
[07:52:52] <kre10s_> well. you can definitely use it. Its got a continuous drain current of 120A.
[07:53:22] <julius> yeah its overkill concerning the current
[07:53:41] <kre10s_> the on threshold is 3-4.5 so you can drive it with your micro.
[07:53:51] <julius> i believe it was like 5 bucks for 10 chips
[07:53:58] <julius> yeah its ttl
[07:54:28] <julius> in gemrany i could probably not even but that thing and if, its like you said expensive
[07:55:24] <julius> JanC, it will probably be running twice a day
[07:56:58] <kre10s_> mouser has it for 4.67EUR... your thermal resistance junction to ambient is 62.5 C/W so at 1.5mW a heatsink would be like a spoiler on a tractor.
[08:02:33] <julius> just checking if i got the numbers wrong
[08:03:02] <julius> if 1.5 is correct....theres no need for a heatsink
[08:08:14] <GeneralStupid> julius: just like a tractor doesnt need a spoiler …
[09:29:41] <Casper> julius: remember that stuff from china is most likelly counterfeit, so double check the math and don't use it in mission critical thing
[09:32:24] <Chillum> as opposed to those electronics not from China
[09:34:39] <julius> casper is right, could be
[09:34:59] <julius> its for watering a plant at home, worst case scenario is that the chip kills itself
[09:35:30] <Chillum> true
[09:35:41] <julius> Chillum, the reseller i bought from on aliexpress could have counterfitted those chips
[09:36:07] <Chillum> ya I know. common with transistors because they have such common pins and packages
[09:36:14] <Chillum> not hard to relabel something cheaper
[09:36:48] <julius> and theres the other chance that they overproduced for some big order and sell the rest a bit cheaper
[09:38:14] <julius> anyway theres a switch at the pump, one position for pump only, one position for light only and one position for both
[09:39:21] <julius> 2 wires going in (+12v and gnd) and 3 comming out of the switch
[09:40:29] <julius> but so far i was unable to get the pump going, theres ground labeled inside the switch. but if i connect that to ground and one of the other pins to 12v the light goes on
[09:41:01] <julius> changing the connection but keeping ground the light also goes on a bit darker
[09:42:20] <julius> without pictures my words wont make much sense
[09:43:10] <Casper> julius: worst case scenario is that the fet short itself "drain to gate" and kill whatever is driving it
[09:48:16] <julius> ah look at that, its not a ac/dc converter...its ac/ac
[09:48:45] <julius> that would be a atmega...i can live with that
[11:11:21] <kre10s_> julius, yes. according to the manual the pump is AC driven. So I assume that wall adapter is a simple transformer.
[11:13:54] <kre10s_> actually theres a table in the manual that says transformer: input 230v/50Hz output 12v/1200mA ... page 14.
[11:14:55] <kre10s_> so what you should be doing is just placing the pump in series with the relay and feeding it from the wall adapter..
[11:36:33] <kre10s_> there is no 'ground' in your case. measure the resistance across the terminals. the two low resistance paths will be the light and pump the high resistance path should be the sum of the light and pump. DC 12v may get the light to turn on, but you need 12vAC to make the pump turn.
[11:40:48] <carabia> Does itoa() write the whole buffer?
[11:41:02] <carabia> overwrite, rather
[11:49:03] <kre10s_> no.
[11:49:30] <kre10s_> It will use however many bytes is required to represent the number in the specified radix.
[11:49:58] <kre10s_> it will also place a null byte on the end.
[11:50:24] <carabia> At the end of the ascii, or at the end of the buffer?
[11:52:40] <kre10s_> at the end of the ascii representation of the number. so if the number is -123456 base 10 and you use that function with a radix of 10 the buffer will be "-123456\0".
[11:53:33] <carabia> Got it.
[11:53:40] <carabia> That's probably the issue here yeah.
[11:53:57] <carabia> Figured it would only use the bytes it needed and no fucking around with NUL
[11:54:36] <kre10s_> that would be highly inconvenient... how would you tell where the number ends?
[11:55:15] <carabia> Well yeah that's true. You could make it return a length... I don't know. Might have to roll my own itoa
[11:56:28] <kre10s_> why? just pass it a larger buffer.
[12:00:02] <carabia> No reason, for my specific application I kind of have to do it backwards if i want to use the standard itoa, then. But it's okay.
[12:14:48] <julius> kre10s_, thats why its so heavy
[12:15:48] <julius> kre10s_, yes the light goes on...that kept me thinking that i missed the right pins. nice trap
[12:16:55] <Casper> variable length variable? malloc hell?
[12:24:11] <kre10s_> Casper, what is malloc hell?
[12:27:22] <Casper> malloc on avr is costly
[12:33:10] <kre10s_> considering that some avrs have only 256Bytes of ram...
[12:37:03] <Casper> and that malloc take some of that
[12:37:05] <Casper> and cpu
[13:20:26] <rue_house> on small microcontrollers you must learn to stream data, but buffer it
[13:20:29] <rue_house> er
[13:20:30] <rue_house> not
[13:20:35] <rue_house> on small microcontrollers you must learn to stream data, not buffer it
[13:55:36] <kre10s_> yea. But sometimes even streaming is hard. I need to shift all the bytes in an external sram page right by 1. for that I need to read, shift, write. My sram is accessed via SPI and although i can read bytes at a time, reading an entire page is allot faster. problem is, a 256 byte buffer would occupy 1/2 the local ram.
[13:58:21] <kre10s_> call only pushes the return addr onto the stack right? assuming addresses are 16bit if my functions don't use the stack i should theoretically be able to make 128 nested function calls with 256B of ram?
[14:08:19] <Casper> no
[14:08:35] <Casper> it push 7-13 bytes into the stack
[14:08:46] <Casper> per function call
[14:09:07] <Casper> more if you have arguments
[14:25:46] <kre10s_> 7? what data is pushed to the stack? all the docs I read say return addr of 22 bits.
[14:30:59] <Emil> Can you recommend a good online resource to learning avr assembly?
[14:44:18] <Casper> Emil: the datasheet is a good start
[14:45:25] <Xark> Emil: If you need more http://www.avr-tutorials.com/assembly/basics-assembly-language (or Google, there are others).
[14:45:31] <Emil> Casper: It's a pain and doesnt really explain how to write complete programs, just bits. The Instruction set manual is comprehensive but a pain to go through
[14:45:42] <Emil> Xark: thanks
[14:47:32] <Xark> Emil: Also, the 328 datasheet will just have a "one line" per opcode (with cycle times etc.). You really want to study: http://www.atmel.com/images/atmel-0856-avr-instruction-set-manual.pdf . This has a page (or more) per opcode and a small example etc.
[14:48:12] <Xark> Do note that not all AVR instructions are available on all chips (so the "one line" reference is useful for a specific chip - and with specific timings).
[14:48:47] <Emil> Yeah, it is a pain to go through and doesnt explain how to write complete programs, either but it is a great resource
[14:48:57] <Emil> Thanks
[15:04:21] <cehteh> mhm funny .. got this ds3231 china boards .. for what is there a eeprom (24c32n) on it?
[15:05:37] <cehteh> https://www.amazon.de/gp/product/B00K67X496/ .. oh its even on the description :D
[16:56:59] <Jan-> hihi avr people
[17:06:41] <carabia> Does anyone know of a european electronics warehouse that sells the latest bare-pcd atmel ice (or whatever it's called)?
[17:07:27] <carabia> (for a reasonable price, obv.) I know digikey sells it quite cheap I think, but shipping will be insane, and i'm in no need of parts right now...
[17:07:50] <carabia> bare-pcb* even
[17:12:10] <Jan-> I may need to read a battery voltage into an AVR's A/D converter. The battery swings between, roughly, 11 and 17 volts.
[17:12:42] <Jan-> Assuming I need to divide it down such that the 17v becomes 5v, which is easy enough, then the 11v would become about 3.5 or 4v.
[17:12:58] <Jan-> This doesn't seem to me to offer a lot of A/D resolution. Should I consider some sort of amplifier solution?
[17:15:06] <rue_house> Jan-, if you want more resolution, drop the voltage down a bit with some zener diodes, to say about the 10V level, then divide it a bit
[17:17:37] <rue_house> (Vb-10)/1.4
[17:18:13] <Jan-> Um, er.
[17:18:19] <rue_house> Vb----]<|----\/\/\/----+----\/\/\/----gnd
[17:18:19] <Jan-> Won't that just crop it off to 10V
[17:18:30] <Jan-> so that it doesn't move
[17:18:35] <rue_house> 10V 10k 25k
[17:18:53] <rue_house> avr hooks to the +
[17:18:58] <Jan-> the idea is to sense the battery voltage going down.
[17:19:00] <Jan-> Not to create a reference.
[17:19:16] <rue_house> when you do a zener like ^^^ it just subtracts 10V
[17:20:17] <rue_house> so the resolution of that would be... 0.0068
[17:20:39] <Jan-> Oh.
[17:20:46] <Jan-> The zener is floating on top of the resistors.
[17:20:50] <rue_house> (10 bit)
[17:20:57] <Jan-> well we can sample slow, so yes.
[17:21:10] <Jan-> it would be nice to be able to sense the voltage of the whole stack of four cells, so we can tell if any cell is getting low.
[17:21:18] <Jan-> I guess that could be done similarly, just with more zeners and resistors
[17:22:38] <cehteh> Jan-: i have code for a battery (lipo) watchdog
[17:22:50] <Jan-> Ooh.
[17:22:57] <Jan-> This one needs to handle four series cells.
[17:23:05] <Jan-> We'd like fuel gauging, but it may be a bit beyond us.
[17:23:08] <cehteh> just voltage divider against the internal 1v1reference
[17:23:47] <Jan-> does this mean I need to divide the battery voltage down to max out at 1.1v or something
[17:24:01] <cehteh> yes
[17:24:29] <cehteh> plus a bit more and some calibration in software because resistor tolerances
[17:25:08] <cehteh> with oversampling&some luck its even a bit more than the 10 bit
[17:25:23] <Jan-> Eesh.
[17:25:26] <Jan-> This is getting complicated.
[17:25:30] <cehteh> nah
[17:25:30] * Jan- *headscratch*
[17:25:32] <cehteh> dead simple
[17:25:38] <Jan-> yah, dead complicated :(
[17:25:52] <cehteh> lol
[17:25:59] <cehteh> just rolling average
[17:26:15] <cehteh> prime the value by adding lets say 16 values
[17:26:31] <cehteh> then for each new value you add, substract the previous average
[17:27:01] <Jan-> that I can do.
[17:27:08] <Jan-> the issue is all the external electronics.
[17:27:12] <Jan-> Still I guess it's all passives.
[17:27:51] <cehteh> i use that to switch the output on and off ... also for fun i measure the voltage drop over the output fet .. which gives me the current sensing (bit coarse but works for overcurrent protection)
[17:28:09] <rue_house> was .0068V not enough resolution?
[17:28:16] <cehteh> http://public.pipapo.org/Battswitch2.png
[17:28:29] <cehteh> http://git.pipapo.org/?p=battswitch.git;a=summary << da code
[17:29:11] <rue_house> jan, 1 zener and 2 diodes
[17:29:16] <rue_house> er
[17:29:20] <rue_house> jan, 1 zener and 2 resistors
[17:29:31] <rue_house> make the 25K a 50K 10 turn pot tho, so you can adjust it
[17:29:45] <Jan-> well sure.
[17:29:51] <cehteh> rue_house: for bias?
[17:29:54] <Jan-> or I guess calibrate in mathematics.
[17:30:11] <rue_house> adjustable divider, cause math dosn't simulate things properly, ever
[17:30:25] <cehteh> huh
[17:30:31] <cehteh> works well enough for my case
[17:30:41] <cehteh> but i can also recommend a trimmer
[17:30:59] <cehteh> either works
[17:32:01] <rue_house> Vb----]<|----\/\/\/----+----\/\/\/----gnd
[17:32:15] <Jan-> that for each cell I guess.
[17:32:18] <rue_house> 10V 10k 50k-10 turn pot
[17:32:25] <cehteh> some avr's have differential ADC ... could make things simpler as well
[17:32:32] <Jan-> why d'you sy 10k and 50k?
[17:32:33] <rue_house> no, cause your top voltage is different every cell
[17:32:45] <Jan-> well yes different (or no) zener
[17:32:53] <rue_house> zippo:/files/programming/c/resistor$ ./R1
[17:32:54] <rue_house> +V
[17:32:54] <rue_house> R2
[17:32:54] <rue_house> VR1
[17:32:54] <rue_house> R1
[17:32:54] <rue_house> GND
[17:32:56] <rue_house> Divider supply: 7
[17:32:58] <rue_house> top resistor: 10000
[17:33:00] <rue_house> divider output: 5
[17:33:02] <rue_house> R1 is :25000.000000
[17:33:04] <rue_house> R2 dissipates 0.000400w
[17:33:06] <rue_house> R1 dissipates 0.001000w
[17:33:08] <rue_house> 17V - 10V (zener) = 7V
[17:33:12] <rue_house> 7V->5V
[17:33:14] <rue_house> ^^
[17:33:27] * Jan- copypastas
[17:33:31] <Jan-> I guess I get the idea.
[17:33:38] <rue_house> you always set an adjustable pot to twice the value you expect to have it set to
[17:33:42] <Jan-> well sure.
[17:33:54] <rue_house> so that centre is the expected position
[17:34:03] <cehteh> be careful about the input impedance on the ADC when you want to sample faster
[17:34:05] <rue_house> then you have the most adjustability either way
[17:34:08] <Jan-> I always assumed that part of it was fairly doable, even if it's going to be like 12 external parts.
[17:34:33] <rue_house> a .01uF cap on the adc pin wouldn't hurt, its not like battery voltage changes really fast
[17:34:35] <Jan-> What I'm not so sure about is the fuel gauging, other than that we can probably get reasonable-ish results just by watching the voltage.
[17:34:57] <cehteh> whats the application for this?
[17:34:58] <rue_house> an amp is a coulomb per second
[17:35:16] <Jan-> cehteh: it's a lithium ion battery pack
[17:35:20] <Jan-> for general purpose use
[17:35:37] <rue_house> damn 3:00 already
[17:35:39] <cehteh> switching something off when battery goes flat?
[17:35:51] <cehteh> or just monitoring?
[17:36:30] <Jan-> both.
[17:36:36] <Jan-> ideally they want a time-to-empty
[17:36:52] <Jan-> which I suspect we can do by just watching the voltage, especially if we do a characterisation pass and record the voltage curve as it discharges.
[17:36:58] <Jan-> then compare
[17:37:00] <cehteh> thats somewhat harder
[17:37:25] <cehteh> voltage curves are drifing with current, temperature, moon phase
[17:37:28] <Jan-> Well it's not that hard to do what I just described, but I'm not sure how accurate it would be.
[17:37:47] <Jan-> there are chips that do it, but none of them are really accessible to the hobbyist :(
[17:37:58] <cehteh> you can calculate the discharged energy
[17:38:03] <cehteh> yes
[17:38:09] <Jan-> You can, but like you said, that's only one part of it.
[17:38:19] <Jan-> The idea is to avoid them wrecking the cells with deep discharge.
[17:38:28] <cehteh> i just watch voltage and turn off at some point, dont calculate ETA
[17:38:43] <Jan-> It'd be interesting to at least try it and see.
[17:38:44] <cehteh> take a peek at my code
[17:39:00] <Jan-> given these will be used on lighting devices and cameras the draw is likely to be fairly constant so it may work usably well.
[17:39:29] <cehteh> http://git.pipapo.org/?p=battswitch.git;a=blob;f=src/battswitch.c
[17:39:38] <cehteh> runnin the avr at 128khz :D
[17:39:53] <Jan-> for low power consumption?
[17:40:11] <cehteh> well .. more for the show :D
[17:40:15] <cehteh> ideally yes
[17:40:28] <cehteh> but the voltage divider prolly draws more than the avr
[17:40:29] <Jan-> we're building the packs, so they'll have a reed switch in the pack and a magnet in the mount
[17:40:35] <Jan-> so it can be absolutely disconnected
[17:40:54] <cehteh> a wet will do
[17:40:57] <cehteh> fet
[17:41:02] <cehteh> dont need a relais
[17:41:05] <Jan-> then just a pushbutton across the switch so you can get an idea of charge when it's off the mount
[17:41:28] <Jan-> it would be nice to be able to detect when it's being charged. I guess you just watch for a rising voltage :)
[17:42:13] <cehteh> but notice that the voltage divider draws little current, and the ADC input impedance should be less than 15k .. you may buffer it with a small cap or run the adc slowly
[17:42:39] <cehteh> keeps things simple first, make it work, add features later
[17:42:50] <Jan-> slowly should still mean hundreds of samples a second which is way more than we need.
[17:42:56] <Jan-> slow is fine
[17:43:30] <cehteh> i trigger by timer, have forgotten, 4 measurements per second or so
[17:43:38] <Jan-> something like that
[17:43:55] <Jan-> I'm going to do this with an arduino board, just to make it easy for people to do it. so it'll be an atmega328p
[17:43:56] <cehteh> but then you cant calculate columbs
[17:44:17] <cehteh> you know that measurement is a momentary value not the average since last
[17:44:48] <cehteh> calculating energy used would require some careful filtering and bit higher sampling frequency
[17:44:49] <Jan-> Sure, but it should be OK so long as the load is reasonably constant. If the load isn't reasonably constant you can't calculate an RTE time anyway.
[17:45:04] <cehteh> thats true
[17:45:22] <cehteh> but then you could just countdown a timer too :D
[17:45:31] <Jan-> well that's basically what I'm doing.
[17:45:40] <Jan-> just slaving that timer to watching the battery voltage drift down
[17:46:29] <cehteh> i once tried to make that clever and it didnt worked :D
[17:46:35] <cehteh> made it simpler, worked
[17:46:48] <Jan-> well plan A is just to get it to read the whole pack voltage.
[17:46:57] <Jan-> Plan B is get it to read all the cells and do over/under voltage protection
[17:47:18] <cehteh> if you want beepers they are available for cheap
[17:47:25] <cehteh> but not switching off
[17:47:30] <Jan-> Plan C is to get it to do the characterisation, and just spit out periodic voltage measurements to serial so we can build a database of the curve.
[17:47:31] <cehteh> RC tools
[17:47:41] <cehteh> w/ single cell watching
[17:47:50] <Jan-> Plan D is get it to use a set of that data to estimate charge and provide a timer.
[17:47:53] <cehteh> you can get these for $2.50 or so
[17:47:59] <Jan-> That sounds like a sensible series of plans, no? :)
[17:48:14] <Jan-> oh and the last thing we want is a beeper, it's to work on movie sets!
[17:49:00] <Lambda_Aurigae> any little piezo speaker should work.
[17:49:01] <cehteh> yeah guessed so
[17:49:05] <cehteh> http://www.hobbyking.com/hobbyking/store/__74024__HobbyKing_8482_Lipo_Voltage_Checker_2S_8S_.html
[17:49:11] <cehteh> shit loud :D
[17:49:44] <Jan-> the idea is a gentle red pulsating light.
[17:49:55] <Jan-> nothing too obnoxious or attention-grabbing
[17:50:01] <cehteh> replace the beepers with high power leds
[17:50:15] <Jan-> did you guys hear about that incident a couple years back where christian bale yelled at a member of the film crew?
[17:50:49] <Jan-> ...that was for distracting him with a light.
[17:51:07] <cehteh> hehe
[17:52:18] <Jan-> it's funny until you're there, as an easily replaceable member of a film crew, with a big star yelling at you.
[17:52:31] <Jan-> so yes. no beepers, no big flashing lights. A *gentle* warning :)
[17:57:57] <Lambda_Aurigae> shotgun to the temple will cure christian bale of his obnoxious yelling...whoever christian bale is.
[17:58:15] <Jan-> weirdly, at ebay prices, it's actually cheaper to do this with an AVR than with a commercial battery management chip.
[17:58:23] <Lambda_Aurigae> doesn't even have to be loaded...I'm sure he would wet himself nicely and shut up.
[17:58:32] <Jan-> you can buy an arduino nano board for less than the chips in ones.
[17:58:42] <Lambda_Aurigae> Jan-, yup.
[17:58:50] <Jan-> lambda, apparently he gets really into his characters, he was playing John Connor from terminator at the time :)
[17:59:16] <Tom_itx> no excuse not to be human
[17:59:28] <Lambda_Aurigae> and civil.
[17:59:46] <Lambda_Aurigae> I don't care how much you are over-fucking-paid for doing a poor job.
[18:00:06] <Jan-> I quite like his performances but people who've worked with him say he's a bit intense.
[18:00:18] <Jan-> generally though I'm with tom on this.
[18:06:17] <Jan-> also
[18:06:31] <Jan-> it is now cheaper to buy voltmeters and rip the 7 segment displays off them than it is to buy 7 segment displays
[18:06:33] <Jan-> china is crazy
[18:14:52] <Lambda_Aurigae> buy?
[18:14:54] <Lambda_Aurigae> BUY?
[18:15:06] <Lambda_Aurigae> screw that...I just collect junk and tear it apart and make things.
[18:15:19] <Lambda_Aurigae> I get printers by the truckload to tear apart.
[18:16:02] <Jan-> teehee
[18:16:13] <Jan-> cehteh, how did you do your current sensing?
[18:16:42] <cehteh> just measure the voltage drop around the FET
[18:16:44] <Lambda_Aurigae> I fix copiers and printers for a living and we regularly have piles of old traded in machines that I can scavenge from.
[18:17:19] <Lambda_Aurigae> I've got a pile of HP LJ displays.
[18:17:19] <Jan-> cehteh: that's clever, use the rds(on) of the fets as the current sense!
[18:17:21] * Jan- is impressed
[18:17:43] <Jan-> I guess you needed an external op amp though, to read the "shunt"
[18:17:45] <Lambda_Aurigae> measure current drop across anything with a low resistance works well.
[18:17:48] <cehteh> i have no idea how accurate it is, also its a very low voltage
[18:17:57] <kre10s_> Jan-, you can use fets as constant current sources!
[18:18:09] <cehteh> i just use it to for overcurrent protection
[18:18:52] <cehteh> rds(on) is iirc not really linear
[18:19:23] <Lambda_Aurigae> if you are just looking for a set point then it should work great.
[18:19:32] <cehteh> yes there it works
[18:19:38] <Jan-> again you could do a lookup table and calibrate it I guess.
[18:19:54] <cehteh> but measureing current as in varying amperes may be not
[18:20:04] <cehteh> dunno look at datasheet
[18:20:20] <cehteh> i bet you have 3 variables (temperature, voltage, current)
[18:20:27] <Jan-> Suspect you're right
[18:20:28] <cehteh> maybe moon-phase too
[18:20:33] <Jan-> color of user's socks?
[18:20:38] <Jan-> user's star sign!
[18:21:08] <Lambda_Aurigae> sign is only for measuring the polarity of the neutron flow.
[18:21:09] <cehteh> so far i only use it with a calibration point which gets stored
[18:21:20] <WormFood> [06:40:07] <Jan-> it is now cheaper to buy voltmeters and rip the 7 segment displays off them than it is to buy 7 segment displays <-- not if you factor in your time
[18:21:27] <cehteh> (add some load resistors, and programm whatever they draw)
[18:21:38] <Jan-> I'm not sure that we're going to be able to do current sensing.
[18:21:50] <Jan-> I guess it's possible. One very low value shunt resistor, and an op amp.
[18:21:57] <Jan-> read that into another ADC input.
[18:22:13] <cehteh> i want to change this for a factor so like load resistors are only 75% of the shutdown current or so
[18:22:36] <cehteh> there are very good hall sensors for current sensing
[18:22:49] <cehteh> but adds to the parts count
[18:22:59] <Jan-> yeah, but - one factor that's at play here is that we're trying to create an "open battery" spec that's easy to implement.
[18:23:11] <Jan-> so, we're trying to avoid using unusual or hard to get parts, anything that's expensive.
[18:23:18] <Jan-> if we can make as much of it as possible on an arduino nano, we're happy.
[18:23:37] <cehteh> they are not *that* esoteric, should be obtainable
[18:23:48] <Jan-> sure, but - if there's another way, y'know.
[18:23:48] <cehteh> what currents do you draw?
[18:23:53] <cehteh> what ballpark?
[18:23:56] <Jan-> if we use an opamp we'll use a 741 or an NE series.
[18:24:08] <Jan-> we're designing for 10A
[18:24:14] <Jan-> so really I guess we're designing to stand 15, fuse at 20.
[18:24:15] <cehteh> i mean if its less than few A .. just add a shunt resistor
[18:24:26] <Jan-> 10A is the spec.
[18:25:14] <cehteh> 10A is already a lot for a shunt, will do but not so great
[18:25:27] <cehteh> but this hall sensor thingies are about 100A or more :)
[18:26:59] <cehteh> http://www.allegromicro.com/en/Products/Current-Sensor-ICs/Fifty-To-Two-Hundred-Amp-Integrated-Conductor-Sensor-ICs.aspx
[18:27:27] <Jan-> my concern would be cost, availability, and complexity.
[18:27:54] <Jan-> it used to be possible to get those big metal-cased shunt resistors which were always designed for 75mv at whatever current they were rated for
[18:28:53] <cehteh> that 750mW heat .. not much but noticeable
[18:30:02] <cehteh> http://www.watterott.com/de/ACS711EX-Current-Sensor-Carrier-31A-to-31A?x9bdad=3ec071fd1eabe88994e23eb54dd2719b
[18:30:16] <Jan-> true.
[18:30:19] <cehteh> these hall sensor thingies are not terribly hard to get
[18:30:20] <Jan-> don't really want to waste a watt.
[18:30:25] <Jan-> but as I say, I'm not sure if we even need current sensing.
[18:30:28] <cehteh> and not that expensive
[18:30:29] <Jan-> nice to have, but not essential.
[18:31:18] <cehteh> if you have a swithing FET anyway then you may try my trick
[18:32:05] <cehteh> maybe one can calibrate that to get sensible results
[18:32:13] <cehteh> polynome multiplication or so :D
[18:37:26] <Jan-> poor little avr
[18:37:32] <Jan-> he doesn't even have an FPU :)
[18:37:42] <Jan-> is there an FPU chip you can use with an AVR?
[18:37:51] <cehteh> nop
[18:38:05] <cehteh> integers are enough
[18:38:57] <Jan-> I did some work on the curve fitting
[18:39:06] <Jan-> integers won't fly for that, even if you just do linear interpolation
[18:40:28] <Lambda_Aurigae> you could make an spi or i2c interfaced fpu from one of those tiny arm chips..
[18:40:40] <Lambda_Aurigae> but, if you are going that route,,just use the arm and forget the avr..
[18:41:07] <Jan-> well yes.
[18:41:21] <Jan-> possibly a bit over specced for a battery pack.
[18:41:23] <Lambda_Aurigae> there used to be a uFPU or something like that for sale commercially...was spi/i2c interfaced fpu for microcontrollers.
[18:41:34] <Jan-> I guess people just go arm now
[18:41:42] <Jan-> does xmega have an fpu?
[18:41:43] <Lambda_Aurigae> turned out to just be a pic with floating point processing routines on it.
[18:41:55] <Lambda_Aurigae> dunno..never used xmega myself.
[18:41:57] <Jan-> Oops :)
[18:46:11] <Lambda_Aurigae> not seeing an fpu on the xmega series.
[18:46:16] <Lambda_Aurigae> have to go to avr32 for that.
[18:46:32] <Lambda_Aurigae> but xmega is faster so can do floating point math faster.
[18:46:44] <Lambda_Aurigae> regular mega avr can do it...just not very fast.
[18:48:52] <cehteh> dunno if you really need floats for that
[18:49:08] <cehteh> the curve fitting part can be done offline
[18:49:41] <cehteh> maybe you dont even need that
[19:07:19] <Jan-> well you'd just need to linear interpolate
[19:07:35] <Jan-> you can't store that many points for the graph due to lack of space on the AVR, it's not like you can do it very accurately anyway.
[19:14:32] <kre10s_> so i'm looking at the code examples in the atmega48pb datasheet... it uses out UBRR0H r17... which makes no sense because UBR0H is 0xc4 but the arg to out can only be at most 0x3f...
[19:15:15] <kre10s_> so like... is bullshit?!