The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
I have a digital potentiometer I'm trying to get working with the Netduino. It's I2C, obviously. I've gotten this part working quite well with the Arduino and ChipKit boards, but I'm utterly confused by how I2C works in NETMF. I've looked all over and have found numerous examples, but nothing that really tells me exactly what each command does and how to do basic things such as read and write. Are there any such resources that have just escaped me?
If it would help, I can post the Arduino/ChipKit library I wrote for this part. It's the AD5175.
This is a sample for a PCF8574 digital i/o expander.
Flashing all 8 bit ouputs.
public class Program { public static void Main() { var device = new I2CDevice(new I2CDevice.Configuration(0x38, 100)); I2CDevice.I2CTransaction[] actionsWrite; var buffer = new byte[1]; actionsWrite = new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(buffer), }; for (; ; ) { buffer[0] = 255; device.Execute(actionsWrite, 1000); Thread.Sleep(1000); buffer[0] = 0; device.Execute(actionsWrite, 1000); Thread.Sleep(1000); } } }
This is a sample for a PCF8574 digital i/o expander.
Flashing all 8 bit ouputs.
public class Program { public static void Main() { var device = new I2CDevice(new I2CDevice.Configuration(0x38, 100)); I2CDevice.I2CTransaction[] actionsWrite; var buffer = new byte[1]; actionsWrite = new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(buffer), }; for (; ; ) { buffer[0] = 255; device.Execute(actionsWrite, 1000); Thread.Sleep(1000); buffer[0] = 0; device.Execute(actionsWrite, 1000); Thread.Sleep(1000); } } }
Thanks. Can you explain why I need to specify a timeout for the write transaction?
Because end of every byte there is an acknowledge bit from slave device.
If no ACK you know something wrong (wire problem, resistor problem, wrong slave address).
I get that, but is there something special about using 1000 as the value for the timeout? Is that 1 second that my microcontroller is just sitting there waiting, or is that acting like a maximum amount of time it will wait before it decides to throw up an error?
I get that, but is there something special about using 1000 as the value for the timeout? Is that 1 second that my microcontroller is just sitting there waiting, or is that acting like a maximum amount of time it will wait before it decides to throw up an error?
It return immediately if got answer. Waiting 1 sec when no answer.
I did run this code on Netduino plus with 4.1 vesion with no device attached to I2C port. I used 4.7k pull ups. When I look at the pins (A4, A5) with my scope, I just see 5 volts DC(3.3volts) and no signal. Do I need to have a device attached?.
I did this to make sure, it is not my device that is causing no signal.
Just one problem (at least) with the [color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]PCF8574 code - the device address is 0x20 not 0x38.[/color]
Hi Guys!, im pretty new into the forum, i have several doubts about if netduino 1 (with firmware 4.1) can use i2c, and if so, where can i find classes or libraries to do so.