What i want to know is that when i change
sendI2CMsg(S1,ledArray.i2cMessageSize,1); to
sendI2CMsg(S1,ledArray.i2cMessageSize,0);

or the other way round what change would i expect etc by the way i have tried changing the value from 1 to 0 or 0 to 1 but the NXT and the interface do not respond to the change even if i switch the NXT off an ON again.

I dont understand what this "...,1); or ...0);" represent or what they mean or do etc I am tryin to read from the pins what is this 0 or 1 doing and what is it about?

I now the above may sound rather dumb but my programming skill are quite poor and i dont seem to understand this problem

After the sensor receives a message, you can tell the sensor to send you back information, and how much. that is what the 1 or 0 means. The i2cMessageSize is how many bytes your sending to the sensor, not how much the sensor is sending back to you.

Different applications will use 1 or 0

A motor multiplexer that you tell to turn on and off would probably have a 0 at the end, you tell the multiplexer what to do and don't need any data back.

A compass sensor however would be different. You would send a command to the senor an say you want the compass current heading. You would use a 1 to specify you want 1 byte of data returned to you. The sensor would then return whatever value the sensor had in 1 byte.

so what would i expect if i was using a thermistor voltage divider circuit with an ADC to recieve the digital output across the pins

_________________Ghat

Wed Mar 12, 2008 5:31 pm

ghat

Rookie

Joined: Tue Mar 11, 2008 7:12 pmPosts: 5

Also
my programming skills are rather poor could anyone explain what the two different codes below mean and what they do plzzzz

if (nI2CStatus[S1] == NO_ERR)

while (nI2CStatus[S1] == STAT_COMM_PENDING)

thanks

_________________Ghat

Wed Mar 12, 2008 8:13 pm

Dick Swan

Creator

Joined: Fri Feb 09, 2007 9:21 amPosts: 616

The PCF8574 is different from most of the available I2C sensors for the NXT. It has a single byte of data that you write; most of the sensors have multiple bytes.

When you write to a I2c device, the first byte is the address of the device on the I2C bus. By "convention" most of the NXT sensors are given address 2 (hex). There can be several devices on a I2C bus and each should be assigned a unique address.

By convention (but not specified in the I2C standard on devices with multiple internal locations the next byte is the internal address pointer. This byte is used to set the "index pointer" within the device. If you want to write to the device, then subsequent bytes are written to the current index pointer location which is then auto incremented for the next byte. If you were reading from the device then this is the first location that is being read and if you wre reading multiple bytes then the index pointer is auto-incremented after each byte.

The PCF8574 device has only one internal byte that is read/written so the "internal address pointer is not read. Writing "02 7F" (hex) for this assumes the I2C address is "02" and you're writing value "7F'. If you read back 1 byte it should hopefully give you value "7F'>

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum