#avr | Logs for 2014-06-23

Back
[03:19:33] <AllinYourhead> any advice on a component or circuit that can help me convert 11-15V input to 5V for my uC without affecting the signal read? It's an automotive signal and i don't want to mess up the car ECU by voltage dividing
[03:23:28] <Yolarina> AllinYourhead, how about a voltage regulator?
[03:23:40] <madist> AllinYourhead: you have 15V logic circuits ?
[03:24:23] <AllinYourhead> dont have but can fix if needed
[03:24:49] <AllinYourhead> and voltage regulator won't work
[03:25:16] <Yolarina> AllinYourhead, how about a transistor then, with the 15v at the gate?
[03:26:58] <AllinYourhead> could work. There must excist logic IC's for this type of operation but have a hard time googling so hoped someone could suggest a IC series
[03:30:56] <malinus> 15V logic seems kinda crazy
[03:31:09] <malinus> is that normal in cars?
[03:39:38] <Thrashbarg> AllinYourhead: http://i.stack.imgur.com/EUVMW.png <-- probably something like that
[04:18:54] <AllinYourhead> loading voltage can be up to 14.8-ish volt in a car
[04:22:42] <twnqx> where exactly do you have 15V logic in your EC
[04:22:44] <twnqx> ECU*
[04:22:59] <twnqx> the µCs in those i disassembled where all 3V
[04:23:10] <twnqx> (3.3)
[04:24:20] <twnqx> and there are quite some full custom ICs from freescale, infineon, ti, ... that have no references whatsoever on the web
[04:25:13] <AllinYourhead> a sensor giving 0-12V input for example, in order for ECU uC to read signal it does a voltage dividing. If i want to hijack this signal without altering it i need to read it without using my own voltage divider because that would cause a parallell resistor circuit on the signal, still i have to somehow scale it down for my own uC input voltage
[04:25:34] <twnqx> personally i'd use an opamp
[04:25:48] <twnqx> very high impedance input and easily available in the +-15V range
[04:26:22] <AllinYourhead> now we're talking :)
[04:26:54] <AllinYourhead> any suggestion on a circuit that would help me?
[04:27:45] <twnqx> http://www.instructables.com/id/Non-inverting-amplifier-with-uA741/ something like that
[04:28:12] <twnqx> with R2=R1 you get 1x gain, so the same as input
[04:28:17] <twnqx> err
[04:28:20] <twnqx> no :P
[04:28:34] <twnqx> too early
[04:28:54] <AllinYourhead> how about a voltage follower with voltage divider on output side before uC?
[04:29:30] <twnqx> http://www.ipson.nl/opamp-circuits
[04:29:32] <twnqx> there
[04:30:03] <twnqx> yeah, probably just that
[04:30:27] <twnqx> i wonder if you could get the gain to 0.25 or so to feed straight into your ADC
[04:31:28] <twnqx> with two opamps it seems possible
[04:31:36] <AllinYourhead> ye that would be optimal. too long ago since i learned about op-amp circuits though
[04:31:50] <twnqx> gain <1 is only possible in inverting modes
[04:31:59] <AllinYourhead> okey
[04:32:08] <twnqx> reminds me... i bought some opamps for exactly the same purpose
[04:32:13] <twnqx> where are they...
[04:33:09] <AllinYourhead> i have op-amp opa4347 on the board already, for straight voltage followers for 0-5v sensors so would be good to reuse those. And if i place voltage divider resistors after the op-amp in follower mode i can easily adapt the board for 6V and 24V vehicles as well
[04:33:53] <twnqx> http://www.ti.com/product/lm324 look at those, i intended to skip on the negative voltage
[04:33:59] <twnqx> ah ok
[04:34:01] <AllinYourhead> ahh too bad, opa4347 only 5.5V max supply
[04:35:14] <twnqx> and the lm324 ranges up to 32V :P
[04:35:24] <AllinYourhead> thank you, i will look into that
[06:25:59] <Tachyon`> good morning
[06:26:34] <Tachyon`> when an AVR powers up, with arduino libs etc., are the pins in a known state, low/high/etc.?
[06:27:06] <Tachyon`> er, afternoon*
[06:31:41] <mateusz_> all registers are set to 0 by default so input without pull-up
[06:40:44] <Lambda_Aurigae> with the ardweeny libs, there's no telling, but I would guess they start with the system at default state...I would hope they do.
[07:00:06] <kline> Tachyon`: the only thing that would be questionable are arduino pins 0/1
[07:00:34] <kline> as theyre used by the bootloader to get a new hex
[07:01:05] <kline> possibly also pin 13
[07:04:39] <Tachyon`> ahh, next question, when connecting two avr chips with serial, do I need to do anything other than connect rx to tx and tx to rx? I seem to be getting a fairly noisy link
[07:05:04] <Tachyon`> would shielded cable be perhaps better?
[07:06:50] <Lambda_Aurigae> all depends on what kind of cable, how long the wires, are you running at ttl or rs232 levels?
[07:07:20] <Lambda_Aurigae> twisted pairs with one wire of each pair connected to GND on both ends works well usually.
[07:07:39] <Tachyon`> ttl, it's just from a 328 to a 1284
[07:07:56] <Tachyon`> wouldn't connecting parts of it to ground prevent it working at all
[07:07:59] <Lambda_Aurigae> ok, that's one question answered.
[07:08:06] <Lambda_Aurigae> no.
[07:08:14] <Lambda_Aurigae> you have 4 wires in 2 twisted pairs.
[07:08:24] <Tachyon`> oh, pairs
[07:08:24] <Tachyon`> lol
[07:08:28] <Lambda_Aurigae> 1 wire of each pair gets used for GND at both ends.
[07:08:48] <Tachyon`> I have some comms cable that's a single twisted pair with shield for grounding, would that do, I don't have anything with two
[07:08:52] * Tachyon` eyes the phone extension cable
[07:08:58] <Lambda_Aurigae> how long is it between the two devices?
[07:09:04] <Tachyon`> I've not had a landline in 10 years so I suppose I could
[07:09:08] <Lambda_Aurigae> do you have any ethernet cable?
[07:09:11] <Tachyon`> err, about 15cm
[07:09:35] <Lambda_Aurigae> if you are getting noise on 15cm of wire between two devices you have other issues.
[07:10:01] <Tachyon`> well, it's a stripboard prototype
[07:10:17] <Lambda_Aurigae> that's about as bad as solderless breadboards...hehe
[07:10:19] <Tachyon`> http://kupo.be/ab/bastest6.jpg
[07:10:21] <Tachyon`> that to be exact
[07:10:36] <Tachyon`> we have a 328 for terminal duties and a 1284 for actual processing
[07:10:39] <Lambda_Aurigae> but I do well with solderless breadboards up to 14.4Kb/s at ttl levels.
[07:10:57] <Tachyon`> hrm, well, it failed at 38400 but worked at 1200
[07:11:13] <Tachyon`> I'll try 9600
[07:11:13] <Lambda_Aurigae> so go down to 14.4K
[07:11:21] <Tom_itx> why didn't you use a regular keyboard?
[07:11:37] <Jartza> my modem works with 12kbps on breadboard easily :)
[07:11:49] <Tachyon`> because it's going to be an actual device with its own keyboard
[07:11:53] <Tom_itx> oh i bet this is that school project
[07:11:57] <Tachyon`> haha
[07:12:01] <Tachyon`> I'm about 20 years too old for school
[07:12:08] <Lambda_Aurigae> naa.
[07:12:15] <Tom_itx> ahh well we had one of those here last week
[07:12:16] <Lambda_Aurigae> I'm 47 and going to school.
[07:12:18] <Tachyon`> although if you think I'm learning electronics a little late
[07:12:20] <Tachyon`> you'd be correct
[07:12:31] <Tom_itx> never too late
[07:12:42] <Jartza> https://www.dropbox.com/s/cwhe2tng1wpcbo1/pic_18_1.gif
[07:12:55] <Jartza> that's how the signal now looks on my attiny pin
[07:12:57] <Jartza> even on breadboard
[07:13:06] <Jartza> I'm fairly happy with that
[07:13:08] <Lambda_Aurigae> nice..got it all smoothed and squared I see.
[07:13:09] <Tom_itx> cute
[07:13:37] <Lambda_Aurigae> Tachyon`, you might look at putting a pair of max233 or max232 chips in there and send your data at RS232 levels rather than TTL levels if you need higher speeds.
[07:13:39] <Jartza> an oh, I'm 41 and just started learning electronics
[07:13:42] <Tom_itx> you just wanna show off your new scope
[07:13:42] <Jartza> so it's never too late
[07:14:29] <Jartza> Lambda_Aurigae: yeah, and with really simple circuit, without opamp
[07:14:50] <Jartza> Tom_itx: there's not much to see in my new scope :)
[07:15:03] <Jartza> isn't that about the cheapest crap one can buy? :)
[07:15:14] <Jartza> but it still helps me in this learning-process, a lot
[07:15:29] <Tom_itx> yeah
[07:15:39] <Tom_itx> i wish i had a nice new digital scope
[07:15:51] <Tom_itx> i hardly ever get mine out
[07:16:03] <Lambda_Aurigae> I wish I had a scope...but,,,,
[07:16:09] <Lambda_Aurigae> off to worky.
[07:16:16] <Tom_itx> earn your keep
[07:16:41] <Tom_itx> don't just fill the void
[07:16:45] <Jartza> I'm soon going to finish working for today
[07:19:37] <Jartza> still one hour left and then back to these more fun tasks ;)
[07:53:00] <volbus> Hi! Is there any tool to compute/analyse the stack-depth for a program? I would like to know the maximum depth of my stack, and so use my SRAM fully without risk of corrupted return pointers...
[07:57:41] <volbus> I'm talking about asm programming for avr's, and about the stack inside the mcu
[08:00:07] <volbus> anyone? I'm running dry on my resources and really need every byte in my SRAM...
[08:22:45] <twnqx> noise on those links? just put in passive filtering (ferrite, capacitor) according to your frequency specs
[08:34:28] <Casper> volbus: then use assembler and calculate manually
[08:35:28] <volbus> ufff..., that's complicated, count evey routine entry dependind on conditions...
[08:35:49] <volbus> and if I change something, I'll have to count again
[08:36:23] <twnqx> you can always write a tool to do that for you :3
[08:36:30] <volbus> how come nobody has written a software tool for this?
[09:25:24] <Jartza> volbus: first hit on google: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=52249
[09:25:40] <Jartza> when searching avr stack usage monitor
[09:28:46] <volbus> ok, I'll check it, but I write my code in assember, let me see if this helps and what is all about...
[09:42:01] <volbus> Jartza: that is just a testing thing, while the mcu is running, but it doesn't supply any certainty. Not all events and routine calls happen/take place always in the same way! If you have an interrupt exactly when the mcu is in a deeper subroutine, things can change dramaticaly
[09:42:33] <volbus> and that kind of testing I've been doing a lot in the past...
[09:43:18] <volbus> I want a software tool that theoreticaly computes the deepest possible value of the stackpointer
[09:44:36] <Jartza> have you tried running your code in simulator?
[09:46:25] <volbus> no, I use avr-gcc, but I've been using the simulator in the past, and, as far s I know you have to manualy enable interrupts, flags, set ports, it doesn't help. You can't go automaticly in deeper nested routines
[09:47:07] <volbus> even manual counting is simpler...
[10:29:32] <Encrypt> Hello there o/
[10:29:45] <Encrypt> I'm working on a small project which uses an ATtiny9
[10:29:59] <Encrypt> I'd like to be able to program it in the system (ISP)
[10:30:17] <Encrypt> However, I directly connected (on my sheet) the ~RESET pin to Vcc
[10:30:52] <Encrypt> So, it's not possible to program it thanks to a TPI programmer
[10:30:59] <Encrypt> I was wondering what I can do to do so...
[10:31:22] <Encrypt> Apparently, in the datasheet, the ~RESET is pulled low during programmation
[10:32:00] <Encrypt> So, could I connect a 10kohms resistor as a pull-up to the ~RESET pin and put the "RST" pin of the TPI programmer between ths resistor and the pin?
[10:32:06] <Encrypt> Would it do the job?
[10:44:38] <twnqx> yes.
[10:44:46] <twnqx> that is how it is usually done
[10:46:28] <Encrypt> Ok, thanks :)
[10:46:47] <Encrypt> twnqx, Do you also use KiCad by the way?
[10:46:57] <twnqx> no, i am an eagle person so far
[10:47:12] <Encrypt> Ok
[11:01:05] <Encrypt> I have to go!
[11:01:11] <Encrypt> Thanks for your help twnqx
[15:00:33] <umquant> is it a bad idea to put register configurations into an enum: https://gist.github.com/anonymous/1c8aa22fbf4e512204ce
[15:02:24] <antto> well, the only possible thing that i can think of is that the compiler decides what type the enum is..
[15:02:54] <antto> so if that somehow causes a side effect... but otherwise it should work methinks
[15:03:18] <umquant> Ah okay didn't think of that. What is a common "best practice" for doing something like this?
[15:03:50] <antto> well, try this (as you've already written it) and see if it works
[15:04:52] <umquant> will do. Appreciate the insight into the possible compiler problem mention
[15:07:07] <antto> i mean.. if you accidentally use a larger value in the enum, the compiler will make the enum use a big enough type to handle it (thus bigger than you expected/intended)
[15:07:34] <antto> tho, i think it should still generate some kind of warning
[16:54:32] <Jartza> hmmh
[16:55:09] <Jartza> can the "progmem" struct be placed in arbitrary address on attiny85?
[16:55:31] <Jartza> I'd like it to be in "known" address, as my sw is going to rewrite to it ;) (self-programming)
[17:10:19] <antto> u naughty h4x0r
[17:21:49] <Jartza> not a naughty hax :)
[17:35:15] <twnqx> i think only with a custom ld script
[17:35:25] <twnqx> progmem is just flash, along the program
[17:36:47] <twnqx> so you'd define a custom section at a particular address with the linker script, and then force your progmem to reside in that section. how that works out the "standard" progmem code i don't know, you may have to rewrite that, and i don't know details either
[17:37:35] <Jartza> well isn't progmem just a pointer to memor
[17:37:39] <Jartza> except, it points to flash
[17:39:52] <twnqx> yes, but C doesn't allow you to fix addresses
[17:40:14] <twnqx> well, of course you could assume things, like "top of flash will be empty as my program is small"
[17:40:23] <twnqx> but then it will be uninitialized
[17:41:13] <Jartza> well I have to dig into it
[17:42:08] <twnqx> imho, fixing it with the linker is the cleaner option. might also be the more difficult (steeper learning curve) though
[17:46:56] <Jartza> linker script is no prob.
[17:51:26] <Jartza> oh
[17:51:50] <Jartza> char table[42][42] __attribute__ ((section (".mysection"))) = {…}
[17:52:12] <Jartza> and then just LDFLAGS += -Wl,--section-start=.mysection=0x2000
[17:52:17] <Jartza> doh
[17:52:56] <Jartza> pgm_read_byte etc. actually accept fixed address
[18:03:31] <Jartza> seems to work
[18:06:43] <Jartza> except address 0x2000 is of course out of question for attiny85, but I tried with 0x1800 which seems to work ok
[18:06:50] <Jartza> as flash address is specified in words
[18:12:16] <Jartza> Contents of section .sec2: 1800 4e6f2064 61746120 65786973 74732c00 No data exists,. 1810 00000000 00000000 00000000 00000000 ................ 1820 506c6561 73652075 7365206d 6f64656d Please use modem 1830 21000000 00000000 00000000 00000000 !...............
[18:12:22] <Jartza> ...
[18:12:41] <Jartza> seems to work ok
[19:13:00] <Jartza> yeah. and also overwriting the data works, as now I know where it is located
[19:13:01] <Jartza> great
[19:13:08] <Jartza> this is getting along nicely
[23:42:42] <onr> could you recommend a starter learning kit?