#avr | Logs for 2016-02-18

Back
[01:32:51] <julius_> lorenzo: thanks
[01:33:46] <julius_> morning
[02:39:07] <Jartza> morning
[02:39:19] <cehteh> morning
[05:56:08] <julius_> i tested my pwm motor control code with a bc537 and a 35ma 5v motor. according to the datasheet: http://www.suzushoweb.com/pdf_file/1484000000006.pdf (mine is the ka11c) it works with 1...6v
[05:56:33] <julius_> but even if i start the motor with a duty cycle of 50% and then reduce it to ~20% it stops
[05:56:55] <julius_> how do you calculate what pwm duty cycle is giving out 1v?
[05:58:07] <cehteh> what pwm frequency?
[05:59:39] <julius_> have to eat, be back in a few
[06:00:54] <cehteh> pwm duty cycle is not linear when you include a inductive load, try different pwm frequencies
[06:01:50] <cehteh> and are you sure the bc537 can drive full current in this way, i am not sure
[06:02:05] <cehteh> (base current too much limited)
[06:02:48] <cehteh> can you measure your vcc on the motor poles on 100% duty cycle? or less
[06:09:16] <cehteh> meh .. utf8 support in my line editor weights 200 bytes :D
[06:09:37] <cehteh> i should optimize that someday
[06:24:52] <julius_> does this look like the right formula to calculate frequency? Clock Speed / 2 * PWM Resolution MaxCount * Clock Prescaler.
[06:25:04] <julius_> lets measure
[06:27:42] <julius_> 8000000/(2*1024*1) = 4khz
[06:28:28] <julius_> with OCR1A = 290 i get about 0.45v at the motor. so it does even run at half the voltage specified. without load
[06:29:30] <julius_> it kinda works well
[06:29:51] <julius_> i can see/hear the motor going really slow
[06:32:40] <cehteh> thats 16 bit timer?
[06:34:14] <cehteh> (8 bit pwm should be enough or?)
[07:01:29] <julius_> yes 16, just used one of the examples
[07:01:53] <julius_> later on, it can be reduced...but what about the frequency...is that calculated right?
[08:20:35] <vaskozl> Hey I'm building a simplee line following robot with this code: https://skozl.com/s/main.c
[08:21:13] <vaskozl> If I put PB0 and PB1 as led's it all works fine as the analog input in PB3 and PB4 changes
[08:21:48] <vaskozl> The led's would dim properly.
[08:22:05] <vaskozl> Now if I connect them to the base of some bjt's instead (that then power the motor)
[08:22:14] <vaskozl> it works fine so long as I only connect one of the outputs.
[08:22:21] <vaskozl> as soon as I connect both they both stop.
[08:23:06] <vaskozl> I also here a high pitched noise when the analog input is low and I connect the bjt's (when they should be off).
[08:23:21] <vaskozl> Can anyone tell me why this happens?
[09:04:21] <julius_> pins to motor? what kind of motor
[09:04:47] <julius_> theres a 20ma (or less) limit on output for all pins combined.
[09:05:06] <julius_> you are torturing and killing the avr...probably
[09:05:36] <julius_> oh wait, theres a bjt
[09:06:41] <julius_> a circuit diagram would probably help
[09:07:00] <julius_> but im no expert on "bjt"
[09:07:50] <daey> im not seeing diodes :x
[09:21:09] <vaskozl> I got the exact same functionality with the Arduino IDE
[09:40:04] <vaskozl> Basically I have a potential divider with a 12k resistor and a phototransi
[09:40:48] <vaskozl> s/$/stor that feed inputs at PB3 and PB4/
[09:41:07] <vaskozl> Then the outputs are PB0 and PB1
[09:41:13] <vaskozl> That is all.
[09:41:27] <vaskozl> daey: What diodes?
[09:53:30] <daey> vaskozl: flyback diodes?
[09:53:41] <daey> not srue what they are claled in english
[10:09:37] * flyback BITES daey
[10:09:50] <flyback> THEY ARE CALLED FLYBACK Diodes
[10:09:56] <flyback> or surge diodes
[10:12:34] <flyback> which are usually zener or avalance for over voltage clamping
[10:12:48] <flyback> can just be a normal diode for back-emf flyback effect grounding
[10:15:05] <flyback> pretty neat shit
[10:15:43] <flyback> vaskozl, you did use flyback diodes on the motor didn't you?
[10:39:00] <Tom_itx> you have your won diodes??
[10:39:04] <Tom_itx> own*
[10:39:27] <cehteh> so your nick is not from flyback transformers? :)
[10:40:15] <LeoNerd> "The name's Flyback. Ćuk Flyback"
[10:40:34] <Tom_itx> flapjack
[10:48:59] <cehteh> julius_: pwm freq depends on the configuration, something like F_CPU/prescaler/TOP
[10:50:08] <vaskozl> flyback: no I did not
[10:55:00] <cehteh> vaskozl: put a small, fast diode in reverse direction between the motor poles .. also a small (10nF) capacitor too
[11:02:31] <flyback> vaskozl, uh good way to burn the transistors
[11:02:33] <flyback> withouit them
[11:02:40] <flyback> my nick is from the transformer
[11:02:41] <flyback> bbl
[11:07:23] <vaskozl> ok
[11:08:36] <cehteh> biggier cap around the whole things is also a good idea, not for a less than 100mA motor , but for anything bigger
[11:08:47] <vaskozl> But if I use analogWrite from with the arduino IDE and all that it is fine.
[11:08:55] <vaskozl> The motor is really weak
[11:09:57] <cehteh> when you dont use flyback diodes the transistor or arduino may eventually fry
[11:10:41] <cehteh> when it works in one case but not in another either you have a bug or its becasue of different pwm freq
[11:23:55] <twnqx> what's a "silicon AF transisor"? seems some special kind of pnp/npn...
[12:12:54] <theBear> audio frequency if you looking at old/traditional original-design-purpose stuff
[12:13:11] <theBear> and silicon is mentioned cos other kinds used to be more common, or err, exist at all
[13:08:44] <cehteh> oops .. still bug in utf8 handling :/
[15:43:10] <julius> if i set DDRD = 0x80 - does this translate into 00001000 ? so pd4 is outpout?
[15:43:14] <julius> pd3
[15:43:21] <LeoNerd> 0x80 is the topmost bit
[15:43:25] <LeoNerd> PD7
[15:43:29] <julius> oh
[15:43:32] <julius> i meant 0x08
[15:43:39] <LeoNerd> If you wanted PD3, also, you might find it more readable to write DDRD = _BV(PD3);
[15:43:45] <LeoNerd> Then it's there nice and directly
[15:43:50] <julius> true
[15:43:59] <julius> will do that, currently reading other code
[15:44:15] <julius> so 0x08 is PD3 ?
[15:44:19] <LeoNerd> Also don't forget that a plain assignment like that will turn off all the other 7 bits.. that may or maynot be the effect you wanted
[15:44:32] <LeoNerd> If you didn't want to disturb the others, you could DDRD |= _BV(PD3);
[15:44:35] <julius> i know, they are ored (|) together
[15:46:59] <lorenzo> (_BV(x) is just a macro for 1<<x if you're curious)
[15:47:10] <LeoNerd> For (1<<x) most critically
[15:47:29] <LeoNerd> So as things like _BV(1)+_BV(2) etc.. still work correctly ;)
[15:47:39] <lorenzo> yup
[15:47:45] <lorenzo> I'm always scared to use these functions :D
[15:47:51] <lorenzo> dunno, compiler compatibility
[15:48:20] <LeoNerd> They're defined as a macro in the main <avr/io.h>
[15:48:29] <LeoNerd> It's nothing to do with the compiler. It's literally the macro #define _BV(x) (1<<x)
[15:48:59] <lorenzo> yeah I mean, if I happen to stumble upon a avr-libc version that hasn't got that
[15:50:07] <julius> i know that the question sounded stupid, but im still a bit uncomfortable with reading OTHER peoples code
[15:50:19] <LeoNerd> Hah.. that happens :)
[15:50:33] <julius> please, help me and tell me that 0x08 is pd3
[15:51:00] <LeoNerd> 0x08 is 1<<3
[15:51:10] <julius> ok
[15:52:22] <lorenzo> yay
[15:52:24] <lorenzo> atmel shipped me attiny841
[15:52:32] <julius> i need some sleep
[15:52:39] <julius> have a good one
[15:52:44] <lorenzo> " 2 full duplex USARTs with Start Frame wake up from power down" <3
[15:52:56] <julius> sounds great
[15:53:09] <LeoNerd> Yah; the tiny841 is nice
[15:53:12] <lorenzo> yeah, software serial in attiny2313 was starting to get in my way
[15:53:24] <lorenzo> ran out of program memory too easily
[15:53:27] <LeoNerd> I have a tiny841 devboard, and it's the chip I use in a couple of my projects
[15:53:43] <lorenzo> where did you get the devboard?
[15:53:55] <LeoNerd> Hah; yeah... I never quite understood why the tiny2313 has a UART... 2K of flash and almost no other peripherals to speak of
[15:54:02] <LeoNerd> It's Bot_Thoughts' one from tindie
[15:54:15] <LeoNerd> I have the full collection of his :)
[15:54:23] <lorenzo> ah yeah, seen that, but still to expensive to ship here
[15:54:58] <LeoNerd> https://www.tindie.com/products/bot_thoughts/eezeetiny841/
[15:55:24] <LeoNerd> I tend to use the tiny84 on most of my small projects, or the 841 if I need that UART
[15:57:10] <lorenzo> along with the attiny841 I also got an at89S52
[15:57:29] <lorenzo> which is not avr :D but should still be interesting to program
[16:15:48] <WormFood> I hope you guys appreciate the changes I'm making to my calculator. I have it now, where you can supply your own list of clock speeds, and bit rates. So, you can totally customize what it gives you (almost)
[16:16:58] <lorenzo> WormFood: what's the link?
[16:19:24] <WormFood> http://wormfood.net/avrbaudcalc-testing.php?bitrate=300,600,1200,2400,9600,14400,15200&clock=1,2,3 <-- here is a link, with an example of the new feature
[16:20:45] <WormFood> I'm obviously still working on it, but I'm soliciting comments and suggestions.
[16:21:09] <lorenzo> default setting is already 8n1 right?
[16:22:09] <lorenzo> nice, you're also first google result for "avr ubrr" ;p
[16:22:38] <WormFood> that page has a very high ranking with google. Just google for "baud", and it's in the top 25
[16:23:05] <WormFood> That's pretty impressive for a single word, as popular as that.
[16:23:24] <WormFood> And, I've done zero SEO on that page. My rankings with google are purely organic.
[16:24:52] <WormFood> default is 8N...the stop bits don't matter.
[16:25:25] <WormFood> and that setting does affect what it considers to be valid and invalid, as more bits has a lower tolerance for errors.
[16:26:28] <WormFood> You can get an example of that, by deleting the bit rate, and clock speed, and setting the data bits to 5 and look at the tables, then set the data bits to 10 (ok, 9 data bits + parity), and see how the colors change.
[16:36:41] <lorenzo> I see
[16:36:46] <lorenzo> ah yeah you're in third google page for "baud"
[16:38:58] <WormFood> logout of google, and see what you get
[16:39:18] <WormFood> They customize your search results.
[16:40:04] <WormFood> oh. I misread. You're right, 3rd google page for me too. I used to be 20 or 21, but last time I checked, I was 22 or 23
[16:41:28] <WormFood> The Icom ex-494 is a frequency programmer, for some older models of Icom VHF, and UHF radios. If you just google for "ex-494", I come up #1 ;)
[16:41:58] <lorenzo> yeah first
[16:42:43] <WormFood> I think that's pretty cool. I haven't found anyone linking to that page, but I know people must, since I have the only schematics of it, that I know of.
[16:48:54] <WormFood> also, if you search google images for "gimix computer" and "pt68-k4", I have a few images that rank fairly high. The mame guys are emulating the pt68-k4 computer now, and even have a link to one of my pictures, in their source code ;D
[16:51:09] <WormFood> I actually know one of the guys on the mame project (or at least he was on it), but I don't know his name. He gave me a smart card emulator he wrote, and you could use it to emulate an ST19CFxx smart card, and if you give it the right rom/eprom images, it can emulate a satellite smart card, and can get free TV with it ;)
[16:52:39] <WormFood> I modified the hell out of it, to support the newer smart cards. That was a lot of fun. I used that software up until 2008, when I left usa.
[22:05:36] <ColdKeyboard> can someone tell me why I'm getting these errrors http://pastie.org/10728274 when I try to compile project
[22:05:51] <ColdKeyboard> And this is the project that I'm trying to compile https://github.com/adafruit/IRKey
[22:06:17] <ColdKeyboard> Not sure if linker cannot find files or something else is wrong :\
[22:07:14] <Casper> you use string and do not import the string header
[22:09:11] <ColdKeyboard> Casper: You mean #include <string.h> ?
[22:09:24] <Casper> most likelly
[22:09:46] <ColdKeyboard> I tried adding it and it stil doesn't help
[22:10:14] <Casper> isn't it however avr/string.h ?
[22:11:46] <ColdKeyboard> I get error main.h:4:24: error: avr/string.h: No such file or directory
[22:11:47] <ColdKeyboard> :\
[22:12:13] <ColdKeyboard> I don't get it, Adafruit says that this is the source code that they are shipping with their hardware, I guess it should compile
[22:12:39] <Casper> maybe your include path is wrong
[22:13:08] <Casper> quite possibly actually
[22:14:36] <ColdKeyboard> In makefile?
[22:14:41] <ColdKeyboard> INCLUDES = -I '.'
[22:15:42] <Casper> ya
[22:16:33] <ColdKeyboard> Any idea how should I fix it? :\
[22:17:22] <Casper> -I/usr/avr/include/avr/ <=== what I have
[22:41:59] <ColdKeyboard> Darn it... Cannot make it to compile :\
[22:42:44] <ColdKeyboard> Casper: This is the make file -> http://pastie.org/10728291
[22:42:51] <ColdKeyboard> See any reason why it shouldn't compile?
[22:43:08] <ColdKeyboard> I'm not sure how to point to avr/includes
[22:47:46] <ColdKeyboard> Well It compiled from the Atmel Studio command line :\
[22:49:18] <Casper> https://bpaste.net/show/968f9669fbe4 <=== the generic Makefile I use
[22:52:34] <cehteh> do you really need the map file?
[22:55:44] <Casper> most likelly no
[22:56:03] <Casper> but the .lst is super usefull