#avr | Logs for 2016-07-24

Back
[07:14:42] <LOMAS> hello there .. the formatted string (printf()) is not being supported when compile with the .cpp main file
[07:14:51] <LOMAS> in the new atmel studio solution
[07:15:16] <LOMAS> found some discussion in the forum but no clear solution
[07:23:08] <theBear> erm, i'd guess the avr libc doesn't include most of that fancy formatting stuff, or anything involving international-libs like the real full glibc includes, erm, do you need to do the formatting/conversion right there, or at all ? and is printf even the right way to be doing the actual "output" you wanna err, output ?
[07:24:05] <LOMAS> printf is like a universal and easy
[07:24:32] <LOMAS> yeah..avr libc incldes it
[07:24:40] <LOMAS> http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html#stdio_without_malloc
[07:25:09] <LOMAS> but the error is due to the .cpp extenshion instead of .c
[07:28:59] <Lambda_Aurigae> if you are using C++ then use the C++ output.
[07:29:17] <Lambda_Aurigae> I'm guessing the compiler is doing one or the other.
[07:30:02] <Lambda_Aurigae> in C you use printf
[07:30:11] <Lambda_Aurigae> in C++ you use cout <<
[07:30:25] <Lambda_Aurigae> yes, in a full implementation you can use both in C++
[07:30:42] <Lambda_Aurigae> however, that would grow your binary to horrendous sizes for a microcontroller
[07:30:56] <Lambda_Aurigae> so, it makes sense for the compiler to do one or the other.
[07:31:04] <LOMAS> its okay to use C++ operator <<.. but all the codes are in C and I don't like to make the file .cpp just for formatted output
[07:31:11] <theBear> oh, stupid oo, stupid *duino land, stupid c++ being different to old father c.... ummm, pfft i dunno, i don't oo, specially in teeny ween ylittle micros where i can often manually add up and juggle cputime/clock cycles quicker than some pile of poorly written and often redundant wrapper functions by italians in c++ will even compile <grin>
[07:31:13] <LOMAS> oh yes..
[07:31:17] <LOMAS> its just for debug
[07:31:41] <Lambda_Aurigae> I don't use C++ on a microcontroller so never ran into it.
[07:31:53] <Lambda_Aurigae> just stick with ansi C and you are good to go.
[07:32:21] <LOMAS> yes .. I havent too.. and dont like to use C++ just for this small issue
[07:32:43] <LOMAS> how can we create C execuatable file instead of C++
[07:33:01] <LOMAS> there used to be a C option rather than C++ previously
[07:33:16] <LOMAS> http://www.atmel.com/webdoc/atmelstudio/atmelstudio.Projects.NewProject.GCC_Project.html
[07:33:17] <Lambda_Aurigae> use .c instead of .cpp
[07:33:32] <Lambda_Aurigae> as for atmel studio..no clue.
[07:33:37] <theBear> tho i should mention the only place i know that printf makes much sense in arduino land is on those few models with a mega328 as the main micro, and a far-better-spec 32u4 or similar hw-usb-capable micro "hidden" pretending to be a ft232? or similar, for some sick reason, tho in a few rare cases the whole independant micro just to deal with what to present to the usb host, and able to pass simple uart-serial "zero cost" output from the "main" micro over
[07:33:37] <theBear> to usb in arbitrary and configgable/programmable ways if desired, is kinda cool
[07:33:40] <Lambda_Aurigae> it doesn't run on linux and I don't have windows.
[07:33:47] <LOMAS> after renaming the program won't work in some case
[07:33:47] <LOMAS> oh.. :(
[07:34:11] <Lambda_Aurigae> I do everything command line with text editor and makefiles.
[07:34:29] <theBear> huh ? eclipse and arduino ugly-old-looking-gui-widget dumb app thinger ? they work in almost any crappy half-baked linux env i seen in modern times
[07:34:55] <Lambda_Aurigae> eclipse?
[07:34:57] <Lambda_Aurigae> blah.
[07:35:07] <Lambda_Aurigae> vi
[07:35:43] <theBear> oh sorry, atmel studio, i say eff that, i float between plain text editors, simple gui of the same, and occasionally dabble in something fancy like kdevelop or even stupid overkill eclipse one time long ago, if i feel like some syntax highlighting or fancy multi file/revision control stuff
[07:36:03] <theBear> i only mentioned eclipse ccos i think that's what the duino-stupid-suite uses/includes
[07:36:10] <Lambda_Aurigae> sometimes I will go gui with kate or gedit but not often.
[07:38:41] <theBear> it's ridiculously resource-heavy (standard java behaviour there <grin>) overkill button for anything you can think of incase you lazy AND stupid kinda annoying cos it doesn't just work like a text edior silliness, at least in the bitter jaded eyes of a retired bear, kdevelop i didn't mind, minimal sneakiness other than working highlighting and maybe some tab/indent assistance, but things like terminal-window-integration and simple macro style things you
[07:38:42] <theBear> can setup to do things like run a program cycle or make command for you in the way YOU see fit or appropriate, making for what i consider a nice comfy fully-featured kinda dev env in a single window
[07:39:38] <theBear> mmm, i forgot kate, recently for general-purpose no-fancy-eol-convs kinda plaintext in desktop land i been using the leafpad, which ya know, shows text and seems to make it stick if i hit save, that's what yer want from a text editor
[07:39:44] <theBear> it's what i want from one :)
[07:41:07] <Lambda_Aurigae> yup.
[07:41:20] <Lambda_Aurigae> and kate is good for that...can even do code highlighting if I want it to.
[07:41:35] <Lambda_Aurigae> and it's preinstalled in kde environments.
[07:55:24] * kre10s_ uses gedit + terminal + make + git...
[08:00:04] <notfunnyguy> I made a simple avr input/output test (I'm using attiny85), a button and a red LED, I powered it with my usbasp2 3.3 voltage. I saw my LED was blinking shortly, even if the button wasn't pressed down. When I pressed the button the LED was shining till I released button. What could cause that unexplained blinking from nowhere?
[08:00:59] <notfunnyguy> Is my avr broken? Or usbasps are not good to power avrs?
[08:01:08] <Lambda_Aurigae> yes
[08:01:11] <Lambda_Aurigae> possibly
[08:01:30] <Lambda_Aurigae> usbasp is good for an emergency programmer only in my opinion, but I'm kinda biased.
[08:01:42] <Lambda_Aurigae> what frequency are you running the attiny85 at?
[08:01:50] <notfunnyguy> 1 MHz
[08:02:04] <Lambda_Aurigae> then it should be ok.
[08:02:20] <Lambda_Aurigae> I would still not power from the usbasp.
[08:02:49] <theBear> the errm, what is your program/code supposed to do, generally and with the led, if it is working ?
[08:02:54] <Lambda_Aurigae> without knowing how much power it requests from the usb bus you don't know how much power you can draw from it.
[08:03:24] <Lambda_Aurigae> might be a good idea to post the code and sweet talk someone into looking at it.
[08:03:34] <notfunnyguy> yeah, wait a moment
[08:04:35] <notfunnyguy> http://pastebin.com/eLW2L6tG
[08:04:59] <notfunnyguy> the LED is connected to PB3, the button to PB4
[08:05:57] <Lambda_Aurigae> try && rather than &
[08:07:53] <Lambda_Aurigae> & is a bitwise operator....like combining two numbers... C=A&B
[08:08:00] <Lambda_Aurigae> && is a logic relational operator
[08:08:21] <Lambda_Aurigae> if (A&&B) {do something}
[08:09:18] <Lambda_Aurigae> your comparison in the if statement doesn't compare anything.
[08:11:11] <Lambda_Aurigae> http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf
[08:13:13] <notfunnyguy> now it's shining all the time
[08:14:26] <notfunnyguy> getting back to previous code
[08:14:27] <_ami_> notfunnyguy: input pullup resistor is not set for PB4
[08:14:53] <_ami_> PORTB |= 1 << PB4 would be a good idea.
[08:15:53] <_ami_> undefined blinking was actually happening because of this since pullups were not set.
[08:15:58] <notfunnyguy> and then connect the button to the ground, yes?
[08:16:08] <_ami_> yeah
[08:18:26] <_ami_> notfunnyguy: your pin was actually floating without pullup resistor
[08:19:14] <notfunnyguy> hmmm... the LED is still blinking :/
[08:19:24] <notfunnyguy> even when I unpin PB4
[08:19:35] <_ami_> notfunnyguy: show your code please. pastebin?
[08:19:41] <_ami_> the changed one.
[08:20:20] <notfunnyguy> http://pastebin.com/gBDsAVvf
[08:23:16] <_ami_> notfunnyguy: does it blink for sometime affter you unpress the button?
[08:23:29] <_ami_> or remain blinking forever?
[08:23:57] <_ami_> may be hardware bouncing ?
[08:24:02] <notfunnyguy> when I press the button it turns off
[08:24:10] <notfunnyguy> when I release the button it returns to blinking
[08:25:34] <_ami_> notfunnyguy: seems like your switch connection is either wrong or faulty
[08:26:12] <_ami_> notfunnyguy: whcih type of swith are you using? tactile switch?
[08:26:16] <_ami_> 4 legs?
[08:26:17] <notfunnyguy> yes
[08:26:31] <notfunnyguy> no, it's not possible
[08:26:41] <notfunnyguy> because when I disconnect the button, it remains blinking
[08:26:52] <notfunnyguy> what the heck is happening?
[08:29:14] <kre10s_> sounds like a floating pin. floating pins can go anywhere
[08:30:23] <_ami_> notfunnyguy: just checking if you connected the switch to PB4 ? :)
[08:30:51] <notfunnyguy> checked, it's in PB4
[08:31:47] <kre10s_> your button should pull PB4 to ground when pressed and PB4 should be pulled up by ~10KOhm.
[08:32:09] <_ami_> kre10s_: he enabled internal pullups
[08:32:14] <theBear> "the rules" say never leave a digital input floating, it'll always be bad, maybe just a bit wiggly, maybe oscillating so hard the whole ic locks up, maybe just messing up things periodically to really drive you insane in a hurry, but it's never better with a floating input
[08:32:39] <theBear> oh, magic soft-flippable pullups counts as not floating, i should mention
[08:33:40] <_ami_> notfunnyguy: which avr mcu are you using?
[08:33:59] <_ami_> notfunnyguy: can u try with this code? http://pastebin.com/Jp7xDhrS
[08:34:09] <_ami_> PB0 - switch
[08:34:14] <_ami_> PB2 - LED
[08:35:05] <notfunnyguy> attiny85
[08:35:11] <notfunnyguy> compiling
[08:35:23] <kre10s_> Ah. I was just about to mention debouncing. but that seems a bit complicated when the led blinks even without the button connected.
[08:40:44] <notfunnyguy> still not ok
[08:41:09] <notfunnyguy> after releasing the button, sometimes the LED remains switched on
[08:41:17] <notfunnyguy> IDK what's happening....
[08:41:37] <notfunnyguy> sometimes it does not switch on
[08:42:24] <notfunnyguy> broken avr?
[08:43:55] <theBear> the umm, what is connected to the reset pin on the tiny chip ?
[08:44:10] <notfunnyguy> now nothing
[08:44:19] <notfunnyguy> I pin reset only when I program
[08:44:44] <theBear> mmm, that is considered a floating input and will be unpredictable particularly after a reset or program maybe
[08:45:19] <theBear> so err, you mean literally nothing (when the testing/fault happens) or to some reset line on the programmer/isp thing which is effectively "nothing" between programming ?
[08:45:54] <notfunnyguy> literally nothing
[08:48:18] <theBear> yeah, that's not cool, from memory you want maybe somewhere between 1 and 10k (i'm feeling like 10k is what i should remember easily) to vdd/micro power supply to make it default to what you want to say "start program running after a reset, ya know, just be cool" assuming something like a programmer or reset button isn't pulling it the other way (down to 0v) much harder for its own agenda reasons
[08:48:48] <theBear> the datasheet probly says all that but shorter and more accurate and easier to understand under the reset pin in the big table of stuff you wanna know about a given pin
[08:52:39] <notfunnyguy> Okay, I'll check this later, because I don't have any 10k resistors
[08:53:09] <notfunnyguy> thanks for help
[08:59:27] <theBear> that's aiiiiiiight
[09:51:55] <_ami_> I am trying to decode an IR remote of Tata sky India (set up box for Tv).
[09:52:00] <_ami_> Decode results: http://pastebin.com/9y4NRiSc
[09:52:24] <_ami_> just wonder which protocol are they using? http://www.techdesign.be/projects/011/011_waves.htm
[09:52:40] <_ami_> it does not match with the protocols mentioned on above link.
[09:53:09] <_ami_> start bit: 2.5 ms ON and .80ms OFF
[10:07:11] <_ami_> oh boy, its RC6
[10:07:14] <_ami_> http://www.sbprojects.com/knowledge/ir/rc6.php
[10:07:18] <_ami_> hmm
[14:26:12] <rue_bed> lirc
[15:59:06] <theBear> nah, this is just regular irc, but that was a real close attempt, good work buddy !
[16:10:30] * Chillum makes an lirc to irc bridge
[16:12:53] <LeoNerd> ATmega328PB chip. Using UART, but every other GPIO is set to input with pullup (PORTx)
[16:13:27] <LeoNerd> Every input reads as high, except for PB5 (== SCK), which happens to be the pin I have an LED on.
[16:13:36] <LeoNerd> LED has 330R resistor
[16:13:57] <LeoNerd> That -ought- to still read as high, right?
[16:14:08] <liwakura> Arduino Nano?
[16:14:16] <liwakura> the LED is pull down there iirc
[16:14:28] <LeoNerd> Not a nano, no. a 328PB
[16:14:34] <LeoNerd> On a nano-sized breakout board I just made ;)
[16:14:43] <Lambda_Aurigae> if the led and resistor go to gnd then it should not read high.
[16:15:38] <LeoNerd> Ooooh.. hrm. According to datasheet, it needs at least 70% of VCC to read as high
[16:16:12] <LeoNerd> VCC being 5V, so it wants 3.5V. I'm willing to bet the top of the resistor is under that, because LED is probably around 2.2Vf
[16:16:53] <LeoNerd> I wonder if I need a bigger resistor. I think I want a bigger one -anyway- because the lumens off this red LED are TOO DAMN HIGH
[16:23:29] <theBear> if the thing is lit you can meaasure with a meter on volts, bing bang bong, uncle Bob V.F. Obtained would be so proud
[16:26:29] <kre10s__> what the!? Is that supposed to make sense theBear?
[16:27:22] <kre10s__> the later half of your sentence anyway...
[16:32:31] <liwakura> he always speaks like that
[16:37:31] <theBear> kre10s__, maybe, unusually high levels of chronic painage and associated lack of sleep, mania and scrambled mind from the endless fistfulls of painkillers and so forth make it a bit hard to be sure today, in advance ishould mention please forgive me, i'm trying to be all selfish and help myself out, not trying to abuse you poor folks and your likely quite lucid conversations :)
[17:28:53] <LeoNerd> Hrm... maybe what I'm trying to do doesn't work on a real arduino nano either
[17:29:20] <LeoNerd> The arduino nano has a 1k resistor inline with the PB5 LED to ground, so that would be worse than my board now I've put a 2k2 in there
[17:29:48] <LeoNerd> With the PB5 internal pullup enabled, the LED glows really dimly, and I get about 1.8V on the PB5 pin, which seems insufficient to make it read logic high
[17:30:04] <theBear> herm, wonder if the bot works in here too
[17:30:28] <theBear> !math (5-3.2)/2200
[17:30:33] <theBear> apparently not
[17:30:54] <LeoNerd> Vf of this LED is apparently 1.65V
[17:33:19] <theBear> you know how to math that up, basically waht i just did there, kinda (supplyV - NOMledV) / resitance = current (v = r.i -> v / r = i -> v /i = r even if yer need it
[17:35:45] <inkjetunito> internal pullup and a led?
[17:36:01] <LeoNerd> HAH
[17:36:09] <LeoNerd> Arduino themselves acknolwedge this is a bug on the real board :)
[17:36:19] <LeoNerd> See the NOTE about 60% down the page: https://www.arduino.cc/en/Tutorial/DigitalPins
[17:36:55] <LeoNerd> OK so now I'm happy. My board is no worse than that
[17:37:03] <theBear> oh, i wasn't listening real hard, tho mmmm, internal pullup + led, you could just flip the pullup on/off OR (i think you can have a pullup and have the port in output mode ?) just drive the pin low to turn off the led... i like it
[17:37:26] <theBear> i believe you, i don't need to expose myself to their nonsense for that :)
[17:37:52] <LeoNerd> It's fine. all I'm doing is a little test program so I can test if my new breakout board works
[17:38:02] <LeoNerd> I'm happy to not test PB5 this way, and maybe just blink the LED instead
[17:39:37] <theBear> i just never thought/heard that idea before, but i think i like it cos it qualifies as a tricky trick and ilike them
[17:39:58] <LeoNerd> Hrm?
[17:47:23] <theBear> using a internal pullup like avr always got anywhere you might use as an input as the series/current limitey resistor paired with an external ledand no extra resistor/components, and just being careful to only ever turn the led "off" by either softwaring that resistor away again, of outputting a low level or whatever, and never to sdrive that pin properly high due to that making it look like just an 2.somehting volt glowing zener being pulled right up
[17:47:24] <theBear> to 5v or3.3 or what you got, and generally punishing the poor avr output pin
[17:47:44] <LeoNerd> Oh.. sure
[17:48:12] <LeoNerd> I wasn't *intending* to using pullup to power the LED. It's just that the LED happens to be there, and I was wondering why this pin alone doesn't work for that pullup test
[17:49:24] <LeoNerd> Anyway,.. that aside, I believe I have a fully-working ATmega328PB breakout
[17:49:38] <LeoNerd> In Nano size. But with real Atmel port namings on the pins
[17:49:40] <LeoNerd> Who wants one? :)
[17:49:47] <cehteh> o/
[17:50:00] <LeoNerd> I'll point ya at my tindie page when it's up
[17:50:03] <theBear> the errr, you only got one ?
[17:50:20] <LeoNerd> I've got 2 new ones (plus my prototype). but I#ll be making lots more
[17:50:30] <LeoNerd> Quite how many more, will depend how quickly they sell on tindie
[17:51:57] <cehteh> well what will be the price tag?
[17:51:59] <theBear> i still ain't played with my shiny cheap something-duiney-clone board from last week sales at local shop, i think it was $14 for a nice little board including usb hole and psu stuff, real brandname ft232something, and a whole 328 there too that can demand the ft232 to do all sorts of things, perhaps based on a manually uploaded config or something stored olocally on the tiny microwire prom, whatever
[17:52:07] <cehteh> i am just waiting for some china clones
[17:52:17] <LeoNerd> Ahyes.. price.. I should work that out
[17:52:27] <cehteh> wattenrott has some too
[17:52:46] <LeoNerd> Yah.. I think those are larger though
[17:52:50] <cehteh> http://www.watterott.com/de/Wattuino-pro-mini-PB-5V-16MHz
[17:53:06] <cehteh> small enough
[17:53:20] <cehteh> and they did the proper AVCC decoupling
[17:53:23] <LeoNerd> Ohwait that does look similar
[17:54:31] <cehteh> you saied nano? with USB bridge?
[17:55:08] <LeoNerd> Yup
[17:55:16] <LeoNerd> Am using a CH340
[17:55:46] <cehteh> sounds good
[17:56:18] <cehteh> i dont really need one, would be just a plaything
[17:56:22] * LeoNerd nod
[17:56:27] <LeoNerd> Yah;I'm only really playing with it because two UARTS
[17:56:42] <cehteh> yes same thinking here
[17:56:55] <cehteh> but should be cheap enouh
[17:57:23] <cehteh> and i bet sooner or later chinese cloners will open the floodgates
[17:57:23] <LeoNerd> I can't really see why I'd need two SPI ports. Two I²C modules -might- be useful if I had lots of devices, and wanted to split the 400s from the 100s,.. but that's pushing it
[17:57:31] <LeoNerd> Can't really see why I'd need 5 timers or 10 PWM channels
[17:57:46] <LeoNerd> PORTE might be useful though - sometimes I do get close to the limit of IOs.. more GPIOs always good :)
[17:57:47] <cehteh> more PWM could be nice
[17:57:57] <cehteh> but they are only 8bit or?
[17:58:20] <cehteh> or moment didnt it have 2 16 bit timers?
[17:58:27] <cehteh> which would be nice
[17:58:30] <LeoNerd> timer0 and timer2 are the original two 8bit ones. timer1 and now newly-added timer3 and timer4 are identical 16bit units
[17:58:45] <cehteh> ah thats cool
[17:59:14] <cehteh> what about power consumption? much more than the old 328p?
[17:59:54] <LeoNerd> Not read that far into it
[18:00:02] <LeoNerd> I would hope that with the extra units powered down it wouldn't be more
[18:00:02] <cehteh> ok
[18:00:28] <cehteh> maybe even less because of newer technology/improvements
[18:00:43] <cehteh> but i am wondering what it draws when you use all bells and whistles
[18:28:21] <theBear> what i'm blowing on or hitting with tiny little padded hammer-sticks shouldn't affect how much power the micro chews up, err, i don't think it should ;-]
[20:17:27] <carabia> theBear, eheheh you so funny
[20:17:32] <carabia> you crack me up.
[20:19:53] <carabia> though i'm not sure the bells in question are the kinds of ones you hit, so maybe your smartassness got the better of you...
[23:02:27] <ewong> I got the wrong zif dil adapter for my avr dragon. :( my bad.. I soldered it in.. then noticed the atmega8a chip doesn't fit it;... ;/ what's the right kind of zif socket for this?
[23:03:11] <ewong> but first , I need to desolder this.. and it's a pita even with a braid
[23:05:53] <cehteh> whats wrong with it?
[23:06:04] <cehteh> i never used these zif things
[23:06:55] <ewong> basically.. the holes for the through-hole (for lack of the right terminology) leads are too wide apart for the atmega8
[23:07:09] <cehteh> ah may happen
[23:07:21] <ewong> so I need to desolder this zif socket and replace it with the right one..
[23:07:24] <cehteh> hey you could stack another zif socket on it or?
[23:07:41] <ewong> oh possibly
[23:07:47] <ewong> cehteh: damn good idea
[23:08:43] <cehteh> what do these zif sockets cost?
[23:08:55] <cehteh> if i am in a hurry i do some 'destructive' desoldering :D
[23:09:27] <ewong> cehteh: about 10USD or something..
[23:09:28] <cehteh> cut the component apart, then desolder pin by pin, thats much easer
[23:09:34] <ewong> ahhh..
[23:09:50] <cehteh> (but careful not to destroy any traces)
[23:10:13] <ewong> I was really tempted in doing that yesterday... but thought i better not be too impatient and try desoldering all 40pins
[23:10:55] <ewong> but prior to that fiasco.. I did manage to connect the avrdragon to my comp and have the atmel studio talk to the atmega8 chip via a breadboard setting