#avr | Logs for 2013-12-02

Back
[05:31:31] <braincracker> hey
[05:32:25] <bighead123> Hello, how to out 16 bit value to PortA on pins 16-31? I'm using SAM3N-EK kit
[05:32:42] <braincracker> no idea
[05:33:02] <braincracker> what device?
[05:33:06] <braincracker> portA is 16 bit?
[05:33:16] <bighead123> braincracker: SAM3N4C
[05:33:20] <braincracker> oh
[05:33:33] <bighead123> braincracker: no, 32 pin port
[05:33:53] <braincracker> i see, so you want to out higher 16 bits on the 32 bit port
[05:34:02] <bighead123> braincracker: yes :)
[05:34:51] <braincracker> outvar = your16bitvalue << 16;
[05:34:52] <bighead123> braincracker: i.e. how to out uint_16t on pins 16-31 when port has 32 pin in overall
[05:35:00] <braincracker> just shift your value up 16 bits
[05:35:31] <braincracker> uint32_t outvar = (uint32_t)your16bitvalue << 16;
[05:35:43] <braincracker> first you need to convert it to 32 bit ofc
[05:36:28] <bighead123> braincracker: but how to write port and set port direction? here http://asf.atmel.com/docs/3.11.0/sam3n/html/sam_pio_quickstart.html and http://asf.atmel.com/docs/3.11.0/sam3n/html/ioport_quickstart.html is described how to set single pin but not how to set entire port
[05:38:27] <bighead123> braincracker: I can set each pin one by one as output? but how to out 32bit value to port?
[05:39:43] <braincracker> haven't used SAM device yet but on the AVR you just PORTA = value to output value, DDRA is data direction register and
[05:41:01] <bighead123> braincracker: I have used AVR also many times, :) would try on SAM with the same way, maybe it would work
[05:41:19] <braincracker> i think it is compatible
[05:44:22] <braincracker> bighead123 http://pastebin.com/dzMEi236
[05:44:27] <braincracker> here is my blinkertest
[05:45:17] <bighead123> braincracker: nop :( Error 15 'DDRA' undeclared (first use in this function)
[05:45:27] <braincracker> ;/
[05:45:36] <bighead123> braincracker: same error with DDRA
[05:49:13] <braincracker> bighead123 www.atmel.com/Images/doc11097.pdf‎
[05:49:18] <braincracker> i think you need this
[05:51:03] <braincracker> hm i see this is nothing like avr
[05:52:38] <braincracker> yo hackman
[05:53:00] <hackman> hell braincracker
[05:53:10] <braincracker> what's up ?
[05:53:32] <bighead123> braincracker: :) found here http://asf.atmel.com/docs/3.11.0/sam3n/html/group__ioport__group.html full API reference is here http://asf.atmel.com/docs/3.11.0/api.html :)
[05:54:13] <braincracker> yea i see many new high level functions, input debounce flags... will be a horror if something stops working
[05:58:14] <bighead123> braincracker: yes, seems I need ioport_set_port_level , I'm using this board just for testing 176x220 LCD, atmel studio is the worst embedded software IDE ever seen, however ICs are great but without ATMELs default software
[06:46:57] <beaky> hello
[06:47:09] <braincracker> hey
[06:47:31] <beaky> hello
[06:57:19] <braincracker> life on mars?
[06:57:46] <ArakuS> mars ? http://www.marsboard.com/
[06:57:56] <braincracker> got land for sale on mars?
[06:58:00] <braincracker> ;>>
[07:00:04] <ArakuS> ping curiosity.arq -> 64 bytes from 172.16.1.1: icmp_req=1 ttl=64 time=0.294 ms
[07:00:27] <ArakuS> I'm not to far from curiosity ;]
[07:00:57] <braincracker> google is everywhere ;)
[07:44:59] <jadew> test
[07:46:01] <braincracker> WARNING: General Protection Faults in these executables
[10:30:39] <braincracker> okey, sw pwm smoothly ramps up down with the led :) now i'd need some magic
[14:59:37] <PigFlu> how do i go about pwm controlling 100 leds
[14:59:55] <tzanger> 100 LEDs all at different levels?
[14:59:59] <tzanger> a small FPGA
[15:00:02] <PigFlu> yes
[15:00:04] <PigFlu> no
[15:00:30] <PigFlu> something cheap
[15:00:53] <PigFlu> i have tons of different avr chips and shift registers
[15:01:25] <jerkey> pigflu have you heard of the addressible LED strips? search WS2812
[15:01:32] <tzanger> PWMing even 10 LEDs in 10 groups would be difficult at the same time
[15:01:41] <PigFlu> no led strips
[15:01:45] <tzanger> you could use say 2 PWM channels per AVR, and use 50 AVRs networked together
[15:01:52] <jerkey> you can get a strip of 240 LEDs for $75 and control them all from a single pin of an arduino
[15:02:09] <tzanger> you could also bit-bang them easily enough, say an XMEGA doing software PWM you could get 20ish LEDs at different rates per chip
[15:02:25] <jerkey> $75 is for the weatherproof LED strip stuff, you can get bare tape for cheaper probably
[15:02:48] <PigFlu> i dont want a led strip, though
[15:03:20] <tzanger> you were given several solutions
[15:03:41] <tzanger> If you'd like more specific help I contract out at US$125/hr, because it seems you are looking for someone to design it for you
[15:03:51] <jerkey> oh pigflu i forgot: lolshield is exactly what you want
[15:04:03] <PigFlu> my idea was to use shift registers, and turn the leds on or off at a rate of about 100 Hz
[15:04:17] <jerkey> individually? why?
[15:04:41] <PigFlu> ive tried, and as long as i dont toggle it on/off less than 24 times a second it looks decent
[15:05:02] <PigFlu> my worry is that i have to output at a rate of 100*100 Hz
[15:05:26] <jerkey> you can use lolshield with a faster CPU to get a higher refresh rate. http://www.makershed.com/LoL_shield_for_Arduino_p/mkjr3.htm
[15:05:32] <PigFlu> jerkey: in order to set the brightness of each led individually..
[15:06:01] <PigFlu> im actually programming on a pi at the moment.. :-)
[15:06:28] <tzanger> jerkey: 100Hz? so you want blinking/strobing and not really PWM from that description
[15:06:45] <PigFlu> well, its sort of pwm i guess.
[15:07:35] <PigFlu> if i toggle a led at 100 Hz it would appear half as bright, no?
[15:07:51] <PigFlu> well, any rate above 24 would do
[15:08:07] <PigFlu> but in order to get different levels i need a much higher rate
[15:08:52] <PigFlu> does this make sense, or am i retarded?
[15:08:53] <ambro718> false
[15:09:31] <PigFlu> how is it false..
[15:10:22] <ambro718> toggling the led at 24Hz does not mean you're limited to turning it on/off with 24Hz granularity
[15:12:17] <ambro718> i.e. you don't have to implement it by choosing for each 1/24th of a second whether it should be on or off. You can say that you'll turn it on exactly 0.03412137 seconds after you turn it off
[15:12:34] <ambro718> precision limited to your timer resolution, *not* to your PWMing frequency
[15:12:53] <ambro718> * after you turn it on
[15:13:31] <PigFlu> i dont think i follow you
[15:16:47] <ambro718> PigFlu: suppose you make use of one timer (16bit at least) for the PWM. Suppose your PWM frequency is 1/24s which corresponds to 1000 ticks of this timer (depending on your timer prescaler and F_CPU). You turn it on at T=0, and off at T=253, and on at T=1000, and off at T=1253, and off at T=2000, ....
[15:18:06] <ambro718> and you can see that in each cycle the LED is on for exactly (253/1000)*(1/24s)=0.0105417s which presumably is *not* a multiple of 1/24s
[15:18:42] <ambro718> so even if PWM frequency if 24Hz, higher timer resolution allows you to specify the on-time precisely
[15:25:03] <ambro718> this implies you're using the timer in normal mode, not CTC or something. And this *will* allow you to control 100 leds assuming you do it from a busy loop (you don't have enough interrupts or that many leds).
[15:26:06] <PigFlu> how can 1 timer control 100 leds..
[15:27:05] <ambro718> Strange how most people don't know how to properly use overflowing timers. Example: void waitUntil (uint16_t target_time) { while ((uint16_t)(TCNT1 - target) >= UINT16_C(0x8000)); }
[15:28:04] <ambro718> bool timeReached (uint16_t target_time) { return (uint16_t)(TCNT1 - target) < UINT16_C(0x8000); }
[15:29:25] <ambro718> wait a minute, I'll put some sample code together
[15:29:32] <PigFlu> :)
[15:37:45] <ambro718> PigFlu: here, something like this http://ideone.com/15iKO7
[15:38:26] <ambro718> it does have a small issue that at full power the leds will still be turned off for a very small time, but you should be able to fix that
[15:39:43] <ambro718> note PWM inteval needs to be less than 2^15 (that's 15, not 16). It's because timeReached() treats the "lower half" of the range as "past"
[15:40:04] <PigFlu> hmm
[15:40:13] <ambro718> it works (in the absence of bugs)
[15:40:15] <ambro718> lol
[15:41:05] <PigFlu> but the case is "turn led i OFF"
[15:41:15] <ambro718> huh?
[15:41:29] <PigFlu> how would you actually connect the 100 leds to this code
[15:41:46] <ambro718> one to each pin
[15:41:51] <PigFlu> right
[15:41:55] <PigFlu> i dont have 100 pins.
[15:42:06] <ambro718> so you can't independently drive 100 leds
[15:42:19] <PigFlu> well... -_-
[15:42:26] <PigFlu> this is why i asked in the very beginning
[15:43:06] <PigFlu> my idea is to use only 1 pin, and shift registers
[15:43:40] <PigFlu> 100 times a second, i send out 100 bits, right
[15:43:56] <PigFlu> these 100 bits go to each led, making it either turn on or off
[15:44:00] <ambro718> sure but you need some dedicated hardware which actually drives the leds
[15:44:20] <PigFlu> how do you mean
[15:44:40] <ambro718> where are you going to connect the leds?
[15:44:51] <PigFlu> to the shift registers.. -_-
[15:45:10] <PigFlu> each one is perfectly capable of driving 8 leds
[15:46:00] <PigFlu> the only problem as i see it, is outputting my bitstream fast enough
[15:47:35] <ambro718> yeah that might be a problem. But if you can't find anything better, my algorithm will still work if you periodically flush the m_state's into the shift registers
[15:47:44] <ambro718> I don't think I can be of more help :/
[15:48:31] <tzanger> what's the max freq on your shift reg?
[15:48:41] <tzanger> 50MHz shouldn't be unobtainable, although your AVR probably can't drive that
[15:49:48] <N1njaneer> FPGA is usually used here. :)
[15:50:58] <tzanger> N1njaneer: 15:44 < tzanger> a small FPGA
[15:51:04] <N1njaneer> Much of TI's signage products are constant-current LED drivers attached to cascadable shift registers. You do your PWM or similar modulation at the head-end and just stuff the registers. If you are intending to do any kind of intensity control via PWM, you will absolutely need to minimize jitter or it will be extremely visible.
[15:51:19] <N1njaneer> +timing jitter
[15:53:59] <PigFlu> well, its just a 10 kHz signal..
[15:54:00] <ambro718> you do know there are AVRs with lots of pins? atmega2560 and friends have 86
[15:54:11] <PigFlu> shouldnt be a problem
[15:54:16] <ambro718> so if you use two of those you can cover it
[15:57:38] <N1njaneer> 10Khz for what?
[15:58:17] <N1njaneer> 10Khz for the update rate of the LEDs?
[15:58:40] <N1njaneer> Or are you not driving them for intensity. If just on/off then the jitter is far less of a concern.
[15:59:24] <PigFlu> the leds are refreshed at 100Hz
[15:59:46] <N1njaneer> Are you doing intensity modulation or not?
[15:59:50] <PigFlu> but since there are 100 of them, the signal controlling it all is 10 KHz if my math is correct
[16:00:10] <PigFlu> uh.. i just want to dim them
[16:00:18] <PigFlu> i guess you can call it intensity modulation
[16:00:44] <N1njaneer> If you don't mind them being noticably flickery then you can get a couple steps of PWM
[16:01:04] <PigFlu> of course i dont want them to flicker
[16:02:07] <N1njaneer> Then you may want to go to a higher rate depending on the bit depth of dimming you desire. If it's only going to be like 0%, 25%, 50%, 100% you'd probably still be okay since you'd still have a 25fps update rate.
[16:03:51] <PigFlu> yea, i dont need that many different levels
[16:04:47] <N1njaneer> Then 0%, 50%, 100% would still give you a 50fps update rate, which should be sufficient to not flicker if you don't move your head or the array around much.
[18:07:24] <Elco> I wrote a library to pwm lots of leds with shift registers: ShiftPWM
[18:07:39] <Elco> you might find it helpful
[18:09:02] <Elco> with 240 leds (30 shift registers), you´ll get about 100 brightness levels at 75Hz
[18:11:24] <Elco> that´s software PWM over the SPI bus, 66% CPU load on a 16MHz avr
[18:12:23] <Elco> if you use TLC5916 instead of normal shift registers, you have constant current sink outputs and don´t need resistors
[18:18:13] <N1njaneer> Or use 5951's and you get 24 outputs per chip that automatically PWM on 1024-bit resolution with only a clock input, which the Atmega's will do nicely with the CLKOUT feature. It's what I used in plasmatrim.com -- ATMEGA32 and 5951
[18:18:41] <N1njaneer> Then you have zero load on the CPU unless things are changing :)
[18:21:23] <N1njaneer> But only really useful if you need high-speed PWM for critical dimming or reduced CPU load
[19:54:07] <FoxGT> Tom_itx, did you send my autographed programmer!?
[19:54:32] <Tom_itx> ages ago
[19:55:04] <FoxGT> Sweeeeeet
[19:55:13] <FoxGT> Did you autograph it with a soldering iron?!
[19:55:14] <Tom_itx> you should have gotten an email