Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

Hi this is vishnu.

   

i am trying to interface temperature sensor MLX90614. before doing this i have inerfaced 24c56 with PSoC sucessfully.

   

but when i  am trying to interface with this itemperature sensor it is taking 9-10 startup p[ulses to get  ACK (acknowledgement)

   

after that i am sending (0x07 which is a RAM adress of sensor ) here i am not getting ACK agian we need to send startup signal because of this it is keep on  in that loop only.

   

i've thought there might be problem with I2C clock .

   

how we can fix this?

   

and even how we can get desired clodk for I2C?

   

i amattaching my project and datasheet of sensor

   

 

   

Thanking you

   

V.Vishnu kumar

0 Likes
1 Solution
Anonymous
Not applicable

sorry file not uploaded

View solution in original post

0 Likes
29 Replies
Anonymous
Not applicable

sorry file not uploaded

View solution in original post

0 Likes
MR_41
Employee

The below code is not correct.  What you are doing is calling the bWriteBytes function again and again till the WR_COMPLETE flag is set.

while (!(I2CHW_bReadI2CStatus() & I2CHW_WR_COMPLETE))
{
   I2CHW_bWriteBytes(0x00, (char*)&ReadAddress, 2, I2CHW_CompleteXfer);   
   while(!(I2CHW_fSendStart(0x00, I2CHW_WRITE)))
   {
      I2CHW_SendStop();        // Send stop to terminate the previous interaction
   }
}

Inside the same loop, SendStop is being called as well.  This will totally mess up the transactions and will never let the Write transaction to complete.

Let me know what transaction you are trying to do with the sensor (reading from a particular location or writing to a particular location) and I will provide you with the code snippet.

Best Regards,
Ganesh
The PSoC Hacker

0 Likes
Anonymous
Not applicable

Hi sir thanks for the reply.

   

                Sir i  am trying to read temperature value which is available in RAM adress 0x07. now here i am including new modified c file and application note of the sensor. In this application note in page no 16 they provided a flowchart according that now i've written code. in this i am not getting any acknowledgement the sensor. Master device (PSoC) continuosly sending start signal.

   

            how we can change the I2C clock?

   

 

   

Thanks and regards

   

V.Vishnu Kumar
 

0 Likes
MR_41
Employee

I think there is no need to follow the flow chart as it is.  There should be no problem with the Slave sending an ACK to the Master's transactions.  So, you can use the high level APIs bWriteBytes and fReadBytes to write the command and read the temperature from the sensor.  I have modified the project to write a command 0x07 and read 3 bytes of data from the slave.  See if this works.  Try to understand how the high level APIs are used.  That will help you to implement other read/write operations with the slave successfully.

   

 

   

Best Regards,

   

Ganesh

   

The PSoC Hacker

0 Likes
Anonymous
Not applicable

hi sir

   

i've tested that code but i am not getting any thing. it is wending write signal and it is stoping. here i am including the output waveform which is obtained.

   

 

   

Thanks & Regards

   

V.Vishnu kumar 

0 Likes
Anonymous
Not applicable
    
         
  • MLX90614 uses SMBus instead of I2C interface. Please note that there are certain differences between I2C and SM Bus operation. I have successfully interfaced MLX90614 with PSoC3 using I2C module.
  •      
  • This sensor can give output in PWM form as well as SM Bus. The MLX90614’s SMBus needs a request to switch from PWM to SM Bus(By default on power up sensor gives PWM output). SMBus request condition requires forcing LOW the SCL pin for period longer than the request time 2 milli seconds . The Data line value is ignored in this case.
  •      
  • Once disabled  PWM,  it  can  be  only  enabled  by  switching  Off-On  of  the  supply  or  exit  from  Sleep Mode.  
  •     
   
0 Likes
MR_41
Employee

Without the hardware, it is very difficult to guess what the problem could be.  But I am sure you have to use the logic similar to the one I have used in the program.  Do some other debugging.  Check if the pull up resistors are fine on the SDA and SCL lines.  Try calling the fSendStart and SendStop functions continuously and check with the logic analyzier if the slave ever acknowledges the address.  If it does not, then there should be some other problem.

   

 

   

Best Regards,

   

Ganesh

   

The PSoC Hacker

0 Likes
Anonymous
Not applicable

hi .

   

i've interfaced same sensor with "MBED nxp LPC 1768" sucessfully. but coming to PSoC i am not getting the acknowledgement. even with MBED board also i am getting perfect output at 20khz I2C frequency only . if i chnaged the frequcny i am not getting the acknowledgment there. thats why i am trying to know how to change the I2C clock in PSoC.

   

here i am including MBED code also.

   

 

   

Thanks and Regards

   

V.Vishnu Kumar

0 Likes
Anonymous
Not applicable

sorry file uploaded is different here is the right one

   

 

   

thanks

   

V.Vishnu Kumar

0 Likes
MR_41
Employee

There is a parameter called I2C Clock in the I2CHW settings.  You can select 50KHz for I2C clock and try.  Also, first use only the fSendStart function repeatedly and see if you are getting an ACK from the slave.  Remove all other code and use the below code.

   

while(!(I2CHW_fSendStart(0x00, I2CHW_WRITE)))
{
    I2CHW_SendStop();        // Send stop to terminate the previous interaction
}
 

   

The above code will keep loopin till the slave issues an ACK.  Analyze this with the logic analyzer and let me know if you get an ACK at all.

   

 

   

Best Regards,

   

Ganesh

   

The PSoC Hacker

0 Likes
Anonymous
Not applicable

hi i've tried those settings which are available 50,100, 400 but no use.

   

the code line which you sent i've tried that this before , i am getting acknowledgment after 9 write operations (some  times).

   

is any other way to get custom clocl for I2C?

   

 

   

 

   

 

   

 

   

Thanks & Regards

   

V.Vishnu kumar

0 Likes
Anonymous
Not applicable

hi Mr. U2

   

  Can i get the details of your code which is developed on PSoC3. it might be useful for me to implement on PSoC1.

0 Likes
Anonymous
Not applicable

Please find attached the project that works on PSoC3 device with MLX90614. You might want to use PSoC Creator software to view the same. For your benefit i have attached the "main.c" file separately.

   

Please note that i was facing the issue that you are facing, that is no ACK from Slave(MLX sensor). I held the SDA line low for about 10ms and then started issuing I2C commands, it started working. You need this pulse to enter SMBUS operation.

0 Likes
Anonymous
Not applicable

Project is attached now.

0 Likes
Anonymous
Not applicable

Main.c if attached now.

0 Likes
Anonymous
Not applicable

hi

   

sorry for the delayed reply . first thanks for providing the details about your project. i ve tried that but i am unable to obtain output.

   

I have written a software I2c to get the results.i am able to get acknowledgement from sensor , but unfortunately the data which i am getting is not correct(while reading). always it is a fixed value.

   

 thanks & Regards

   

Vishnu

0 Likes
Anonymous
Not applicable

Upon power up the MLX90614 module will be reading the temperature data held in RAM address 0x07. There is a minimum 1 ms delay between each temperature reading. In the non-sleep operation mode the timing is adjustable from 1 to 2550 ms and can be set in the low data byte of the reading time interval command address (0x21). In the sleep operation mode the timing is adjustable from 1 to 255 seconds and can be set in the high data byte of the reading time interval command address (0x21). It takes approximately 1 ms to perform a temperature reading. Interval timing for non-sleep and sleep operation modes have been factory set at 50 ms and 1.15 seconds, respectively. 

   

   

Esure proper delays between read operation. Register 0x06 gives ambient temperature and register 0x07 gives object temperature. Try reading both registers to see the variation.

0 Likes
Anonymous
Not applicable

 Thanks for your code, it was really helpfull.

0 Likes
AnFa_301266
New Contributor II
0 Likes
AnFa_301266
New Contributor II
        Hi U2, ....... Please find attached the project that works on PSoC3 device with MLX90614. Just wanted to say that despite this being a pretty old post it worked very well for me as my first I2C experience when I ran it on a PSoC 5. I happened to be using the MLX90614 so had a bit of luck! Many thanks!   
0 Likes
AnFa_301266
New Contributor II
        PS Sorry about the formatting of the message above but IE only gives me a tiny box to type in and Chrome won't let me type anything - any clues? Thanks   
0 Likes
Bob_Marlowe
Expert II

Turn on the "Compatibility Mode" for Cypress.com, that will help with the small window.

   

 

   

Bob

0 Likes
AnFa_301266
New Contributor II

Thanks for the tip Bob!  Compatibility Mode works just fine! 

   

All the best,

0 Likes
Bob_Marlowe
Expert II

I suffered from this "small window" for three (3) months until I found out, so I know how you felt....

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi,

   

I am trying to interface MLX90614 with PSOC 4 BLE. With reference to above code I have made necessary changes, but I am not able to read the data. Can anyone please help me out.

   

This is my code

   

#include <project.h>
#include <stdio.h>
uint8 Ta_ToBar=0;
void Read_Temperature(void);
void print(uint8);
uint8 i;
uint8 rdBuf[10];
uint8 wrBuf[10];
//uint16 pec = 0; 
int main()
{
uint8 Uart_Data;
uint8 Uart_Data1;
//double tempFactor = 0.02; 
    // 0.02 degrees per LSB 
double tempData = 0x0000; 

   

//uint16 data_low = 0; 
//uint16 data_high = 0; 

   

 

   

CyGlobalIntEnable; 

   

I2C_1_EnableInt();
I2C_1_Start();

   


UART_1_Start();

   


 
 for(;;)
    {

   

    Read_Temperature();
       

   


    //This converts high and low bytes together and processes temperature, 
    //MSB is a error bit and is ignored for temps 
    // This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte. 
    //data_low = rdBuf[0];
    //data_high = rdBuf[1];
    //pec =  rdBuf[2];
    /*tempData = (double)(((data_high & 0x007F) << 😎 + data_low); 
    tempData = (tempData * tempFactor)-0.01; 
    tempData = tempData - 273.15; */
    //Uart_Data=(uint8)tempData; 
    //print(Uart_Data);
    Uart_Data=(uint8)rdBuf[0]; 
    Uart_Data1=(uint8)rdBuf[1];
    UART_1_UartPutString("data available");
    UART_1_UartPutString("rdbuf0");
    UART_1_UartPutChar(Uart_Data);
    UART_1_UartPutString("rdbuf1");
    UART_1_UartPutChar(Uart_Data1);
    
    
    tempData=tempData-(int)tempData; 

   

    
    
        
    }
}

   


void Read_Temperature(void)
{
 I2C_1_I2CMasterWriteBuf(0x5A,wrBuf,2,1);
CyDelay(1);
I2C_1_I2CMasterReadBuf(0x5A,rdBuf,3,1);

   

CyDelay(1);
I2C_1_I2CMasterSendStop(); 

   


}

   

 

   

Regards,

   

Likhitha

0 Likes
Bob_Marlowe
Expert II

Welcome in the forum, Likhitha.

   

You are a bit wrong here, this is a PSoC1 forum and you have got a PSoC4 or PSoC4 BLE problem. It can turn out that none of the guys that have the knowledge read your post.

   

Can you post your complete project, so that we all can have a look at all of your settings? Makes it much easier to find the cause. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

   

Attcahed is my complete project. 

0 Likes
Bob_Marlowe
Expert II

Some comments on I2C.

   

Use pins P5_0 and P5_1 for I2C. Pullups are already installed. The P3 pins are connected to the KitProg on the board.

   

A delay after read and write I2C is not needed

   

Don not send an additional stop() command.

   

The WriteBuf() function returns a status, check that for a successful transfer before reading.

   

Comments on UART

   

Use pins P1_5 and P1_4 for UART.  These are connected to the Kitprog which will act as an USB-UART bridge emulating a com-port on the windows side. You will see that com-port in windows device manager. Connect PuTTY with the correct baud rate to that port.

   

You are sending binary data (int, uint) to UART, these are not printable. Use sprintf() to convert the data to strings and send the string over UART. under Project->Build settings-> linker is an item to allow for float formatting, use that when memory usage allows. In .cdwr view, system tab increase the heap size to at least 0x0100,

   

 

   

Bob

0 Likes
ETRO_SSN583
Esteemed Contributor

Formatting string help for printf, sprintf, attached.

   

 

   

Regards, Dana.

0 Likes