Pages: [1]   Go Down
Author Topic: Communicating with IC's without a library  (Read 403 times)
0 Members and 1 Guest are viewing this topic.
Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

So I have had this question for ages and I've tried to tackle it step by step.  Although I've realized I don't know what the first step is (aside from analyze the datasheet as if it were the last document in its language). 

i'll start fairly simple.  Say I have the TLC5940, which there is an arduino library for.  What would I have to do in order to get that library to work with the ATtiny85. 

Or say I have an IC that doesn't have a library, but I want to use it with an Atmega328p chip.  What would I do there?

Anybody have a good guide?
Logged

Accelerate to 88 miles per hour.

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You answered the question in your first paragraph.

The datasheet is the only document that can help you.

That will tell you what protocol (if any) to use to communicate with the device, or what voltage levels, etc it gives out.  You can then use the tools at your disposal (things like SPI, I²C, analog reading, etc) to communicate with it in the right way.
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

But how do you know what kind of data to send to it?

HIGH, LOW, 10110010, 3E, 0x000004.
Logged

Accelerate to 88 miles per hour.

Dallas, Texas
Offline Offline
God Member
*****
Karma: 3
Posts: 718
Old, decrepit curmugeon
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Print out the data sheet, print out a working Arduino library for that device, and walk through the code, cross referencing the data sheet.  WIth a little time and some effort, the example of the working code will allow you to understand the datasheet and vice versa...  Ultimately doing this once or twice with different chips will allow you to get to the point where you can read a datasheet and then write the needed code for it.

Some form of logic analyzer or oscilloscope can be very helpful.  If you don't already have one, you can pick up something like the Bus pirate for about the price of an Arduino that can give you many of the abilities of a logic analyzer (among other functions) that can help (but is not necessary) achieve the needed understanding.

http://www.sparkfun.com/products/9544 One source for the Bus Pirate
Logged

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 0.7.2

Finland
Offline Offline
Sr. Member
****
Karma: 0
Posts: 270
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
But how do you know what kind of data to send to it?

HIGH, LOW, 10110010, 3E, 0x000004.

If you send data to an external IC,  you send HIGHs and LOWs to it, that is, you set the pins to 0V and 5V (different ICs may require different voltage levels) in certain order for certain periods of time. Things like 10110010, 3E, 0x000004 are higher level abstractions of the data and the datasheet explains how the data maps to HIGHs and LOWs.
« Last Edit: June 17, 2012, 01:58:39 pm by pekkaa » Logged

Offline Offline
Edison Member
*
Karma: 4
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A library is just the collected data of how to communicate with a device and put in an easy to use form, you can communicate with an ic without a library , just in a sketch with the right commands
even digitalwrite is an example, if you look at the source you see that just to set a pin high or low there's a little work involved, the command makes it simple almost like a shortcut to all those other commands that are needed
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, So I think i'm just gonna buckle down with the library i'm most familiar with, TLC5940, and then compare it to the datasheet and how it works and all that good stuff.  Thanks for the help everybody!
Logged

Accelerate to 88 miles per hour.

Pages: [1]   Go Up
Jump to: