Show Posts
Pages: 1 [2] 3
16  Using Arduino / Programming Questions / Re: Is there an easier way to do all of this? on: September 11, 2012, 01:02:18 pm
http://pastebin.com/Fpy9ZTdj

I have updated the code to remove the repitition, still haven't finished saving, or all of the modes. I will be goign through and adding in the suggestions I have gotten later this evening or tomorrow(back and forth between this and the android app).
Quote
Maybe you could post the design files if they are in a format some of us have.
I have Eagle, and gerbers, but these are not images, my server has no domain, and it would be an abuse of my corporate hosting account to put anything personal up. How do you suggest sharing my files?
17  Using Arduino / Programming Questions / Re: Is there an easier way to do all of this? on: September 10, 2012, 07:04:20 pm
Memory is not the issue, speed is. Without missing any incoming serial data, I want the loop to run as many times per second as possible, so that if the audio mode is in use, no audio events will be missed. That is to say, If the user has "bass" selected for response, I don't want the code to miss an incoming peak corresponding to "bass" resulting in a delayed or missing "pulse" to the music. The simple setting for just choosing a color to display, won't have this problem, but the "color organ" functionality is time sensitive in relation to whatever happens to be playing at the moment.
Quote
and can you please unindent your { and } lines one level?
No, I'm so used to HTML that this is the structure I am used to seeing, and makes it easier for me to read my own code... Even my java looks like that...
Quote
Oh, and you're going to stop using String, aren't you?
I don't have to take serial data as String?
Quote
Here it would be prudent to do a bounds check before appending to the array, just in case.
From here on out, it is obvious to me that you are a much more advanced C++ programmer than myself. I have no idea what a bounds check is...
Quote
Also, wouldn't it be best to reset serialIn to zero and re-terminate the buffer every time you get a StartOfPacket character?
Yes, yes it would. Thank you!
Quote
I'd parse each message directly into an int array instead of building arrays of char * and cut out all that horribly repetitive chanxsort() stuff. If you parse and validate the channel field first, you can chuck the remaining fields directly into the relevant chanx array. I'd much prefer to see those stored in an array of arrays. In general, when you find yourself appending numbers to variable names, you should be looking for ways to put them in an array and consolidate the processing into common code.
Greek.
Quote
In any case, do you really need map() here? All you need is rojo = 4095 - rojo.
YES! THANK YOU! I never thought of doing it that way in all the nights of lying in bed, staring at the ceiling, coding in my head and wondering about another way to invert those values...
Quote
This code above that seems to be defining fading implies some code to detect an end time which will not deal correctly with timer overflow. Maybe you don't expect this to be kept powered up for the month or so it will take for that to happen, and I don't even know whether tlc_addFade() is your code, but make a mental note that this is not a good way to specify a time for things that are intended to happen in the future.
The original purpose of this lighting controller was a car underglow controller, it has grown to much more than that now, and so would need to be reset because of overflow when used indoors. Most of my target market is kids with civics, and they won't idle for a month... So battery or gas, the boards will get reset. Tlc_addFade is a part of the TLC5940 Library on google code and is the recommended method of using a TLC5940 with an arduino. Maybe something else you guys can help with. I passed DRC with my boards I sent to Seeedstudio's fusion PCB service, but after 10 days the sent me today, "Sorry, the lines are too clutter, could you please correct it and resend to pcb@seeedstudio.com ." They included the top layers of my board as an image.
18  Using Arduino / Programming Questions / Re: Is there an easier way to do all of this? on: September 10, 2012, 04:46:13 pm
Okay using a matrix (that is what we are talking about here? or is a vector a different kind of 2d array?), I see how to use it as a table and store the data for each channel in it, modifying the address based on channel. So from there, reading the data off to output it, I don't see a way to replace doChan<NUM>() with doChan(), the way I will sortData(), but then again shortening sortData() to a single function will slim my code a bit. The biggest thing I am worried about, and why I am looking to shorten the code, is speed. I don't care if my code is ugly (just being honest!) But some songs are 200bpm! In audio mode, I figure if I can get the whole loop to run greater than 1000 times/sec, I will never miss an audio pulse. I realize a serial counter would slow down that figure, and not give me an accurate rate, but as long as no input, or ouput is missed, I'll be happy. Right now seeedstudio is throwing a fit about my boards, so this whole thing (all of my spare time this past 14 months) may be for nothing...

PS. I asked in the comments in the code, I read that while() can freeze/slow the TLC5940 library somewhere, should I read Uart with If()?

Is this what I am looking to do, and have "chan' specify the row?::

// Defining Storage and Manipulation here (addresses)
//    Column   row
//           red      green           blue           mode           audc           audb           auds
// chan0   0,0      0,1      0,2      0,3      0,4      0,5      0,6
// chan1   1,0      1,1      1,2      1,3      1,4      1,5      1,6
// chan2   2,0      2,1      2,2      2,3      2,4      2,5      2,6
// chan3   3,0      3,1      3,2      3,3      3,4      3,5      3,6
// chan4   4,0      4,1      4,2      4,3      4,4      4,5      4,6

out to:
red value (0-4095)
green value (0-4095)
blue value (0-4095)
mode (0-?)
audio channel (0-1[L-R])
audio band (0-5)
audio sensitivity (0-31)
19  Using Arduino / Programming Questions / Re: Is there an easier way to do all of this? on: September 10, 2012, 03:25:08 pm
Sorry, my arrayDimensionCount was incremented too far smiley-grin. That would be a 2d array. Still perhaps some coding examples?
20  Using Arduino / Programming Questions / Re: Is there an easier way to do all of this? on: September 10, 2012, 03:12:22 pm
That would be a 3d array. I will be honest and say that this is not anything that I have any experience with.
21  Using Arduino / Programming Questions / Re: Is there an easier way to do all of this? on: September 10, 2012, 02:59:53 pm
I updated my first link with commented code. My packet structure and modes are at the bottom. Yes the only differences in the "Sorts" and "do's" are the arrays that they reference. How could I use a single two-dimensional array, when the data will differ between the channels? I also don't understand what you meant by tables. Examples would be simply amazing...
22  Using Arduino / Programming Questions / Re: Is there an easier way to do all of this? on: September 10, 2012, 02:38:29 pm
I assumed that in any way that I could reduce the repetitive sortChan() I could also apply to doChan(). If you would like me to apply comments to the rest of my code I shall. One thing I forgot to mention is that each "channel" is three TLC5940 outputs, grouped together to ouput Green, Red, and Blue. Each RGB Channel is (intended to be) independently controllable from each of the others. This is why they are separated the way that they are now.
23  Using Arduino / Programming Questions / Is there an easier way to do all of this? on: September 10, 2012, 02:21:09 pm
I am attaching a pastebin link to an ALMOST complete program for boards I am making. The question is, are the repetitive blocks the best way to do this, or is my brain broken since I programmed TI-83's in High School? The code interfaces a Teensyduino, MSGEQ7, TLC5940, and Mosfets to RGB LED Strips. I realize that I have not completed the save function and some of the modes are missing (incomplete, not hidden). The serial data to control the boards comes either from an android phone over bluetooth, or a physical controller that I will worry about later. If my code is childish and stupid, let me know, I can take it. Just no trolling please.

http://pastebin.com/TtZ4RiRY
24  Using Arduino / Project Guidance / Re: Conflicting TLC5940 Information on: April 14, 2012, 05:29:49 pm
Thank you, so, If I use the software in the IDE, I use it's pin descriptions. Could you please look at my other forum post, perhaps you could help there too?
25  Using Arduino / Project Guidance / Re: Conflicting TLC5940 Information on: April 14, 2012, 04:24:43 pm
http://bildr.org/2012/03/servos-tlc5940-arduino/
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1204292903
http://code.google.com/p/tlc5940arduino/wiki/ArduinoDiecimilaHardwareSetup

Unless I'm just stupid, which I may very well be, there appear to be different pins used for control between these pages. I am attempting to design a board in Eagle using the TLC5940 a Serial Bluetooth module and an MSGEQ7, this will be a shield...
26  Using Arduino / General Electronics / Re: Single PWM Trigger for Common Anode, and Common Cathode LED Strips on: April 14, 2012, 04:21:00 pm
Before I run a batch of bad boards, both the N and P channel mosfets from what I am reading are pin compatible with the IRF540 (as far as eagle is concerned). If not could someone help with eagle parts for the above schematic?
27  Using Arduino / Project Guidance / Conflicting TLC5940 Information on: April 13, 2012, 05:23:38 pm
I am trying to use the tlc5940, but I get many different suggestions for how to connect it to the arduino when I google. Could someone list proper Arduino - TLC pins please?
28  Using Arduino / Project Guidance / Re: Two process intensive Serial devices, ruh roh! on: March 30, 2012, 08:46:44 pm
You sir, are a genius! I on the other hand, open foot-insert mouth. I read "On the left-hand side of the board all serial inputs are broken out" on the sparkfun product page for the breakout, and assumed they UART, not even considering SPI... Thank you!
29  Using Arduino / Project Guidance / Two process intensive Serial devices, ruh roh! on: March 30, 2012, 05:59:14 pm
I desperately want to use a bluetooth module, and a TLC5940 together in a project. The TLC5940 will be very, very busy, so I know that it absolutely cannot use NewSoftSerial, but Bluetooth should be kind of periodic. Can I reliably use a bluetooth module with Software Serial?
30  Using Arduino / General Electronics / Re: Single PWM Trigger for Common Anode, and Common Cathode LED Strips on: March 09, 2012, 02:33:24 pm
Would you do me a huge favor and draw that again, but using mosfets, as I know I will be above 500ma? I will do it myself, if you can explain to me which goes where... I am willing to do the work and learn, I just need some help.
Pages: 1 [2] 3