#avr | Logs for 2015-10-13

Back
[10:13:48] <joeka> Hello!
[10:15:31] <joeka> I think I'm missing something here: trying to use the timer0 and its overflow interrupt on my atmega32, but it resets rapidly. Can paste some stuff in a seconds
[10:18:38] <gorroth> what resets, the avr does a full reset?
[10:19:09] <joeka> http://pastebin.com/jH0eh8X0
[10:19:19] <joeka> It looks like it
[10:19:27] <joeka> just playing around here really
[10:19:34] <gorroth> do you have BOD turned on?
[10:19:59] <joeka> you see how I toggle the LED before my loop in main? It gets toggle multiple times per second
[10:21:23] <joeka> gorroth, have to check for BOD
[10:21:38] <gorroth> i dn't see how it would toggle. you don't have it toggling
[10:21:47] <gorroth> oh
[10:22:15] <gorroth> anyway, maybe you have BOD enabled, and your voltage is falling too low
[10:22:16] <gorroth> i don't know
[10:28:21] <joeka> would be strange, what I pasted is really everything I run at the moment. No idea, i'm new to this ^^
[10:30:05] <joeka> btw. if I only activate global interrupts with sei() it still works. Only when I set the overflow interrupt with "TIMSK |= (1 << TOIE0);" it starts resetting all the time
[10:30:40] <joeka> maybe I'm doing something wrong here, but it looks like in the examples I found, I think
[10:47:13] <CasperAtwork> be sure that your interrupt routine use the right name
[10:47:24] <gorroth> you don't do anything to turn off your lights
[10:47:25] <CasperAtwork> an unhandled interrupt will cause a reset
[10:47:32] <gorroth> which makes me think that you have a voltage problem
[10:47:40] <gorroth> ah
[10:47:47] <gorroth> CasperAtwork could be right too; i haven't worked with ISRs yet
[10:48:48] <gorroth> joeka: btw, are you working with an arduino board or an avr directly?
[10:51:03] <joeka> gorroth, doesn't a reset turn of the light anyway? Also otherwise "PORTD = PORTD ^ (1<<PD5);" would toggle it
[10:51:19] <joeka> voltage problem would be possible of course
[10:52:56] <joeka> CasperAtwork, interrupt handling looks right for me as a newbie.
[10:53:06] <joeka> gorroth, I'm using an atmega32 on a atmel evaluation board from pollin.de
[10:53:57] <joeka> CasperAtwork, if you want to look at it, it's only a few lines: http://pastebin.com/jH0eh8X0
[11:01:12] <CasperAtwork> I'm at work, boss is here, can't check
[11:01:41] <joeka> CasperAtwork, thanks anyway
[11:34:23] <gorroth> your PORTD toggle is not in a loop
[11:34:31] <gorroth> so your code is not toggling it in a good manner
[11:34:44] <gorroth> like i said, check voltage, and you can do what CasperAtwork said
[11:34:48] <gorroth> gtg
[11:37:23] <joeka> gorroth, that is on purpose, so that I can easily see when it's restarted. I added the line when I realized that it#s resetting
[11:55:26] <CasperAtwork> joeka: at first glance, it appear to be fine
[11:55:28] <CasperAtwork> however
[11:55:35] <CasperAtwork> your interrupt routine is empty
[11:55:45] <CasperAtwork> gcc may optimise it out
[11:57:27] <CasperAtwork> try to put anything there.... like a _NOP();
[12:00:26] <Jartza> NOP );
[12:01:14] <Jartza> I think better would be to put naked ISR there with RETI
[12:28:07] <joeka> I increased a variable in there earlier, same problem
[12:33:42] <CasperAtwork> does your makefile create a .lst file?
[12:34:21] <CasperAtwork> the .lst is a pseude asm file, it can help alot to figure out what happening
[12:52:15] <joeka> gorroth, CasperAtwork: maybe I shouldn't tell gcc that's to compile it for an ATmega8 when using an ATmega32
[12:52:34] <joeka> :/
[12:52:39] <CasperAtwork> LOL yeah that can do it
[12:53:04] * CasperAtwork puts duct tape on joeka's arm and pull quickly on said duct tape
[12:53:45] <CasperAtwork> that shall serve better than a wrist slap :D
[12:54:02] <joeka> well, now it works! :D
[12:54:17] <Strangework> LOL
[12:55:19] <Strangework> I don't know about you, but discovering problems are only trivial mixups is always a relief for me.
[12:55:52] <Strangework> It means that you aren't necessarily missing a fundamental concept
[12:57:26] <joeka> but it's really tricky, I would have never searched for the error in the Makefile instead of the sourcecode, if a friend hadn't told me to check
[12:58:27] <CasperAtwork> and I assumed that you did changed it...
[15:00:00] <LeoNerd> Hrmmm... buy a PSU with 10mV/10mA resolution for £230, or 1mV/1mA for £320.
[15:00:17] <LeoNerd> (Siglen SPD 3303 D vs. S)
[15:00:21] <LeoNerd> Siglent
[15:00:59] <LeoNerd> I guess the question is whether than 1mA of current draw readout resolution is worth £90 to me
[16:39:41] <CasperAtwork> same voltage and current range?
[17:18:29] <LeoNerd> CasperAtwork: Yah; 0-30V, 0-3A
[17:20:28] <CasperAtwork> I'ld like a 0-30V 0-20A :D
[17:20:36] <CasperAtwork> dual
[17:26:55] <hetii> Hi :)
[17:27:05] <hetii> I plan build http://www.trioda.com/forum/download/file.php?id=43911&mode=view but instead 2k 1% pot that control voltage and current I want to use AVR that will do this job,
[17:27:33] <hetii> Any idea how I can use avr to control current and voltage in this psu ?
[17:28:33] <hetii> I find in the past some electronic resistor that is controled over i2c but no clue if it can work here.
[19:40:25] <gorroth> damn, i gotta figure out how to create reliable comms over uart
[19:40:27] <gorroth> like
[19:40:30] <gorroth> i have uart working
[19:40:40] <gorroth> but if my pc tries to write to the tty too quickly, the avr loses sync
[19:44:38] <Lambda_Aurigae> cut your speed down.
[19:45:03] <gorroth> the baud rate?
[19:45:10] <Lambda_Aurigae> yes.
[19:45:24] <Lambda_Aurigae> you are running with an external crystal at 16MHz, yes?
[19:45:26] <gorroth> alright, i'll try that.
[19:45:29] <gorroth> external at 8mhz
[19:45:31] <Lambda_Aurigae> what bit rate are you running?
[19:45:36] <gorroth> 57600
[19:45:50] <gorroth> i coudln't get reliable between pc and avr at 115200
[19:46:13] <gorroth> i'll try 9600
[19:46:44] <Lambda_Aurigae> 57600 is between 3% and 5% out of range.
[19:47:02] <Lambda_Aurigae> 3.7% actually.
[19:47:08] <Lambda_Aurigae> 9600 is 0.2%
[19:47:13] <gorroth> oh shit
[19:47:13] <Lambda_Aurigae> within stable specs.
[19:47:18] <gorroth> yeah, i forgot to look at the datasheet again
[19:47:20] <Lambda_Aurigae> 38400 is 0.2%
[19:47:26] <gorroth> yeah
[19:47:29] <Lambda_Aurigae> http://wormfood.net/avrbaudcalc.php?postbitrate=57600&postclock=8&bit_rate_table=1
[19:47:34] <Lambda_Aurigae> use the avrbaudcalc.
[19:47:40] <gorroth> i remember i was meaning to check that baud rate on the datasheet; it talks about that at various speeds
[19:47:48] <Lambda_Aurigae> there is a table down there for 8MHz that shows where things are.
[19:47:54] <gorroth> thank you
[19:47:59] <Lambda_Aurigae> gives you nice colorful layout too.
[19:48:09] <Lambda_Aurigae> green, dark green, yellow, orange, red.
[19:48:21] <Lambda_Aurigae> 250000 is 0.0%
[19:48:23] <gorroth> so if it has a 0.2% rate, does that mean i will still have problems, or is it that the parity error detection will pick it up with an error rate that low?
[19:48:26] <Lambda_Aurigae> nice fast.
[19:48:38] <Lambda_Aurigae> 0.2 is within the autoadjustment specs pretty much.
[19:48:46] <gorroth> okay, cool
[19:48:54] <Lambda_Aurigae> less than 1% is really good.
[19:49:13] <gorroth> thanks for the help; i completely forgot to check those specs again
[19:49:36] <Lambda_Aurigae> this is probably your biggest issue.
[19:49:40] <gorroth> i only got the crystal hooked up last night, for the first time i've hooked up a crystal
[19:49:50] <gorroth> yeah, i'll find out in a bit... will reconfigure my code
[19:50:03] <Lambda_Aurigae> go with a 14.7456mhz crystal and you can go really fast with 0.0%
[19:50:22] <Lambda_Aurigae> you did set the fuses to use an external crystal, yes?
[19:50:50] <gorroth> yes, of course i did :)
[19:50:59] <gorroth> i set it for full-swing oscillation with slow power up
[19:51:00] <Lambda_Aurigae> had to ask.
[19:51:10] <Lambda_Aurigae> many people just figure they can put a crystal on and it will use that.
[19:51:15] <gorroth> i had watched a video on it the night before, so i had an idea what to do
[19:51:18] <gorroth> has 22pF caps on it
[19:51:21] <Lambda_Aurigae> but, many people don't bother to actually read the datasheet.
[19:51:40] <gorroth> no, i knew i had to do something; i just wasn't sure all what until seeing the video
[19:51:59] <gorroth> video talked about the baud rate errors and where in the sheets they are, and then i just forgot to check... i was just happy to have the crystal working
[19:52:39] <Lambda_Aurigae> if you run double rate,,if your avr supports it,,you can get to 2.1% at 57600 and 8MHz.
[19:52:54] <gorroth> your hunch was right, Lambda_Aurigae ; i took the usleep calls out of my PC driver, and i'm not losing sync anymore
[19:53:01] <Lambda_Aurigae> wormfood's baudrate calculator is much easier to understand than the datasheet sometimes.
[19:53:17] <gorroth> 2.1% error rate?
[19:53:37] <gorroth> my avr supports it; i'm using atmega88 and atmega168 chips
[19:53:56] <Lambda_Aurigae> http://wormfood.net/avrbaudcalc.php?postbitrate=57600&postclock=8&u2xmode=1
[19:54:05] <Lambda_Aurigae> look down at the 8MHz table.
[19:54:33] <gorroth> omg
[19:54:34] <gorroth> that is hot
[19:55:12] <gorroth> only bad thing is that without hacking around is that i can't get termios to go above 115200
[19:55:17] <Lambda_Aurigae> if your pc will do 76800 then you can be back down to 0.2%
[19:55:21] <gorroth> so i'll just stick to 38400 for now
[19:56:16] <gorroth> with 8mhz clock, 76800 is a 7.5% error
[19:56:25] <Lambda_Aurigae> dual speed.
[19:56:43] <Lambda_Aurigae> running dual speed it is 0.2
[19:56:43] <gorroth> 38400 double-rate?
[19:56:49] <Lambda_Aurigae> no..
[19:57:16] <Lambda_Aurigae> do you see, on the 8MHz table, X2U=0 and X2U=1 ?
[19:57:29] <gorroth> oh, i was looking at the wrong table
[19:57:29] <Lambda_Aurigae> from the last link I posted.
[19:57:35] <Lambda_Aurigae> http://wormfood.net/avrbaudcalc.php?postbitrate=57600&postclock=8&u2xmode=1
[19:57:50] <gorroth> yeah, i see x2u=1 has 0.2
[19:57:59] <Lambda_Aurigae> you can turn x2u mode on, use the ubrr setting from the second set of numbers and get much closer.
[19:58:29] <gorroth> okay. and my PC would only have to know that it's running at 76800?
[19:58:46] <Lambda_Aurigae> yeah.
[19:58:52] <Lambda_Aurigae> because it will be.
[19:59:03] <gorroth> yeah
[19:59:09] <Lambda_Aurigae> that thing just doubles the speed of the oscillator used to drive the usart.
[19:59:17] <gorroth> anyway, termios doesn't have those settings. skips from 57600 to 115200
[19:59:28] <gorroth> i'd have to do a lot of work to get that kind of baud rate going on the pc
[19:59:54] <Lambda_Aurigae> yeah...sometimes this is true.
[20:00:01] <gorroth> hehe
[20:00:03] <Lambda_Aurigae> minicom doesn't like it either.
[20:00:07] <gorroth> for my purposes, it won't matter
[20:00:11] <gorroth> even 9600 is fast enough
[20:00:27] <gorroth> atm, i'm just sending PS3 joystick information to the AVR to control some connected devices
[20:00:36] <Lambda_Aurigae> or a 20MHz crystal!
[20:00:47] <gorroth> i can't do that without going to 5v
[20:00:48] <Lambda_Aurigae> or an 18.432MHz crystal even.
[20:02:12] <Lambda_Aurigae> then go 7.3728
[20:02:26] <Lambda_Aurigae> I've ripped them out of old modems in the past.
[20:02:27] <gorroth> well, i'm going to stick to 8 MHz to make it easy to do PWM calcs
[21:51:49] <gorroth> omg, i got it all working
[21:52:02] <gorroth> the PS3 controller now controls the motors like a freaking boss!
[21:55:35] <Casper> yay
[22:03:48] <gorroth> :)
[22:19:16] <gorroth> one moment while i upload the video to youtube
[22:27:53] <gorroth> https://www.youtube.com/watch?v=NqLD8liBMcM <== my RPi/AVR/PS3 system for controlling 24v motors!!!
[22:30:23] <Casper> hi william
[22:31:56] <Casper> ... cheater :D
[22:32:22] <Casper> rpi... I was expecting the avr to talk directly to the ps3... :(
[22:38:43] <gorroth> lol
[22:38:46] <gorroth> yeah
[22:38:52] <gorroth> i'm sorry about that :)
[22:39:06] <gorroth> that would've been kind of cool too
[22:39:16] <Casper> it can be possible, I think
[22:39:20] <gorroth> probabl
[22:39:28] <gorroth> but it'd probably cost more than just using an rpi to help out
[22:39:45] <Casper> the main issue is: usb host...
[22:40:10] <Casper> I suspect that using bluetooth would be easier than wired..
[22:40:25] <Casper> ... or not... due to the pairing..
[22:44:41] <gorroth> maybe, i dno't know
[22:44:48] <gorroth> i do have the ps3 controller working with bt
[22:44:52] <gorroth> i just wasn't using it there
[22:45:16] <gorroth> i have posted all the code at http://github.com/grimwm/avr, and it's becoming a big set of libraries for avr and pc
[22:45:21] <gorroth> i'm going to split the project very soon
[22:45:43] <gorroth> and then i'm gonig to get ISr-driven UART working and uploaded to that repo as well
[22:46:39] <gorroth> but code is there for the 16-bit pwm, uart, spi, and standard servo controls, along with things to help from the pc side, including getting that data to the AVR and setting up serial devices simply and easily
[22:46:43] <gorroth> and using the ps3 controller