Recommended Posts

Hi

 

I would like to communicate with MCP4725 DAC from Papiio DUO through I2C.

Is it possible to use I2C library or it could work only with WII Chuck?

 

Thank you

 

rmb.

Share this post


Link to post
Share on other sites

Hello rmb,

 

The I2C library should work with any I2C device, the Wii Chuck has its own separate library that uses I2C.

 

The Wii Chuck library actually gives you a good idea of how to use the I2C library:

https://github.com/GadgetFactory/DesignLab_Examples/blob/master/libraries/WiiChuck/WiiChuck.cpp

 

Jack.

Share this post


Link to post
Share on other sites

Jack, thank you for your answer.

I started from simple task however no luck yet.

I added I2C to wishbone 9 and attached signals to pins Arduino_7 and Arduino_6 like in provided example.

For sketch I used next modified code (originally provided for Wire arduino library):

#include <i2c.h>

#define DAC_ADDR 0x60

int lookup = 0; // index

int mysin[512] =

{

  2048, 2073, 2098, 2123, 2148, 2174, 2199, 2224,

  1847, 1872, 1897, 1922, 1948, 1973, 1998, 2023

};

void setup() {

  I2C.begin(100000);

  I2C.enable();  

  }

void loop() {

  I2C.start(DAC_ADDR,0);

  I2C.tx(64); 

  I2C.tx(mysin[lookup] >> 4); 

  I2C.tx((mysin[lookup] & 15) << 4); 

  I2C.stop();

 

 

  lookup = (lookup + 1) & 511;

}

Unfortunately I don’t  see any activity at Pins 6 an 7.

I would like to ask some questions which could help me moving forward:

How need I declare in sketch that I attach I2C to wishbone 9 at ZPUino soft processor?

What is second argument in function I2C.start?

Thank you

rmb

Share this post


Link to post
Share on other sites

 

Unfortunately I don’t  see any activity at Pins 6 an 7.

 

Hi, are your pins at logic '1' or '0' ? Do you have external pullups ?

 

 

How need I declare in sketch that I attach I2C to wishbone 9 at ZPUino soft processor?

 

No need, it will detect the slot (you should see that when you start your sketch).

 

 

What is second argument in function I2C.start?

 

If I recall well, it's how I2C handles read vs. writes (direction). See "I2C Device Addressing" here: http://www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html

Share this post


Link to post
Share on other sites

If you bring up a serial terminal at 115200 and press reset on the Papilio you should see it say that it detects the I2C device and the wishbone slot it is connected to.

 

Jack.

Share this post


Link to post
Share on other sites

Gents, thank you for answers.

A half issue was that probably I made some mistake when I modified ZPUino Vanilla soft processor (I attached I2C symbol to wishbone 9, remove Arduino pins 6 an 7 from WING_AL, extend I2C pins by wires, create markers to that and rename ports as Arduino_7 and Arduino_6 ). When I uploaded this to FPGA and test it with blinked pin6 sketch the pin6 change his value. It means something wrong with my modified soft processor.

When I loaded circuit from of WIIChuck sketch and uploaded my I2C sketch, I see activity on pins 6 and 7. However another half issue remains unsolved. DAC does not change his output value.

I suppose it is not connect with next behavior, but my question why it is happened:

I saw drift of first clock pulse between 5us to 8us on oscilloscope when processor send each third byte to DAC (from 4 bytes send within loop()).

Thank you.

rmb

Share this post


Link to post
Share on other sites

I found solution for second part of issue.

I need to add at least 10us delay at loop().

It give me the Sin with f~4.5Hz what is compatible with arduino uno.

rmb.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now