#avr Logs

May 29 2017

#avr Calendar

01:41 AM day__ is now known as daey
02:06 AM day__ is now known as daey
02:39 AM JanC_ is now known as JanC
04:00 AM day is now known as daey
08:01 AM day is now known as daey
12:37 PM polprog: i know i should not be using delay loops in my code
12:37 PM polprog: but i cant get my head around calculating them..
12:37 PM polprog: if you have any good guide please share
12:44 PM Casper: there is nothing wrong in using delay loop
12:44 PM Casper: and is in fact mandatory sometime, as in no other way to do it
12:44 PM polprog: well, i dont know
12:44 PM polprog: it's a month since i started assembly...
12:44 PM Casper: it is however seen as a bad practice as you waste time, but you do need to waste time sometime..
12:45 PM polprog: yeah
12:45 PM polprog: what are you gonna do, stop the clock :P?
12:46 PM Tom_L: if you can figure out how to do that you may become rather wealthy
12:46 PM Casper: to make busy loop, you basically make a loop of useless instructions and calculate how much time each instruction use.. like a NOP is 1 cycle, a jump is 2 I think and I think a conditionnal jump is 3.... and so on... there is a table at the end of the datasheet for that
12:46 PM Tom_L: nop
12:47 PM polprog: well that i understand
12:47 PM Tom_L: loop inside loop inside loop if necessary
12:47 PM polprog: the problem begins at, let's say, 10k cycles where the loop must be in another loop
12:47 PM Casper: and that's the thing... busyloop are frowned uppon, but those who complain about them can't tell you what else to use
12:47 PM Casper: you can use a loop in loop in a loop
12:47 PM Tom_L: void Delay(int delay)
12:47 PM Tom_L: {
12:47 PM Tom_L: int x, y;
12:47 PM Tom_L: for (x = delay; x != 0; x--)
12:47 PM Tom_L: {
12:47 PM Tom_L: for (y = 1000; y != 0; y--)
12:47 PM Tom_L: {
12:48 PM Tom_L: asm volatile ("nop"::); //do nothing for a bit
12:48 PM Tom_L: }
12:48 PM Tom_L: }
12:48 PM Tom_L: }
12:48 PM polprog: what is this
12:48 PM Tom_L: a delay
12:48 PM polprog: you cant just mix two fors
12:48 PM polprog: and assembly
12:48 PM polprog: and expect a predictable delay
12:48 PM Casper: of course you can
12:48 PM polprog: what if the compiler version changes?
12:49 PM polprog: what if it decides to store X and y in RAM?
12:49 PM polprog: i dont fell this is a precise way
12:49 PM polprog: feel*
12:49 PM Tom_L: what if, what if what if....
12:49 PM Tom_L: life is uncertain
12:49 PM polprog: let me finish
12:49 PM Casper: of course, with C you may have issues, but if you do it in ASM them replicate that
12:50 PM Tom_L: do it all in asm then...
12:50 PM Casper: but the compiler will try to optimise it, those loop are basic things and shouln't change from version to version
12:50 PM polprog: i can calculate a loop like this
12:50 PM polprog: ldi r18, 10
12:50 PM polprog: loop:
12:50 PM polprog: dec r18
12:50 PM polprog: brne loop
12:50 PM Tom_L: that's the closest you can get to full control
12:50 PM Casper: also, if you use C then you can use the _delay_ms/us();
12:50 PM polprog: im coding in asm now, in c i'd use the functions
12:50 PM polprog: ofc
12:51 PM polprog: but the problems starts when theres a nested loop and one of the registers overflows to 255
12:51 PM polprog: i mean i just cant calculate the proper cycle amount
12:51 PM polprog: i got close...
12:51 PM polprog: still off by 2/4 cycles
12:52 PM polprog: im trying to understand the way of thinking behind this
12:52 PM polprog: http://www.bretmulvey.com/avrdelay.html
12:52 PM Casper: read more the opcode list
12:52 PM Casper: and do more math
12:52 PM polprog: i have it on my laps
12:52 PM polprog: if the ldi takes 2 cycles then my life is complete
12:53 PM polprog: becuase i spot the final mistake
12:53 PM theBear: when i wanna workout why something timey isn't right i tend to give the compiler asm output a quick browse and usually it's not THAT hard to spot
12:53 PM polprog: its not
12:53 PM theBear: that's what the datasheet is for
12:53 PM theBear: aww
12:53 PM polprog: i do check the compiled asm against the original
12:54 PM Casper: asm is assembled, not compiled.... C get compiled and you can get a pseudo asm output with some command magics
12:54 PM polprog: my mistake
12:56 PM Casper: extremelly usefull actually when you try to figure out why your timing is screwed up in C (the compiler love to kill 'redundant' stuff... nop nop nop nop -> nop
12:56 PM polprog: yeah
12:56 PM polprog: so, i guess i will try to do math again
12:56 PM polprog: going more into abstractions
12:56 PM polprog: calculating more stuff in particular
12:56 PM Casper: heck... once uppon a time, I did like: while(1) { PORTA = PINB; } the compiler decided to optimise it to just PORTA = PINB; once... no loop...
12:56 PM polprog: lol
12:57 PM Casper: it figured out that the loop was useless, since you never write to pinb
12:57 PM polprog: that's why i disable optimisations
12:57 PM polprog: if stuff breaks
12:57 PM theBear: asm is kinda a remotely readable version of what becomes the final code that the cpu sees, looks a lot like the stuff at the back of the datasheet describing all yer ldi etc's
12:57 PM Casper: they fixed it, it was a bug... incomplete declaration of stuff
12:58 PM theBear: unless i forgot the words in which case that won't be right :)
12:58 PM Casper: asm is human readable machine code with some extra labels
12:58 PM polprog: that's the lowest comfortable level
12:58 PM theBear: been a long time, and i never known anyone else that is into programming nearly that low to talk to about it, so ya know, the words don't matter much :)
12:59 PM polprog: i started on avrs with c
12:59 PM polprog: i just wanna learn assembly because i feel that writing the lowest level stuff in it is useful
12:59 PM polprog: i would never do some advanced algorhitms in it though
12:59 PM aczid: just disassemble your avr binaries and look at what the compiler makes of your C
12:59 PM polprog: like quicksort
01:00 PM aczid: good way to learn asm imho
01:00 PM polprog: the learning part of asm is the syntax and quirks of your assembler mostly
01:00 PM theBear: either way, unlike how normal code gets compiled as the compiler feels is best to achieve what the code is, yer asm doesn't "change", it gets ya know, reformatted into something much less readable that a cpu can chomp on, but yer can add up/count stuff in there and be sure that is how many cycles it'll take to actually run on the cpu
01:00 PM theBear: cpu/micro
01:00 PM polprog: and how you can mix asm and C
01:01 PM aczid: yeah that remains a pain very often :D
01:01 PM aczid: puzzling/fighting with inline asm syntax
01:01 PM polprog: well, it took me a whole week to find some obscure presentation that actually made it clear
01:01 PM theBear: inline assembler they call it, basically you write a chunk of asm, and tell the compiler not to touch it, just pass it verbatim between it's output on either side of that chunk in yer program
01:01 PM aczid: well, you can pass in/out arguments from/to C
01:02 PM Casper: the gain in speed and space on assembler is only due to the experience of the coder in that exact field
01:02 PM polprog: that the params from the c function should be put in even registers staring with r24
01:02 PM Casper: in many cases, C isn't faster
01:02 PM polprog: ok, so i just put 1500 cycles into that webiste
01:02 PM aczid: in many cases the compiler is smarter than you though
01:02 PM polprog: ^^
01:02 PM polprog: let me try checking it by hand
01:03 PM theBear: hehe, you maybe, but yer need a special compiler to be smarter than me <cheeky grin>
01:03 PM aczid: it all depends :)
01:03 PM aczid: size matters too
01:03 PM theBear: heh well played
01:04 PM polprog: theBear: can i email you my code and you'll reply with the hexfile? :P
01:05 PM theBear: not until i renew my dns registration <grin>
01:05 PM polprog: oh man
01:05 PM polprog: i got it!
01:05 PM polprog: yay
01:05 PM polprog: i just needed to think a bit more
01:05 PM polprog: also im getting a dns
01:06 PM theBear: yeah, but yer email address won't start like polprog@fucking.rememberit.something <grin>
01:06 PM polprog: it will be simpler
01:14 PM Lambda_Aurigae: how about ray@bethnray.com ?
01:14 PM Lambda_Aurigae: from that one can guess the wifey's address.
01:21 PM xentrac: heh
01:23 PM xentrac: very often when I'm writing something in assembly, I write a C version and look at the compiler's output
01:23 PM polprog: nice trick
01:23 PM xentrac: then I can take parts or the whole thing if it seems better
01:23 PM xentrac: than what I thunk up
01:24 PM xentrac: this prevents my assembly from being slower than C would be :)
01:24 PM xentrac: but sometimes it's faster
01:29 PM Lambda_Aurigae: I haven't done a full project in assembly in some time.
01:29 PM Lambda_Aurigae: mostly just assembly blocks in C functions.
01:30 PM Lambda_Aurigae: for tight timing stuff like for vga video generation.
01:43 PM xentrac: yeah, it really isn't worth it any more
01:43 PM FL4SHK: Lambda_Aurigae: I'd rather use an FPGA for that kind of stuff tbh
01:43 PM FL4SHK: :P
01:44 PM FL4SHK: I tried to do composite video (NTSC) generation with an AVR at one point
01:44 PM FL4SHK: Decided that cycle counting wasn't for me :P
01:44 PM FL4SHK: UNLESS it's in FPGA code
01:44 PM xentrac: there's a library called TVout for that, but it only does B&W on an AVR
01:44 PM xentrac: well, it's an AVR library
01:44 PM FL4SHK: Yeah
01:45 PM xentrac: also it only works in framebuffer mode, which is pretty suboptimal on an AVR
01:45 PM FL4SHK: ...yes
01:45 PM xentrac: (so I understand why you would want to write your own. and why you'd want to do it on an FPGA instead)
01:46 PM xentrac: I still haven't done anything with those PALs I picked up
01:46 PM FL4SHK: I think I'd prefer to do VGA generation instead of composite video
01:46 PM FL4SHK: VGA is still analog, mind you, but you get 8 colors out of just three pins
01:47 PM FL4SHK: without a DAC
01:47 PM FL4SHK: though you might still need a DAC for some other stuff, hm...
01:47 PM FL4SHK: but at least you don't need it for colors themselves IIRC
01:48 PM FL4SHK: I haven't been successful generating VGA signals before
02:03 PM xentrac: you could probably get 8 grayscales out of three pins with some resistors, although they might not be quite evenly spaced
02:03 PM xentrac: but the gamma curve for the monitor is probably going to add more nonlinearity than whatever imprecision you get with modern resistors :)
02:04 PM xentrac: but yeah, VGA color is definitely going to be a lot less demanding on the timing than composite video color!
02:05 PM xentrac: I haven't tried but it sounds like you're saying it isn't as easy in practice as it sounds?
02:13 PM Lambda_Aurigae: FL4SHK, with 4 pins you can get 16 colors..just need a few resistors to make a little dac-ish thingie.
02:13 PM Lambda_Aurigae: you get RGBI
02:13 PM FL4SHK: oh
02:13 PM FL4SHK: interesting
02:13 PM Lambda_Aurigae: the 4th bit changes all 3 of the other colors at the same time.
02:13 PM xentrac: but you don't have RAM for a decent-resolution framebuffer on an AVR
02:14 PM Lambda_Aurigae: just like CGA
02:14 PM Lambda_Aurigae: if you use an atmega1284p you can get ok.
02:14 PM Lambda_Aurigae: Jartza does a text/graphics video with attiny85
02:14 PM xentrac: CGA had 32 kilobytes of framebuffer
02:14 PM Lambda_Aurigae: or 3 bit color with 3 of them.
02:14 PM Lambda_Aurigae: yes..you get higher resolution with larger framebuffer.
02:15 PM Lambda_Aurigae: you can still generate 640x480 video signal and a lower resolution overall in that venue.
02:15 PM xentrac: yes, certainly
02:15 PM Lambda_Aurigae: I have played with some serial srams that clock out at 20MHz for generating video.
02:15 PM xentrac: You mentioned!
02:15 PM xentrac: They sound pretty tasty
02:15 PM Lambda_Aurigae: 1Mbit serial srams with sqi capability.
02:16 PM Lambda_Aurigae: 4 bits at a time output giving me rgbi
02:16 PM xentrac: right
02:16 PM xentrac: I'm just saying that if your framebuffer is in the AVR's RAM, 4-bit color is super expensive
02:16 PM xentrac: even on an ATMega1284p!
02:16 PM Lambda_Aurigae: I've switched to pic32 for it though just because that's what I've been playing with.
02:16 PM xentrac: what's pic32 lik?
02:16 PM Lambda_Aurigae: you could run 4 atmega1284p chips
02:16 PM xentrac: like?
02:16 PM Lambda_Aurigae: pic32 rocks.
02:16 PM Lambda_Aurigae: it's a mips32 core.
02:16 PM Lambda_Aurigae: not a pic processor at all.
02:16 PM xentrac: heh
02:16 PM xentrac: thank god!
02:17 PM Lambda_Aurigae: but has the nifty pic peripherals on it.
02:17 PM xentrac: ahhh
02:17 PM xentrac: awesome!
02:17 PM Lambda_Aurigae: the one I use is the pic32mx270f256b
02:17 PM xentrac: is there anything out there that has a PDM peripheral rather than PWM?
02:17 PM Lambda_Aurigae: 256k flash, 64K sram, 50MHz/83dmips
02:17 PM xentrac: in hardware I mean
02:17 PM Lambda_Aurigae: PDM?
02:17 PM xentrac: pulse density modulation
02:17 PM Lambda_Aurigae: not familiar with that one.
02:18 PM Lambda_Aurigae: aaahh..
02:18 PM Lambda_Aurigae: FM
02:18 PM xentrac: I guess you could use the AVR's PWM peripheral for it actually...
02:18 PM xentrac: kind of, yeah
02:18 PM xentrac: I mean you do change the frequency all the time
02:19 PM Lambda_Aurigae: never done anything with that.
02:19 PM Lambda_Aurigae: did some PPM a while back...like, 6 years ago.
02:19 PM xentrac: but the frequency is at its max when you're at 50% duty cycle
02:19 PM Lambda_Aurigae: both encoding and decoding.
02:19 PM xentrac: what for?
02:19 PM Lambda_Aurigae: RC aircraft control
02:19 PM Lambda_Aurigae: well, RC groundcraft really.
02:20 PM Lambda_Aurigae: older radios would send a stream of pulses with different timing...pulse position.
02:20 PM Lambda_Aurigae: and the position of the pulses within the frame would determine the position of the servos(or speed of the motor being controlled)
02:20 PM Lambda_Aurigae: it's how older RC radios worked.
02:22 PM Jartza: wuut
02:22 PM Jartza: I've been mentioned
02:23 PM xentrac: I had no idea! I thought they were all FM or something
02:23 PM Lambda_Aurigae: FM is the carrier.
02:23 PM Lambda_Aurigae: older ones were AM
02:23 PM Lambda_Aurigae: but the signal being sent to control the servos is very simple PPM.
02:24 PM Lambda_Aurigae: at least, for older systems.
02:24 PM Jartza: FL4SHK: https://www.youtube.com/watch?v=G1QWNDck0yU
02:24 PM Lambda_Aurigae: the transmitter would send the ppm and the receiver would just grab the 1ms duration timing areas and feed the pulse out to the servos.
02:24 PM Jartza: that's attiny85 :)
02:24 PM Lambda_Aurigae: heya Jartza
02:26 PM xentrac: Jartza: if we were on a better timeline that diverged in 1960 or so, what would we have instead of ANSI graphics?
02:26 PM xentrac: this is a very nice demo :)
02:26 PM Lambda_Aurigae: it does graphics too!
02:26 PM Lambda_Aurigae: bitbanged 9600 baud serial input.
02:27 PM Lambda_Aurigae: for the color version all 3 chips run from one crystal oscillator and all receive the same serial signal and just accept the one intended for that color.
02:29 PM Jartza: yeah
02:29 PM Jartza: :)
02:29 PM Jartza: it's pretty genious
02:29 PM xentrac: very nice :)
02:29 PM xentrac: Lambda_Aurigae: interested to hear your opinion on that question too
02:29 PM Jartza: xentrac: gif :D
02:30 PM Jartza: this is the same octapentaveega: https://www.youtube.com/watch?v=YL0RwEtTN70
02:30 PM Jartza: but this time it does graphics
02:30 PM Jartza: it can also do split-screen graphics/text
02:30 PM Lambda_Aurigae: xentrac, not sure really how to answer that.
02:31 PM Lambda_Aurigae: I like ANSI/ASCII
02:31 PM Jartza: resolution isn't much, but hey, it has 512 bytes of ram :D
02:31 PM xentrac: hmm, like an LZW-encoded stream of chunks of pixels that can include time delays, Jartza?
02:31 PM Jartza: dunno
02:31 PM Jartza: ansi is pretty nice in it's own merit
02:31 PM xentrac: Lambda_Aurigae: yeah, certainly there are worse possible timelines we could be on. we could have had EBCDIC or Baudot
02:31 PM Jartza: just thinking what would world be like if we didn't have the 6 and 7 bit serial connections before :)
02:32 PM Jartza: then we could've made ansi espace character to be something else than <esc>
02:33 PM xentrac: one possible alternate timeline diverging around 1970 has 16-bit words instead of 8-bit bytes as the fundamental unit of exchange; the Data General Nova worked this way
02:33 PM xentrac: maybe that would have offered space for a larger character set or something, but the DG dunderheads just used them to store two 8-bit bytes of ASCII
02:33 PM Lambda_Aurigae: baudot rocked! for teletypes.
02:33 PM Emil: xentrac: >words
02:34 PM Emil: xentrac: those 16-bit numbers would be called bytes
02:34 PM Lambda_Aurigae: I remember typing sequences out onto punched tape then playing them out through the teletype.
02:34 PM Jartza: oh and yeah, of course
02:34 PM Jartza: https://github.com/rakettitiede/octapentaveega
02:34 PM xentrac: baudot wasn't super great for teletypes
02:34 PM Jartza: octapentaveega is pure open source
02:35 PM Jartza: both sw and hw
02:35 PM xentrac: Emil: maybe if the divergence was around 1950 they would be
02:35 PM Jartza: there's even arduino shield for those who like that kind of thangs
02:35 PM Lambda_Aurigae: or incoming messages that would print out 300 feet of tape that we had to give to the crypto guys to decrypt...5 level baudot.
02:35 PM Emil: xentrac: ah, that kind of alternative history
02:35 PM Emil: Jartza: you speak of the devil
02:35 PM Jartza: actually.... I use those arduino shields myself, but not with arduino
02:35 PM Jartza: but with nucleo boards
02:36 PM Jartza: and even with this NXP FRDM-devkit
02:36 PM Jartza: seems the stupid half-assed arduino headers have become "de facto" of dev boards
02:36 PM Emil: Yeah
02:36 PM xentrac: heh, I love that you have the chips painted different colors in the README, Jartza
02:37 PM Jartza: :)
02:37 PM Emil: the technological debt is annoying af
02:37 PM xentrac: Jartza: do you mean the JTAG headers, or the ones along the edges for Arduino shields?
02:37 PM Jartza: xentrac: yeh. and the picture has been drawn in ascii :D
02:38 PM Jartza: xentrac: the ones along edges
02:38 PM xentrac: ah, sorry
02:38 PM Jartza: https://drive.google.com/file/d/0B2dTzW9TMeBxUDQ4QUduWDV2TFE/view
02:38 PM xentrac: what's wrong with them?
02:38 PM Jartza: the spacing
02:38 PM xentrac: the ASCII accounts for the absence of resistor symbols ;)
02:38 PM xentrac: aren't they standad 2.54 mm spacing?
02:38 PM Jartza: there's 0.05" empty space between headers
02:38 PM xentrac: oh! yeah, that's shitty
02:39 PM Jartza: so... you can't just dump in stripboard of perfboard on top of arduino
02:39 PM xentrac: without cutting it in half first
02:39 PM Jartza: and that's only in TOP headers
02:39 PM Jartza: not bottom
02:39 PM Jartza: bottom ones have 2.54mm empty in between them
02:39 PM Jartza: so you can't even cut it in half :D
02:40 PM xentrac: I see
02:41 PM xentrac: speaking of that, did you see the STEMTera?
02:42 PM Jartza: nope
02:42 PM Jartza: I don't much use arduino anyway
02:42 PM polprog: Jartza: that board looks kinda cute
02:43 PM Jartza: polprog: https://drive.google.com/file/d/0B2dTzW9TMeBxRXVzSUNCT1h2NHM/view
02:43 PM Jartza: this is even cuter :D
02:43 PM Jartza: if you don't need arduino shield
02:44 PM polprog: this ones even better
02:44 PM polprog: its so tiny
02:44 PM polprog: i like the way you cut the corners
02:46 PM Jartza: yeah, originally designed that for hackaday 1 square-inch compo
02:46 PM Jartza: but forgot to submit, lol
02:46 PM xentrac: Jartza: what do you think of http://www.excamera.com/sphinx/gameduino/index.html#gameduino ?
02:47 PM Jartza: well it's FPGA :)
02:47 PM Jartza: sure it's neat too
02:48 PM Jartza: I'm waiting to get this to my hands: http://pokitto.com/
02:48 PM Jartza: that's neat device :)
02:48 PM Jartza: I'll probably get some early protos
02:48 PM xentrac: that looks super cute
02:49 PM Jartza: Jonne (one of the devs) came to show us the protos
02:50 PM xentrac: I still haven't done anything with ARMs or even the LPC21xx chips I bought
02:50 PM Jartza: and the devices already in proto form looked pretty nice
02:50 PM xentrac: I mean except for like use cellphones and stuff
02:50 PM Jartza: now the photos of the real cases look even nicer
02:50 PM xentrac: I really enjoy AVR's easy flashability and I don't know which of the zillion ARM-based chips are reasonable at that
02:50 PM Jartza: well, most of my customer projects have been arm-based for the last 5 years or so
02:51 PM Jartza: AVR is nice hobby chip because it's so easy to do stuff with it
02:51 PM Jartza: it's sort of like "switch brains off and code with AVR"
02:52 PM xentrac: really? I keep finding myself frustrated with RAM and speed limitations on AVR
02:52 PM xentrac: and so I play all kinds of games to defeat them
02:52 PM xentrac: which is fun but not exactly "switch brains off"
02:55 PM Jartza: hehe
02:55 PM Jartza: well. I guess we have different definition to "brains off" then :D
02:55 PM Jartza: because making octapentaveega for example was extremely fun
02:55 PM Jartza: pushing the limits of that puny chip
02:55 PM xentrac: maybe your brains are just way more powerful than mine :)
02:56 PM Jartza: and it's "little sister", pentaveega was as much fun
02:56 PM xentrac: I can imagine!
02:56 PM Jartza: because the chip was even smaller
02:56 PM Jartza: https://www.youtube.com/watch?v=WdBNR0JEDcY
02:56 PM xentrac: what ARM chips are most practical for that kind of thing?
02:56 PM Jartza: if you've seen that?
02:56 PM polprog: pushing the limits is always fun
02:57 PM xentrac: that is very impressive!
02:57 PM Jartza: https://cdn.hackaday.io/images/7619951485034497221.jpg
02:57 PM Jartza: that's the hardware :D
02:57 PM polprog: this vid reminds me the older amiga demos
02:57 PM polprog: its probably because of the color bars in the bg
02:57 PM Jartza: IC1 is the microcontroller
02:57 PM Jartza: attiny5, 32 bytes of ram, 512 bytes of flash
02:58 PM Jartza: 8-color vga generated from 3 pins (vga needs hsync, vsync, red, green and blue)
02:58 PM Jartza: U1 is oscillator
03:01 PM Jartza: and yeah, that's vga connector :)
03:05 PM Jartza: https://bitbucket.org/jartza/pentaveega
03:05 PM Jartza: and here's the source for that
03:05 PM xentrac: I wonder if you could do Pong on the ATtiny5
03:05 PM Jartza: probably yes
03:06 PM Jartza: I've been actually thinking about that :)
03:06 PM Jartza: I can drive monochrome vga from 2 pins, leaving 1 pin free for input
03:06 PM xentrac: heh, I was just going to say you might have to sacrifice color in order to be able to sense potentiometers
03:07 PM Jartza: yeah :)
03:07 PM Jartza: or actually I could use 3 colors
03:07 PM xentrac: which you could do with a capacitor discharge time since I think the ATtiny5 doesn't have ADC?
03:07 PM Jartza: it does
03:07 PM xentrac: oh nice
03:07 PM Jartza: that demo runs on attiny4 too, which is basically the same as attiny5, but without adc
03:08 PM xentrac: aha
03:08 PM Jartza: I just couldn't find any supplier for attiny4 :D
03:08 PM xentrac: a fun thing I did with an ATtiny2313 some years back was use the discharge time of a reverse-biased LED as an analog light sensor
03:08 PM Jartza: yeah, leds are fun
03:08 PM xentrac: it took way longer to discharge the LED than I thought it would though
03:08 PM xentrac: like hundreds of milliseconds in the dark
03:09 PM Jartza: yeah
03:09 PM polprog: reverse biased led as a light sensor
03:09 PM polprog: tell me more
03:09 PM xentrac: polprog: http://canonical.org/~kragen/light_sensing
03:10 PM polprog: tyvm
03:10 PM xentrac: hmm, my notes say tens of milliseconds
03:11 PM Jartza: I'm actually trying to get monochrome VGA out from single pin of MCU :)
03:11 PM xentrac: oh, that was with a flashlight on it
03:11 PM Jartza: it just needs a monitor that supports "composite sync"
03:11 PM xentrac: Jartza: that sounds challenging
03:11 PM Jartza: but it looks like about 90% of monitors with vga connector do support that
03:11 PM xentrac: with a PWM pin and some kind of filtering?
03:11 PM Jartza: same technique I used with that 8-color vga from 3 pins
03:12 PM Jartza: if that is possible, then there could be some kind of sound in pong
03:12 PM xentrac: but don't you need more than two voltage levels for composite sync?
03:12 PM Jartza: no
03:13 PM polprog: i was thinking about the hardware part of generating composite
03:13 PM polprog: it came down to 3 pins and some resistors
03:14 PM polprog: although im not this advanced
03:14 PM polprog: to even check if it would work
03:14 PM xentrac: TVout generates composite (not VGA with composite sync) using 2 pins and some resistors
03:14 PM Jartza: not composite video
03:14 PM Jartza: composite sync for vga
03:17 PM Jartza: http://what-when-how.com/wp-content/uploads/2012/06/tmp7ee1140_thumb.png
03:17 PM Jartza: it's pretty simple actually
03:18 PM Jartza: basically just xor hsync & vsync to single signal
03:18 PM xentrac: sure, but don't you also need to encode the image to put onto the screen on some pin?
03:18 PM Jartza: sure
03:19 PM Jartza: https://bitbucket.org/jartza/pentaveega/raw/3efd1a9a8145104bd30f60b16b0982a224718cc6/hardware/pentaveega_v1.pdf
03:19 PM xentrac: and doesn't that need to be a different voltage level than the sync voltage?
03:19 PM xentrac: sorry if I'm asking dumb questions
03:20 PM Jartza: if you look at that, I'm driving hsync + red color out of single pin, and vsync + green from another :)
03:20 PM Jartza: so.. same technique, but just single color and instead of hsync or vsync, I run composite sync
03:21 PM xentrac: I see that on the schematic but I don't understand how it works :)
03:21 PM Jartza: the led acts as a diode
03:21 PM xentrac: indeed
03:21 PM Jartza: and in the vga monitor, there is 75ohm pulldown in color signals
03:22 PM xentrac: okay
03:22 PM Jartza: so that's not drawn into schematics
03:22 PM Jartza: and then I'm utilizing the fact that AVR pins have three different states :)
03:22 PM xentrac: ohhhhh
03:22 PM xentrac: hahahaha
03:22 PM Jartza: floating, pulled high and pulled low
03:22 PM xentrac: that's the part i was missing
03:22 PM xentrac: four actually
03:22 PM xentrac: because there's really floating and floating with a poorly specified but weak pullup
03:23 PM Jartza: when floating, the pull-up resistor pulls the sync signal up, but the color signal stays down, because of the 75ohm pulldown. and the led acting as diode prevents sync signal from being driven low
03:24 PM xentrac: so floating and pulled-low look the same to the green pin on the cable because of the diode
03:24 PM xentrac: but different to the vsync pin because of the 1k pullup resistor
03:24 PM Jartza: when as output and low, it pulls the sync signal low and the color still stays low
03:24 PM polprog: that's impressive
03:24 PM xentrac: yeah, brilliant
03:24 PM Jartza: when output and high, both sync and color signal are high :)
03:24 PM polprog: i mean really, awesome stuff
03:25 PM Jartza: and because VGA sync signals are "off" when high, they are only pulled low when I don't draw pixels.
03:25 PM Jartza: because you don't draw pixels during the sync pulse
03:25 PM xentrac: are there any pins on the VGA connector that the monitor pulls high?
03:25 PM xentrac: right
03:25 PM polprog: there is some kind of presence detection i think
03:25 PM Jartza: depends of the monitor, but color signals are supposedly 0..0.7V
03:25 PM Jartza: and with 75ohm pulldown
03:26 PM Jartza: that's why there is this 220ohm resistor, to keep color signal from overdriving
03:26 PM xentrac: right
03:26 PM Jartza: sync signals don't have any pullup/downs
03:26 PM xentrac: I was thinking it would be neat if you could build a dongle like this that drew power from the monitor
03:26 PM Jartza: they are basically TTL level
03:26 PM xentrac: instead of needing a separate Vcc
03:26 PM Jartza: ahh no, there's no way to pull power from monitor
03:26 PM xentrac: bummer
03:27 PM Jartza: VGA port DOES provide power, but from display adapter to monitor...
03:27 PM xentrac: there are ground pins, and it pulls the color pins to ground with the 75Ω pulldown, but no pins are pulled high, even weakly?
03:27 PM Jartza: because monitor talks to computer via i2c too (DDC2 etc)
03:28 PM Jartza: nope, not even weakly. not even i2c pins
03:28 PM Jartza: they also have pull-ups in display adapter, not monitor
03:28 PM polprog: i guess you could put a small cell there, like cr2032
03:29 PM xentrac: I see
03:30 PM Jartza: polprog: or single AAA? ;)
03:30 PM Jartza: https://drive.google.com/file/d/0B2dTzW9TMeBxLW93YXM3TDJmYTQ/view?usp=sharing
03:30 PM Jartza: like this :)
03:30 PM polprog: lol
03:30 PM Jartza: that's my power booster that provides USB-port with 5V out from single AAA
03:30 PM polprog: how much current can it give?
03:31 PM Jartza: about 80mA max
03:31 PM polprog: hmm
03:31 PM Jartza: I've used it once to charge cell phone, LOL
03:31 PM polprog: i just noticed something
03:32 PM polprog: that ltc1799 looks like a cool chip
03:32 PM polprog: anyway, goodnight
03:32 PM Jartza: yeah, it's nice chip :)
03:32 PM Jartza: I don't much use locked oscillators anymore
03:32 PM Jartza: night
03:33 PM xentrac: the single AAA is larger than a VGA port though :)
03:33 PM xentrac: night polprog!
03:35 PM Jartza: yeah :D
03:35 PM Jartza: but cr2032 doesn't really give you much amps out
03:35 PM Jartza: or it dies out quickly
03:35 PM Jartza: recommended max is like 2mA
03:36 PM Jartza: you CAN suck out like 25mA, but then the capacity becomes lame, like 50mAh instead of 250mAh
03:40 PM xentrac: yeah, I guess for a VGA signal you pretty much need to be running flat out all the time
03:40 PM xentrac: you don't get much chance to be in power saving mode
03:41 PM latenite: Hi does anyne in here use an AVRdragon? I need some help programming an ATmega8. I am unsure how to wire it all up.
03:42 PM xentrac: I hadn't heard of it before
03:43 PM xentrac: a devboard with OCD, that's all I need
03:43 PM xentrac: I'm so obsessive even my microcontroller has OCD!
03:45 PM polprog: latenite: i use it on a daily basis
03:45 PM Jartza: xentrac: hehe yeah, especially with octapentaveega, as it's also using bresenham's line algorithm basically to scan uart, it parses the ansi escapes etc...
03:45 PM Jartza: the chip is full 20MHz all the time
03:45 PM Jartza: in busyloop
03:46 PM latenite: xentrac, what is OCD?
03:46 PM Jartza: there's some neat "interleaving" done in few functions, like scrolling, because there's not enough time to scroll the whole screen sideways in one scanline
03:46 PM xentrac: latenite: in the DSM-IV it's "obsessive-compulsive disorder"; in the AVRDragon it's "on-chip debug"
03:46 PM Jartza: so it had to be separated in multiple passes
03:46 PM xentrac: I don't actually have OCD, it was just a joke
03:47 PM latenite: polprog, I have this https://www.heise.de/imgs/18/7/6/1/7/4/8/ISP-Adapter.jpg-591c1e9a1b5e88b8.jpeg
03:47 PM latenite: polprog, and the avrdragon
03:47 PM polprog: yeah
03:47 PM Jartza: but the code is open source, so it could be used to learn yourself a trick or two of AVR asm
03:47 PM latenite: polprog, how do I get at it?
03:48 PM polprog: you mean how to connect those?
03:48 PM latenite: I connected the 10 wire ribbon cable from the JTAG pins of the dragonm to the https://www.heise.de/imgs/18/7/6/1/7/4/8/ISP-Adapter.jpg-591c1e9a1b5e88b8.jpeg
03:49 PM polprog: no
03:49 PM polprog: dont mistake jtag and isp
03:49 PM polprog: its two different things
03:49 PM polprog: do you have jumper cables?
03:49 PM latenite: then I used avrdragon. But I get this error: https://gist.github.com/anonymous/0170802f2fef21cc7f6b6db3ba6867ac
03:50 PM latenite: can I use both JTAG and/or ISP? or only ISP?
03:50 PM latenite: what _exactly_ are jumper cables?
03:50 PM polprog: isp is for programming amd jtag for debug, in a simplified approach
03:50 PM polprog: google jumper cables
03:51 PM latenite: ok so I guess getting at it with the JTAG headers was plain wrong of me :/
03:51 PM Jartza: atmega8 doesn't have jtag
03:51 PM latenite: polprog, I did but: https://www.google.de/search?q=jumper+cables&client=ubuntu&hs=oiT&channel=fs&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjD587o9pXUAhXJORoKHZJVB6oQ_AUICygC&biw=1197&bih=551
03:51 PM Jartza: only isp
03:51 PM latenite: these are for cars?!
03:51 PM polprog: it is misleading. there is a 10 pin isp and a 6 pin isp connectos. dragon has 6 pi isp
03:51 PM xentrac: heh, "google jumper cables" may not have been the best advice
03:52 PM polprog: wait a sec
03:52 PM Jartza: yeah but in 10 pin there are just multiple ground-pins
03:52 PM Jartza: signal pins are same in both
03:52 PM polprog: https://images-na.ssl-images-amazon.com/images/I/41DRhh-JcPL._SX425_.jpg
03:52 PM latenite: Jartza, ah nice to know :D
03:53 PM latenite: polprog, yes I have those cables
03:53 PM Jartza: basically you need to connect sck to sck, miso to miso, mosi to mosi, gnd to gnd
03:53 PM Jartza: and then power the chip
03:53 PM polprog: latenite: what i did is i soldered a female socket to multiple separate and labeled cables
03:53 PM Jartza: ahh, and reset to reset :)
03:53 PM Jartza: pretty straightforwrd
03:53 PM polprog: and made myself an isp cable i can plug into the breadboard
03:54 PM Jartza: https://hackadaycom.files.wordpress.com/2010/10/avr-isp-header.jpg
03:54 PM polprog: you can always get a ZIF socket (the big blue thing with lever) and solder it to the dragon
03:54 PM Jartza: http://wspublishing.net/img/avr-dragon-pin-1.jpg
03:54 PM polprog: theres a space for that
03:54 PM polprog: you then connect the isp pins to the AVR in the ZIF
03:55 PM latenite: polprog, how do I connect the isp pins to the AVR in the ZIF?
03:56 PM Jartza: breadboard is nice thingamabob
03:56 PM polprog: ^^^
03:56 PM latenite: amabob?
03:56 PM Jartza: thingamabob ;)
03:56 PM latenite: I dont know the word
03:56 PM Jartza: http://www.learnersdictionary.com/qa/what-is-a-thingamabob
03:57 PM polprog: latenite: https://puu.sh/w4QcE/4e7c8a3715.jpg
03:57 PM polprog: latenite: get a breadboard
03:57 PM latenite: ahh :D
03:57 PM polprog: and connect the isp pins via a breadboard
03:57 PM latenite: I have a breadboard
03:58 PM polprog: in the picture i libked theres the ZIF and the cable
03:58 PM Jartza: so just plug the chip into it and connect jumper wires?
03:58 PM latenite: how do I know which pins are which ones on the dragon? the docs don't say
03:58 PM Jartza: latenite: I just pasted you two pics
03:58 PM polprog: flip the dragon pcb upside down xD
03:58 PM Jartza: 23:24 < Jartza> http://wspublishing.net/img/avr-dragon-pin-1.jpg
03:58 PM Jartza: 23:24 < Jartza> https://hackadaycom.files.wordpress.com/2010/10/avr-isp-header.jpg
03:59 PM Jartza: an atmega8 pins can be found from the datasheet
03:59 PM latenite: LOL up side down ... there we go :D
03:59 PM polprog: pin numbers are printed on the dragon
03:59 PM latenite: I get it... cool
03:59 PM latenite: and that is it? no external power or oscillator is needed?
04:00 PM Jartza: avrs are programmed at factory to use slow internal oscillator
04:00 PM polprog: you need to providr external power
04:00 PM Jartza: external power you need
04:00 PM Jartza: vcc and gnd
04:00 PM latenite: how much volts?
04:00 PM polprog: max 5V
04:01 PM Jartza: 3.3 to 5 is safe
04:01 PM Jartza: might work with lower too, but depends of the speed
04:01 PM latenite: So I ues my external power supply and connect 3.3V to the ATmega8 on the breadboard?
04:01 PM polprog: rxactly
04:01 PM Jartza: yes
04:01 PM Lambda_Aurigae: latenite, atmega8 has jtag on it?
04:01 PM Jartza: no it doesn't :)
04:01 PM Jartza: only ISP
04:01 PM latenite: great I think I have an idea how it works now... let me go to the e-lab and try this...
04:02 PM latenite: Can I use the https://www.heise.de/imgs/18/7/6/1/7/4/8/ISP-Adapter.jpg-591c1e9a1b5e88b8.jpeg instead of the breadboard somehow?
04:02 PM polprog: its a 10 pin adapter
04:02 PM latenite: yes
04:03 PM polprog: and i would advise using a breadboard
04:03 PM latenite: I want to try both ways....for learning
04:03 PM polprog: because it has different sockets for different avrs
04:03 PM Lambda_Aurigae: latenite, so long as those headers have the same pinout as your programmer's cable.
04:03 PM polprog: and its just more complicated
04:03 PM polprog: i dont like those multiadapters
04:04 PM polprog: if you are sure the pins are ok and you are using the right socket then go ahead,
04:04 PM latenite: if I had one of them soldered on the dragon... how would I connect the 6pins from the IPS to the https://www.heise.de/imgs/18/7/6/1/7/4/8/ISP-Adapter.jpg-591c1e9a1b5e88b8.jpeg on the dragon?
04:06 PM Lambda_Aurigae: well, not knowing the PINOUT on those connectors, no clue
04:06 PM polprog: it looks like 10 pin isp, make an adapter cable
04:07 PM Lambda_Aurigae: get pinouts for both ends,,,make them match up.
04:07 PM polprog: soldering practice :P
04:08 PM latenite: So I use the 6 pin ISP on the dragon and find the right conncetion on the https://www.heise.de/imgs/18/7/6/1/7/4/8/ISP-Adapter.jpg-591c1e9a1b5e88b8.jpeg
04:08 PM latenite: but ONLY using 6 wires...not 10
04:08 PM latenite: right?!
04:08 PM polprog: yes
04:09 PM polprog: you just plug the wires into the roght pins
04:09 PM polprog: right*
04:10 PM latenite: okay so I have 3 ways to try to wire it up...
04:10 PM latenite: I get to work now... let's see how that goes
04:11 PM latenite: polprog, Lambda_Aurigae xentrac Jartza thank you tons for helping
04:11 PM polprog: you need to connect the same pins on both connectors
04:11 PM polprog: no problem, happy hacking
04:12 PM latenite: :D
04:15 PM Lambda_Aurigae: don't really need 6 either.
04:15 PM Lambda_Aurigae: miso, mosi, sck, gnd, reset
04:15 PM polprog: dragon used vtg to adjust the programming voltage
04:15 PM Lambda_Aurigae: the 10 pin header was meant for future expansion...
04:16 PM Lambda_Aurigae: and 10pin headers were easier to come up with than smaller ones back in the day.
04:16 PM Lambda_Aurigae: I would have gone with a straight 5 myself, but,,,
04:16 PM polprog: i was about to as why did they do the 10 pin one
04:16 PM polprog: i kinda see the point of having the vtg pin
04:16 PM Lambda_Aurigae: I have put usart TX and RX on it in the past.
04:16 PM Lambda_Aurigae: when making my own customer programmers.
04:17 PM polprog: id love to program customers
04:17 PM Lambda_Aurigae: that way I had one connector for programming and data connection.
04:17 PM polprog: so they dont do dumb stuff
04:17 PM Lambda_Aurigae: oh, that's what a cattle prod is for.
04:17 PM Lambda_Aurigae: one button binary programming.
04:17 PM Lambda_Aurigae: zapon, zapoff
04:17 PM polprog: a clue-by-four
04:17 PM Lambda_Aurigae: too big
04:18 PM polprog: hardware interrupt
04:18 PM polprog: non maskable
04:18 PM Lambda_Aurigae: I can make a high voltage device to fit in the palm of my hand.
04:18 PM Lambda_Aurigae: did have that one kid I threatened in the airport years back..well,,I threatened his mother.
04:18 PM polprog: i like those lighter igniters
04:19 PM Lambda_Aurigae: kid was 8 or 9...running around hitting people with a tennis racket.
04:19 PM Lambda_Aurigae: he hit me and I looked at his mother and said, "If he hits me with that thing again I will take it from him and beat you with it until he learns to behave."
04:19 PM Lambda_Aurigae: her eyes got great big and she grabbed him and made him sit down.
04:20 PM polprog: i guess that worked, how tall are you?
04:20 PM Lambda_Aurigae: I'm something of a,,rather,,,intimidating person.
04:20 PM Lambda_Aurigae: 5 feet 11 inches.
04:20 PM Lambda_Aurigae: 225 pounds.
04:21 PM polprog: im of quite similar height
04:21 PM FL4SHK: same height, 30 pounds lighter
04:21 PM FL4SHK: need to lose more
04:21 PM FL4SHK: I do I mean
04:21 PM FL4SHK: :P
04:21 PM Lambda_Aurigae: I do too.
04:21 PM polprog: so about the igniters, you can find them on the street sometimes
04:22 PM Lambda_Aurigae: want to get back down to my fighting weight of 190 pounds.
04:22 PM Lambda_Aurigae: polprog, I use disposable camera flash units.
04:22 PM FL4SHK: 190 is a little much for me, I should be 20 pounds lighter
04:22 PM Lambda_Aurigae: or just make them myself from scratch.
04:22 PM Lambda_Aurigae: FL4SHK, 170 would be thin for me I think.
04:22 PM FL4SHK: not for me
04:22 PM FL4SHK: I was 150 when I was 18
04:22 PM Lambda_Aurigae: I've been heavy for many years though and have a lot of bone mass.
04:23 PM FL4SHK: I mean if it's muscle it's fine
04:23 PM Lambda_Aurigae: I was 165 when I graduated high school.
04:23 PM polprog: tge igniter is useful when you need somebody to be bit, not to restart his hear
04:23 PM Jartza: hmmh
04:23 PM Lambda_Aurigae: polprog, bah....I want to STOP their heart...then maybe restart it when they have learned their lesson.
04:23 PM Jartza: seems I'm really living on the edge of modern technology
04:23 PM Jartza: I'm doing an IoT product for customer
04:24 PM polprog: ;)
04:24 PM Jartza: ...with Modbus sensors
04:24 PM Jartza: lol
04:24 PM FL4SHK: as far as I can tell, Internet of Things is just going to lead to Mega Man Battle Network
04:24 PM polprog: Jartza: add a directory traversal bug and you are good to go
04:24 PM Lambda_Aurigae: Jartza, me too...just put a solar panel up on my workshop...20Watt...feeding 168aH of SLA batteries.
04:24 PM Jartza: well... modbus
04:24 PM Lambda_Aurigae: IoT is just going to lead to a psychotic version of skynet.
04:24 PM Jartza: d'oh
04:25 PM polprog: i thibk i have a modbus thermo somewhere
04:25 PM FL4SHK: in Mega Man Battle Network, anything and everything could be infected with malware
04:25 PM FL4SHK: and was
04:25 PM FL4SHK: always
04:25 PM Lambda_Aurigae: FL4SHK, that sounds like windows networks!
04:25 PM Jartza: I have modbus temp sensor, and two 4-port AD converters
04:25 PM polprog: lol
04:25 PM Jartza: the other measure current from 4-20mA, the other voltage from 0-10V
04:25 PM polprog: the current loop stuff?
04:26 PM Jartza: yes
04:26 PM polprog: onteresting
04:26 PM polprog: interesting*
04:27 PM Jartza: the current loop thingamabob is connected to actual current measuring device
04:27 PM Jartza: and the voltage thingamabob through voltage divider (!) to measure battery voltages (48V batteries) :)
04:28 PM Jartza: high tech stuff
04:28 PM polprog: high tech voltage dividers
04:28 PM Jartza: yes
04:28 PM Jartza: resistors and all that good shit
04:28 PM polprog: wow
04:28 PM FL4SHK: Lambda_Aurigae: it applied to things like toasters and coffee makers and even playground equipment
04:28 PM Jartza: and modbus rtu over rs485
04:28 PM FL4SHK: ridiculously
04:29 PM specing: Does anyone have favorite DC-DC converted modules from china?
04:29 PM Jartza: it's nice to have these customer projects where you get to see all the latest tech
04:29 PM specing: and if so which are they?
04:29 PM polprog: Jartza: how hard is rs485 actually?
04:29 PM polprog: i have max485
04:29 PM Jartza: hard? it's a serial
04:29 PM Jartza: lol
04:29 PM polprog: vut half duplex
04:29 PM Jartza: yes
04:30 PM Jartza: the actual IoT Gateway has full duplex RS485 though (4-wires) but the sensors only have 2-wire connection
04:30 PM polprog: guess i gotta just try it,
04:30 PM Jartza: well. it's just a serial.
04:30 PM polprog: night for real noe
04:30 PM Jartza: night
09:13 PM Tachyon` is now known as Tachaway
09:58 PM rue_bed: specing, there is only one
09:59 PM rue_bed: the 35->1.2V one
09:59 PM rue_bed: Jartza, lap the tx and rx
09:59 PM rue_bed: for siplex
11:50 PM day__ is now known as daey