View unanswered posts | View active topics It is currently Wed Apr 16, 2014 12:00 pm






Reply to topic  [ 39 posts ]  Go to page Previous  1, 2, 3
NXT + PCF8574 
Author Message
Rookie

Joined: Fri Apr 20, 2007 3:22 am
Posts: 36
Post 
Well, if those pins are grounded you're ok. You can test that with a continuity detector. I had to add solder. It's possible they changed their design though. They changed from the PCF8574 to the PCF8574A without changing their documentation.


Thu Jun 19, 2008 2:49 am
Profile
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post 
squiggy wrote:
Here's a picture, hope it's not too large

http://home.comcast.net/~squig/pics/pcf8574-nx.jpg

The sample I posted in this thread should work. There's a header and then a sample program.

Are you trying to output or input?


Input... my problem is that i only got the PCF8574, not all that circuit...
i will try it any way... code and idea...

Thanks

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Jun 19, 2008 5:55 am
Profile
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post 
I have conections like these:

G |01......16| VDD (5V)
G |02......15| Resistor to 5V and SCL from NXT
G |03......14| Resistor to 5V and SDA from NXT
Switch |04......13|
|05......12|
|06......11|
|07......10|
G |08......09|

This works with 04 pin (the code 0xFF)

what codes should i use to 05 to 07, and 09 to 12
what msg should i send to light a led on in another place?

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Jun 19, 2008 7:02 am
Profile
Rookie

Joined: Fri Apr 20, 2007 3:22 am
Posts: 36
Post 
So take a look at your chip, is it labeled

1. PCF8574

2. PCF8574A

?

There's a difference in the base address

The PCF8574A is 0x70
The PCF8574 is 0x40

If you have the PCF8574 the header file of the sample code I gave would need to be changed to

Code:
typedef struct{
   byte i2cMessageSize;
   byte i2cDeviceAddress;
   byte i2cWriteMessage;
   } i2cBlock;

i2cBlock PCF8574A_I2C;
byte PCF8574AwriteMessage = 0;
tSensors PCF8574Aport;

void setupPCF8574A(tSensors setPort)
{
   PCF8574Aport = setPort;
   SensorType[PCF8574Aport] = sensorI2CCustomFast;
   PCF8574A_I2C.i2cMessageSize=1;
   PCF8574A_I2C.i2cDeviceAddress=0x40;
   PCF8574A_I2C.i2cWriteMessage=0xFF;
}

void writePCF8574A(byte mess)
{
   PCF8574A_I2C.i2cMessageSize=1;
   PCF8574A_I2C.i2cDeviceAddress=0x40;
   PCF8574A_I2C.i2cWriteMessage=mess;
   PCF8574AwriteMessage = mess;

   if (nI2CStatus[PCF8574Aport] == NO_ERR)
       sendI2CMsg(S1,PCF8574A_I2C.i2cMessageSize,1);

}

int readPCF8574A(byte ioMask)
{
   byte value[1];
   PCF8574A_I2C.i2cWriteMessage=0xFF;
   PCF8574A_I2C.i2cWriteMessage=PCF8574AwriteMessage|ioMask;

   if (nI2CStatus[PCF8574Aport] == NO_ERR)
       sendI2CMsg(PCF8574Aport,PCF8574A_I2C.i2cMessageSize,1);
   wait1Msec(20);

   if (nI2CStatus[PCF8574Aport] == NO_ERR)
      readI2CReply(PCF8574Aport, value[0],1);

   return (int)value[0];
}


Pins A0-A2 would be connected to your ground.


Thu Jun 19, 2008 4:41 pm
Profile
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post 
PCF8574AN

not working... =(

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Jun 19, 2008 6:15 pm
Profile
Rookie

Joined: Fri Apr 20, 2007 3:22 am
Posts: 36
Post 
OK,

so Im not sure which address you would have, I suspect ox70, but first you need to check to see if the device is working.

try using from the sample programs:

NXT Scan All I2C Add.c

It should tell you if it's working or not.


Thu Jun 19, 2008 6:58 pm
Profile
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post 
hi all

in Input mode, everything working now...

a few questions...:

how to get ask a singular bit? (know if P0 is 0 or 1)
how to set a port as 0 or as 1 ? (Output)...

I wanna light a led on P1, how to control it?

I don't know what to send on "write to" function

Thanks

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Jul 03, 2008 3:51 pm
Profile
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post 
Ford Prefect wrote:
hi,
in our German forum we have a member who wrote a program with this PCF to connect a small keypad to the NXT:
http://www.mindstormsforum.de/viewtopic.php?t=2885

foto: Image

HTH!


Hi, i saw the code of that, but as it is explained in german, i didn't understand what codes use to the OUTputs

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Jul 03, 2008 3:58 pm
Profile
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post 
I did it =)

I Finally did it =)

Sorry about all problems that i give to you,

Now i can put a LDR, 2 Leds, and 2 Buttons...

I will later on try put some old SRF-04 working on that PCF...

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Jul 03, 2008 6:51 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 39 posts ]  Go to page Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.