#avr | Logs for 2014-03-01

Back
[05:01:06] <guanche> I'm trying to drive a 16x2 lcd, and I hooked it's vcc to my circuit's vcc, then it shows up as the upper row filled with dots when I power up
[05:01:26] <guanche> can I still send the initialization sequence and have it properly initialized?
[05:01:35] <guanche> it doesn't seem to make any effect
[05:02:16] <guanche> I mean, all the characters on the upper line, shows all it's dots
[05:02:29] <guanche> just 16 black boxes
[06:37:08] <specing> guanche: that means it is uninitialized
[06:37:39] <guanche> so, I can send those three 0x30 after that?
[06:38:00] <guanche> I'm trying to initialize it by hand to no avail
[06:38:30] <guanche> been all the morning re-checking the connections, and everything, I just don't know what I'm doing wrong
[06:41:11] <specing> did you write your own code for it?
[06:44:50] <guanche> no, I'm following a tutorial
[06:45:05] <guanche> this one: http://www.8051projects.net/lcd-interfacing/commands.php
[06:47:05] <guanche> but in theory, by leaving the lcd initialize on it's own
[06:47:38] <guanche> rathern than hardcoding the desired configuration, I should be able to write a simple letter to it with de default settings
[06:51:27] <megal0maniac_afk> guanche: You need _at least_ a function set command
[06:52:00] <guanche> so, providing the internal reset circuit conditions are met, and it's done
[06:52:21] <guanche> can I afterwards send my initialization sequence to override default config?
[06:52:32] <megal0maniac_afk> This is what I wrote http://pastebin.com/fq6DVwL7
[06:52:56] <guanche> let me try
[06:53:16] <megal0maniac_afk> See if that code works. If it doesn't, then your connections are bad.
[06:53:29] <guanche> ok thanks
[06:53:30] <megal0maniac_afk> It's designed for 8bit mode. Just edit the header
[06:53:42] <guanche> it's fine, I'm also using 8-bit mode
[06:54:21] <megal0maniac_afk> I mean edit the header for pin assignments
[06:54:40] <guanche> yes, sure
[08:01:29] <guanche> can you guys believe the problem was having db7 as an input?
[08:01:50] <guanche> shouldn't it be an input to check for the busy flag? I though it wasn't used while sending data
[08:32:34] <The_Coolest> did you guys see this? AVR based :P https://www.kickstarter.com/projects/70308014/kings-assembly-a-computer-mouse-full-of-awesome
[08:32:55] <The_Coolest> and just to clarify, not my project
[12:51:22] <guanche> thanks, bye
[15:25:55] <bblaze> hey, does anyone in here use "TinySafeBoot"?
[16:02:06] <bblaze> i guess not..
[16:02:28] <bblaze> can anyone recommend a serial bootloader for tiny? I've tried a few, but had little luck
[16:35:00] <vsync2> sup avr
[16:35:07] <vsync2> i love #avr
[16:53:45] <naquad> in PWM mode how do i know that timer1 has hit the top?
[16:54:13] <Casper> use an interrupt?
[16:54:16] <Casper> for the timer
[16:54:25] <naquad> Casper, mmm and what about main loop?
[16:55:44] <Casper> you mostly want to use interrupt... else check the counter value, and hope to not miss a tick
[16:55:48] <naquad> Casper, https://gist.github.com/9298583 - thats my code and it doesn't work the way i need it. general idea: setup loop for timer1 in pwn mode with 50Hz frequency and drive a servo, it is driven, but i don't know when to stop. motor doesn't make a complete loop and when i remove disable_bit line that stop PB1 from output i'm getting a problem that servo doesn't stop at all
[16:56:24] <naquad> see line 34
[16:56:38] <naquad> that doesn't work somewhy, i've tried various values including 1999, 20000 and etc...
[16:57:17] <naquad> and that delay there doesn't make much sense
[17:00:07] <Casper> icr1... line 25, the avr do not know what frequency it run at, so this is probably wrong
[17:00:23] <naquad> Casper, in makefile i have -DF_CPU=1000000
[17:00:57] <naquad> fuses are by default and this is atmega168p which is claimed to run at 1MHz on default settings
[17:01:01] <Casper> I'ld have to check the datasheet and all, but I'm still sure it's wrong
[17:01:02] <Casper> but...
[17:01:18] <Casper> are you doing software pwm???
[17:02:28] <Casper> 30/32, how are you getting the value? with hex? if not then you did it wrong there
[17:03:15] <naquad> Casper, mmm why software? i want to count it
[17:03:35] <naquad> *timer1 to do it
[17:03:54] <Casper> the avr can take care of the PWM by itself, and you generate it by software using the timer as a timebase... it's half wrong unless there is a reason behind it
[17:04:16] <Casper> ah I see the read16 now...
[17:05:00] <Casper> are you aware that a servo require a pulsetrain to work and not just a single pulse?
[17:05:33] <Casper> often it need like 5 pulses before it even consider it valid and start to move
[17:05:58] <sabesto> and the frequency might not matter at all
[17:06:49] <Casper> the frequency may matter, depending on the servo
[17:06:58] <Casper> some are said to be extremelly picky
[17:07:15] <Casper> other has been said to be quite... forgiving
[17:07:38] <naquad> Casper, erm, first of all it looks like i've just broke 1 servo (it turned 360), second of all is how do i do it then? in book and here: http://extremeelectronics.co.in/avr-tutorials/servo-motor-control-by-using-avr-atmega32-microcontroller/ - i see there's only one pulse
[17:07:54] <naquad> i've tried to do it via interrupt (timer1 overflow)
[17:07:58] <sabesto> like the speed controllers made for quads that has a refresh of 400+Hz
[17:08:00] <naquad> but no luck
[17:08:26] <naquad> updated the code
[17:08:36] <Casper> naquad: the standard for servo is 50Hz with a pulse width of 1 to 2ms
[17:08:50] <Casper> so 1-2ms high, 19-18ms low
[17:09:01] <naquad> Casper, erm is there any example code?
[17:09:11] <Casper> don'T have one on hand
[17:09:12] <naquad> seriously, i've seen only continuous pulse
[17:09:20] <naquad> in the book and in the article above
[17:09:24] <naquad> they use single pulse
[17:09:27] <Casper> that pulse need to be repeated all the time
[17:09:29] <naquad> and motor moves, it just doesn't stop
[17:09:46] <sabesto> nope
[17:09:54] <Casper> wait...
[17:09:58] <Casper> are you using a motor or a servo?
[17:10:02] <naquad> servo
[17:10:05] <Casper> 3 pins one?
[17:10:06] <naquad> servomotor :)
[17:10:07] <naquad> 3
[17:10:13] <Casper> ok
[17:10:17] <naquad> +,- and signal
[17:10:45] <sabesto> naquad: you got the complete code in the link you just pasted
[17:10:48] <Casper> as I said, it depend alot on the servo used...
[17:10:59] <sabesto> it sets up pwm, which is continuous
[17:14:17] <naquad> it is definitely not continuous
[17:14:30] <naquad> it is just the article that moves servo continuously
[17:14:43] <naquad> but when i try to set it up to continuous operation i get 360 spin
[17:14:47] <naquad> which is definitely not right
[17:15:42] <sabesto> do you have a link to the servo you got, because it does not seem like a normal servo
[17:17:36] <sabesto> ive written code to run servos many times, and what casper says is right
[17:19:08] <naquad> http://www.servodatabase.com/servo/towerpro/mg90
[17:19:10] <naquad> thats my servo
[17:19:55] * Casper wonders...
[17:19:59] <sabesto> how do you get 360 degrees of rotation out of a 180 degree servo?
[17:20:05] <sabesto> did you modify it?
[17:20:37] <naquad> sabesto, very simple: you give it forever 0 and it breaks the internal blocker => servo blocked and replaced with another one
[17:20:40] <naquad> i've got 4 more tries
[17:20:54] <naquad> s/blocked/broked/
[17:21:13] <naquad> https://gist.github.com/9298583 - is this a correct code?
[17:21:17] <Casper> ah my code use hard coded delays...
[17:21:20] <Casper> not timer...
[17:21:44] <Casper> line 30 is still wrong
[17:22:00] <Casper> 37-38 is unneeded
[17:22:44] <Casper> 32 can cause trouble since you don't use interrupts
[17:22:50] <Casper> waut
[17:22:52] <Casper> wait you do
[17:22:56] <Casper> nm 32 then :D
[17:23:11] <Casper> but the interrupt is... doing anything...
[17:23:22] <Casper> shouln't be there
[17:23:30] <naquad> what should it do then?
[17:25:56] <Casper> look at the datasheet for your avr for the proper PWM output
[17:26:40] <naquad> Casper, why isn't this one proper? mode 14, just like the article and book say
[17:26:45] <naquad> atmega168p
[17:27:01] <naquad> WGM11, WGM12, WGM13
[17:27:40] <naquad> top is ICR1 (20000 = 20ms), Update of OCR1A at bottom, overflow at top
[17:30:25] <naquad> any ideas?
[17:32:43] <Casper> hmmm may be ok, but I didn't made the math... but hmm oh you use 1MHz... duh... nm :D
[17:33:04] * Casper is food sleepy, bbl
[17:46:19] <naquad> is there any good guide on PWM? it looks like i don't understand how does it work :(
[17:48:56] <PoppaVic> given a digital source of N volts; pulse to ON for a percentage of time, generating an RMS value of voltage, current, and envy.
[17:53:41] <naquad> PoppaVic, in any case nothing works, either i'm stupid or there's some damn magic :( i've just put same servo on arduino and it works like a charm
[17:55:31] <PoppaVic> Yes.
[17:55:38] <naquad> yes what?
[17:55:48] <PoppaVic> yer stupid or there is damn magic
[17:56:11] <naquad> i can't even find a working example, the one from article even with changed values doesn't work out
[23:51:48] <rue_shop2> naquad, want to show me details?
[23:51:58] <rue_shop2> what are you trying to do/
[23:52:02] <rue_shop2> ?