arduinoでTLC5940+74595を使ったLED制御

前回はTLC+74138を使ってのLED制御でしたが今回は74595を使用してのテストです。わかりやすい違いは、74138では最大8chでしたが74595ではその制限が無いことです。(デイジーチェイン)
ただし、人間の目を誤魔化すのに60hz位必要らしいので、そんなにつなげないとおもいますけれど。

■基板イメージ

74595_2

■回路図(抜粋)

74595+

■テストコード

[cpp]

#include "Tlc5940.h"

//74HC595 LED control pins
int latchPin = 7; //Pin connected to ST_CP
int clockPin = 6; //Pin connected to SH_CP
int dataPin = 5; //Pin connected to DS

void setup()
{
/* Call Tlc.init() to setup the tlc.
You can optionally pass an initial PWM value (0 – 4095) for all channels.*/
Tlc.init();

//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}

void loop()
{
int direction = 1;
for (int channel = 0; channel < NUM_TLCS * 16; channel += direction) {

Tlc.clear();

if (channel == 0) {
direction = 1;
} else {
Tlc.set(channel – 1, 1000);
}
Tlc.set(channel, 4095);
if (channel != NUM_TLCS * 16 – 1) {
Tlc.set(channel + 1, 1000);
} else {
direction = -1;
}

Tlc.update();

for (int j = 0; j < 8; j++) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 1<<j);
digitalWrite(latchPin, HIGH);
delay(100);
}
}
}

[/cpp]

どちらがいいかはその時にやりたいこと次第ですが、大電流流したいなら74138ですね。部品点数減らしたい or 8ch以上なら74595でしょうか。ラッチアップとかが不要なので、切り替えスピードは74138の方が早いです。

IMG_6153res

  1. コメントはまだありません。

  1. トラックバックはまだありません。


Warning: Undefined variable $user_ID in /home/r3087696/public_html/blog.eldhrimnir.com/wp-content/themes/monochrome/comments.php on line 172

Fatal error: Uncaught Error: Undefined constant "cs_print_smilies" in /home/r3087696/public_html/blog.eldhrimnir.com/wp-content/themes/monochrome/comments.php:185 Stack trace: #0 /home/r3087696/public_html/blog.eldhrimnir.com/wp-includes/comment-template.php(1617): require() #1 /home/r3087696/public_html/blog.eldhrimnir.com/wp-content/themes/monochrome/single.php(57): comments_template() #2 /home/r3087696/public_html/blog.eldhrimnir.com/wp-includes/template-loader.php(106): include('/home/r3087696/...') #3 /home/r3087696/public_html/blog.eldhrimnir.com/wp-blog-header.php(19): require_once('/home/r3087696/...') #4 /home/r3087696/public_html/blog.eldhrimnir.com/index.php(17): require('/home/r3087696/...') #5 {main} thrown in /home/r3087696/public_html/blog.eldhrimnir.com/wp-content/themes/monochrome/comments.php on line 185