View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 27, 2012 1:31 pm |
|
|
1. Run the "ack test" again (discussed on page 1 of this thread). See if
it can find your sensor chip. Post the addresses that it reports.
2. Post your current test program for the sensor chip. Don't just say
"I'm using Lewcocks code". Post the program you are using. |
|
|
prixsecco
Joined: 18 Dec 2011 Posts: 26
|
|
Posted: Fri Jan 27, 2012 2:29 pm |
|
|
Okey here's the result from the scan:
Code: |
Start:
ACK addr: 10 ACK addr: 12 ACK addr: 14 ACK addr: 16 ACK addr: 18
ACK addr: 1A ACK addr: 1C ACK addr: 1E ACK addr: 20 ACK addr: 22
ACK addr: 24 ACK addr: 26 ACK addr: 28 ACK addr: 2A ACK addr: 2C
ACK addr: 2E ACK addr: 30 ACK addr: 32 ACK addr: 34 ACK addr: 36
ACK addr: 38 ACK addr: 3A ACK addr: 3C ACK addr: 3E ACK addr: 40
ACK addr: 42 ACK addr: 44 ACK addr: 46 ACK addr: 48 ACK addr: 4A
ACK addr: 4C ACK addr: 4E ACK addr: 50 ACK addr: 52 ACK addr: 54
ACK addr: 56 ACK addr: 58 ACK addr: 5A ACK addr: 5C ACK addr: 5E
ACK addr: 60 ACK addr: 62 ACK addr: 64 ACK addr: 66 ACK addr: 68
ACK addr: 6A ACK addr: 6C ACK addr: 6E ACK addr: 70 ACK addr: 72
ACK addr: 74 ACK addr: 76 ACK addr: 78 ACK addr: 7A ACK addr: 7C
ACK addr: 7E ACK addr: 80 ACK addr: 82 ACK addr: 84 ACK addr: 86
ACK addr: 88 ACK addr: 8A ACK addr: 8C ACK addr: 8E ACK addr: 90
ACK addr: 92 ACK addr: 94 ACK addr: 96 ACK addr: 98 ACK addr: 9A
ACK addr: 9C ACK addr: 9E ACK addr: A0 ACK addr: A2 ACK addr: A4
ACK addr: A6 ACK addr: A8 ACK addr: AA ACK addr: AC ACK addr: AE
ACK addr: B0 ACK addr: B2 ACK addr: B4 ACK addr: B6 ACK addr: B8
ACK addr: BA ACK addr: BC ACK addr: BE ACK addr: C0 ACK addr: C2
ACK addr: C4 ACK addr: C6 ACK addr: C8 ACK addr: CA ACK addr: CC
ACK addr: CE ACK addr: D0 ACK addr: D2 ACK addr: D4 ACK addr: D6
ACK addr: D8 ACK addr: DA ACK addr: DC ACK addr: DE ACK addr: E0
ACK addr: E2 ACK addr: E4 ACK addr: E6 ACK addr: E8 ACK addr: EA
ACK addr: EC ACK addr: EE
Found 112 chips |
And here the code I'm using for the MLX90615:
Main.c
Code: |
//This is the main programm
#include <18f4550_modified.h>
#include <MLX90615.c> //includes written methods
float T_Device,T_Object; //Declaration
int i = 0;
void main()
{
while(true){
Delay_ms (1000);
Delay_ms(10);
T_Device = MLX90615_Read_Device_Temp(0x5B); //give slave adress to method, returns device temperature
Delay_ms(10);
T_Object = MLX90615_Read_Object_Temp(0x5B); //give slave adress to method, returns object temperature
Delay_ms(10);
printf ("OBJECT TEMPERATURE");
printf ("TempLSB_obj = %4u\n\r",TempLSB_obj);
printf ("TempMSB_obj = %4u\n\r",TempMSB_obj);
printf ("TempRAW_obj = %3.2lu\n\r",TempRAW_obj);
printf ("Object Temperature = %3.2f\n\r",T_Object);
printf ("Device TEMPERATURE");
printf ("TempLSB_dev = %4u\n\r",TempLSB_dev);
printf ("TempMSB_dev = %4u\n\r",TempMSB_dev);
printf ("TempRAW_dev = %3.2lu\n\r",TempRAW_dev);
printf ("Device Temperature = %3.2f\n\r",T_Device);
printf("Time %3u\n\r",i);
i++;
}
}
|
And here the included MLX90615.c file: Code: |
//This File contains the used methods
//Declaration
int8 TempLSB_dev,TempLSB_obj,TempMSB_dev, TempMSB_obj, PEC;
int16 TempRAW_dev, TempRAW_obj;
float Temperature_dev, Temperature_obj;
//Start Config.
#fuses hs
#use delay(crystal = 20000000)
#use rs232 (baud = 9600, xmit = pin_c6, rcv = pin_c7, bits=8)
#use i2c(SMBUS, SCL=PIN_b1, SDA=PIN_b0)
//Method 1. Read Device Temperature
float MLX90615_Read_Device_Temp(int8 Address)
{
TempLSB_dev=0; //Clear variables
TempMSB_dev=0; //Clear variables
TempRAW_dev=0; //Clear variables
i2c_start(); // Start condition
i2c_write(Address*2); // (Slave Address << 1) For R/W bit low for a write; Adress in Main is 0x5B; 1 Bit-shifted left = 0xB6
i2c_write(0x26); // Device Temp Register address; shouldn't it be 0x06?
i2c_start(); // Restart the bus
i2c_write((Address*2)+1); // (Slave Address << 1 + 1) - R/W bit high for a read; Adress in Main is 0x5B; 1 Bit-shifted left + 1 = 0xB7
TempLSB_dev = i2c_read(); // Read LSB of device temp from register
TempMSB_dev = i2c_read(); // Read MSB of device temp from register
PEC = i2c_read(0); // Read PEC
i2c_stop();
TempRAW_dev = ((int16)TempMSB_dev << 8 ) | TempLSB_dev; // Make 16bit TempRAW from 2 8bit reads
Temperature_dev = ((TempRAW_dev * 0.02) - 273.15); // Calculate Device Temperature in Celsius from Kelvin
return(Temperature_dev); //return the temp. for use in Main
}
//Method 2. Read Object Temperature
float MLX90615_Read_Object_Temp(int8 Address)
{
TempLSB_obj=0; //Clear variables
TempMSB_obj=0; //Clear variables
TempRAW_obj=0; //Clear variables
i2c_start(); // Start condition
i2c_write(Address<<1); // (Slave Address << 1) For R/W bit low for a write; Adress in Main is 0x5B; 1 Bit-shifted left = 0xB6
i2c_write(0x27); // Object Temp Register address
i2c_start(); // Restart the bus
i2c_write((Address<<1)+1); // (Slave Address << 1 + 1) - R/W bit high for a read; Adress in Main is 0x5B; 1 Bit-shifted left + 1 = 0xB7
TempLSB_obj = i2c_read(); // Read LSB of object temp from register (8 Bit)
TempMSB_obj = i2c_read(); // Read MSB of object temp from register (8 Bit)
PEC = i2c_read(0); // Read PEC (8 Bit)
i2c_stop();
TempRAW_obj = ( (int16)TempMSB_obj << 8 ) | TempLSB_obj;
Temperature_obj = ((TempRAW_obj * 0.02) - 273.15); // Calculate Object Temperature
return(Temperature_obj);
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 27, 2012 2:43 pm |
|
|
It found 112 chips ? It should have found one. There is something
seriously wrong with the hardware, or maybe with your modifications to
the Ack Test program. |
|
|
prixsecco
Joined: 18 Dec 2011 Posts: 26
|
|
Posted: Fri Jan 27, 2012 3:06 pm |
|
|
The ACK Test program is just modified in the pin settings for SCL and SDA.
A Hardware problem of the PIC evaluation board?
Or the connection from the sensor to the board? (I will try it with another board, just a moment...)
Just to know, I've connected the sensor as follows:
SDA via resistor to +3.3V; and directly to PIN B0 on PIC
SCL via resistor to +3.3V; and directly to BIN B1 on PIC
VSS directly to GND
VDD via condensator to GND; and directly to +3.3V |
|
|
prixsecco
Joined: 18 Dec 2011 Posts: 26
|
|
Posted: Fri Jan 27, 2012 3:17 pm |
|
|
[quote](I will try it with another board, just a moment...)[/qoute]
Also with another evaluationboard (PIC18F4550), 112 chips found. :-(
Last edited by prixsecco on Fri Jan 27, 2012 3:18 pm; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Jan 27, 2012 3:18 pm |
|
|
Are you absolutely sure you can run the 3v device on a 5v PIC ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Jan 27, 2012 3:22 pm |
|
|
PIC18F4550 [D041]MINIMUM VIH is .7 * Vdd ( .7 * 5) = 3.5 volts. |
|
|
prixsecco
Joined: 18 Dec 2011 Posts: 26
|
|
Posted: Fri Jan 27, 2012 3:24 pm |
|
|
Quote: | 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. |
Yeah i know that the PIC normally run with 5.0V but MPLAB can connect to it also with 3.3 V power setting. (PIC18F4550 found).
I will try it with a PIC which supports 3.3V supply. Just haven't got one at home so have to wait till Monday. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 27, 2012 3:42 pm |
|
|
temtronic,
He didn't specify FORCE_HW in his #use i2c() statement. Therefore, the
compiler generates code for software i2c, and it doesn't turn on the H/W
i2c module. The pins remain as ordinary i/o pins. In the Overview
section of the 18F4550 data sheet, it says that ordinary i/o pins use TTL
levels. The Vih for TTL is 2.0v, according to the Electrical Characteristics
section of the PIC data sheet. Therefore, pull-ups going to +3.3v will
work perfectly with software i2c. No problem at all. |
|
|
prixsecco
Joined: 18 Dec 2011 Posts: 26
|
|
Posted: Fri Jan 27, 2012 3:44 pm |
|
|
Quote: | PIC18F4550 [D041]MINIMUM VIH is .7 * Vdd ( .7 * 5) = 3.5 volts. |
Have i understand it right, 3.5 volts is the minimum supply voltage for the PIC18F4550 or does it mean the input level on pins have to be at a minimum of 3.5V ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 27, 2012 3:59 pm |
|
|
It means the input levels for the pins, when using hardware i2c.
The supply voltage is shown in graphs at the beginning of the Electrical
Characteristics section. It shows what voltage is required for each
oscillator frequency of the PIC. |
|
|
prixsecco
Joined: 18 Dec 2011 Posts: 26
|
|
Posted: Fri Jan 27, 2012 4:32 pm |
|
|
Ok the PIC can't work with 3.3V. I haven't got the LF version.
I changed power supply to +5V and used a Zener diode to regulate the VDD voltage for the sensor to +3.3 V.
But i get the same result as before. (112 chips, values all "0"). |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 27, 2012 4:35 pm |
|
|
Post the Ack Test program you are using.
And post your 4-digit (only) compiler version. It's at the top of the .LST file. |
|
|
prixsecco
Joined: 18 Dec 2011 Posts: 26
|
|
Posted: Fri Jan 27, 2012 4:47 pm |
|
|
The ACK test program I'm using:
Code: | #include <18f4550.h>
#fuses hs
#use delay(crystal = 20000000)
#use i2c(master, SCL=PIN_b1, SDA=PIN_b0)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
// This function writes the slave address to the i2c bus.
// If a slave chip is at that address, it should respond to
// this with an "ACK". This function returns TRUE if an
// ACK was found. Otherwise it returns FALSE.
int8 get_ack_status(int8 address)
{
int8 status;
i2c_start();
status = i2c_write(address); // Status = 0 if got an ACK
i2c_stop();
if(status == 0)
return(TRUE);
else
return(FALSE);
}
//=================================
void main()
{
int8 i;
int8 status;
int8 count = 0;
printf("Start:\n\r");
delay_ms(1000);
// Try all slave addresses from 0x10 to 0xEF.
// See if we get a response from any slaves
// that may be on the i2c bus.
for(i=0x10; i < 0xF0; i+=2)
{
status = get_ack_status(i);
if(status == TRUE)
{
printf("ACK addr: %X", i);
count++;
delay_ms(2000);
}
}
if(count == 0)
printf("\n\rNothing Found");
else
printf("\n\rFound %u chips", count);
while(1);
} |
Compiler: CCS PCH C Compiler, Version 4.109 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 27, 2012 5:38 pm |
|
|
I can't work on this anymore today. |
|
|
|