Go Down

Topic: WS2803 example (Read 2769 times) previous topic - next topic

Danton

Does someone have a working piece of code that I can try with my WS2803?
I want to use it with a led string, but I can only find code for the WS2801.

Thanks!

James C4S

You might be interested in this thread:
http://arduino.cc/forum/index.php?topic=89104.0
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Danton

Thanks for your reply.

Is there anyone who could help me with connecting my WS2803?
Can't find any real answers, and most topics seem almost dead to me.

codlink

You need to give us more details on what you're having trouble with.  What is wrong with the drawing you posted?
//LiNK

Danton

Do I need to add resistors or capacitators?

I saw the following schematic :


But I don't really get the function of the cap. And I can't really find what the 12V 5050 RGB SMD led's will use per three, to calculate the value of the IREF resistor.

James C4S

Quote
But I don't really get the function of the cap.

It's a decoupling capacitor.  All devices should have them.

Quote
And I can't really find what the 12V 5050 RGB SMD led's will use per three, to calculate the value of the IREF resistor.

You don't calculate for all 3.  You are setting the maximum for any of the output channels.  As for the value of to use, that's something you need to decide.  Determine what the maximum current the LEDs you are using can handle and then decide what you want your driver's maximum to be set at.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Danton


Quote
But I don't really get the function of the cap.

It's a decoupling capacitor.  All devices should have them.

Ok, that something I will have to lookup.

Quote
And I can't really find what the 12V 5050 RGB SMD led's will use per three, to calculate the value of the IREF resistor.

You don't calculate for all 3.  You are setting the maximum for any of the output channels.  As for the value of to use, that's something you need to decide.  Determine what the maximum current the LEDs you are using can handle and then decide what you want your driver's maximum to be set at.


I'm trying to understand it.
I have 18 outputs on my WS2803, and all of these outputs are going to send a R, G or B signal to series of three.
Let's say the led's use 20mA each, so a series of three will use 60mA over each channel.
How do I then determine which resistor I will be needing for IREF?


James C4S


I have 18 outputs on my WS2803

The number of outputs used has nothing to do with the value of IREF.


and all of these outputs are going to send a R, G or B signal to series of three.

Did you really mean "series"?

Current running through parts in series is the same.  So if you have 2 parts in series, their current is both 20mA.  If you have 100 in series, their current is still 20mA.


Let's say the led's use 20mA each, so a series of three will use 60mA over each channel.

That is only the case if you put the LEDs in parallel, which you should *not* do with a constant current driver.  Instead, each LED (or series of LEDs) should be on its own channel.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Danton


The number of outputs used has nothing to do with the value of IREF.


It becomes more clearer and clearer to me.

I just found the following, and I think I'm understanding it.

Quote
The datasheet shows Amps = 1.25 / Ohms * 22.  Some simple algebra gets:

Amps / 22 = 1.25 / Ohms

22 / Amps = Ohms / 1.25

(22 / Amps) * 1.25 = Ohms

For example: 20 mA -> (22 / 0.020) * 1.25 = 1375 Ohms



Current running through parts in series is the same.  So if you have 2 parts in series, their current is both 20mA.  If you have 100 in series, their current is still 20mA.


So 3 leds in series also use a total of 20mA.

James C4S


So 3 leds in series also use a total of 20mA.

Yes.  Current is the same, but voltages add up.  So if you have 3 LEDs in series with each other and their forward voltage is 2V, that means the 3 in series will drop a total of 6V.

Since LEDs are not linear (like resistors) you must leave some voltage left over to drop across the output of the chip you're using.  So you need to make sure whatever supply those LEDs are connected to has some voltage higher than their combined voltage drop.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

CrossRoads

The datasheet says you pick the resistor to control the current of every channel, it doesn't know or care that you have an RGB LED connected to 3 pins.
You will have to send data controlling the PWM for each channel to control the average current going to a particular color.


Adjusting the output current

The output current of each channel can be set by an external resistor, Rext, the output current can be set by the following formula:
Iout = (VRext/Rext) x 22

Where, Rext is the resistance of the external resistor connected to Rext terminal [pin 2 on a DIP, labelled confusingly IREF], and VRext is the voltage of Rext pin [labelled Iref] VRext=1.25V.
[Put a meter on it - see if it measures 1.25V]

To set the output current at 20mA, a resistor with 1.25Kohm resistance should be connected from Rext [labelled Iref] to GND. The relationship between IOUT and REXT shown in the following figure. [where as  no such figure is shown - guess that's whi its preliminary]

So: (1.25V/1250ohm) x 22 = 22mA
so their formula is not quite correct.

Rearranging & solving for R with current at 20mA:
1.25V x 22 / 20mA = 1375 ohm

Maybe the 22 factor is wrong, and it should be 20.

"So 3 leds in series also use a total of 20mA."  >> Yes.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Danton

I think I'm having a small problem.
All the schematics don't use a Arduino Leonardo, so I can't find the exact pins to connect the CKI and SDI to.

James C4S


I think I'm having a small problem.
All the schematics don't use a Arduino Leonardo, so I can't find the exact pins to connect the CKI and SDI to.

The example I looked at defined the pins to use in the code, so it wouldn't matter what board it is.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Danton

#13
Jan 14, 2013, 10:41 pm Last Edit: Jan 15, 2013, 12:01 am by Danton Reason: 1
It still doesn't work, tried three WS2803's.

I connected everything and tried the following code:
Code: [Select]

// 8 CLK
const int pinCLK = 5 ;

// 9 CLK Data
const int pinDATA = 6 ;


void setup() {
   Serial.begin( 57600 );  
 pinMode(pinCLK, OUTPUT);
 pinMode(pinDATA, OUTPUT);

 digitalWrite(pinCLK, HIGH);
 digitalWrite(pinDATA, LOW);
}

byte val = 0 ;

void loop () {

 byte c;
 int digit;
 
 delayMicroseconds( 600 );

 val+= 2 ;
 
 for (c= 0 ; c<= 17 ;c++) {
   for (digit= 7 ;digit >= 0 ;digit--) {
   if (val & ( 1 << digit)) {
      digitalWrite(pinDATA, HIGH);
   } else {
    digitalWrite(pinDATA,LOW);
   }
   digitalWrite(pinCLK, HIGH);
   digitalWrite(pinCLK, LOW);
   }
 }

}

James C4S

Sometimes it is good for your comments and code to match. Are you connecting the right pins?
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up