#avr | Logs for 2016-01-08

Back
[05:43:20] <julius> morning
[05:43:46] <julius> i get: Examples/testleds.c:7:13: error: variably modified ‘leds’ at file scope struct cRGB leds[NUM_LEDS]; in this code: http://pastebin.ca/3321783
[05:43:50] <julius> any idea whats wrong?
[05:44:01] <julius> the code is ~15lines long
[06:08:35] <cehteh> thats not your whole code
[06:09:38] <cehteh> and iirc you need c99 at least for that initialization, or #define NUM_LEDS instead const uint
[06:17:27] <julius> i did not poste the includes
[06:17:47] <julius> i did set gnu99, otherwise the for wasnt valid
[06:20:48] <julius> oh wait, the paste is wrong
[06:20:54] <cehteh> how is cRGB defined?
[06:22:06] <julius> http://pastebin.ca/3321802
[06:22:32] <julius> thats from the light_ws2812 library, let me check
[06:22:57] <julius> https://github.com/cpldcpu/light_ws2812/tree/master/light_ws2812_AVR/Light_WS2812
[06:23:51] <cehteh> #define NUM_LEDS 24
[06:24:04] <cehteh> instead of line 17
[06:25:28] <julius> looks good, lets flash
[06:27:59] <julius> great, it works.
[06:28:05] <julius> thanks very much cehteh
[06:28:13] <cehteh> np
[06:28:19] <cehteh> btw delay is evil :D
[06:28:33] <cehteh> but i guess you are only testing there
[06:31:36] <julius> yes, i already set it to 50ms
[06:31:43] <julius> and the full 60 leds
[06:32:43] <julius> i used this led fading code before, https://www.mikrocontroller.net/articles/LED-Fading but since there the positive side of the led is controlled with pwm that wont work with a ws2812 controller
[06:34:46] <cehteh> way to complicated things to fit human perception .. just logarithmic values is often good enough
[06:35:25] <julius> that example looks very smooth with a single leds
[06:35:27] <julius> led
[06:36:12] <cehteh> yeah
[06:36:59] <cehteh> its not wrong, but if you are space constrained on a µC (i did such on a attiny13) then you have to simplify it a bit and still get good results
[06:37:44] <cehteh> someday i may experiment with dithering, to get finer graduation
[06:38:09] <julius> true
[06:38:19] <WormFood> I have an Arduino, and I don't want to use the Arduino environment to program in. I know I can program it with GCC, but I want to know more about outputting via the usb, to the computer, like the Arduino tools do. Is that handled like a regular serial port, or what? Where can I find more info about the details of in/outputting to the USB like a serial port, on an Arduino board with GCC?
[06:38:23] <julius> this is just for fun at home
[06:39:10] <cehteh> WormFood: which arduino?
[06:39:13] <julius> WormFood, a arduino is basically a expensive atmega
[06:39:17] <julius> atmega32 for example
[06:39:32] <cehteh> the ones i use (nano) have just a usb to serial converter (FTDI alike)
[06:39:44] <WormFood> atmega2560
[06:39:51] <cehteh> china nano costs $3 :D
[06:40:07] <WormFood> julius, I bought my board for less than the retail cost of the atmega chip on the board.
[06:40:29] <WormFood> so, I disagree with it being an "expensive atmega" :P
[06:40:43] <cehteh> you can just programm the UART as in the avr-libc tutorials and go
[06:40:57] <WormFood> However, I will agree on the Arduino being expensive. I have a chinese clone.
[06:41:07] <WormFood> awesome cehteh, thanks.
[06:41:16] * WormFood lives in China.
[06:41:19] <cehteh> i am also writing a small scheduler (micro OS) currently for myself which does that, all in work queues interrupt driven
[06:41:44] <WormFood> I like NutOS, for a small AVR OS.
[06:41:50] <cehteh> works well so far but is work in progress
[06:42:04] <cehteh> i just wanted to give it my own try
[06:42:09] <WormFood> I have some EtherNut boards, back in USA, I forgot to bring back with me last time I was there.
[06:42:40] <cehteh> no threads but 'functions' are scheduled
[06:43:07] <cehteh> how big is nuttx for atmegas?
[06:43:20] <cehteh> (basic features + serial)
[06:45:27] <WormFood> not sure
[06:45:42] <WormFood> it depends on what you have enabled.
[06:45:50] <cehteh> yeah possibly
[06:46:03] <cehteh> well i just have fun doing my own stuff
[06:46:11] <julius> WormFood, oh
[06:46:23] <cehteh> currently its mostly functional (but not complete) at under 3500 bytes
[06:46:41] <julius> WormFood, ah, youre a "local" in china. are you chinese?
[06:46:47] <cehteh> well .. nice weather here, i take a bike ride.. bbl
[06:47:02] <WormFood> I have the EtherNut 1.3 and 2.x boards. Which have ATmega128's on them. I did some pretty cool stuff with it. NTP client. Telnet server. Remote management. Reboot, reload firmware, etc. All over the network.
[06:47:24] <WormFood> julius, no, I'm an american. You should have been able to guess by my comment about going back to usa.
[06:47:33] <julius> ah, didnt read that
[06:48:16] <WormFood> I've been in China, for about 10 day short of 8 years.
[06:49:03] <julius> i know 2 girls from china, they study here in germany. what city are you in?
[06:49:10] <julius> just curios how small the world is
[06:49:16] <WormFood> 我住在深圳市
[06:49:21] <WormFood> I live in Shenzhen
[06:49:42] <WormFood> Which is right over the border, with HK. In fact, you can not go to China, from HK, via land, without passing through shenzhen.
[06:50:40] <julius> cool
[06:50:54] <julius> lets see what they respond
[06:51:31] <julius> so reloading firmwares over the network...thats like reflashing a chip with a programmer?
[06:51:38] <WormFood> Yep
[06:51:43] <WormFood> pretty sweet, eh?
[06:51:47] <julius> oh yes
[06:51:54] <julius> how much hardware do you need for that?
[06:52:02] <gevorg> afternoon all
[06:52:22] <WormFood> I had it set up, so if you hit 3 keys on the keyboard, at the same time, it'd reload the firmware over the network, or I could telnet in, and do it remotely.
[06:52:52] <WormFood> the hardware is nothing. Just the ethernut board, and a network connection, and of course, properly configured network.
[06:53:02] <Snert> wow...a cat walk simulator
[06:53:31] <WormFood> I had these setup with 20x4 LCD displays, 16 key keyboards, 3 ibutton inputs, and a 2 color LED. Basic stuff.
[06:54:57] <julius> sound great, since china mostly chips without postage to the world i already packed some things in the basket on alibaba, will add it
[06:59:51] <WormFood> add what? an EtherNut board?
[07:00:25] <julius> yes
[07:00:40] <julius> and arduino
[07:00:41] <WormFood> I've been to alibaba headquaters before :D (and taobao)
[07:00:51] <WormFood> hell, I've been all over China.
[07:01:08] <WormFood> I've been to more places in China, in 8 years, than I've been to in USA, in 35 years.
[07:02:12] <julius> :)
[07:02:24] <WormFood> I don't see an ethernut board there. Can you give me a link?
[07:02:25] <julius> didnt even know that hey have a local store
[07:02:44] <julius> no, ethernut directly does not output anything
[07:03:00] <julius> im just looking trough the example boards on the ehternut homepage
[07:03:25] <WormFood> http://www.alibaba.com/product-detail/-Integrated-Circuits-AVR-ETHERNUT-V_2003768611.html this is all I could find
[07:04:16] <WormFood> and the price/pictures don't feel right. Of course, if it really is an EtherNut board, then that's cool, but obviously that price can't be right. The hardware design on the board is open source, but they're not allowed to use the Ethernut name.
[07:04:20] <julius> doesnt really look like a complete board
[07:04:31] <WormFood> It's definitely not an Ethernut in that picture.
[07:04:44] <WormFood> It's a whole board, with avr and ethernet chip on it. external ram
[07:04:46] <WormFood> etc
[07:04:49] <julius> yes
[07:04:55] <julius> thats how the example boards look like
[07:05:07] <julius> anyway, im gonna look for a way to fade in my ws2812 led strip
[07:05:11] <WormFood> The ones on the ethernut website, are exactly what I have.
[07:05:39] <WormFood> https://www.sparkfun.com/products/11821 this?
[07:06:01] <julius> since im in germany, i dont wanna know what they take for shipping ;)
[08:19:48] <Jartza> evening
[08:24:45] <gevorg> hello
[09:59:33] <cehteh> re
[10:09:03] <LeoNerd> I need some verbs. What would you say that the SPI master does to a CS line? Does it "activate" and "deactivate" it? Assert / release? ...?
[10:16:14] <Jartza> LeoNerd: I have a "feeling" that assert is mostly used, at least in datasheets
[10:38:40] <Chillum> I like assert
[10:39:59] <LeoNerd> And the opposite? deassert? release?
[10:42:37] <Chillum> huh... I like release but it lacks symmetry
[10:42:48] <Chillum> you writing a datasheet?
[10:43:04] <LeoNerd> No, an interface abstraction
[10:43:11] <LeoNerd> https://metacpan.org/pod/Device::Chip::Adapter#readwrite
[10:46:17] <Chillum> POD, it is what separates the dabblers from the builders
[10:47:00] <Jartza> LeoNerd: to me "release" sounds good
[11:12:09] <LeoNerd> Huh. Ordered a pack of 10x 32kHz timer crystals on ebay. Received a bag of 20.
[11:12:15] <LeoNerd> Ohwell.. looks like I have spares :)
[11:14:39] <Jartza> heh yea
[11:14:47] <Jartza> I've had similar experiences
[11:15:39] <Jartza> ordered some pF -level caps for crystals, IIRC 22pF or something, 10 bag
[11:15:42] <Jartza> got like 40
[11:17:38] <Jartza> but, I was supposed to order 40 microcontrollers from farnell (element14), seems I entered "4" in the amount field
[11:18:13] <Jartza> I got 4 MCUs packaged between two plastic trays, resealed in vacuum with those moisture indicators and silica gel.
[11:18:33] <Jartza> I think they were attiny88 :D
[11:18:40] <Jartza> so like 0.6€ each
[11:19:11] <LeoNerd> Isn't the "tiny"88 one of those ones with about a billion pins on it?
[11:22:52] <Jartza> well, 32
[11:22:53] <Jartza> :D
[11:23:21] <Jartza> as many as in atmega328p
[11:24:15] <Jartza> I think it's one of the cheapest attinys
[11:24:55] <Jartza> single attiny88 0.537€
[11:25:14] <Jartza> 100 pieces 0.493€ each
[11:27:17] <Jartza> attiny9 is just tiny bit cheaper, but attiny88 comes next
[11:28:20] * LeoNerd still pondering whether to buy http://www.ebay.co.uk/itm/24MHz-Dual-Channel-DDS-Function-Signal-Generator-Arbitrary-Waveform-FY3224S/361440629220
[11:30:31] <Jartza> TEP-VQFN
[11:30:35] <Jartza> what's "TEP"?
[11:31:28] <LeoNerd> TEP? No clue
[11:31:31] <Jartza> oh, thermally enhanced plastic
[11:31:37] <Jartza> wat?
[11:32:01] <Jartza> http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=517834&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D517834
[12:49:13] <MarkX> when is it beneficial to have FAST PWM with a top of OCRnA vs FAST PWM with a top of 0xFF?
[12:51:53] <cehteh> you only need OCRnA when you need some specific frequency and steps you cant derrive otherwise from the clocks
[12:52:53] <MarkX> ah okay
[12:53:19] <MarkX> so for generic dc motor control, regular fastpwm with top of 0xFF is good enough
[12:53:32] <cehteh> likely
[12:54:37] <MarkX> beauty
[13:29:06] <julius> hi
[13:29:53] <julius> got a led wandering from the first led on the strip, to the last one. one for loop. but how would you let 3 leds in a row go from the first led to the last one?
[13:37:50] <inkjetunito> julius: congratulations, but how are the leds connected / controlled?
[13:38:34] <cehteh> knight rider is so 80's :D
[13:39:42] <cehteh> julius: you implement 2 cursors .. one for the leading, which led to turn on, one for the tailing which led to turn off
[13:39:58] <cehteh> then you can sweep over any numer of leds
[13:40:04] <cehteh> (if i get you right)
[13:41:03] <julius> its a ws2812 strip, currently im using light_ws2812
[13:41:16] <julius> ah yes, let me try something
[13:46:26] <nuxil> Get some shift registers :p
[13:46:41] <nuxil> sipo
[13:47:00] <cehteh> not with ws2812
[13:47:06] <Tom_shop> fpga
[13:56:06] <julius> i get: /usr/lib/avr/include/util/delay.h:163:28: error: __builtin_avr_delay_cycles expects a compile time integer constant when compiling: http://paste.pound-python.org/show/tZpwDGaKF7hOqm4UBcAr/
[13:57:51] <nuxil> yea
[13:58:25] <julius> i used a const, but its still wrong
[13:58:27] <nuxil> dont do _delay_ms(someVar) ,, you need to use a constant. as the error says.. _delay_ms(100) ;
[13:58:42] <julius> cant i defined a variable before?
[13:59:01] <nuxil> no as i know.. i tried and i get that error each time i do that
[13:59:10] <cehteh> you can while(milliseconds--) delay(1) ;
[13:59:19] <nuxil> yea
[13:59:20] <cehteh> not exactly good or exact
[13:59:37] <cehteh> any code which using delay stinks :D
[13:59:41] <nuxil> cos you pass in a ""constant"" from the compilers perspecive of vire
[13:59:44] <cehteh> better use timers
[13:59:45] <nuxil> *view
[14:01:02] <nuxil> indeed. or make your own sleep function if lot of switch / cases :p void sleep(ms) { switch (ms) { case 1: foo; break;} case 2: so on :p
[14:01:17] <nuxil> *with lots
[14:03:03] <nuxil> julius, what chip are you messing around with?
[14:03:14] <julius> atmega32 / ws2812
[14:03:21] <nuxil> :)
[14:03:27] <julius> now it works, at least 3 leds are always on and go from left to right
[14:04:54] <nuxil> idea for you.. make em all leds off.. light one by one up from left to right. then start over again from left and turn off the leds one by one :D
[14:05:46] <cehteh> state machine ftw
[14:06:03] <nuxil> explain
[14:06:39] <julius> nuxil, that certainly looks nice
[14:07:25] <nuxil> or do a binary counter on your leds :D
[14:07:58] <nuxil> like do a range from 0 to ff or ffff
[14:14:19] <nuxil> julius, are you making anything or just messing around?
[14:31:43] <julius> http://paste.pound-python.org/show/JN7qnnbAT7WumTFyqi6f/
[14:31:54] <julius> this one runs forward, and backward
[14:32:04] <julius> without fading
[14:32:47] <julius> nuxil, testing the led strip...still waiting for infrared sensors. then it will become a ir activated light that slowly fades in...stays on for some time and goes out
[14:34:28] <julius> they are kinda bright if you look at them directly. but overwall theres not much light. maybe i need something bigger
[14:35:36] <nuxil> ws2812_setleds function or..light is doing the data on the pins to the chip on the
[14:36:01] <nuxil> *light->light_ws2812.h
[14:40:24] <cehteh> julius: some diffusing lenses will sometimes make it nicer, put them in a milky glas tube or so
[14:40:39] <cehteh> hotglue works sometimes too
[14:43:08] <julius> yes, ive seen some acrylglass "plates", and a led behind them...very nice
[14:43:24] <julius> nuxil, was that for me?
[14:43:47] <nuxil> sorry.. lol
[14:43:49] <nuxil> yeah
[14:43:57] <nuxil> but got distracted
[14:45:35] <nuxil> julius, i meant to ask. does the header ws28 blah.h contain the logic to control the pins on your atmega ? or am i just to stupid to see it in the code you pasted :p
[14:51:50] <cehteh> nuxil: these leds need some protocoll to talk to
[14:52:18] <cehteh> each one has its own microcontroller inside
[14:55:15] <nuxil> oh. interesting
[14:56:11] <julius> nuxil, oh yes...the library does all the nasty timing things and control
[14:56:53] <nuxil> ok
[14:56:53] <julius> the ws2812 / ws2811 is one of the cheaper led controllers. got a constant current source on the chip
[14:57:24] <julius> google ws2812 and cpldcpu, thats his library. he got a blog who goes into the technical details
[14:57:40] <julius> s/who/where he/
[14:58:19] <nuxil> will do.
[14:58:49] <julius> got a 1m led strip here with 60 leds on it, for 22€. you can get them cheaper in china
[15:00:27] <julius> nuxil, ws28 bla.c will contain the protocol
[15:00:33] <nuxil> i think im gonna get some of thouse leds :D
[15:00:52] <nuxil> i'll add them to my shopping list. :p
[15:04:42] <julius> look out, they are sold in 30/60/144 per meter
[15:05:13] <julius> the 60 are spaced like 1,3cm apart. but the 144 almost look like a complete line
[15:05:26] <julius> much more impressive
[15:05:43] <nuxil> i'll keep that in mind
[15:06:27] <cehteh> and note that the more you have the slower you can update them
[15:07:16] <cehteh> they have a slightly stupid protocoll, no addressing you always have to change all leds and latch them
[15:07:56] <LeoNerd> Also the protocol is /rediculously/ timing-critical
[15:08:00] <LeoNerd> You will want to cli()
[15:08:17] <LeoNerd> I keep meaning to make a little tiny85-based offload chip that you'd talk to over SPI or somesuch
[15:12:54] <julius> LeoNerd, looks like you worked with them
[15:13:08] <julius> any way of a good slow fadein/ fadeout?
[15:13:30] <LeoNerd> I'm not sureI understand the question
[15:13:40] <LeoNerd> You can set arbitrary brightness on any of the channels
[15:13:52] <LeoNerd> So... just have some "grand master" scaling factor that you multiply by
[15:14:21] <julius> https://www.mikrocontroller.net/articles/LED-Fading#Das_Demoprogramm this code works great (just ignore the german)
[15:14:24] <julius> for one led
[15:15:01] <julius> a normal led that is, they control the voltage
[15:15:07] <LeoNerd> That's driving a discrete LED using PWM
[15:15:12] <LeoNerd> And no, it doesn't control the voltage.
[15:15:38] <julius> does it not turn on the voltage for some duty cycle?
[15:16:06] <LeoNerd> It's either on or off, yes.. but it's not a variable voltage
[15:16:08] <julius> ok its always 5v, for some time. before it gets cut off
[15:16:19] <LeoNerd> Anyway, that's all entirely unrelated to how you drive a WS2812 chain
[15:16:24] <julius> yes
[15:16:45] <julius> do you use some library for that?
[15:16:48] <LeoNerd> *internally* within the individual LED modules, that happens to be how they control brightness. But you don't need to know or be aware of that externally, to do it
[15:16:51] <LeoNerd> No, I wrote my own
[15:17:03] <julius> asm/c?
[15:17:06] <LeoNerd> But that's because I had some rather crazy exact requirements
[15:17:16] <cehteh> you have this array of rgb values one for each led .. updateing them and then send them down to the leds
[15:17:25] <LeoNerd> Mine is handrolled assembly, because I needed to manage a DMX512 buffer during the timing NOP slots
[15:17:26] <cehteh> rinse repeat
[15:17:41] <LeoNerd> Most people probably don't need that ;)
[15:18:01] <julius> uh, asm...my mother warned me about that ;)
[15:18:02] <cehteh> yeah that protocoll is considerably crazy
[15:19:41] <julius> this code, kinda works for pwm. http://paste.pound-python.org/show/3BhoBfNiH3hPRkVJ8fwI/ but its still to "sluggish/laggy"
[15:19:55] <julius> driving a discrete led with pwm is way smoother
[15:20:08] <cehteh> LeoNerd: i wonder if one could abuse the uart for driving the leds
[15:20:46] <LeoNerd> Possibly
[15:20:54] <LeoNerd> But that wasn't an option for me, as the UART was in use for doing DMX512
[15:21:06] <cehteh> yes
[15:21:16] <Jartza> https://www.youtube.com/watch?v=g0IYBAw0j0Y
[15:21:17] <Jartza> yea
[15:21:23] <Jartza> :D
[15:21:35] <cehteh> julius: http://www.mikrocontroller.net/articles/WS2812_Ansteuerung btw german for you
[15:21:57] <cehteh> Jartza: wow nice
[15:22:28] <Jartza> 256 bytes :)
[15:22:33] <Jartza> 8 color vga from 3 pins
[15:22:44] <cehteh> schematic?
[15:22:59] <Jartza> don't have one yet
[15:24:07] <Jartza> I have a pic of breadboard :)
[15:24:27] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxTFFiMnB1Q0N3X28/view
[15:26:13] <cehteh> julius: try with NUM_LEDS 1 dim only one led, is that smoother?
[15:26:58] <cehteh> and how long does ws2812_setleds take .. i am too lazy to calculate
[15:31:11] <cehteh> julius: eh .. and your 'pwmtable' contains 10 bit values while the LED iirc only talk 8 bit
[15:38:19] <julius> isnt num_leds set to 1?
[15:38:23] <julius> oh, 8 bit
[15:40:01] <julius> cehteh, oh shit, i posted the wrong code
[15:41:17] <julius> cehteh, so sorry, this is the right code: http://paste.pound-python.org/show/Xwvs9NX1okFvoZKVZHj9/
[15:41:50] <julius> the other one makes no sense, since the values for r/g/b only go up to 255. but in the code they go up to 1024
[15:42:14] <cehteh> so whats the problem with the code?
[15:42:22] <julius> it works
[15:42:32] <julius> the fadin is just not very nice to look at
[15:42:55] <cehteh> well you had a nice one before with PWM'ing in 10 bit code?
[15:43:09] <julius> but im still looking at the mikrocontroller link you posted
[15:43:24] <julius> for one discrete led, yes
[15:43:32] <julius> no ws2812
[15:43:45] <cehteh> 8bit esp with this gamma table will have some visible steps
[15:44:51] <cehteh> you have only 32 steps there from dark to full, that isnt much
[15:45:23] <julius> true
[15:48:09] <cehteh> just loop from 0 to 255 and calculate the brightness value for each step (logarithmic)
[15:50:05] <cehteh> if you do that fast enough (updating the leds faster than 30hz) then you may even dither betwenn intermin values
[16:04:57] <julius> im gonna look into that tomorrow, thanks
[22:15:46] <MarkX> hi
[22:16:27] <MarkX> i have a setup like this >> https://youtu.be/3WpRZQ_DTMU?t=41 << where i have a motor connected to a potentiometer. i want to control the motors position using PID closed loop.
[22:17:04] <MarkX> any suggestions (besides the existing arduino PID library) for where i can get a nice library or existing code?
[22:17:22] <MarkX> i found the AVR221 code/pdf. anything else?