CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Melexis 90615 connection problem
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
prixsecco



Joined: 18 Dec 2011
Posts: 26

View user's profile Send private message

Melexis 90615 connection problem
PostPosted: Sun Dec 18, 2011 12:28 pm     Reply with quote

Hello

I have problems with connection to my IR-Sensor.
Data Sheet see here: http://www.melexis.com/Assets/IR-sensor-thermometer-MLX90615-Datasheet-5477.aspx

I always get back a "0" (=DATA).

Used code is this:


Code:

#include <18F4550.h>

#fuses hs
#use delay(crystal = 20000000)

#use i2c(master, smbus, SCL=PIN_C7,SDA=PIN_C0) //slave,smbus, sda=C0 , scl=C5
#use rs232 (baud = 9600, xmit = pin_c6, rcv = pin_c4, bits=8)


void main(){



while(1)
{



i2c_start();    // Start condition
delay_ms(20);
i2c_write(0xB6); // Slave Address - write bit low - the '1' here is the bit number in the diagram, _not_ the value.... [0x5A<<1]
delay_ms(20);
i2c_write(0x07); // Register address
delay_ms(20);
I2C_start();    //Restart the bus
i2c_write(0xB7); // Slave Address - write bit high for a read (to change data direction)



         DATA = i2c_read();
         DATA1 = i2c_read();
         DATA2 = i2c_read(0); //You need to _NACK_ the last byte
    i2c_stop();
      delay_ms(20);
      printf("\n\rDATA: ");
      printf("\n%4u",DATA);

}

}


Hope anyone can help me...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 2:57 pm     Reply with quote

Is the PIC running at +5v ? I would assume so, because you didn't say
you were using the "LF" version which can run at +3.3v.

The Melexis chip must not be run at +5v. The data sheet says +3.6v
is the maximum operating voltage. What voltage are you using for it ?

The i2c bus (or SMbus) must have pullup resistors on it. The pullups
should be connected to the same Vdd voltage as the Melexis chip uses.
Assuming your Melexis Vdd is +3.3v, you could use 3.3K resistors for the
pullups. (or 4.7K would be OK).

On page 6 of the MLX90615 data sheet, it says the output is typically valid
0.5 seconds after power-on reset. To be safe, you should have a delay
of lets say, 750 ms, at the beginning of main().

Quote:
#use i2c(master, smbus, SCL=PIN_C7,SDA=PIN_C0) //slave,smbus, sda=C0 , scl=C5

Your comment does not match the #use statement pins. Also, you are
not using the hardware pins, so the SMBUS parameter has no effect.
But you should not use the hardware i2c module, because it requires
Schmitt Trigger input levels, which are +4.0v for a PIC running at +5v.
Your pullups should not exceed +3.6v, so Schmitt Trigger inputs are not
appropriate for this design. Use TTL-level PIC input pins. Which means
you can't use Port C pins for this design. You have to use Port B for the
i2c bus. It's the only one that has TTL levels on its i/o pins.
(Note: Pins C4 and C5 are TTL, but they are input-only pins, and not i/o).

Your code that talks to the Melexis chip should be made into callable
functions. That's the best way to write a device driver. Currently you
are using inline code.

Also, I don't know your skill level, so I will add the following:
- SDA on the PIC must connect to SDA on the Melexis chip.
- SCL must go to SCL.
- There must be a ground connection between the PIC and the Melexis chip.
prixsecco



Joined: 18 Dec 2011
Posts: 26

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 3:32 pm     Reply with quote

Thanks for your fast and detailed answer.

I'm using 4.7k pullup-resistors. VDD Voltage is set to +3.3V.

Do i have to set VDD Voltage to +5.0 V? And do i need a voltage divider if using +5.0 V power supply because of the maximum voltage of 3.3V for the Melexis Sensor?

I tried several PIN connections, so you can ignore my comment you were talking...
Isn't SCL hardwired on PIN C7?

What i haven't understand is the connection at all. So i have to use Port B for the I2C connection? Some specific PINs of Port B?

I connected the Melexis Chip to the PIC as shown in figure 18 (page 21) at data sheet.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 4:00 pm     Reply with quote

Quote:
VDD Voltage is set to +3.3V.

Are you referring to the PIC or the Melexis chip ?


Quote:
Do i have to set VDD Voltage to +5.0 V?

According the the 18F4550 data sheet, in the Electrical Specifications
section, the "F" version of the PIC requires a minimum Vdd voltage of 4.2v.
It's possible that it will work at 3.3v for hobby testing purposes, but I
never do that, so I have no experience with it.

Quote:
Some specific PINs of Port B?

Use any PortB pins except B6 and B7. Those pins are used for the ICD
programmer/debugger. You could use B0 for SDA and B1 for SCL.

For better help, post your CCS compiler version.
prixsecco



Joined: 18 Dec 2011
Posts: 26

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 4:33 pm     Reply with quote

According to the VDD voltage setting, i mean the PIC. (vdd voltage setting in MPLAB)


I'm using ccsc v. 4.3.0.285


Okay i will connect the sensor as you said on Port B and will change VDD to +5.0V. But do i need a voltage divider than? Or thus the 4.7k pullup resistors are protection enough for the sensor?


Last edited by prixsecco on Sun Dec 18, 2011 4:42 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 4:38 pm     Reply with quote

The 4.7K pullup resistors should be connected to +3.3v. That's high
enough to work with TTL-level inputs, such as pins B0 and B1. The PIC
can run at +5v. The pullups and the Melexis chip can run at +3.3v.
It will all work.


Quote:
vdd voltage setting in MPLAB

What does this mean ? Are you providing power to the board from the
ICD ? If so, do you have any method of providing +5v for the PIC, and
+3.3v for the pullups and the Melexis chip ?
prixsecco



Joined: 18 Dec 2011
Posts: 26

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 4:47 pm     Reply with quote

The board is powered by the PICKIT 2.
Simmiliar to this:
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 5:19 pm     Reply with quote

That means everything has to run at the same voltage. You don't have
a separate regulator on the board.

I tested the 18F4550 just now, while running it at 3.3v with a 20 MHz
crystal and it works, at least at room temperature. So use 3.3v on the
Pickit 2. Run both chips at 3.3v.
prixsecco



Joined: 18 Dec 2011
Posts: 26

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 5:23 pm     Reply with quote

Okay thanks for today. Your are great.
I will try it tomorrow and let you know than.
prixsecco



Joined: 18 Dec 2011
Posts: 26

View user's profile Send private message

PostPosted: Mon Dec 19, 2011 1:44 am     Reply with quote

I changed the hardware connection and PIN definition in program code but now I get nothing out on Hyperterminal.
Whats the problem?
prixsecco



Joined: 18 Dec 2011
Posts: 26

View user's profile Send private message

PostPosted: Mon Jan 09, 2012 1:07 am     Reply with quote

Any idea??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 09, 2012 1:27 am     Reply with quote

Yes, run this i2c bus scanner program and see if it finds the Melexis chip:
http://www.ccsinfo.com/forum/viewtopic.php?t=42368&start=4
You need to modify the program slightly to make it work with your
hardware. Change the #include for the PIC, and the #fuses, and the
#use delay(). Edit the #use i2c() statement so it uses your i2c pins.
Also edit the #use rs232() statement so it uses your pins.
prixsecco



Joined: 18 Dec 2011
Posts: 26

View user's profile Send private message

PostPosted: Mon Jan 09, 2012 1:54 am     Reply with quote

Okey thank you. I tried it with the Melexis 90615 sensor. Nothing!
On Hyperterminal only "Start:" appears.
No True or False. ?!?

I tried it with another known working i2c sensor (not the Melexis 90615) and there I get a result.
(...1 chip found...)

Is the sensor dead? Or whats the problem?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 09, 2012 12:48 pm     Reply with quote

Are you certain that you have the Melexis chip connected correctly ?
The pin diagram shown on page 1 of the data sheet is a Top view.
But the diagram on page 5 is a Bottom view of the pins.

Are you sure that you wired it correctly ? Did you ever wire it
incorrectly, so that Vss and Vdd are reversed ? If so, you probably
destroyed the chip.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Jan 09, 2012 1:22 pm     Reply with quote

my 2 cents

with a compiler update
you may find the 18F45K20
to be of some help as well
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group