#avr Logs

Oct 09 2017

#avr Calendar

12:11 AM day__ is now known as daey
04:19 AM eth3: is there an x86's RDTSC equivalent for atmegas?
04:19 AM ohsix: does reading the timer count register count
04:20 AM eth3: i'm trying to insert a minimal code fragment into an existing firmware, so I don't know if the timer is used for something
04:20 AM eth3: is there a safe way to read it?
04:20 AM eth3: with no external assumptions
04:20 AM eth3: and not reading the whole code
04:23 AM eth3: to simplify things - i just want to measure how long does it take for a piece of code to execute. what's the least invasive way?
04:26 AM rue_bed: led before the code starts turned off after the code finishes
04:26 AM rue_bed: use a scope or logic analizer to measure
04:26 AM rue_bed: speeling
04:27 AM eth3: nothing simpler than that?
04:27 AM rue_bed: nope
04:27 AM rue_bed: you should have atleast a $5 logic analizer anyhow
04:27 AM rue_bed: stil cant speel
04:27 AM rue_bed: lskjfd
04:27 AM eth3: i think i do, but it worked so bad i never tried second time
04:28 AM eth3: anyway, a software change is still cheaper than $5
04:28 AM rue_bed: what type was it?
04:28 AM eth3: one of those usb ones. something bee? usbee?
04:28 AM rue_bed: hmm, I got a salee knockoff that works great
04:29 AM eth3: ah, and btw i don't have a spare pin for an led
04:29 AM rue_bed: you have something, you just dont want to
04:31 AM eth3: indeed i don't want to wait for a delivery of an analyzer, paying for it, unsoldering something to be able to add a led
04:31 AM eth3: too complicated to get an integer
05:43 AM Emil: eth3: donät listen to rue_bed
05:43 AM Emil: if you want to check how long a piece of code takes to execute
05:43 AM Emil: then config timer, start timer, execute code, stop timer, send timer value out of uart
05:44 AM Emil: if you have a scope then toggling a port value is good, though
05:56 AM eth3: i'm afraid the timer is used in the firmware elsewhere
05:56 AM eth3: wouldn't it break things if i start adjusting it on the fly?
06:26 AM thardin: what the.. memset() won't set areas larger than 32k
06:28 AM thardin: -Wno-stringop-overflow seems to fix it
06:30 AM Lambda_Aurigae: you have 32K of ram to set?
06:32 AM thardin: 64k
06:32 AM thardin: xmem
06:32 AM Lambda_Aurigae: on what chip?
06:32 AM thardin: atmega128
06:32 AM Lambda_Aurigae: aahh.
06:33 AM thardin: using a constructor so it gets set up before main()
06:33 AM Lambda_Aurigae: I got an old mega128 here somewhere.
06:34 AM Lambda_Aurigae: did external memory with it once.
06:34 AM Lambda_Aurigae: glub,,that was,,12ish years ago.
06:45 AM thardin: holy crap avrdude (avr109) is slow at reading EEPROM
06:47 AM Emil: thardin: you are probablu using the divide by 8 fuse
06:47 AM Lambda_Aurigae: eth3, all 3 timers are used?
06:47 AM Emil: disable that fuse
06:48 AM thardin: nope, running on 7.28 MHz crystal
06:49 AM thardin: but no biggie, I only need to write a few bytes
06:49 AM Emil: ...
06:49 AM Emil: mate
06:49 AM Emil: your clock source is irrelevant
06:49 AM Emil: divide by 8 fuse is after the clock source
06:50 AM thardin: I'll have a look. but considering USART works fine with -DF_CPU=7372800LL ..
06:52 AM Lambda_Aurigae: eeprom isn't exactly speedy to start with on the AVR
06:52 AM Lambda_Aurigae: but shouldn't take very long to read the whole thing.
06:53 AM thardin: like 30 seconds currently. but this is over 115200 baud serial
06:54 AM Lambda_Aurigae: eeprom isn't that large.
06:54 AM Lambda_Aurigae: no way it should take that long to read, even if the chip was running at 1MHz.
06:54 AM Lambda_Aurigae: sounds like a software problem to me.
06:55 AM eth3: Lambda_Aurigae: no idea, i probably need to read the whole source to find that out...
06:55 AM Lambda_Aurigae: unless for some reason avrdude is doing it one byte at a time
06:55 AM thardin: I suspect it is
06:56 AM thardin: there's no divide by 8 fuse on atmega128
06:56 AM Lambda_Aurigae: eth3, you could read a timer at the beginning and at the end and find the difference, however, no guarantee that particular timer will be running during that time frame or won't get reset.
06:57 AM eth3: Lambda_Aurigae: would i potentially need to disable interrupts as well during that period?
06:58 AM Lambda_Aurigae: eth3, if you didn't want anything else running during that time, yes.
06:58 AM Lambda_Aurigae: but that could break other things in your code if they rely on interrupts...
06:59 AM eth3: yeah, this is why i'm a bit reluctant to dive in
06:59 AM Lambda_Aurigae: you need to understand the program, what it does, how, and when.
06:59 AM eth3: thought there might be an easy way
06:59 AM Lambda_Aurigae: there is an easy way.
06:59 AM Lambda_Aurigae: but
06:59 AM eth3: i really don't want to read hundreds of kb of sources
06:59 AM Lambda_Aurigae: you have to understand your code.
06:59 AM eth3: so there is no direct RDTSC equivalent?
07:00 AM Lambda_Aurigae: no matter what, if you want just your little code segment to run and get timed you will have to turn off interrupts or other things could be interrupting your code.
07:00 AM Lambda_Aurigae: no, there isn't.
07:01 AM eth3: that's pity, thanks anyway
07:01 AM Lambda_Aurigae: guessing you also haven't read the datasheet on the chip you are working with.
07:01 AM eth3: why? would it tell me something about the firmware?
07:02 AM Lambda_Aurigae: no, but it would tell you about the chip you are working with and answer the question on the RDTSC equivalent.
07:03 AM eth3: which is negative
07:03 AM eth3: so why bother?
07:03 AM Lambda_Aurigae: you don't pick up a screwdriver and start working on your car engine without having knowledge of how that engine works...same thing for microcontrollers in my opinion.
07:03 AM eth3: too far-fetched example
07:04 AM Emil: eth3: ...
07:04 AM Lambda_Aurigae: sorry, but it's early.
07:04 AM Emil: eth3: you are a tad arrogant
07:04 AM Emil: Listen to Lambda_Aurigae
07:04 AM Lambda_Aurigae: you want to work with microcontrollers, read the datasheets.
07:04 AM Lambda_Aurigae: learn how they work
07:04 AM Lambda_Aurigae: what they can and can not do...it's all in the datasheet.
07:04 AM eth3: Lambda_Aurigae: i don't work with a microcontroller. i work with a specific existing code
07:04 AM eth3: Emil: why am i arrogant?
07:04 AM Lambda_Aurigae: which code you apparently don't understand
07:05 AM eth3: of course i don't
07:05 AM Lambda_Aurigae: Emil, I'm the arrogant one!
07:05 AM Lambda_Aurigae: [:
07:05 AM eth3: otherwise i wouldn't be here
07:06 AM eth3: all i wanted to know if there is a shortcut to reading a pile of irrelevant code
07:06 AM Lambda_Aurigae: the easy way to do what you want is to pick an unused timer, configure said timer, set it to zero, start it running, run your code, stop the timer, read the timer
07:06 AM eth3: apparently there isn't
07:07 AM eth3: Lambda_Aurigae: this is something i wanted. all i need is to confirm that the existing code does not use all three timers
07:09 AM Lambda_Aurigae: if your code also uses interrupts and there is a chance an interrupt could fire during your code snippet then you should turn off interrupts as well...not understanding what is going on in the code and with the chip can lead to some issues by disabling interrupts...things like communications or realtime-responses to stimuli..
07:10 AM eth3: Lambda_Aurigae: the problem is - it's not my code
07:10 AM eth3: Lambda_Aurigae: i'm just fiddling with some small fragment
07:10 AM eth3: this is why i want to be extra careful
07:10 AM Lambda_Aurigae: it still helps to know the code and know the chip.
07:12 AM eth3: i don't really understand what else do i need to know about the chip apart the number of timers it has
07:12 AM Lambda_Aurigae: how to work with the timer for starters.
07:13 AM Lambda_Aurigae: all depends on what your code overall and your specific code snippet do too.
07:14 AM Lambda_Aurigae: chaos, panic, disorder...my job here is done...time to go to work.
07:14 AM eth3: when i get to the moment of working with timers, i open the datasheet and read the relevant parts. reading all thousand pages is an overkill for this simple task
07:14 AM eth3: thanks and good luck with the job!
10:25 AM enh: hi
10:54 AM enh: Can a keyboard be made directly on a PCB, without switches? Would be quite cool
10:58 AM Emil: whatcha mean without swtiches
10:58 AM Emil: switches*
10:58 AM Emil: Sure you can do those plastic dome things
10:58 AM Emil: But they are switches all the same
10:58 AM Emil: you could also do capacitive sensing
10:59 AM enh: more like capacitive stuff.
10:59 AM enh: with keys painted using silk
11:05 AM HighInBC: you could, but it would not be fun to use
11:10 AM Emil: It depends how skillful your filtering scheme is
11:10 AM Emil: You'll have to employ nonlinear filters
11:10 AM Emil: And decision trees
11:16 AM HighInBC: keyboards should give a nice tactile response in my opinion, touch keyboards always drive me nuts
11:21 AM Emil: It depends
11:34 AM polprog: touch keyboard sucks for anything else that the phone. it's just not possible to type without looking.
11:36 AM Emil: wat
11:37 AM Emil: of course you can type without lookin
11:37 AM Emil: as long as you can see the feedback on your screen
11:38 AM polprog: good luck lol
11:39 AM polprog: but i guess im biased. i went for a lower laptop model just to have an old style keyboard
11:57 AM polprog: https://twitter.com/mikelectricstuf/status/916675099624902656
01:14 PM Emil: cehteh: you've got an opto to recommend?
02:34 PM JanC_ is now known as JanC
02:36 PM cehteh: Emil: nop
02:49 PM Emil: https://emil.fi/jako/kuvat/2017-10-09_22-18-13_hQNimW0V.png
02:51 PM polprog: still doing your power thingy?
02:52 PM cehteh: just some generic opto, check which forward current it needs, pick approbiate cap for that (below the max current) and zener around the forward voltage of the opto
02:53 PM Emil: polprog: eh
02:53 PM Emil: whatcha my own power thingy?
02:53 PM Emil: s/my/mean
02:54 PM polprog: you know, the one where you had that diff amp with a lot of resistors
02:54 PM polprog: what was thatt
02:54 PM Emil: a) it wasn't a diff amp
02:54 PM polprog: opamp*
02:55 PM Emil: b) the lots of resistors were to provide protection in case one of them fails
02:55 PM Emil: and shorts
02:55 PM polprog: yes, what was that device
02:55 PM Emil: to measure mains voltage
02:55 PM polprog: aha
02:58 PM polprog: thats what i wanted to know
02:59 PM Emil: If you want exercise
02:59 PM Emil: Look at that picture
02:59 PM Emil: and analyse the bottom portition
02:59 PM Emil: Why I have included and what
02:59 PM Emil: Why have I put in stuff
02:59 PM polprog: ok
03:00 PM polprog: diode for coil transient suspression, MOS for enabling with a pulldown
03:00 PM polprog: im thinking about that 1M resistor and 1u cap combo
03:00 PM Emil: MOS for enabling with a pulldown but is it a direct pulldown?
03:00 PM Emil: I don't see a direct pulldown
03:01 PM polprog: it has low impedance for AC and 1M for DC
03:01 PM polprog: is that 3x1 header for configuring whether it's a pullup or pulldown?
03:01 PM Emil: yes
03:01 PM polprog: nice
03:01 PM Emil: why would I do that?
03:02 PM polprog: to pull up or down the gate...
03:02 PM polprog: you probably arent sure whether to pull up or down so it's configurable>
03:02 PM polprog: ?
03:02 PM Emil: It's so that the user can select which state they prefer
03:02 PM polprog: yeah
03:03 PM polprog: thats what i said, moreless
03:03 PM Emil: the capacitor resistor combo is to have the configuration be selected slightly faster than the device is enabled
03:04 PM Emil: I might tweak the values
03:04 PM polprog: i dont get it... im listening
03:04 PM Emil: We are dealing with relays here
03:05 PM polprog: yeah
03:05 PM Emil: Switching high voltages
03:05 PM Emil: or currents or whatever
03:05 PM polprog: the coil side is low voltage
03:05 PM Emil: You don't want the circuit to be enabled before you have made the configuration
03:05 PM Emil: since the relays aren't latching
03:05 PM Emil: So you want the circuit to be enabled slightly slower than the configuration is made
03:06 PM polprog: configuration == jumper on the coil
03:06 PM polprog: ?
03:09 PM polprog: ?
03:11 PM Emil: what jumper on coil :D
03:11 PM polprog: gah
03:11 PM polprog: on the gate
03:13 PM Emil: https://emil.fi/jako/videot/2017-10-09_22-42-18_UHfijaUf.mp4
03:14 PM Emil: Hmm
03:14 PM Emil: I wonder why it's so god damn laggy
03:14 PM Emil: http://tinyurl.com/y9occpn6
03:14 PM polprog: yeah, i see, that cap is slowly charging up
03:16 PM polprog: so, i put the jumper, the output is sloowly rising.
03:16 PM polprog: then
03:16 PM Emil: But the other relay is triggered faster
03:16 PM polprog: ah
03:16 PM polprog: gah
03:16 PM polprog: of course!
03:17 PM Emil: Meaning that the wanted configuration will be enabled first, and then the enable relay triggers later
03:17 PM polprog: i have an idea
03:17 PM polprog: a schmit triger there so the mos is sitll driven with a logic level instead of analog
03:17 PM Emil: The 1M resistor is to slowly bleed it out if there's no power
03:18 PM Emil: polprog: not a bad idea
03:18 PM polprog: :)
03:18 PM polprog: yay
03:18 PM polprog: i invented something ;)
03:21 PM Emil: I need a small schmitt trigger
03:22 PM polprog: make one...
03:22 PM polprog: 0603 resistors and a so 8 op amp
03:22 PM Emil_: that's huge
03:22 PM polprog: how big is your relay
03:23 PM twnqx: single gate hct logic, sot-23?
03:23 PM Emil: that's good
03:25 PM twnqx: http://www.ti.com/product/SN74AHC1G14
03:25 PM twnqx: or the same from on semi
03:25 PM Emil: On the other hand I don't realy care if there's some heat dissipation in the mosfet
03:26 PM twnqx: https://www.onsemi.com/pub/Collateral/MC74VHC1G14-D.PDF
03:26 PM twnqx: https://www.onsemi.com/pub/Collateral/NL17SZ17-D.PDF in non-inverting
03:27 PM twnqx: cuties.
03:33 PM polprog: cool chips
03:55 PM rue_shop3: I have some 1G14
03:56 PM rue_shop3: why did they make the 17 version if the 14 exists?
03:56 PM rue_shop3: the 1G14 I got for making TINY oscillators
04:31 PM twnqx: the 17 is noninverting. maybe some people just want non-inverting buffers?
07:00 PM rue_shop3: ah
07:01 PM rue_shop3: thats right, I was mixing it up with the 07
07:01 PM rue_shop3: (hv driver)