#avr Logs

Oct 15 2017

#avr Calendar

12:03 AM day__ is now known as daey
04:08 AM polprog: time to crack max232 communication via a native pc serial
08:45 AM Lambda_Aurigae: been there, done that, bought the book, read the t-shirt
08:45 AM Lambda_Aurigae: mx232 is just a level shifter really.
12:36 PM mudkip908_ is now known as mudkip908
02:36 PM JanC is now known as Guest41887
02:36 PM JanC_ is now known as JanC
04:36 PM enh: Quetion... What happens if two interupts collide in an AVR?
04:36 PM enh: interrupts...
04:36 PM enh: Like SPI and timer
04:37 PM Emil: enh: mate
04:37 PM Emil: :D
04:37 PM Emil: anycase
04:37 PM Emil: if two interrupts are triggered "simultaniously"
04:37 PM Emil: simultaneously*
04:37 PM Emil: their vector order selects what you are going to do
04:38 PM enh: Do both get executed?
04:38 PM Emil: of course
04:38 PM Emil: enh: as long as there is a flag set that hey, I am an interrupt, execute me, it will be executed
04:39 PM Emil: your standard ISR(VECTOR_NAME_vect) does it all for you
04:39 PM enh: If a second interrupt hits in the middle of the first, execution returns to first then to normal code, after second is finished?
04:39 PM Emil: but if you do ISR(VECTOR_NAME_vect, ISR_NAKED) you have to do that yourself
04:39 PM Emil: enh: it'll probably be executed the second you reti
04:39 PM Emil: But I don't actually know
04:40 PM Emil: even if you do return to normal code it's only a single or two cycles, really
04:41 PM enh: I have a SPI interrupt vector enabled (ISR(SPI_STC_vect). When I enabled a timer interrupt too, I started getting bad responses from SPI protocol, intermittently.
04:41 PM Emil: spi slave?
04:42 PM Emil: because, mate, duh
04:42 PM Emil: if you send data too fast you lose bytes
04:43 PM enh: I was not loosing before
04:44 PM Emil: ...
04:44 PM Emil: because you didn't have an "async" timer that can take up your cpu time at any point
04:44 PM Emil: Come one now, enh
04:45 PM enh: I can fix this by using cli on the SPI interrupt, maybe.
04:45 PM Emil: Yes
04:45 PM Emil: wait
04:45 PM Emil: wat
04:46 PM Emil: mate
04:46 PM Emil: ISR(NAME_vect) already disables interrupts
04:46 PM Emil: you have to specifically enable them again to enable nesting
04:46 PM enh: is this always true?
04:46 PM Emil: http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html
04:49 PM Emil: http://www.nongnu.org/avr-libc/user-manual/optimization.html#optim_code_reorder
04:50 PM Emil: I need myself a fucking macro compiler
04:50 PM Emil: Can't trust gcc for shit
04:50 PM Emil: I'll just write everything in asm
04:50 PM enh: This is almost like writing your own compiler
04:51 PM Emil: You ARE the compiler
04:51 PM enh: I wonder how to do this with a coplex code
04:52 PM enh: *complex
04:52 PM Emil: C is stupid
04:52 PM Emil: Asm is where it's at
04:52 PM Emil: C is stupid and compiler writers are a bunch of faggots
04:53 PM enh: I wish I could disable my neighbours audio system from here. Legally.
04:54 PM enh: One day I will know enough to see things as you see, Emil
04:54 PM enh: Currently, gcc is my best bet.
04:56 PM Emil: enh: hah
04:56 PM Emil: enh: gcc is fine
04:56 PM Emil: but sometimes
04:56 PM enh: And currently, two ISR collisions, or what, are generating enough delays to mess my SPI protocol. I will have to limit the protocol to transfer only a possible set of value sizes, instead of data of arbitrary size.
04:56 PM Emil: sometimes you just need that optimisation
04:57 PM Emil: enh: but from a theory standpoint
04:57 PM Emil: enh: you understand the issue?
04:57 PM enh: yep.
04:57 PM Emil: that's good
04:58 PM Emil: so you should know how to fix it
05:00 PM enh: sometimes, very randomly, the slave does not respond the SPI interrupt call. The master calls and gets a copy of the last transmitted value. Usually, when this happens in the size of data transfer, it creates a big mess.
05:00 PM enh: Only when the timer ISR is also enabled this happens.
05:03 PM Emil: can you provide a pseudocode version?
05:03 PM Emil: I would have asked for code but from previous examples, I'm not touching your massive system :D
05:04 PM Emil: I mean
05:04 PM Emil: You have your timer vector
05:04 PM Emil: that's executed every nth cycle consistently
05:04 PM Emil: I assume
05:04 PM Emil: it does somethin and then exists
05:04 PM Emil: then you have your SPI interrupt
05:05 PM enh: yep
05:05 PM Emil: What SPI interrupt was it btw?
05:05 PM Emil: Executed at what point?
05:05 PM enh: ISR(SPI_STC_vect)
05:05 PM enh: Executed when a byte arrives at slave SPI
05:06 PM enh: and ISR(TIMER1_COMPA_vect) executed with a 1024 timer prescaler
05:07 PM Lambda_Aurigae: sounds like your timer interrupt is interfering with your spi timing.
05:07 PM enh: yep
05:07 PM Emil: Yeah so
05:07 PM Emil: You don't even get an interrupt until after the first byte has already finished shifting?
05:08 PM enh: SPI interrupts after shifting is complete
05:08 PM Emil: That means that if you send too fast you cannot load bytes quickly enough into a read bytes quickly enough from the spi
05:09 PM Emil: because the TIMER interrupt might block
05:09 PM enh: maybe yes
05:09 PM enh: but maybe worse
05:10 PM enh: if I do not put the correct byte into SPDR, in the correct time, the last byte transfered from master gets copied back to master
05:11 PM enh: Depending on which point of the protocol this happens, master receives a wrong value as data size.
05:11 PM enh: And works to transfer it
05:11 PM enh: And works to transfer all those bytes back.
05:12 PM enh: So. I cannot have a timer competing with SPI on the slave,
05:12 PM enh: or i cannot have the option of transfering data of arbitrary sizes
05:14 PM enh: or I need a much more complex protocol, using part of the byte as signals. Which gets way slower and more complex.
05:14 PM Lambda_Aurigae: send data twice...once forward once backward...master checks the two against each other.
05:14 PM Lambda_Aurigae: 10101100 00110101
05:15 PM Lambda_Aurigae: that's how the original lego mindstorms worked over their IR link.
05:15 PM enh: I tried that. Could be used on slave also. But then I have to introduce another acknowledge step after that.
05:17 PM enh: I do not know how complex it gets. Must try to implement and see if it does not create more problems than I can fix
05:18 PM enh: I'll try anyway. Thanks, Emil and Lambda_Aurigae.
05:21 PM enh: It was very hard for me to create a two way, one byte, protocol. I found it amazing to see how many problems I had to deal with.
05:22 PM enh: Just three states on the slave, and five on the master.
05:22 PM Lambda_Aurigae: I prefer i2c myself.
05:23 PM enh: I heard it hangs too.
05:23 PM enh: Not sure about it
05:23 PM Lambda_Aurigae: for one to one chip to chip rs232 works too.
05:24 PM enh: unfortunately i have a shared bus
05:24 PM Lambda_Aurigae: have done master slave with rs232 too.
05:24 PM Lambda_Aurigae: 9bit.
05:24 PM Lambda_Aurigae: like, master/multiple slave
05:25 PM LeoNerd: 9bit UART for addressing is fairly nice
05:25 PM Lambda_Aurigae: works great.
05:25 PM LeoNerd: Probably easier overall than trying to do the DMX-style BREAK stuff
05:25 PM Lambda_Aurigae: turn bit 9 on for address...slaves listen for that and when they hear their own address they start responding on the bus.
05:26 PM Lambda_Aurigae: send address a second time and that slave stops listening.
05:26 PM Lambda_Aurigae: from there it's just simple serial comms.
05:26 PM enh: How do you differ address second time from real data?
05:26 PM Lambda_Aurigae: 9th bit
05:27 PM enh: ok
05:27 PM Lambda_Aurigae: 9th bit set to 1 then the byte is an address
05:27 PM Lambda_Aurigae: 9th bit set to 0 then the byte is data.
05:27 PM enh: silly question. You said it before.
05:27 PM enh: never had problems?
05:27 PM Lambda_Aurigae: nope.
05:28 PM LeoNerd: One downside of 9bit is relatively few USB UART adapters will talk it
05:28 PM LeoNerd: So you're generally stuck "on your own" between AVR devices
05:28 PM enh: and speed. Isn't it slow?
05:28 PM Lambda_Aurigae: I've gotten 2Mb/s between AVRs
05:28 PM LeoNerd: Well it's surely only 8/9ths as fast as 8bit :)
05:28 PM enh: quite fast
05:29 PM Emil: Lambda_Aurigae: I love uart
05:29 PM Lambda_Aurigae: usually 1Mb/s is your max speed.
05:29 PM Emil: I know
05:29 PM Lambda_Aurigae: with some horking you can double that.
05:29 PM Emil: but from a protocol standapoint
05:30 PM Emil: It's super kawaii
05:30 PM Emil: You have full duplex
05:30 PM Lambda_Aurigae: no clue what a kawaii is other than some hawaiian island.
05:30 PM enh: i second
05:30 PM LeoNerd: Lambda_Aurigae: I've mentioned this before
05:30 PM LeoNerd: Apparently it's obvious in context and we don't need to ask
05:30 PM enh: yep
05:31 PM Emil: I mean
05:31 PM * LeoNerd finds himself reading about GPIB, also
05:31 PM Emil: Actually
05:31 PM Emil: Clocked full duplex spi would be best
05:31 PM Emil: But that takes 4 lines
05:31 PM polprog: ^^^
05:31 PM LeoNerd: Lots of wires though
05:31 PM Emil: yup
05:31 PM polprog: clocked full duplex paralell
05:32 PM polprog: superfast
05:32 PM Lambda_Aurigae: sqi
05:32 PM enh: I used a lot of GPIB, LeoNerd
05:32 PM Emil: polprog: I've been thinking about using parallel to transfer data in my project
05:32 PM polprog: nice
05:32 PM LeoNerd: enh: Any brief intro to its general abilities, anywhere? I don't want to recreate it itself, but I wonder if there's any cute tricks it has that I can steal for something else
05:32 PM Emil: polprog: you can get like 160Mbps theoretically
05:32 PM polprog: i think i should give it a try
05:32 PM enh: I used only commercial devices
05:33 PM Emil: But lets say that 40Mbps is enough
05:33 PM Lambda_Aurigae: GPIB and HPIB...wonderful stuff for its time.
05:33 PM enh: There is a cheap interface from prologix
05:33 PM enh: which can be handled via USB
05:33 PM LeoNerd: Oh, I don't need (or really want it) itself - infact physically I'm using a shared UART bus thing
05:33 PM enh: Much better than any NI like stuff
05:34 PM LeoNerd: .. which I feel sure ought to have a name but I still don't know of one
05:34 PM enh: Never got into the techncalities of the protocol. Only had to deal with it inside the lab.
05:35 PM LeoNerd: OK
05:35 PM enh: It hangs, though. sometimes.
05:35 PM enh: switch the computer off, from power cord, type of hanging.
05:37 PM Lambda_Aurigae: sounds like a software problem to me.
05:37 PM enh: A driver one, probably.
05:37 PM Lambda_Aurigae: still software.
05:38 PM enh: There are some things you cannot do, like taking off a GPIB cable with the interface online.
05:38 PM Lambda_Aurigae: aahh...back to GPIB...yeah...you don't hotplug that.
05:38 PM Lambda_Aurigae: it's not USB
05:38 PM Lambda_Aurigae: although, billy gates found out tht even USB hotplug has issues.
05:39 PM enh: Have to switch all off, switch off interface, detach, attach, switch all on, switch interface on.
05:39 PM LeoNerd: Well,... first off: all my serial bus devices are little MCUs, not a PC.. and secondly I'm defintely supporting replugging while running
05:39 PM LeoNerd: seems silly not to
05:40 PM enh: But with the USB GPIB from prologix (not NI), this issue got less critical.
05:40 PM enh: The NI USB GPIB still had this problem
05:46 PM enh: Is it hard to do data checksum?
05:48 PM enh: (I really want to bomb my neighbour 's sound system...)
05:52 PM Lambda_Aurigae: time to invent the rap-seeking-missile?
05:53 PM enh: more like a rap bombing drone...
09:43 PM enh: Is it possible to make a directional loud speaker?
09:46 PM Tom_itx: lidar
09:49 PM enh: https://filebin.ca/3dvvRDrdFAL0
09:53 PM Cracki_: enh, yes, it's called a phased array
09:53 PM Cracki_: https://twitter.com/FauthNiklas/status/919199135303168000
09:53 PM Cracki_: you don't even need settable delay.
09:58 PM Tom_itx: are those piezos?
10:00 PM Cracki_: no idea
10:00 PM Cracki_: ultrasonic though
10:01 PM Cracki_: it's his custom design. first iteration was a hexagon with no delay lines, so fixed beam. had really good directionality.
10:02 PM Cracki_: almost no perceivable attenuation over 10 meters
10:02 PM Cracki_: and this is the second iteration. it can do more, as you see
10:08 PM enh: Very nice
10:09 PM Cracki_: people were rickrolled with this at the last c3
10:10 PM Cracki_: (and other events)
10:25 PM enh: But I meant a way of producing a loud noise directly inside my neighbour's house, through his window.