Lost w/I2C ???

SolidWorksMagi

Senior Member
Hi,

I am trying to communicate using I2C to a PIXY2 CMUcam5 ... the PIXY2 docs say I need to send a short series of characters to ask the PIXY2 (address 0x54) to request data;
0xae
0xc1
0x0e
0x00

Somehow I'm not seeing anything happening on either the SDA or SCL line.

How do I initialize the PICAXE 20M2 chip for I2C

What should the hi2cout line look like?
 

Aries

New Member
HI2CSETUP I2CMASTER, slaveaddress, mode, addresslen

Make sure you know what the slave (PIXY2) is expecting as its address, and include it here. Also, "The slave address is the address that is used by the PICAXE chip for identification. It can be a number between 1 and 127, but must be held in bits 7 to 1 of the address (not bits 6 - 0) e.g. %1010000x. Bit0 is the read/write bit and so ignored." So make sure you format it correctly.

Mode - I always use I2Cslow. Unless you really need the speed, it's safer.

AddressLen - again, check what the slave requires (can you address areas beyond 256? - if so you need I2Cword).
 

SolidWorksMagi

Senior Member
HI2CSETUP I2CMASTER, slaveaddress, mode, addresslen

Make sure you know what the slave (PIXY2) is expecting as its address, and include it here. Also, "The slave address is the address that is used by the PICAXE chip for identification. It can be a number between 1 and 127, but must be held in bits 7 to 1 of the address (not bits 6 - 0) e.g. %1010000x. Bit0 is the read/write bit and so ignored." So make sure you format it correctly.

Mode - I always use I2Cslow. Unless you really need the speed, it's safer.

AddressLen - again, check what the slave requires (can you address areas beyond 256? - if so you need I2Cword).


Hi,

In my initial post I listed the PIXY2 I2C address ...

The PICAXE 20M2 will be the Master to request data from the Slave PIXY2 CMUcam5.
 

Aries

New Member
The Picaxe 20M2 can only operate as a master anyway.

As the address you give (0x54) is larger than 127, I assume it has already been shifted left. If so, you need something like
HI2CSETUP I2CMASTER, $54, I2CSLOW, I2CWORD or I2CBYTE

I don't know whether you need word or byte addressability - assuming you can get I2C to work, you can experiment.

Then use HI2COUT to send data to the PIXY2, HI2CIN to receive data from it.
 

westaust55

Moderator
$54 is in fact = 84 decimal
So we may in fact need to shift 1 bit left.
Therefore in the absence of the data sheet for the peripheral,
Also try the slave address as
168 = $A8

A link to the datasheet would be good.
Some sources give the raw 7-bit slave address and the background firmware/library adjusts but for the PICAXE those 7 bits must be the upper 7 bits of the byte variable and as mentioned earlier bit0 is used for the read/write flag (which is auto set)
 

SolidWorksMagi

Senior Member
The Picaxe 20M2 can only operate as a master anyway.

As the address you give (0x54) is larger than 127, I assume it has already been shifted left. If so, you need something like
HI2CSETUP I2CMASTER, $54, I2CSLOW, I2CWORD or I2CBYTE

I don't know whether you need word or byte addressability - assuming you can get I2C to work, you can experiment.

Then use HI2COUT to send data to the PIXY2, HI2CIN to receive data from it.
Hi,

hi2csetup I2CMASTER, $54, I2CSLOW, I2CBYTE

That's the initializing line I've been using ... but I don't see any data going out from the 20M2 chip when I using my DSO nano on PIN 11 or PIN 13
 

inglewoodpete

Senior Member
Do you have pull-up resistors in place on the scl and sda leads (suggested values 4.7k)? The outputs from any i2c device are open drain or open collector and need the resistors in order to idle high.
 
Last edited:

Aries

New Member
Assuming you do get something to appear on the output ... as WestAust55 said, you will need address $A8 (not $54 - my mistake).
 

melcator07

New Member
Hello,
I am interested in your work on pixy2. But I'm a novice and wanted to know if you managed to use this camera with Picaxe.
If yes, do you have a program as an example ...
thank you in advance
 

westaust55

Moderator
Hello,
I am interested in your work on pixy2. But I'm a novice and wanted to know if you managed to use this camera with Picaxe.
If yes, do you have a program as an example ...
thank you in advance
@melcator07,
Please note that:
1. This thread is from 2018
2. The OP (SolidWorksMagi) has not logged in since August 2019
From 2. It seems the OP is likely not to see your question/post.
 

westaust55

Moderator
The same OP has another slightly earlier thread here on the PIXY cam:
 

SolidWorksMagi

Senior Member
Hi,

Finally getting back to the problem. I have so many X-Projects in development so when I get stuck in one place, I can just hop on another project in the mean time. Anyway I have given up on I2C communications with the PIXY2 ... Now I'm trying UART and hserin and hserout with this code;

GetData:
low C.0
sertxd ("The 1st data before serin = 0xae,0xc1,0x0e,0x00,sigMap,maxBlocks",13,10,13,10)
hserout 0, (0xAE,0xC1,0x20,0x02,"sigMap","maxBlocks")
;sertxd ("The 1st data before serin = 0xae,0xc1,0x0e,0x00",13,10,13,10)
;hserout 0, (0xAE,0xC1,0x20,0x02)

sertxd ("The 1st data is ",13,10,13,10)
hserin [1000,GetData],0,2
SerTxd (b1, b3,b2, b5,b4, b7,b6, b9,b8, b11,b10, b13,b12)
;SerTxd ($AA, #b1, #b3,#b2, #b5,#b4, #b7,#b6, #b9,#b8, #b11,#b10, #b13,#b12)
high C.0
return


I see the data being sent out, but the PIXY2 isn't responding as far as the terminal window shows.

24175
 
Top