Pages: [1]   Go Down
Author Topic: WS2803 example  (Read 2257 times)
0 Members and 1 Guest are viewing this topic.
NL
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6106
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You might be interested in this thread:
http://arduino.cc/forum/index.php?topic=89104.0
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

NL
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* arduino-01.jpg (280.26 KB, 842x763 - viewed 180 times.)
Logged

USA, FL
Offline Offline
God Member
*****
Karma: 14
Posts: 688
A life? Where can I download one of those?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

//LiNK

NL
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6106
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

NL
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6106
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

NL
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6106
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26371
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

* WS2803-preliminary-En.pdf (436.67 KB - downloaded 19 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

NL
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6106
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

NL
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It still doesn't work, tried three WS2803's.

I connected everything and tried the following code:
Code:
// 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);
    }
  }

}


* Photo1 kopie.jpg (518.51 KB, 1632x1224 - viewed 64 times.)
« Last Edit: January 14, 2013, 06:01:06 pm by Danton » Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6106
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sometimes it is good for your comments and code to match. Are you connecting the right pins?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Pages: [1]   Go Up
Jump to: