#avr | Logs for 2014-04-30

Back
[03:24:45] <dgriffi> was someone trying to tell me something earlier? I noticed that someone had, but whatever it was went off the top of my scrollback buffer.
[03:42:34] <superware> I'm struggling with this for a few days now... I want to setup a communication channel between an atmega382 and an attiny25/45/85 (or even attiny13) which acts as a sensor. I need a query and a reset command (1 byte) and in return the sensor will reply with 2-bytes of data. any ideas?
[03:47:23] <superware> anyone?
[03:47:56] <Roklobsta> i2c
[03:47:59] <Roklobsta> or spi
[03:48:09] <Roklobsta> how far apart are they?
[03:48:22] <superware> very close
[03:48:41] <Roklobsta> can attiny do i2c? you can bit bang it if not
[03:48:53] <Roklobsta> i only have the behemoth 1280
[03:49:23] <superware> i2c slave you mean, I think it might be hard to bitbang, right?
[03:49:37] <Roklobsta> no
[03:50:07] <Roklobsta> what i/o does attiny have?
[04:06:49] <anton02> what is a good low-input alkalkine voltage for a boost SMPS?
[04:14:33] <Tachyon`> http://playground.arduino.cc/Code/USIi2c <- i2c on attiny
[04:15:30] <Tom_itx> anton02, https://learn.adafruit.com/minty-boost
[04:15:45] <superware> yeah https://github.com/rambo/TinyWire/blob/master/TinyWireS/usiTwiSlave.c too much "talking" on ISR(USI_START_VECTOR) :)
[04:19:36] <naquad> several times here i've heard people where doing something like super small RTOS mostly providing multitasking feature. is there some example available publicly? i just can't figure out how does one switch from one task to another in AVR
[04:20:39] <naquad> s/where/were
[04:21:15] <Valen> co-operative multi-tasking as a rule
[04:21:35] <Valen> there are lots of things that are different to how one does things on a PC
[04:21:53] <Valen> I'm yet to really see the benefit of that kind of thing
[04:22:26] <naquad> mmm still can't imagine how to make a coroutine in C 0o
[04:23:04] <Valen> coroutine?
[04:23:32] <Roklobsta> wiki coroitines and read about the C brainfuck that involves creating them.
[04:23:58] <Roklobsta> the guy who made putty ssh did a nice writeup.
[04:24:18] <Valen> ahh
[04:24:38] <Valen> sounds like you are trying to run some huge java thing on your tiny AVR
[04:24:41] <Valen> ;-p
[04:24:56] <Valen> yer doin it wrong
[04:25:32] <naquad> well its not me who invented that, i've heard people here were doing that
[04:25:34] <Valen> I suggest taking a look into all the interrupt options you have available in your AVR, and the timers.
[04:25:59] <Valen> between the two of those most of the time my main loop consists of main { sleep() }
[04:26:20] <naquad> and yes, i recently experiment a lot. one of my experiments has shown that having a class hierarchy along with interfaces (C++) is a generally very bad idea in case with AVR :) it just didn't fit
[04:27:07] <Thrashbarg> so why use them on a 'real' PC?
[04:27:07] <Roklobsta> i am playing with my own homebrew round robin scheduler on the avr to get my head around the whole thing.
[04:27:08] * Thrashbarg ducks
[04:27:36] <naquad> Roklobsta, mmm any chances its somewhere publicly accessible? :)
[04:27:38] <Roklobsta> the idle task sleeps.
[04:27:52] <Valen> Thrashbarg: the idea is you write bigger programs on bigger hardware, and you can trade run time efficiency for code development time
[04:28:00] <Roklobsta> yeah. i will. i am going to super duper doxygen it.
[04:28:07] <Thrashbarg> Valen: well that's the theory anyway :P
[04:28:21] <Roklobsta> i'll make noise here an on avrfreaks when it's done.
[04:28:53] <Thrashbarg> Valen: I still can't see how programming in C++ can save time
[04:29:01] <Valen> I've never done it
[04:29:07] <Valen> its C or python for me
[04:29:11] <Thrashbarg> yup
[04:29:21] <Valen> (or JAL on pics or visual basic 6)
[04:29:33] <Thrashbarg> I'm not really against OOP in general, I just despise the bad implementations of it...
[04:29:34] <Roklobsta> c for embedded is fine.
[04:29:44] <naquad> Thrashbarg, have you ever seen GTK or something GObject based?
[04:29:46] <Roklobsta> it's always good to look at what the c compilter spits out.
[04:30:00] <Roklobsta> you can do your own oop in c.
[04:30:08] <Thrashbarg> naquad: from what little I've researched... I don't think I want to
[04:30:23] <Valen> you should take a look at how they wrote the code for the lunar lander
[04:30:31] <Roklobsta> plenty of writeups about it. you just have to make your own 'wizard behind the curtain' magic that C++ and so on hide from you.
[04:30:32] <Valen> that is some grade A stuff there
[04:30:49] <naquad> Thrashbarg, GObject provides a OOP for C. the way it works damages your brain irreversibly
[04:30:54] <Thrashbarg> Valen: that was on an RTL IC based minicomputer with about as much power as a Z80 :P
[04:31:08] <Thrashbarg> naquad: like programming in BASIC heh
[04:31:39] <naquad> Thrashbarg, programming in basic very good, conceptual and structured compared to GObject insanity
[04:31:50] <Thrashbarg> hehehe that says a lot
[04:32:03] <Thrashbarg> and what happens when you write to a mailing list to get some advice on it?!
[04:32:23] <Valen> I never really understood the hate on basic
[04:32:35] <Roklobsta> i worked on a 8051 project once that had horrible cooperative multitasking that was a spaghettifest
[04:32:41] <Valen> i mean like any language you can do bad things with it
[04:32:46] <naquad> Thrashbarg, never tried, i've had enough at irc.gnome.org/#gtk+
[04:32:51] <Valen> but take a glance at java ;-P
[04:32:57] <Thrashbarg> Valen: structured BASIC is good for readability
[04:33:12] <Valen> thats what I like about it
[04:33:23] <Valen> its "self documenting" to some extent
[04:33:32] <Roklobsta> naquad: there are lots of avr schdulers but the thing about all of them is that I didn't make them.
[04:33:34] <Valen> like python if you don't get too fancy with generators and the like
[04:33:37] <Thrashbarg> naquad: Given the reputation of GTK etc mailing lists..... yeahhh don't want to go there
[04:34:36] <Roklobsta> naquad: i'd like to make something that is straightforward to comprehend, well documented and useful to a 1/2 decent avr user.
[04:35:03] <Thrashbarg> choose two...
[04:35:21] <Roklobsta> no choose 4
[04:36:11] <Roklobsta> i am undecided about implementing threads.
[04:36:49] <Valen> perhaps its just that I hardly ever use an avr with more than 1kb of code space but you guys really seem to over think stuff ;-P
[04:37:52] <Roklobsta> yeah well, i'd like to minimise code space but once you start needing to be useful and add abstractions like device drivers you get bloaty.
[04:38:29] <Valen> half the time I don't have the physical room to put a larger IC in ;->
[04:38:33] <Thrashbarg> Valen: I worked on an 80-column composite display using an ATmega324. Most of the code binary was the font bitmap. I think it was about 2kB total. I needed the 32k AVR because of the 2k internal SRAM
[04:38:51] <Thrashbarg> in assembler
[04:39:00] <Roklobsta> i know you can make tight little machiens with avr's and irqs.
[04:39:15] <Valen> thats about all I use
[04:39:37] <Valen> i mean, embedded stuff is all about dealing with stuff thats happening outside
[04:39:57] <Roklobsta> depends on what you want to do.
[04:40:32] <Roklobsta> this australian thing uses the 1280. http://www.atx-pro.com/
[04:41:34] <Thrashbarg> "I want a flashing LED, which flashes five times when someone walks past this sensor." "Well.... you'll need a Raspberry Pi to do that because I only know how to program in Java"
[04:41:55] <Roklobsta> kids think a computer is a magical black box.
[04:42:13] <Thrashbarg> so do a lot of professional programmers
[04:42:54] <naquad> XD
[04:42:56] <Roklobsta> that's what i mean
[04:43:15] <Roklobsta> the interesting thign about makeing a schduler is you have to think about how to make the magic happen.
[04:43:16] <naquad> i've recently seen a quadrocopter with RPi. it doesn't fly. suddenly!
[04:43:45] <naquad> yeah, i agree with Roklobsta, its more research and education than actually trying to stuff that into some project
[04:44:04] <Thrashbarg> someone needs to make a quadcopter that works on analogue electronics
[04:44:13] <Roklobsta> oh now that's hard
[04:44:23] <Roklobsta> I am no Bob Pease
[04:45:22] <naquad> will that have a nixie tube on board? :)
[04:45:33] <Roklobsta> i have 24 nixie tubes
[04:45:49] <Roklobsta> from the Former Ukraine.
[04:45:56] <naquad> heh
[04:46:01] <naquad> haven't seen those much
[04:46:05] <Roklobsta> IN14s
[04:46:05] <Thrashbarg> I'm making a synthesizer VCO and VCA out of tubes
[04:46:21] <Roklobsta> i think the internet is a series of tubes
[04:46:32] <Thrashbarg> no it's a dump truck
[04:46:41] <Roklobsta> yeah, it is.
[04:46:45] <Thrashbarg> heh
[04:47:03] <Roklobsta> loads of crap with flies.
[04:51:36] <naquad> god damn it! people who write registers as *(0x1010101) should at least replace that when they publish their code
[04:51:48] <Thrashbarg> well you can get accelerometers with analogue outputs so there's nothing really stopping anyone making an analogue quadcopter...
[04:52:41] <Valen> naquad: with what?
[04:52:48] <naquad> #define macroes
[04:52:57] <Valen> ahh
[04:53:36] <Valen> yes, I'll grant you that
[04:54:09] <Valen> would be nice I think if you could do it without all the | 1 << foobit stuff
[04:54:25] <Valen> just foobit | barbit | stuff
[04:54:30] <naquad> Valen, i've managed to do it, but had "ewwww" reaction here
[04:54:48] <Valen> get rid of the 1 << ?
[04:54:58] <naquad> yes
[04:55:04] * Valen is interested
[04:55:06] <naquad> well cover it with variadic macro
[04:55:21] <naquad> https://gist.github.com/11422362
[04:56:26] <Valen> set_bits(DDRB, PB0, PB1, PB5); => DDRV = _BV(PBO) | _BV(PB1) | _BV(PB5)
[04:56:35] <naquad> yes
[04:56:38] <Valen> you mean by that the left becomes the right?
[04:56:50] <naquad> yyes
[04:56:58] <Valen> nice
[04:57:10] <Valen> I was under the impresion _BV was not good in some way?
[04:57:57] <naquad> well, after configuring a PWM i've got tired of writing | _BV(...) | _BV(...) | _BV(...) so i thought it would be awesome to explicitly state what i'm doing with much less typing
[04:58:38] <naquad> kind of set_bits(TCCR1B, WGM12, WGM13, CS10);
[04:58:42] <Roklobsta> BV is fine
[04:58:47] <Roklobsta> it's not goign anywhere
[04:59:12] <Valen> don't get me wrong I like your setbits thing
[04:59:24] <Valen> you have seen avr035 with setbit and the like?
[04:59:45] <naquad> nope
[05:00:03] <naquad> what is that and where can i see it?
[05:01:48] <Valen> www.atmel.com/Images/doc1497.pdf‎ i think
[05:01:57] <Valen> pg 16
[05:03:36] <naquad> Valen, its not variadic. the trickery here is that my version can set up to 8 bits at once. if you do SETBIT(x, y) 3 times (like in the example above) you get 3 separate instruction, with my macro it gets optimized and becomes 1 instruction with combined value calculated at compile time. if it is calculatable of course
[05:05:05] <naquad> wtf is __C_task? 0o
[05:07:54] <naquad> Valen, thanks for the guide. interesting reading
[05:32:26] <Valen> so atmel has some files you can include and you get setbit and clearbit
[05:32:40] <Valen> I like your setbits and clearbits
[05:33:09] <Valen> I can see them perhaps complimenting each other naquad
[05:33:10] <specing> #define setbit (val, bit) (val |= (1 << bit))
[05:38:46] <naquad> Valen, i've got set_bit too :) just an alias to set_bits actually: #define set_bit(x, y) set_bits(x, y) - because they don't differ in the end i don't see a reason to include those
[06:49:31] <voxadam> I keep running across mentions to USI (Universal Serial Interface) on Atmel devices (ATmega3260p at the moment) but little documentaion on what's required to implement a UART on such a device. I'm specifically looking to have a 3290p on an AVR Raven dev board act as a Modbus/RTU master. This RS485 Modbus/RTU master running Contiki would in turn be used to control a small network of Modbus slaves.
[06:49:31] <voxadam> Does anyone have any documentation that might help me in my quest to prototype this with as few resources as possible?
[06:55:45] <Lambda_Aurigae> voxadam, it's in the datasheet.
[06:56:18] <Lambda_Aurigae> although, I don't see an atmega3260p anywhere.
[06:56:49] <voxadam> I'm reading the ATmega3290P datasheet now.
[06:57:11] <Lambda_Aurigae> you said 3260 earlier.
[06:57:42] <voxadam> I'm sorry I meant the 3290 found on the AVR Raven boards.
[06:59:13] <voxadam> Maybe I shouldn't be reading datasheets at 0441.
[06:59:33] <Lambda_Aurigae> the USI looks like it is SPI and I2C but not USART compatible.
[07:00:17] <Lambda_Aurigae> yeah...datasheet only talks about SPI and TWI modes...TWI being atmel's name for I2C so they don't have to pay royalties.
[07:00:24] <voxadam> Maybe I'll look at the USART but I'm not clear if it's used for intraboard communication.
[07:00:30] <Lambda_Aurigae> it says nothing about asynchronous comms like you would use a USART for.
[07:01:33] <voxadam> Well, maybe I'll give up configuring the Raven's I have on my shelf to act as a Modbus/RTU master.
[07:01:43] <Lambda_Aurigae> USART can be used for board to board communications easily enough.
[07:01:59] <Lambda_Aurigae> no clue on the Modbus/RTU thing..never used them...
[07:02:05] <Lambda_Aurigae> nor on the raven board.
[07:02:33] <voxadam> It's a protocol level thing, I'm more worried about a 485 connection.
[07:02:57] <jacekowski> voxadam: well, how much do you know about modbus?
[07:03:38] <voxadam> I know enough about the software protocol. I'm more concerned about the electrical connection at the moment which happens to be RS/EIA485
[07:03:48] <jacekowski> voxadam: quite easy
[07:04:32] <voxadam> What hardware should I be looking to connect the 485 tranciever to on the mega?
[07:04:53] <jacekowski> voxadam: if you want to do it right http://datasheets.maximintegrated.com/en/ds/MAX1480A-MAX1490B.pdf
[07:05:11] <jacekowski> voxadam: it has optoisolation+ power supply for the network side builtin
[07:05:22] <jacekowski> voxadam: so it's just pretty much plug and play
[07:05:27] <Lambda_Aurigae> it's like a max232, only for rs485!
[07:06:28] <voxadam> Why are the isolated 485 transceivers 24 pins while the max485 are something like six pins? Is that much extra physical space required to provide the isolation?
[07:06:59] <jacekowski> voxadam: you need power supply inside, optoisolation
[07:07:00] <Lambda_Aurigae> look at page 21 of that datasheet.
[07:07:13] <Lambda_Aurigae> shows how it's hooked up and all.
[07:07:15] <jacekowski> and optoisolators have to be big
[07:07:23] <jacekowski> you can use max485 as well
[07:07:48] <jacekowski> but to do it right, you will need optoisolation as well + power supply for the network side
[07:08:15] <jacekowski> depends on size of your network
[07:08:21] <jacekowski> but actual standard requires isolation
[07:08:28] <voxadam> Fair point. I'm just trying to keep my board sizes as small as possible. I'll have to look at the SMT offerings.
[07:08:36] <voxadam> I wasn't aware of that.
[07:08:59] <jacekowski> SMT will not make it much smaller
[07:09:15] <jacekowski> it's the transformer inside and optoisolators that make it big
[07:09:30] <Lambda_Aurigae> that chip looks like it has both opto and transformer isolation.
[07:09:37] <voxadam> Currently 485 and Modbus are just being used to keep my xceiver nodes to a minimum while prototyping. So, I may be able to use max485s for now.
[07:09:54] <jacekowski> Lambda_Aurigae: yeah
[07:10:13] <voxadam> I will seriously look at the properly isolated transceivers anyway.
[07:10:40] <jacekowski> Lambda_Aurigae: all in one solution, it takes about 1/3rd of board space compared to doing it with non isolated chip + transformer + optos
[07:10:49] <Lambda_Aurigae> I can imagine.
[07:10:55] <Lambda_Aurigae> never had to do rs485 myself.
[07:12:03] <Lambda_Aurigae> old serial terminals had enough power on the lines to cause a nice buzz...specially the ones running over twinax...them things could burn you.
[07:12:28] <voxadam> Those MAX1480 interfaces are insanely expensive. US$18 per unit vs $1.71 for old MAX485s without isolation.
[07:12:41] <Lambda_Aurigae> not even sure what the voltage levels are on rs485.
[07:13:15] <voxadam> Since I'm not planning on using 485/modbus in my final design maybe I'll just be careful with the max485s and hope for the best while working in a proto environment.
[07:13:26] <jacekowski> voxadam: yes, but get MAX485, then add a transformer to it + smps driver + two optos + extra board space
[07:13:32] <jacekowski> Lambda_Aurigae: 5Vish
[07:13:42] <Lambda_Aurigae> aahh.
[07:14:00] <jacekowski> between A and B and common
[07:14:16] <jacekowski> however voltage between A and B and common can be up to 2kV
[07:14:35] <voxadam> jacekowski: I was suggesting going wtih the max485 and avoiding the isolation for the initial protostage.
[07:14:51] <jacekowski> voxadam: it will be ok if you have same source of power
[07:14:57] <voxadam> jacekowski: Where does that 3kV come from?
[07:15:17] <voxadam> jacekowski: That's exactly how I plan on doing the inital proto.
[07:15:20] <jacekowski> but in real world, your master might be 1000m away
[07:15:28] <jacekowski> and supplied from another source with another ground
[07:15:51] <Lambda_Aurigae> voxadam, seems the difference can be just the ground reference level...hence the need for isolation.
[07:15:53] <jacekowski> and then things will blow up if you are non insulated
[07:16:11] <jacekowski> isolated*
[07:16:47] <voxadam> For my proto the devices will be no more than a meter apart.
[07:17:03] <voxadam> jacekowski: Insulated or isolated?
[07:17:05] <Lambda_Aurigae> heck, just having things plugged into different outlets in different rooms and cross connected can cause problems if someone wired an outlet backwards.
[07:17:13] <Lambda_Aurigae> insulated by isolation?
[07:17:36] <voxadam> jacekowski: "<jacekowski> and then things will blow up if you are non insulated"
[07:18:37] <voxadam> All my (<6) devices will be deriving their power from the master via CAT5 wiring. They should all be at nearly the same potential.
[07:18:58] <voxadam> CAT5 or the like.
[07:19:17] <voxadam> All of the power for the devies on the bus will be coming from a central point.
[07:19:28] <voxadam> This is simply a very early proto setup.
[07:20:47] <voxadam> My final designs won't be utilizing 485 or modbus. Each device will have its one wireless interface and they'll all be independat.
[09:40:19] <superware> http://www.atmel.co.il/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf section 15.3.3 page 112: "The code example assumes that the DO and USCK pins have been enabled as outputs in DDRB." if it's an SPI slave, why should USCK be output?
[09:50:30] <superware> anyone?
[12:01:35] <superware> I have an SPI scheme where an ATmega328 is master and ATtiny85 slave, any idea why I'm getting garbage on the master instead of 0x6699cc? http://pastebin.com/YQsHBwsr
[12:02:15] <bitd> Have anything other than the two mcu's in the proximity?
[12:02:25] <superware> nope
[12:05:12] <superware> the connections are: atmega328P 11-12-13 (MOSI-MISO-SCK) connected to attiny85 5-6-7 (DI-DO-USCK)
[12:06:21] <superware> bitd: I guess it's something in the code :)
[12:06:46] <bitd> Any long wires?
[12:06:56] <superware> not more than a few cm
[12:09:48] <superware> bitd: is spi_init ok?
[12:13:41] <bitd> Not sure superware, never written it like that.
[12:13:58] <bitd> What you could do is use an arduino library to test if the connections are alright.
[12:14:24] <bitd> So just put the SPI library on the atmega328.
[12:15:57] <bitd> Or you could look up how the arduino library does it.
[12:19:09] <superware> yeah
[12:20:25] <superware> I don't think it's doing it like this, I guess it's using interrupts
[12:49:57] <N2TOH> can the fusebits be set on the newer AVR chips with common programers? or do I still need to use the STK500 board?
[15:57:36] <ColdKeyboard> I ordered some LEDs from ebay and they got allright but their leads are 10mm shorter than the standard one... wtf???
[16:17:11] <Casper> ColdKeyboard: you got the medium length ones
[16:17:22] <Casper> they come in different length and size and shape
[16:18:02] <ColdKeyboard> well I didn't check the length and now when I got back to the item details, seller didn't list that info in the item details...
[16:18:35] <ColdKeyboard> I'm looking for good leds for 8x8x8 cube... these will have to do for something else :)
[21:37:19] <dingbat> N2TOH: Which chips? An USBASP or USBtinyISP, etc, and avrdude will do just fine for fuse programming on any ATmega or ATtiny, AFAIK