Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] 3 more i2c pins and communication code for arduino needed

Status
Not open for further replies.

riz_raxi

Junior Member level 1
Junior Member level 1
Joined
Mar 29, 2014
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
126
Dear Sir,
I want to interface 3 more DAC chips for my current code with 3 more pins of arduino which are interfaced with I2C. I have used wire.h currently. How can i do 3 more? I mean how to change wire.h and which specific thing is to change for 3 more PCF8591 chips of DAC chip to be interfaced with 3 pins of arduino through 3 soft I2C communications.
Summarizing it, I need to understand i2c communication through soft pins and their code.
Thank you

My current code for one pin i2c is


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "Wire.h"
#define PCF8591 0x90 >> 1
void setup()
{
Wire.begin();
Serial.begin(9600);
}
int val=0;
void loop()
{
if (Serial.available()) {
val = Serial.read();
}
//for (int i=0; i<256; i++)
//{
Wire.beginTransmission(PCF8591); // wake up PCF8591
Wire.write(0x40); // control byte - turn on DAC (binary 1000000)
Wire.write(val); // value to send to DAC
Wire.endTransmission(); // end tranmission
//val=val+1;
//}
/*for (int i=255; i>=0; --i)
{
Wire.beginTransmission(PCF8591); // wake up PCF8591
Wire.write(0x40); // control byte - turn on DAC (binary 1000000)
Wire.write(i); // value to send to DAC
Wire.endTransmission(); // end tranmission
}*/
}

 
Last edited by a moderator:

The PCF8591 chip can be hardware addressable by three pins available for that purpose: A0, A1 and A2 ( two are enough for your need ). The question that come now is to know if these pins are connected to core processor at your board.



+++
 

The PCF8591 chip can be hardware addressable by three pins available for that purpose: A0, A1 and A2 ( two are enough for your need ). The question that come now is to know if these pins are connected to core processor at your board.



+++

No can i control with control bits to A0, A1, A2 ?
How to change or edit address?
what this 0x90 >> 1 means in address?
 
Last edited:

The solution is to give the hardware address first by setting A0 A1 and A2 then converting that 8 bit binary to hex and then in programming code use that 0xHEX number to start communicating to that DAC chip.
(See data sheet of PCF 8591 for A0 A1 A2 and othe 5 bits of addresses).
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top