#avr Logs

Nov 17 2017

#avr Calendar

05:20 AM Emil: Hmm
05:23 AM Emil: What's the best way to test if a byte has a bit pattern like 0b10xxxxxx?
05:23 AM Emil: where x is don't care
05:23 AM Emil: Single cycle multi level shift is also ok to include
05:23 AM Emil: so >>6 can be a single cycle instead of 6 like on avr
05:23 AM cehteh: huh? why so complicated?
05:23 AM cehteh: byte&bits_in_question == bitpattern
05:23 AM cehteh: byte& 0b11000000== 0b10000000
05:23 AM Emil: (v>>6)==m, (v&(128+64))==m, ((v^m)>>6)==0, ((v^m)&0b11000000)==0
05:24 AM cehteh: no shifts
05:25 AM Emil: cehteh: I said that multi shifts are okay since they are on x86 :D
05:25 AM Emil: but still it's an additional op to load that 6
05:25 AM cehteh: but why?
05:25 AM Emil: unicode
05:25 AM cehteh: unless i understand you wrong the above should just work with 2 instrructions
05:26 AM cehteh: and i have some tiny unicode functions .. moment
05:27 AM Emil: yeah, value&mask==pattern is perhaps the best
05:28 AM cehteh: http://git.pipapo.org/?p=muos;a=blob;f=src/muos/lib/utf8.h;h=5ce5a6429d3e396a712045a834466af2b6a79777;hb=refs/heads/lineedit
05:28 AM cehteh: and the utf8.c
05:28 AM cehteh: 48 return ((c & 192) == 192);
05:29 AM cehteh: :) looks familar :D
05:29 AM Emil: yup
05:29 AM Emil: It's quite annoying building the boilerplate in C for string distance metric
05:30 AM cehteh: at least these things are simple in utf8
05:30 AM Emil: https://emil.fi/projektit/strdist
05:30 AM cehteh: that was for AVR's .. but should be portable
06:08 AM Emil: hmm
06:08 AM Emil: cehteh: you have a bug
06:09 AM Emil: (c&192)==192 is not a good enough check for utf8 start
06:09 AM Emil: though, if you are assuming that there's only ascii and utf8 then it's fine
06:28 AM cehteh: yeah i dont check for validity
06:53 AM noHitW_work: is it wrong to put "paste" icon before "copy" icon ?
06:53 AM noHitW_work: or is there some universal rule that must be followed with them
06:54 AM noHitW_work: its just that "paste" is the more important function inj this case
10:04 AM Emil: It's not wrong
10:04 AM Emil: Just think about the usability
10:06 AM polprog: Emil: yeah i mean that ufw. i had to make a temporary nat but that got solved my iptables, i just had to temporarily unblock that port on ufw
12:04 PM enh: cehteh?
12:04 PM enh: https://plus.google.com/photos/photo/101630853631645381323/6489444872903674306?icm=false&iso=true
12:07 PM polprog: would be uncool if somebody misuploaded the face data and that thingy hunted the presenter
12:09 PM cehteh: hum doesnt play in my browser
12:10 PM enh: https://spectrum.ieee.org/automaton/robotics/military-robots/lethal-microdrones-dystopian-futures-and-the-autonomous-weapons-debate
12:11 PM cehteh: ah finally
12:12 PM cehteh: https://www.youtube.com/embed/fRj34o4hN4I
12:12 PM cehteh: thats even more scary
12:12 PM learath: boston robotics?
12:13 PM polprog: c++ on avrs?
12:33 PM enh: I use
12:34 PM enh: https://hackaday.io/project/11724-yauvec-yet-another-unmanned-vehicle-controller
12:34 PM enh: all c++
12:34 PM enh: I can shoot a big robot. What I can't shoot is a microdrone
12:35 PM enh: cehteh: How long can a microdrone fly?
12:35 PM polprog: my face when somebody sets up a darknet site where you upload the victim photo with 100btc and off goes a drone
12:36 PM polprog: disturbing as hell
12:36 PM enh: yep
12:36 PM enh: will happen.
12:36 PM cehteh: enh: as long the battery lasts
12:36 PM enh: there are dark enough people to create this
12:37 PM enh: dark minded, I mean
12:37 PM cehteh: 5-10 minutes .. depends on weight/efficiency
12:37 PM cehteh: and speed
12:38 PM enh: cehteh: there is a limit for that time. Is it based on the relation between battery power density x battery mass density and max throttle
12:38 PM enh: 5 minutes is a lot of time
12:39 PM enh: can you make a microdrone?
12:40 PM cehteh: what do you mean by micro?
12:40 PM enh: palm of your hand
12:40 PM cehteh: the smaller the more critical things become less marigin for choosing components
12:41 PM cehteh: i dont have interest in too small things, i like flying line of sight, which means i need to see the shit
12:41 PM enh: makes sense
12:42 PM cehteh: http://public.pipapo.org/00273.mkv that was years ago, my first fat hexa
12:42 PM cehteh: 2.5kg
12:43 PM enh: could not open
12:44 PM cehteh: what OS? what videoplayer?
12:44 PM cehteh: save to file perhaps
12:44 PM enh: I'll try
12:44 PM enh: have to go buy food. Be back in one hour
12:45 PM cehteh: http://public.pipapo.org/comp__M778602.jpg
12:45 PM cehteh: i go to bed
12:46 PM enh: Nice picture!
12:46 PM enh: Sleep well
12:56 PM fooman2011: Hello. I would to use an AVR to talk periodically (1 time per day) to 2 devices. One using I2C and the other using UART. The power is given by 3 AAA cells. Could you please tell me what is the best AVR that fit these requirements and with the lowest current consumption ?
12:58 PM polprog: i'd go for some attiny series
12:58 PM polprog: whether you put the cpu in sleep mode or not has a significant impact on current consumption
12:59 PM fooman2011: polprog: ok but attiny support UART and i2C at same times ?
12:59 PM polprog: some probably do
12:59 PM polprog: havent used them much
12:59 PM fooman2011: in this chart https://en.wikipedia.org/wiki/Atmel_AVR_ATtiny_comparison_chart it seems that UART is supported by very few attiny
01:00 PM fooman2011: and I need to talk to an I2C device but I'm not familar with I2C. I don't know if the AVR is the slave or the master. Is it slave ?
01:01 PM polprog: it can be both
01:01 PM polprog: that depends on the other chip
01:01 PM polprog: if the other chip is a slave then the avr has to me master
01:01 PM polprog: or vice versa
01:01 PM fooman2011: it is EEprom
01:02 PM polprog: then the avr is a master
01:02 PM polprog: also, "doesnt have i2c" means it doesnt have *hardware* i2c
01:02 PM fooman2011: oh in the chart they is no attiny as master for i2C. Is this chart is correct ?
01:02 PM polprog: you can always implement a soft i2c
01:03 PM fooman2011: there are existing libs to do that ?
01:03 PM polprog: most likely yes
01:04 PM fooman2011: ok cool thanks and about the UART, I have read that it is possible using USI. But is it easy using lib or should I have to implent this by myself ?
01:04 PM polprog: that depends on the lib, honestly i tried to use libs before i knew how to use usi... aand i learnt usi
01:05 PM polprog: or uart in my case
01:05 PM polprog: usi should be straightforward as well
01:06 PM fooman2011: OK so for example for my project I can use an ATTiny84 ? It should be ok ?
01:07 PM polprog: short answer yes, long answer you'd have to make softuart and soft i2c
01:07 PM polprog: you can use a mega series avr as well
01:07 PM polprog: they have more peripherals built in
01:07 PM LeoNerd: ATtiny84 has the USI module which helps a lot in making I²C
01:07 PM polprog: ^
01:07 PM fooman2011: well mega current consumption is higher. right ?
01:08 PM LeoNerd: It's not an entirely self-contained I²C module but it definitely assists; it's a lot simpler than doing it in pure bitbanging software
01:08 PM polprog: current consumption depends on the program you write
01:09 PM polprog: one attiny can take more current than other atmega if they are running different programs at different speeds
01:09 PM fooman2011: Always in sleep mode, but 1 time per day the AVR has to wake up, send uart and I2C commands and then sleep again.
01:09 PM polprog: it depends on the clock speed
01:09 PM polprog: the consumption is neglible
01:09 PM polprog: in this case
01:09 PM polprog: or i should say very low
01:10 PM fooman2011: I have read that atmega lower consumption is 4µA while attiny is in nA
01:10 PM polprog: again that depends
01:10 PM polprog: if you need exact data look for current consumption in the datahseet ratings
01:11 PM polprog: it's given in mA per MHZ
01:11 PM polprog: the faster the clock the more current it takes. also shutting down unused peripherals reduces that
01:11 PM fooman2011: For this project the clock speed is not very important I think.
01:11 PM polprog: i think that if it wakes up for a moment once a day, then the battery self discharge rate would drain it more than the avr itself
01:12 PM fooman2011: ok
01:12 PM polprog: you can run a properly programmed mega on a cr2032 cell for weeks
01:13 PM fooman2011: well ok so an AtMega328 will be ok.
01:13 PM fooman2011: Thanks very much for your help :)
01:13 PM LeoNerd: Oh also, if you had been considering the tiny84, take a look at the tiny841
01:13 PM polprog: np
01:14 PM LeoNerd: It has two real UARTs and a real I²C slave
01:14 PM NoHitWonder: is it available?
01:14 PM LeoNerd: I've been using them for yeara
01:14 PM NoHitWonder: oh sorry it was 328pb
01:14 PM LeoNerd: *years
01:14 PM polprog: i have some tiny4313s but i bought them for learning assembly and they had high enough pin count
01:15 PM polprog: ok, gotta order parts for the clock
01:15 PM LeoNerd: The 4313 is weird. 4Ki of flash, 17 GPIO pins, almost no peripherals
01:16 PM LeoNerd: No ADC. No USI or heaven-forbid, real SPI or I²C
01:16 PM polprog: yeah, i just picked one at random lol
01:17 PM fooman2011: LeoNerd: it seems that I need an I2C master
01:19 PM LeoNerd: fooman2011: The USI module works well as an I²C master. I've used that before
01:22 PM LeoNerd: In fact I came up with a rather cute way to share SPI and I²C on it :)
01:23 PM Jartza: also bitbanging i2c is simple
01:23 PM Jartza: even if t85 has usi, I'm bitbanging it
01:24 PM polprog: cute: http://pl.farnell.com/productimages/standard/en_GB/2383215-40.jpg
01:29 PM LeoNerd: I might have to turn that idea into another little board to sell on tindie actually
01:29 PM LeoNerd: nRF24 radio, ATtiny841, plenty of IO pins and buses
01:32 PM LeoNerd: The muxed SPI + I²C uses a 2G66 analog switch to isolate the clock+data pins on the 'tiny from the I²C bus
01:32 PM polprog: what else do i need to buy...
01:41 PM polprog: first time ordering from farnell
01:41 PM polprog: let's see how they perform
01:41 PM polprog: (lol at mouser and their 60pln postage)
01:54 PM polprog: https://www.youtube.com/watch?v=R9yLJoD2hz8
02:42 PM day__ is now known as daey
04:49 PM w0bni: I'm trying to control an SSD1306 OLED with the HW SPI of an ATmega328p, but I can't for the life of me get it working. When doing the transfer in software (https://pastebin.com/QAtQchhu) it works perfectly, but when I try to utilize the built-in SPI functionality (https://pastebin.com/px0nT7n1) the OLED commands seem to get messed up, eventually causing a blank screen. I'm guessing I've done something wrong
04:49 PM w0bni: when configuring the SPI, but I can't ...
04:49 PM w0bni: ... figure out what. Can anyone see where I messed up? I've tried all combinations of DORD/CPOL/CPHA without any luck :(
04:51 PM LeoNerd: Are you using it in 3wire or 4wire SPI mode?
04:51 PM LeoNerd: I.e. does it have a D/C# signal?
04:53 PM LeoNerd: Oh, also I believe you still need to set the DDRx register bits correctly when using the hardware SPI module
04:53 PM LeoNerd: The module will set the bits high or low but still needs DDR prodding
04:54 PM w0bni: LeoNerd: it does, which I'm currently controlling like this https://pastebin.com/FRDezPb1
04:54 PM w0bni: LeoNerd: oh, great point, the data direction is only overriden for slaves!
04:54 PM LeoNerd: Mmhm :)
04:55 PM LeoNerd: Do you have a logic analyser? If not I suggest one - they're really useful for this kind of question
04:57 PM w0bni: I don't, unfortunately, but wow, that does seem useful
04:57 PM w0bni: I'd probably be able to locate one at school
04:57 PM LeoNerd: Even just the cheap $20 Saleae clone + Sigrok software would be a good start
04:57 PM LeoNerd: I have that combo and I use it a lot
05:13 PM w0bni: I'll definitely get one, seems it would have saved me maany hours on this one
05:13 PM w0bni: Finally figured it out now, though - I had wired ATmega MISO to OLED Reset, but MISO is perma-configured as an input when SPI is enabled. Moved reset to another pin, and all is good!
05:14 PM w0bni: Thanks for the help and tips! :D
05:17 PM LeoNerd: Ahyes, reset
05:18 PM LeoNerd: I had an SSD1306 on a board that just outright refused to work. I could adjust settings but never managed to write to VRAM
05:18 PM LeoNerd: I tried eeeeverything. I was convinced my program was wrong, since it was the first one I ever tried
05:18 PM LeoNerd: Eventually I got hold of another one, and that worked just fine
05:18 PM LeoNerd: Turns out my original board didn't have the proper poweron-reset circuitry on it, the usual RC filter
05:22 PM w0bni: Oh, wow
05:22 PM w0bni: I can imagine a loot of debugging before trying a different one
05:23 PM LeoNerd: Yah.. I didn't imagine I'd bought a dead board
05:51 PM Emil: Damn
05:51 PM Emil: I'm beginning to get into Initial D
05:51 PM Emil: uhka, uhka.
05:51 PM Emil: LeoNerd: it's also the worst when prepping another board takes time
05:51 PM Emil: Say, with China esp8266 modules
05:52 PM Emil: It. Is. Pain.
11:58 PM day__ is now known as daey