I needed a dac to send analog signals through a cable, so I bought a MCP4725. Unfortunately it came as a 3 x 2 mm chip, so to make it possible to connect to arduino I asked my friend to solder it(the "soldered wires" seem to be working correctly). I wrote what does each pin do according to the datasheet. I think it is labeled correctly (on the picture where you can see the chip, the letters on the chip are upside down). Then I have wired it exactly this same as on Overview | MCP4725 12-Bit DAC Tutorial | Adafruit Learning System and used the same library, but when I launched the trianglewave example or any other code using dac, arduino always hangs on setVoltage method.
My question is, why doesn't it work and what am I doing wrong?
/**************************************************************************/
/*!
@file trianglewave.pde
@author Adafruit Industries
@license BSD (see license.txt)
This example will generate a triangle wave with the MCP4725 DAC.
This is an example sketch for the Adafruit MCP4725 breakout board
----> https://www.adafruit.com/products/???
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
*/
/**************************************************************************/
#include <Wire.h>
#include <Adafruit_MCP4725.h>
Adafruit_MCP4725 dac;
void setup(void) {
Serial.begin(9600);
Serial.println("Hello!");
// For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)
// For MCP4725A0 the address is 0x60 or 0x61
// For MCP4725A2 the address is 0x64 or 0x65
dac.begin(0x62);
Serial.println("Generating a triangle wave");
}
void loop(void) {
uint32_t counter;
// Run through the full 12-bit scale for a triangle wave
for (counter = 0; counter < 4095; counter++)
{
dac.setVoltage(counter, false);
}
for (counter = 4095; counter > 0; counter--)
{
dac.setVoltage(counter, false);
}
}
// For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)
// For MCP4725A0 the address is 0x60 or 0x61
// For MCP4725A2 the address is 0x64 or 0x65
dac.begin(0x62);
No, I have not, I will try it right away. Should I plug A0 to Vcc(it's Vdd on my circuit I suppose), as it is said on the website?
edit1: I have tried it with addresses from 0x60 to 0x65 with no success. I have connected the 5v, Vcc and A0 together and retried with no success too. Any other ideas? Just out of curiosity, is there a way to see if I correctly labeled the ports on the board?
mafiu95:
edit1: I have tried it with addresses from 0x60 to 0x65 with no success. I have connected the 5v, Vcc and A0 together and retried with no success too. Any other ideas? Just out of curiosity, is there a way to see if I correctly labeled the ports on the board?
Yes, I did use the A0 on the board, not on the arduino. Still I don't get any results...
Still no change. Code always hangs on setVoltage method and nothing happens. If comeone could check if I am right, if you look at the dac circuit picture (Dropbox - Error - Simplify your life) the port numbers should go in the following order:
From the upper left corner the pin no. is 6 then 5 then 4 and from lower left corner it is 3 then 2 then 1. The only clue about the pin numbers is the text printed on the board, on the picture I gave the link to earlier the text would be upside down.
I still think it is something wrong with a code, but I want to be sure. I did restarted dac, by simply removing the 5v cable from breadboard, flashing arduino and putting the cable back. Is it the right way?
It's very difficult to try and see which is pin 1 on the DAC from that picture and also which of the tracks coming from the DAC go to which pins on your Arduino.
Can you edit that picture by adding text to it indicating that information and uploading to dropbox again?
From the upper left corner the pin no. is 6 then 5 then 4 and from lower left corner it is 3 then 2 then 1. The only clue about the pin numbers is the text printed on the board, on the picture I gave the link to earlier the text would be upside down.
Actually, the best clue is that the little notch on the chip signifies the end that pin 1 is on. if you look at the chip from above, with the notch away from you, pin 1 is the one on the left, just like it's shown on the datasheet where it show the package type .
lar3ry:
Actually, the best clue is that the little notch on the chip signifies the end that pin 1 is on. if you look at the chip from above, with the notch away from you, pin 1 is the one on the left, just like it's shown on the datasheet where it show the package type .
I knew about it, but it seems my chip does not simply have it. However, on one side (right side on the previous picture of just the circuit) you can see a very small piece of wire or something similar. You can see it clearly on this picture: Dropbox - Error - Simplify your life
Please see attached pic and confirm if correct and if so which pins on your Arduino do the SCL and SDA lines go?
Also solder a capacitor of 100 - 220nF between pins 2 and 3 of the DAC as it will aid in decoupling.
Unfortunately, I got to go to sleep, as it is after midnight in here, I should be back after 15hrs GMT, then I would be able to do any testing and replying.
I don't think so, actually it was glued to the board and the connections. It is quite hard for me to get the capacitor right now, as the electronic store is quite far from my daily route :(. I will try to get it to this weekend anyway.
I've got an idea. Let's say that I used the wrong sides of the dac chip and mislabeled the ports. If I try to change it, could that break the chip, assuming that I did connected it correctly in the first place?
mafiu95:
I've got an idea. Let's say that I used the wrong sides of the dac chip and mislabeled the ports. If I try to change it, could that break the chip, assuming that I did connected it correctly in the first place?
Depends on how you try to make the change. You already have it soldered to the board, and the traces bring the pins out to holes. The safest way is to just unplug everything from the Arduino and replug the wires to whatever configuration you think is right.
It's not completely safe, of course, because if it's wrong now, you may have destroyed the chip, and it it's right now, you may destroy it when you change it and plug it in. I say "you may", because it isn't a sure thing. Some chips are more tolerant than others, of miswiring.
Luckily, there are only two ways the chip can be oriented.