electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Microcontrollers and Programmable Logic
Arduino TLC5940 and 74HC595
Post new topic   Reply to topic Moderators: State Machine
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
makiyoung



Joined: Jun 19, 2017
Posts: 1
Location: USA

PostPosted: Mon Jun 19, 2017 2:25 am    Post subject: Arduino TLC5940 and 74HC595
Subject description: Arduino TLC5940 and 74HC595
Reply with quote  Mark this post and the followings unread

I need to expand Arduino Uno output. After some search I have identified 74HC595 to extend my Digital output and TLC5940 for analog output.

This two setups share some pins, I've seen in this thread that other people use them together but I'm not sure how to connect them to my Arduino. Can you give me a hint?

Libraries are also compatible?

Then how to test 74hc595?
Back to top
View user's profile Send private message
Grumble



Joined: Nov 23, 2015
Posts: 579
Location: Netherlands
Audio files: 19

PostPosted: Mon Jun 19, 2017 2:52 am    Post subject: Reply with quote  Mark this post and the followings unread

TLC5940 is a 16-Channel LED Driver, so I'm not sure how you would use this to expand the analog out of the Arduino Uno (which doesn't have an analog out by the way...)

First I have to mention that I'm not using the Arduino IDE but I program my Arduino's using C++ and the program I use is Atmel Studio 7 and I don't know about lib's.

Ok, have said that: The mentioned ic's both use SPI, that is, they use MOSI, MISO, CLK and a chip select line.
The Chip Select line (active low) may be any digital output line you choose.
The use is like this:

make the CS of the chip you wish to use low,
transfer the data to the chip using SPI,
make the CS of the chip you wish to use high again.

Thats it.

in more detail:

#define cs_74HC595_low PORTB &= ~(1<<PB2); //CS ¯|_
#define cs_74HC595_high PORTB |= (1<<PB2); //CS _|¯

// set I/O pins in INIT
DDRB |=(1<<DDB2)|(1<<DDB3)|(1<<DDB5);//outputs
// PB5 (SCK) = Out
// PB3 (MOSI) = Out
// PB2 (SS) = Out
// SPI-Init
SPCR = (1<<SPE) // SPI enable
|(1<<MSTR) //master mode
|(1<<CPOL) //setup rising
|(0<<CPHA) //sample falling
|(1<<SPR0); //fosc/16
cs_74HC595_high

void data_to_74HC595 (uint8_t to_parallel_data)
{
cs_74HC595_low;
SPDR =to_parallel_data;
while ( !(SPSR & (1<<SPIF))) {}; // ready?
cs_74HC595_high;
}

now every time you need to write data to the 595 you do: data_to_74HC595 (your data);
Back to top
View user's profile Send private message Visit poster's website
Grumble



Joined: Nov 23, 2015
Posts: 579
Location: Netherlands
Audio files: 19

PostPosted: Mon Jun 19, 2017 3:03 am    Post subject: Reply with quote  Mark this post and the followings unread

testing can be done:
while (true)
{
for (uint8_t n=0;n<255;n++)
{
data_to_74HC595 (n);
_delay_ms(1);
}
}

connect the outputs one by one to an amplifier and you will hear 1khz, 500hz, 250hz, 125hz, etc. listening at ouput D0-D7 from the 595 (carefull! the outputs go to +5 volt!)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: State Machine
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Microcontrollers and Programmable Logic
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use