Go to Post Let the team grow, let them fail, let them learn and always be ready to lend a helping hand. I think that's the best way to help rookie teams. - Justin Montois [more]
Home
Go Back   Chief Delphi > Other > Math and Science
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-03-2016, 14:05
ArtemusMaximus's Avatar
ArtemusMaximus ArtemusMaximus is offline
Enginerd
FTC #11722
Team Role: Coach
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Canada
Posts: 248
ArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to all
Re: Help needed with algorithm

Quote:
Originally Posted by Roger View Post
If you have a single long strip of 24 individually controllable LED lights (such as this), you are probably asking about a KITT light, or a Battlestar Glactica Cylon light, or (more generically) a Larson scanner, who created the effect, you can do a search for the names and get plenty of solutions. Adafruit has a nice project that explains it. Your LEDs might have different calls to address the bulbs, but the code concept is the same. This is what it sounds like you're trying to do.

If, instead, you have an array of the LEDs, to make a sine wave, that's different. KITT lights where on my to-do list, I just didn't remember what it was called.

If this is your first time working with LED strips, look for examples on how to use that particular type and try them out, making changes to the examples to see how the code operates.

Sometimes (most of the time) if your code "doesn't work" it is just missing one important bit, or your hardware isn't wired correctly. Code examples that work eliminates a lot of errors.
Thank you all for helping me.
Roger, your first half of your post is most helpful. I will poke at them tonight when I get home.

What I have is Adafruit 24-Channel 12-bit PWM LED Driver - SPI Interface - TLC5947 with individual 24 simple LEDs connected.
Sin or Cos wave is not to display a wave on LED matrix, but rather control brightness of the LEDs of a row of LEDs and that where PWM controller interface come in play.

I don't have NeoPixel strip yet. I will order NeoPixel or DotStar when I get my tax refund . Perhaps it is easier for what i am trying to do. We'll see.
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
2017 FTC 11722 (Coach)
2016 FTC 10544 (Coach) Canadian Championship Finalist, Rockwell Collins Innovate Award.
2014 FRC 5064 (Mentor)
Reply With Quote
  #2   Spotlight this post!  
Unread 04-03-2016, 14:32
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 685
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Help needed with algorithm

The older LED Strips work just as well, by the by. It's mostly density and how they are programmed. The one I pointed out just happened to be the high end $. The lower end cost ones work well with the Arduino family without added boards. With 24 you can get by with just power off the Arduino.

Just be extremely careful not to feed the LEDs with more volts than specified!
Reply With Quote
  #3   Spotlight this post!  
Unread 04-03-2016, 14:39
ArtemusMaximus's Avatar
ArtemusMaximus ArtemusMaximus is offline
Enginerd
FTC #11722
Team Role: Coach
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Canada
Posts: 248
ArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to all
Re: Help needed with algorithm

Quote:
Originally Posted by Roger View Post
The older LED Strips work just as well, by the by. It's mostly density and how they are programmed. The one I pointed out just happened to be the high end $. The lower end cost ones work well with the Arduino family without added boards. With 24 you can get by with just power off the Arduino.

Just be extremely careful not to feed the LEDs with more volts than specified!
I did ordered few of these
http://www.ebay.com/itm/371518334189
Hopefully they are programmed same way as Adafrut strips
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
2017 FTC 11722 (Coach)
2016 FTC 10544 (Coach) Canadian Championship Finalist, Rockwell Collins Innovate Award.
2014 FRC 5064 (Mentor)
Reply With Quote
  #4   Spotlight this post!  
Unread 04-03-2016, 20:10
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 685
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Help needed with algorithm

Quote:
Originally Posted by ArtemusMaximus
I did ordered few of these
http://www.ebay.com/itm/371518334189
Hopefully they are programmed same way as Adafrut strips
Those may be more work than I could take. You have to wire them up yourself, but you do get to put them in your own pattern, even arrays or more. (Just have to wire them serially.)

Searching around for ws2812b I found Sparkfun's tutorial on their own WS2812 and their Breakout board, with of course code. Again, start with their libraries and their examples, and get the feel for the method before trying your own.
Reply With Quote
  #5   Spotlight this post!  
Unread 05-03-2016, 04:59
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 685
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Help needed with algorithm

In regards to the code
Code:
  float in, out;

  for (in = 0; in < pi * 2; in = in + pi/500)
  {
    for (int i = 0; i <= 23; i = i + 1)
    {
      if (in > pi * 2 * i / 24 )
      {
        out = ((cos((in - pi) - (i*(pi*2)/24))+1)/2) *4095;
        tlc.setPWM(i, out);
        tlc.write();
      }
    }
  }
I don't think this does what you think it does.

Running it thru a spreadsheet, that if (in > pi * 2 * i / 24 ) only is true for 1 of the 24 i loops, so re-sets the LED 1/24th of the time. Good practice is setting the LED each loop, even if it is off, because the LED will keep the previous number until changed.

When it does set the LED, out is in a range from zero to the low 4000s. If these LEDs are typical, the range is zero (off) to 255 (full on). Plus if they are color, you have to set each Red-Green-Blue to a level -- typically something like

tlc.setPWM( i, color( outR,outG,outB ) );

Find the command in the examples; I'm just guessing what it is.
Reply With Quote
  #6   Spotlight this post!  
Unread 09-03-2016, 23:57
ArtemusMaximus's Avatar
ArtemusMaximus ArtemusMaximus is offline
Enginerd
FTC #11722
Team Role: Coach
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Canada
Posts: 248
ArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to all
Re: Help needed with algorithm

Quote:
Originally Posted by Roger View Post
Those may be more work than I could take. You have to wire them up yourself, but you do get to put them in your own pattern, even arrays or more. (Just have to wire them serially.)

Searching around for ws2812b I found Sparkfun's tutorial on their own WS2812 and their Breakout board, with of course code. Again, start with their libraries and their examples, and get the feel for the method before trying your own.
Thank you Roger, that is useful info I didn't have. I hope LEDs will arrive soon for me to try them.
I am getting tired of TLC5947, as it continues to produce some artifacts that are not in the code. I tried 3 simple loops, 1st 100%, 2nd 50% and 3rd 0% brightness. It all works as expected but at the end of second loop all LEDs blink.
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
2017 FTC 11722 (Coach)
2016 FTC 10544 (Coach) Canadian Championship Finalist, Rockwell Collins Innovate Award.
2014 FRC 5064 (Mentor)
Reply With Quote
  #7   Spotlight this post!  
Unread 17-03-2016, 01:42
ArtemusMaximus's Avatar
ArtemusMaximus ArtemusMaximus is offline
Enginerd
FTC #11722
Team Role: Coach
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Canada
Posts: 248
ArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to allArtemusMaximus is a name known to all
Re: Help needed with algorithm

I am still waiting for ws2812b LEDs, but after a bit of a break and then practicing on direct PWM pins, I finally cleaned up logic enough for it to do almost what I want. Here is what I got so far:

PHP Code:
void loop() {
  
float inouttemp;
  
int i;
  for (
in = -piin pi 24in in pi 50)
  {
    for (
0<= 231)
    {
      
temp pi LED_Group i;
      if (
in >= -pi temp && in <= pi temp )
      {
        
out cos(in temp) * 2048 2047;
        
tlc.setPWM(iout);
        
tlc.write();
      }
    }
  }

LED_Group is for controlling how many LED to include in a wave
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
2017 FTC 11722 (Coach)
2016 FTC 10544 (Coach) Canadian Championship Finalist, Rockwell Collins Innovate Award.
2014 FRC 5064 (Mentor)
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:38.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi