with battery and with out battery I get different colours

ok So I have resolved my issue with the WS2801's not lighting up but now I have a problem with the battery. I want my project to be portable so I can programme the arduino mega 2560 on the laptop then take it to the position and take my lightpainting shot with the board and LED powered by battery. but it seems that the light sequence works perfectly when I have the board plugged into the laptop via usb. But as soon as I disconnect the USB and connect the battery and switch the pack on the lights just go all red with this code below

//
//LEDType = WS2801
//HardwareSPI = True
//LCDDisplay = False
//DualStrip =False
//StripControl1 = 1
//StripControl2 = 1
//bitmapWidth = 16
//WandLEDs = 12
//delayOffset = 0
//numOffset = 0
//sdiPin1 = 51
//sdiPin2 = 51
//clkPin1 = 52
//clkPin2 = 1
//StartDelay = 0
//EndDelay = 0
//StrobeOn = 419
//StrobeOff = 0
// Lightwand code generated by Phil Wright
#include <avr/pgmspace.h>
#include <SPI.h>
#define GET_FAR_ADDRESS(var) \
({ \
uint_farptr_t tmp; \
__asm__ __volatile__( \
"ldi    %A0, lo8(%1)"  "\n\t"    \
"ldi    %B0, hi8(%1)"  "\n\t"    \
"ldi    %C0, hh8(%1)"  "\n\t"    \
"clr    %D0"  "\n\t"    \
: \
"=d" (tmp) \
: \
"p"  (&(var)) \
);   \
tmp; \
})
#define STRIP_LENGTH 12 // Total LEDs on this wand
#define STRIP_WIDTH 16 // Width on this strip
#if defined(ARDUINO) && ARDUINO >= 100
#else
const uint8_t SS = 50;  // Move the SS pin out of the way of the LCD Display (if installed)
 #endif
int StripControl1 = 1; //Control Wire for Dual Strip no. 1
long buffer[STRIP_LENGTH];
int tmpbuffer[4];
long lCntr[1];
boolean firstloop=true;
static const uint8_t bitmap_0 [] PROGMEM={0x02,0xFE,0x1A,0x01,0x01,0xFF,0x20,0x00,0x01,0xFE,0x20,0x02,0x01,0xFF,0x1D,0x03,0x01,0xFD,0x15,0x03,0x01,0xF7,0x0F,0x03,0x01,0xE9,0x09,0x03,0x01,0xD9,0x05,0x03,0x01,0xC9,0x03,0x03,0x01,0xB1,0x01,0x03,0x01,0x95,0x01,0x03,
0x02,0xFE,0x28,0x00,0x01,0xFE,0x33,0x03,0x01,0xFF,0x2F,0x03,0x01,0xFF,0x26,0x03,0x01,0xFF,0x1C,0x03,0x01,0xFF,0x14,0x02,0x01,0xFF,0x0D,0x02,0x01,0xF7,0x06,0x02,0x01,0xE5,0x02,0x03,0x01,0xCA,0x00,0x03,0x01,0xAF,0x00,0x03,
0x02,0xFC,0x38,0x00,0x01,0xFE,0x40,0x03,0x01,0xFA,0x3D,0x02,0x01,0xFA,0x33,0x03,0x01,0xFA,0x29,0x02,0x01,0xFD,0x1C,0x03,0x01,0xFA,0x10,0x03,0x01,0xF3,0x0A,0x03,0x01,0xE3,0x07,0x03,0x01,0xCD,0x03,0x03,0x01,0xB6,0x00,0x03,
0x02,0xFA,0x48,0x02,0x01,0xFE,0x53,0x04,0x01,0xF8,0x4C,0x04,0x01,0xFA,0x3F,0x03,0x01,0xFA,0x34,0x03,0x01,0xFA,0x26,0x03,0x01,0xFD,0x18,0x03,0x01,0xFB,0x10,0x03,0x01,0xF1,0x0A,0x03,0x01,0xDB,0x07,0x03,0x01,0xC3,0x03,0x03,
0x02,0xFC,0x4A,0x00,0x01,0xFE,0x55,0x02,0x01,0xFA,0x4C,0x02,0x01,0xFA,0x47,0x02,0x01,0xFD,0x3E,0x00,0x01,0xFD,0x33,0x03,0x01,0xFA,0x20,0x03,0x01,0xFC,0x19,0x03,0x01,0xF9,0x10,0x03,0x01,0xE4,0x08,0x03,0x01,0xCC,0x05,0x03,
0x02,0xFC,0x4E,0x00,0x01,0xFE,0x58,0x00,0x01,0xFD,0x50,0x00,0x01,0xFD,0x4D,0x03,0x01,0xFD,0x46,0x03,0x01,0xFD,0x3C,0x00,0x01,0xFD,0x2A,0x03,0x01,0xFC,0x1E,0x03,0x01,0xFD,0x14,0x03,0x01,0xEE,0x0D,0x03,0x01,0xD6,0x07,0x03,
0x02,0xFC,0x54,0x00,0x01,0xFE,0x61,0x00,0x01,0xFD,0x57,0x00,0x01,0xFD,0x53,0x00,0x01,0xFD,0x4D,0x00,0x01,0xFD,0x45,0x00,0x01,0xFD,0x35,0x03,0x01,0xFD,0x27,0x03,0x01,0xFC,0x1B,0x03,0x01,0xF7,0x11,0x03,0x01,0xDE,0x09,0x03,
0x02,0xFC,0x5A,0x00,0x01,0xFE,0x66,0x03,0x01,0xFD,0x5D,0x03,0x01,0xFD,0x57,0x00,0x01,0xFD,0x51,0x00,0x01,0xFD,0x48,0x03,0x01,0xFD,0x38,0x03,0x01,0xFD,0x2A,0x03,0x01,0xFC,0x1E,0x03,0x01,0xFB,0x13,0x03,0x01,0xE7,0x0B,0x03,
0x02,0xFC,0x60,0x00,0x01,0xFE,0x6D,0x03,0x01,0xFC,0x60,0x03,0x01,0xFD,0x5D,0x03,0x01,0xFD,0x53,0x00,0x01,0xFD,0x4A,0x03,0x01,0xFD,0x3F,0x03,0x01,0xFD,0x31,0x03,0x01,0xFD,0x23,0x03,0x01,0xFD,0x14,0x03,0x01,0xEB,0x0A,0x03,
0x02,0xFC,0x64,0x00,0x01,0xFE,0x71,0x03,0x01,0xFD,0x67,0x03,0x01,0xFD,0x61,0x02,0x01,0xFD,0x55,0x00,0x01,0xFD,0x4C,0x00,0x01,0xFD,0x40,0x03,0x01,0xFD,0x32,0x00,0x01,0xFD,0x24,0x03,0x01,0xFC,0x16,0x03,0x01,0xED,0x0D,0x03,
0x02,0xFC,0x66,0x00,0x01,0xFE,0x70,0x02,0x01,0xFD,0x68,0x03,0x01,0xFD,0x63,0x02,0x01,0xFD,0x57,0x00,0x01,0xFD,0x4E,0x00,0x01,0xFD,0x43,0x03,0x01,0xFD,0x34,0x00,0x01,0xFD,0x29,0x03,0x01,0xFC,0x19,0x03,0x01,0xEC,0x0D,0x03,
0x02,0xFC,0x66,0x00,0x01,0xFE,0x72,0x03,0x01,0xFD,0x6A,0x03,0x01,0xFD,0x62,0x02,0x01,0xFD,0x59,0x03,0x01,0xFD,0x51,0x03,0x01,0xFD,0x42,0x00,0x01,0xFD,0x37,0x00,0x01,0xFD,0x29,0x03,0x01,0xFC,0x16,0x03,0x01,0xEC,0x0D,0x03,
0x02,0xFC,0x66,0x00,0x01,0xFE,0x75,0x03,0x01,0xFD,0x6A,0x02,0x01,0xFD,0x60,0x02,0x01,0xFA,0x5B,0x02,0x01,0xFA,0x50,0x03,0x01,0xFD,0x43,0x00,0x01,0xFD,0x34,0x00,0x01,0xFC,0x27,0x03,0x01,0xFD,0x16,0x03,0x01,0xEB,0x0A,0x03,
0x02,0xFC,0x64,0x00,0x01,0xFE,0x71,0x03,0x01,0xFD,0x67,0x03,0x01,0xFD,0x5F,0x03,0x01,0xFA,0x56,0x02,0x01,0xFA,0x4E,0x02,0x01,0xFD,0x40,0x03,0x01,0xFD,0x30,0x03,0x01,0xFC,0x22,0x03,0x01,0xFA,0x15,0x03,0x01,0xE4,0x0B,0x03,
0x02,0xFC,0x60,0x00,0x01,0xFE,0x6B,0x03,0x01,0xFC,0x61,0x03,0x01,0xFD,0x58,0x00,0x01,0xFD,0x50,0x03,0x01,0xFD,0x4B,0x02,0x01,0xFD,0x3C,0x03,0x01,0xFD,0x2D,0x03,0x01,0xFC,0x20,0x02,0x01,0xF9,0x13,0x03,0x01,0xE1,0x09,0x03,
0x02,0xFE,0x60,0x00,0x01,0xFE,0x6D,0x03,0x01,0xFF,0x63,0x03,0x01,0xFF,0x5D,0x03,0x01,0xFF,0x50,0x03,0x01,0xFF,0x49,0x03,0x01,0xFF,0x3B,0x03,0x01,0xFF,0x2B,0x03,0x01,0xFF,0x1C,0x03,0x01,0xFF,0x0E,0x03,0x01,0xEB,0x06,0x03,
0x00};
void writeRGB(uint8_t r,uint8_t g,uint8_t b,int nStrip)
{
  SPI.transfer(r);
  SPI.transfer(g);
  SPI.transfer(b);
  digitalWrite(StripControl1, LOW);
}
void blank_strip()
{
for(int x = 0 ; x < STRIP_LENGTH; x++)
  buffer[x] = 0;
}
void post_frame (void) {
for(int LED_number = 0 ; LED_number < STRIP_LENGTH ; LED_number++) {
long this_led_color = buffer[LED_number]; //24 bits of color data
writeRGB((this_led_color >> 16) & 0xff,(this_led_color >> 8) & 0xff,(this_led_color) & 0xff,StripControl1);
}
delayMicroseconds(800);
}
void setup() {
pinMode(SS, OUTPUT);
SPI.begin();
blank_strip();
delay(0);
}
void loop() {
for(int x=0;x<STRIP_WIDTH;x++) {
uint_farptr_t farptr;
if(x==10) {
pinMode(0,OUTPUT);
digitalWrite(0,LOW);
}
if(x % 100 ==0) {
switch(x / 100) {
case 0:
farptr=GET_FAR_ADDRESS(bitmap_0);
break;
}
}
int bufpos=0;
while(bufpos<STRIP_LENGTH) {
int repeatcolor=pgm_read_byte_far(farptr++);
tmpbuffer[1]=pgm_read_byte_far(farptr++);
tmpbuffer[2]=pgm_read_byte_far(farptr++);
tmpbuffer[3]=pgm_read_byte_far(farptr++);
for(int j=0;j<repeatcolor;j++) {
buffer[bufpos]=(long)tmpbuffer[1] << 16;
buffer[bufpos]|=(long)tmpbuffer[2] << 8;
buffer[bufpos++]|=(long)tmpbuffer[3];
}
}
post_frame();
delay(419);
}
}

I know there is alot of mumbo jumbo script in there, because this code is created by a code generator that writes also for led strips and matrix, but I am not sure if it is to do with the code or with the board. I am using a 9v eveready and the led are plugged into the 5v and gnd of the power section.

Hi moyzie,

What battery are you using? It sounds like it might not have enough current to power the Arduino and the lights. I'm assuming the voltage is in range.

hi Patduino
the bottom of the post was cut off. I am using a 9v eveready battery that has about 1m long cord to the Arduino the lead is a figure 8 braided copper speaker wire

Is it a PP3 9v battery? If so then they Ren't very good for any kind of current demand. They are usually only about 500mAh batteries and designed for very low loads.

Having a long lead from there to the Arduino isn't going to help either.

Try with 6 x AA batteries, to give you 9v. Those have much better characteristics, with at least 1500mAH capacity and the ability to supply a decent amount of current.

Why do you need such a long lead from the battery? Sure the point of that kind of portability is that it is at the same location as the Arduino?

tack:
Is it a PP3 9v battery? If so then they Ren't very good for any kind of current demand. They are usually only about 500mAh batteries and designed for very low loads.

Having a long lead from there to the Arduino isn't going to help either.

Try with 6 x AA batteries, to give you 9v. Those have much better characteristics, with at least 1500mAH capacity and the ability to supply a decent amount of current.

Why do you need such a long lead from the battery? Sure the point of that kind of portability is that it is at the same location as the Arduino?

Thanks very much I will have to look in JayZ tronics for a battery holder that holds 6 X AA batteries and try that.

The point of the lead is that the lights are swung aroung on the end of a wire rope attached to the container the lights are mounted and create a single exposure photograph, it takes around 2-3mins to create this kind of image but with multiple colours as you can see in this link below

Imgur

I was thinking of putting the battery in the container also and just having the negative wire going up the wire rope to a small toggle or button switch at the hand held end.
Do you think that would solve the current issue ?

What is the current requirements of your circuit?

You could also measure the open circuit voltage of your battery (say around 9v) and then measure it again when it is on load. I think you'll find that the current you are trying to draw, coupled with the internal resistance of the battery, causes a significant change in the terminal voltage.

I suspect that you're simply trying to draw too much current from this type of battery.

What exactly is the layout of your LED strips? From your code it looks like 12 LEDs per wand. What is the 16 width? Is this multiplexed?

12 LEDs at 20ma is going to be 240mA. The arduino will take about 50-70mA (I know an UNO is about 50mA with 9v input). That's a total load of around 300mA minimum, which a PP3 won't like at all.

tack:
What is the current requirements of your circuit?

You could also measure the open circuit voltage of your battery (say around 9v) and then measure it again when it is on load. I think you'll find that the current you are trying to draw, coupled with the internal resistance of the battery, causes a significant change in the terminal voltage.

I suspect that you're simply trying to draw too much current from this type of battery.

What exactly is the layout of your LED strips? From your code it looks like 12 LEDs per wand. What is the 16 width? Is this multiplexed?

12 LEDs at 20ma is going to be 240mA. The arduino will take about 50-70mA (I know an UNO is about 50mA with 9v input). That's a total load of around 300mA minimum, which a PP3 won't like at all.

Thank you Tack that is great info there. I thought that might be what the problem was

it is just 12 led 0f a 25 strand Ws2801 RGB led from adafruit.com plugged into the pin 51 and 52 of the arduino.
this is the layout of the LED Programmable RGB LED Orb Tool Tutorial | Programmable RGB LE… | Flickr

I don't know alot about the code writing as such but I have played around with the width and it seems to make the cycle last a bit longer if I make it a larger number as for multiplexed I am not sure what that is.

I have used a programme (code generator that creates code from a image that you import to the programme).which also creates programmes for led strips to create these kinds of images 2011 is... | probably NOT going to be a good year for you kn… | Flickr

from this site http://wright-online.com/Drupal/
but I see it is not there now
but there is a autodownload link of the software which I use from his page here http://www.wright-online.com/downloads/DigitalLightWand_V1_0_0_76.zip
which might explain where the weird script things come from which I have been told in my other post are unnecessary.

apologies for all the links but the photos are easier to show than explain but in breif these are a single shot taking upto a minute and lasting sometimes 3 mins with the light continuously moving across the shot and the sequenced led created the image