Show Posts
Pages: [1] 2 3 4
1  Using Arduino / General Electronics / Re: power supply for a ws2811 on: March 18, 2014, 11:07:19 am
I did a bunch of testing recently with 120 LEDs (5V) being powered off an Arduino, and I just made my code limit how many could actually be on at any given time to prevent doing damage.

Until a cosmic ray causes the Arduino to crash then they all turn on at simultaneously and burn the house down...

(nb. When doing this be sure to add a fuse. They cost 20 cents...)


...that is a most excellent suggestion. I need to do that.

And now I'm going to use "cosmic rays" the next time I have a code bug.
2  Using Arduino / Programming Questions / Re: need help repeating the same code over and over on: March 18, 2014, 11:04:33 am
I've not come across this TVout before. Can it be used for 50Hz PAL (not NTSC) TVs?

It claims to support PAL:

https://code.google.com/p/arduino-tvout/
3  Using Arduino / Networking, Protocols, and Devices / Re: arduino Server with 2 clients + Ethernet Shield. on: March 18, 2014, 11:03:03 am
Quote
There is a bug in the Ethernet library that does not track incoming socket connections. If you try to write a server that listens for more than one connection, all incoming traffic goes to the first connection
That is not true. The ethernet shield and library track incoming connections great.

It is possible. I have tested my server code with three clients and couldn't crash it. The server code only services one connection at a time, so you must keep the client requests and the server responses short.

edit: If you are talking about persistent connections of two clients simultaneously, that is more difficult, but I tested that scenario and it works ok. But in that case, I gave up on the persistent tcp connections and went with udp.


I am glad this has been fixed. It was not possible in the version I worked with a year ago. The code never stored the port, so any packed coming in to that IP would go to whatever connection was there. I wrote simple test programs working through the process and was able to make modifications to the library so it works and could listen to multiple connections at the same time and interact with them.

What version are you running? I probably should check the 1.5 beta stuff because it was a pretty big oversight/bug.
4  Using Arduino / LEDs and Multiplexing / Re: problem with adafruit_neopixel library on: March 15, 2014, 11:53:28 pm
It looks like your library is just not installed. Check your libraries directory and verify you see the folder there:

alsmb:libraries allenh$ ls -l
total 24
drwxr-xr-x   8 allenh  staff   272 Mar 13 19:48 Adafruit_NeoPixel
drwxr-xr-x  11 allenh  staff   374 Feb 11 22:20 TVout
drwxr-xr-x  12 allenh  staff   408 Feb  9 00:26 TVoutfonts
drwxr-xr-x   4 allenh  staff   136 Feb  9 00:26 pollserial
-rw-r--r--   1 allenh  staff    83 Feb  9 00:25 readme.txt


5  Using Arduino / Project Guidance / Re: ws2811 connected to arduino on: March 15, 2014, 11:51:26 pm
ey there!

I have just bought 5mts of ws2811 (http://www.ebay.com/itm/281261795832?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649)

And I am wondering, is there any chance to connect and feed this strip straight from Arduino?

Yes, you can, as long as you never have more than two dozen or so LEDs on at full WHITE at any given time. The power needs are based on the LEDs. The max power required would be every LED on at full WHITE (so the RED, GREEN, and BLUE LED would all be on). I modified my code to disallow setting more LEDs than the power I have available through an Arduino. It means I can't do everything, but it was fine for doing simple testing without an external power supply.

Also, if you are using the Adafruit NeoPixel library, you can use setBrightness(2) to make the LEDs be very dim -- enough to see and test, but take a fraction of the power.

It's best to have a big power supply, but if you can specifically control the situation, you can power off the Arduino just fine.

Look at any cheap lamp or light -- they often say "max 30w bulb" or similar. Sure, you can screw in a 120 watt bulb but you might melt the cord... That's the same situation here. As long as you don't draw more than what the power supply (or wires!) can handle, it's fine. Electricity is cool.
6  Using Arduino / General Electronics / Re: power supply for a ws2811 on: March 15, 2014, 11:48:11 pm
FUNGUS: your advice was the most important so far: THE GROUND OF THE LED STRIP HAS TO BE CONNECTED TO  THE GROUND OF THE ARDUINO BOARD. this is the reason why it didn´t work and it works now.

CONCLUSIONS: the strip works with 12V, and I am using a 1200mA power supply so far, which seems to be enough so far. I´ve tried it with the strandtest.ino sketch, the RGBCalibrate from the "fastled" library, and my own sketch.

FUNGUS, you are right again: the strip is not fully addressable. "Color is only controllable in groups of three LEDs".

Some good stuff here.

Indeed, there are many 12V strips being used for home Christmas light displays (a friend of mine has thousands of them on his house each season).

For future searches, you can hook up a ton of lights and power them with a small power supply if you limit how many are on at a time. Hook up 300 lights and make one LED run back and forth Cylon-style and that works fine... I did a bunch of testing recently with 120 LEDs (5V) being powered off an Arduino, and I just made my code limit how many could actually be on at any given time to prevent doing damage.
7  Using Arduino / LEDs and Multiplexing / Re: Cant get WS2811 RGB strip working with arduino on: March 15, 2014, 11:42:53 pm
One more quick question: Do you know how to make it less brighter? I am going to make a costume with this strip, however I got my eyes burned after looking on this strip for a moment. I switched to 3.7v Li-Po battery, but the brightness remains the same. How can I cut down brightness?

The Adafruit NeoPixel library supports setBrightness(). For my scrolling LED sign project, I use it like this:

strip.setBrightness(2);

2 is a very dim light level. Read the notes in the docs on what this actually does. If you set it up front, then everything is fine. If you try to change it to pixels already set, weird things can happen.
8  Using Arduino / LEDs and Multiplexing / Re: Simple WS2811 scrolling message sign on: March 15, 2014, 11:38:46 pm
I have posted an article about my code here:

http://subethasoftware.com/2014/03/15/simple-scrolling-led-sign-for-neopixel-ws2811-or-lpn8806/

And the source code has been posted to GitHub:

https://github.com/allenhuffman/LEDSign

I have never worked with LEDs before like this, so I am sure I will have many improvements as I get time to work on it. Around 1990, I wrote and sold a banner printing program for the old Radio Shack TRS-80 Color Computer 3. Setting dots on an LED strip was very similar to taking the binary fonts and printing them out on a printer. I plan to dig out all my old 8-bit fonts and incorporate them in to this scrolling sign program.
9  Using Arduino / LEDs and Multiplexing / Simple WS2811 scrolling message sign on: March 13, 2014, 09:20:07 pm
I have two 1m WS2811 LED strips (60 LEDs each) and plan to get a few more to make a scrolling LED message sign. While I wait for the next few samples to arrive from China, I decided to do what I could with two strips and spiral them together and make a micro circular scrolling sign (20x6, circular):

https://www.youtube.com/watch?v=JL1yY7nMaTo

To do this quickly, I used the font6x8[] structure from the TVout library. I will clean up the code a bit and post it here, in case anyone else has a few of these strips laying around and is bored.
10  Using Arduino / Programming Questions / Re: subroutine with struct pointer on: March 05, 2014, 09:57:20 am
And watch out for one of the many IDE "features" that sometimes causes weird errors when using structures. The official Arduino page mentions this:

http://playground.arduino.cc/Code/Struct#FAQ

In several cases, my perfectly working code suddenly stopped compiling due to the behind-the-scenes preprocessing the IDE does to create prototypes and other things for you. The workaround is to put the structure definition in its own .h file and include that at the top of your sketch.

Also, if you want to have an array of strings or a structure that contains strings that are stored in PROGMEM, you have to do some different things to make that work versus standard C (this is due to the Harvard architecture of the Arduino CPU's memory layout).

If something that "should work" doesn't seem to, Google around a bit. So far, every roadblock I have ran in to has been documented somewhere with nice workarounds and examples. I've been trying to do the same at my site when I run in to preprocessor issues.
11  Using Arduino / Programming Questions / Re: need help repeating the same code over and over on: March 05, 2014, 09:38:20 am
I just started playing with TVout a few weeks ago, and one of the first things I did was a simple ball demo. (I wrote up my experiments here: http://subethasoftware.com/2014/02/09/arduino-pac-man-part-2-it-lives/) I will post the source here in case it helps. For moving a pixel, there are a few basic ways. Here's one using a for loop to draw the pixel across the screen:

Code:
uint8_t x; // X position of pixel

for (x=0; x<TV.vres(); x++)
{
  TV.set_pixel(x, 0, WHITE);
  TV.delay_frame(30); // delay 30 frames
}

That would make 'x' go from 0 to whatever the vertical resolution is (120 by default).

You could also take a more brute-force approach and manually increment the x coordinate each time in a loop:

Code:
uint8_t x;

x = 0;
while(x<TV.vres())
{
  TV.set_pixel(x, 0, WHITE);
  TV.delay_frame(30); // delay 30 frames
  x = x +1;
}

For bouncing, if you track the x and y of the object, you can use a movement-x and movement-y variable that can either be +1 (when moving right or down) or -1 (when moving left or up) and do something like this:

Code:
uint8_t x, y; // position of object
int8_t mx, my; // movement offset of object

// Start out at top left of screen
x = 0;
y = 0;
// Start out moving right (x+1) and down (y+1)
mx = 1;
my = 1;

// Do this forever...
while(1)
{
  // Draw pixel
  TV.set_pixel(x, y, WHITE);
  TV.delay_frame(30);
  // Erase pixel
  TV.set_pixel(x, y, BLACK);

  // Do movement.
  x = x + mx;
  // If we hit the left or right of the screen, invert the movement.
  if ( (x<=0) || (x>=TV.vres()-1) ) mx = -xm;

  y = y + my;
  if ( (y<=0) || (y>=TV.hres()-1) ) my = -my;
}

...something like that. The >TV.Xres() may be off by one.

Here is the sample I wrote to move a circle around the screen:

Code:
#include <TVout.h>
 
TVout TV;
 
void setup()
{
  TV.begin(NTSC, 120, 96);
 
  TV.clear_screen();
}
 
void loop()
{
  uint8_t  x, y;    // X and Y position of ball
  int8_t   xm, ym;  // X and Y movement of ball
   
  // Center of screen
  x = TV.hres()/2;
  y = TV.vres()/2;
   
  // Start moving to the right, and down.
  xm = 1;
  ym = 1;
   
  // We will do our own control loop here.
  while(1)
  {
    // Wait for end of screen to be drawn.
    TV.delay_frame(1);
     
    // Erase circle
    TV.draw_circle(x, y, 4, BLACK);
 
    x = x + xm;
    if (x<4 || x>=TV.hres()-4) xm = -xm;
    y = y + ym;
    if (y<4 || y>=TV.vres()-4) ym = -ym;
     
    TV.draw_circle(x, y, 4, WHITE);
  }
}

And here is a modified version that allows bouncing multiple balls... I guess this was my "hello, world" program for TVout:

Code:
#include <TVout.h>
 
TVout TV;
 
#define BALLS    10 // Number of balls to bounce.
#define BALLSIZE 4  // Size of balls.
 
void setup()
{
  TV.begin(NTSC, 120, 96);
 
  TV.clear_screen();
}
 
void loop()
{
  uint8_t  x[BALLS], y[BALLS];    // X and Y position of ball
  int8_t   xm[BALLS], ym[BALLS];  // X and Y movement of ball
  uint8_t  i;       // counter
   
  // Initialize balls.
  for (i=0; i<BALLS; i++)
  {
    // Random position
    x[i] = random(BALLSIZE, TV.hres()-BALLSIZE-1);
    y[i] = random(BALLSIZE, TV.vres()-BALLSIZE-1);
   
    // Start moving to the right, and down.
    xm[i] = 1;
    ym[i] = 1;
  }
   
  // We will do our own control loop here.
  while(1)
  {
    // Wait for end of screen to be drawn.
    TV.delay_frame(1);
     
    for (i=0; i<BALLS; i++)
    {
      // Erase balls.
      TV.draw_circle(x[i], y[i], BALLSIZE, BLACK);
     
      x[i] = x[i] + xm[i];
      if (x[i]<=BALLSIZE || x[i]>TV.hres()-BALLSIZE-1) xm[i] = -xm[i];
       
      y[i] = y[i] + ym[i];
      if (y[i]<=BALLSIZE || y[i]>=TV.vres()-BALLSIZE-1) ym[i] = -ym[i];
       
      TV.draw_circle(x[i], y[i], BALLSIZE, WHITE);
    }
  }
}
12  Using Arduino / Project Guidance / Re: Trying to get Leonardo and iPad talking. on: March 05, 2014, 09:18:11 am
I have posted my Teensy 2.0 (easy to adapt for Leonardo) code that reads digital inputs and emits USB keyboard keys in iCade format:

https://github.com/allenhuffman/iCadeTeensy

I also posted various other work-in-progress experiments, including one that uses a Circuits@Home USB Host shield to read from a standard Playstation style USB arcade joystick and then translate the keys to iCade, allowing me to use my cheap fighter stick with any iCade game on the iPad. Maybe it will be of use to someone. Eventually I will have time to go in and clean up the code and finish it. I have learned much since I started that project.
13  Using Arduino / Networking, Protocols, and Devices / A real Telnet server for Arduino + Ethernet Shield on: March 03, 2014, 03:49:30 pm
Last year, I started looking in to Telnet as a learning exercise. I ended up implementing a full Telnet server for Arduino that actually supported the protocol. Most examples just open a socket and listen, and will get bits of garbage data when command packets come in. My work-in-progress server handles these, and supports many of them (echo, are you there, etc.) and has hooks for where anything else needed could be added.

It has an extensive debug mode that will display all the Telnet protocol stuff in text format -- a fun leaning tool.

I posted this all on my website...

http://subethasoftware.com/2013/04/15/sub-etha-softwares-arduino-telnet-server/

...but since I have not had time to get back to this experiment, I decided to get the source code posted to GitHub so others could mess with it without having to copy/paste it from my website:

https://github.com/allenhuffman/sesTelnetServer

NOTE: This server supports multiple incoming connections (not at the same time; I have that worked out, but not posted) if you modify the Ethernet library to work around a bug:

http://subethasoftware.com/2013/04/09/arduino-ethernet-and-multiple-socket-server-connections/
14  Using Arduino / Networking, Protocols, and Devices / Re: arduino Server with 2 clients + Ethernet Shield. on: March 03, 2014, 03:44:12 pm
There is a bug in the Ethernet library that does not track incoming socket connections. If you try to write a server that listens for more than one connection, all incoming traffic goes to the first connection. I ran in to this last year and hacked the library so I could have multiple connections:

http://subethasoftware.com/2013/04/09/arduino-ethernet-and-multiple-socket-server-connections/

I have not had time to polish my hack, but this may explain the problem so you can work around the limitation.

15  Community / Exhibition / Gallery / Re: The DHG - Dynamic Hi resolution Graphics driver on: February 14, 2014, 11:15:48 am
IWould it be possible for the user to only allocate memory for tiles that are needed? Something like this:

The code would define the bitmap data for the sprites...

// 8x8 spaceship... A box because I am lazy.
#define SPACEBOXW 8
#define SPACEBOXW 8
PROGMEM const uint8_t spacebox[] = {
  0b11111111,
  0b10000001,
  0b10000001,
  0b10000001,
  0b10000001,
  0b10000001,
  0b10000001,
  0b11111111
};

Then, assuming doing PROGMEM reads might be too slow for video, RAM would be allocated for that tile/sprite. Maybe a structure like this that could contain info on where the tile is supposed to be drawn, and information about the tile size:

typedef struct {
  uint8_t x, y;
  uint8_t w, h;
  uint8_t *dataPtr;
} TILE;

Then something like this (maybe hidden in a function to make it easier):

TILE spacebox;
// RAM to hold the copy of the sprite data
uint8_t spaceboxRam[sizeof(spacebox)];
// Copy PROGMEM data to RAM buffer
memcpy_PF(spaceboxRam, spacebox, sizeof(spacebox));
// Update tile object to know where RAM buffer is.
spacebox.dataPtr = spaceBoxRam;
spacebox.x = 255; // Maybe 255 means "do not display"
spacebox.y = 255;

Then some interface to add/remove it to the stuff the video engine is drawing on the screen.

addTile(&spacebox);

Then in the code loop, the engine would go through all the tiles that have been added and display them. The use would do stuff to move them just by modifying the object:

spacebox.x = 50;
spacebox.y = 50;

For a game, such as Space Invaders, where there are five rows of eleven types of aliens, there would be RAM for five tiles buffers allocated, and there would be 55 (11x5) TILE structures to track each invader.

For animation, the tile would just have the pointer changed to point to the next frame. (A clever function could be written to let the user pass in an array of frames and have it actually handle the animation directly.)

spacebox.dataPtr = spaceboxRam2;

(I would be using an array of frames, most likely, and be setting them to something like spaceboxRam[framNum]);

NOTE: This would have to be done between interrupts so it didn't mess anything up, I suspect?

Just some quick thoughts. Displaying full screens of text this would wouldn't necessarily be practical, but it might be great for games. I have about 220 bytes free for my Pac-Man demo, using the low resolution of TVout. It would be fun to see what could be done in an environment with more RAM to play with, and higher resolution to boot!
Pages: [1] 2 3 4