Go Down

Topic: SCP 1000 D11 Model requires I2c protocol (Read 333 times) previous topic - next topic

usmanmunawar

hello how are you ?

i am working on Scp1000 model D11 if someone work on it earlier kindly provide me code to interface using I2c. i shall be very thankful to you if someone provide me with it.

it has two parts available
1. D01
2. D11

while D11 is using I2c protocol so kindly provide me i am stuck in this problem /...

usmanmunawar

hello

how are you?

can you help me in running the I2c protocol on arduino i have pressure sensor and i want to work on it i did some work on it but i didnt get valid data from it. i am sending you code what i write and procedure kindly help me.


Code: [Select]
#include <Wire.h>

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
}

int reading = 0;

void loop()
{
// step 1: instruct sensor to read echoes
Wire.beginTransmission(0x11); // transmit to device #112 (0x70)
// the address specified in the datasheet is 224 (0xE0)
// but i2c adressing uses the high 7 bits so it's 112
Wire.write(byte(0x01)); // sets register pointer to the command register (0x00)
Wire.write(byte(0x55)); // command sensor to measure in "inches" (0x50)
// use 0x51 for centimeters
// use 0x52 for ping microseconds
Wire.endTransmission(); // stop transmitting

// step 2: wait for readings to happen
delay(70); // datasheet suggests at least 65 milliseconds

// step 3: instruct sensor to return a particular echo reading
Wire.beginTransmission(0x11); // transmit to device #112
Wire.write(byte(0x1F)); // sets register pointer to echo #1 register (0x02)
Wire.endTransmission(); // stop transmitting

// step 4: request reading from sensor
Wire.requestFrom(112, 1); // request 2 bytes from slave device #112

// step 5: receive reading from sensor
if(2 <= Wire.available()) // if two bytes were received
{
reading = Wire.read();
Serial.println(reading); // print the reading
}

delay(250); // wait a bit since people have to read the output
}


After following all steps which is given in datasheet but it is giving the raw data on MSB byte of Pressure:
1111111
If i read 0x80
Lsb bit it gives the same data
1111111
1111111
if i read 0x81
it again give same 16 bit
1111111
1111111




Writing data:

1. START BIT (to initiate a transmission, the master sends a start bit)
2. SLAVE DEVICE ADDRESS (slave device address with WRITE access ? LSB = '0')
3. SLAVE ACKNOWLEDGEMENT (having identified device address as its own, slave acknowledges by sending an acknowledge bit)
4. REGISTER ADDRESS (the 8 bit address of the register to be written, MSB first)
5. SLAVE ACKNOWLEDGEMENT (the slave sends an acknowledgement bit)
6. REGISTER DATA (master sends the data to be written to the addressed register)
7. SLAVE ACKNOWLEDGEMENT (after receiving the byte, the slave sends an acknowledgement bit)
8. STOP BIT (master sets the bus free)

Reading of bits procedure

9. START BIT (to initiate a transmission, the master sends a start bit)
10. SLAVE DEVICE ADDRESS (slave device address with WRITE access ? LSB = '0')
11. SLAVE ACKNOWLEDGEMENT (having identified device address as its own, slave acknowledges by sending an acknowledge bit)
12. REGISTER ADDRESS (the 8 bit address of the register to be read, MSB first)
13. SLAVE ACKNOWLEDGEMENT (the slave sends an acknowledgement bit)
14. REPEATED START (from master)
15. SLAVE DEVICE ADDRESS (slave device address with READ access ? LSB = '1')
16. SLAVE ACKNOWLEDGEMENT (the slave acknowledges)
17. REGISTER DATA (the master continues sending the SCK pulses as slave sends the defined register content to SDA line)
18. MASTER NOT ACKNOWLEDGE (master terminates the data transfer by sending not acknowledge bit)
19. STOP BIT (master sets the bus free)

Regards,
Usman Munawar

Go Up