View previous topic :: View next topic |
Author |
Message |
soymoe
Joined: 04 Aug 2014 Posts: 13
|
|
Posted: Fri Sep 12, 2014 2:39 pm |
|
|
This is my code:
Code: | ///Slave Select: pin_b0
///data in: pin_b1
//clock: pin_b4
///
///
///
#include <16F88.h>
#device adc=16
#FUSES NOWDT // No Watch Dog Timer
#FUSES INTRC_IO // >>> Oscilador interno, no CLKOUT
#FUSES PUT // Power Up Timer
#FUSES NOMCLR // Master Clear pin used for I/O
#FUSES NOBROWNOUT // Reset when brownout detected
#FUSES PROTECT // Code not protected from reading
#FUSES NOCPD // No EE protection
int8 TempBin=15;
#use delay(int=8000000) // Especifica al compilador que hace uso del OSC interno
//#USE SPI (MASTER, SPI1, CLOCK_HIGH=100, CLOCK_LOW=100, MODE=0, LOAD_ACTIVE=1, ENABLE_ACTIVE=0, STREAM=SPI_1, MSB_FIRST,FORCE_HW)
#use rs232(baud=9600, xmit=PIN_B5,rcv=PIN_B3,bits=8, parity=N))
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
#define SS PIN_B0
int8 spival[4];
int16 Temp=25;
int1 Error=0;
/*******************************************************************************
//Read SPI data
*******************************************************************************/
void readMAX()
{
output_low(SS);
delay_us(10);
spival[3]=spi_read(0);
spival[2]=spi_read(0);
spival[1]=spi_read(0);
spival[0]=spi_read(0);
delay_us(10);
output_high(SS);
}
/*******************************************************************************
//Fault detection.
//Returns >0 if FAULT. If necessary do a bitwise analisys to check fault source
*******************************************************************************/
int tempFault()
{
int1 Fvdd=0,Fgnd=0,Fopen=0,fault=0;
fault=spival[2]&0x01; // pelos menos uma falha
Fvdd=(spival[0]>>2)&0x01;
Fgnd=(spival[0]>>1)&0x01;
Fopen=spival[0]&0x01;
return (fault*1+Fvdd*2,Fgnd*4,Fopen*8);
}
/*******************************************************************************
//Read thermocouple temperature
//Returns returns signed temperature in ºC approximately
*******************************************************************************/
int16 readExtTemp()
{
int8 aux;
int16 temp1;
aux=spival[2]>>2;
temp1=spival[3];
temp1<<=6;
temp1+=aux;
return temp1/=4;
}
/*******************************************************************************
//Read internal temperature
//Returns returns signed temperature in ºC approximately
*******************************************************************************/
int16 readIntTemp()
{
int8 aux;
int16 temp2;
temp2=spival[1];
temp2<<=4;
aux=spival[0]>>4;
temp2=spival[1]<<4;
temp2+=aux;
return temp2/=16;
}
void main()
{
setup_oscillator(OSC_8MHZ|OSC_INTRC);
setup_spi(SPI_MASTER | SPI_MODE_1 | SPI_CLK_DIV_64);
setup_comparator(NC_NC_NC_NC);
//set_tris_b(0xfB);
delay_ms(500);
while(TRUE)
{
do{
readMAX();
}while(tempFault()!=0);
printf("\n\n Thermocouple: %Ld, Ambient: %Ld\n\r",readExtTemp(),readIntTemp());
delay_ms(500);
}
} |
|
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Fri Sep 12, 2014 2:45 pm |
|
|
soymoe wrote: |
may be max31855 was destroyed for over voltage |
Hi,
I probably shouldn't mention this because it's *not* a solution to your problem, but it's doubtful that your MAX31855 was damaged by any overvoltage. I say that because at my company we had a couple of prototype instruments, and a large number pre-production instruments slip by with the MAX31855 powered at 5V! I noticed the problem during a design review prior to going into full scale production of this instrument. The circuit designer (not me) claimed that the performance of the chip was fine at 5V, and I never observed a performance problem. Of course, when the oversight was discovered, we quickly redesigned our circuit to include a level translator.....
John |
|
|
soymoe
Joined: 04 Aug 2014 Posts: 13
|
|
Posted: Fri Sep 12, 2014 2:56 pm |
|
|
I stay calmer then, thank you. I powered The pic microcontroller which 3.3v from max 31855 power regulator and seems to work, the pic microcontroller write the serial port, but dont show temperature.
Subido en subir imagenes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9291 Location: Greensville,Ontario
|
|
Posted: Fri Sep 12, 2014 2:59 pm |
|
|
You should post your current program as the data in the 'screen shot' is not what I'd expect from your code a couple messages ago.
jay |
|
|
soymoe
Joined: 04 Aug 2014 Posts: 13
|
|
Posted: Fri Sep 12, 2014 4:09 pm |
|
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Sep 12, 2014 4:25 pm |
|
|
1. Post a list of your connections between the PIC and the MAX31855.
2. Also, the MAX31855 data sheet has an SPI timing diagram on Page 5.
It shows the data being clocked out of the MAX31855 on the negative
edge and apparently sampled by the microcontroller on the rising edge
of SCK. This is actually Mode 0. Try using SPI Mode 0 and see if you
get better results. |
|
|
soymoe
Joined: 04 Aug 2014 Posts: 13
|
|
Posted: Sat Sep 13, 2014 3:16 pm |
|
|
This is my circuit:
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9291 Location: Greensville,Ontario
|
|
Posted: Sat Sep 13, 2014 5:01 pm |
|
|
The 16F88 datasheet says it's only supposed to work down to 4 volts. You _might_ be lucky and have it working at 3 BUT it will NOT be reliable. Some peripherals may work sometimes, maybe not,especially during 'transitions' or 'heavy' current demands.
Now the 16LF88 WILL work 100% at 3 volts and should be used.
jay |
|
|
soymoe
Joined: 04 Aug 2014 Posts: 13
|
|
Posted: Sat Sep 13, 2014 6:05 pm |
|
|
I will energize the pic microcontroller with 5v and place the resistors to lower the voltage on the control pins |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Sep 13, 2014 6:14 pm |
|
|
If you still try to use hardware SPI, it won't work. The 3.3v levels coming
from the SDO pin on the MAX31855 to the PIC's SDI pin, are too low for
it work. The hardware SDI pin on the PIC requires an input high level
of at least 4.0 volts, when the PIC runs a 5v.
To fix this, you need to add a 74HCT125 buffer between the SDO pin
on the MAX31855 and the SDI pin on the PIC. This chip will take 3.3v
logic levels from the MAX31855 and shift them up to the 5.0v logic levels
required by the PIC's hardware SDI input pin.
This is the schematic of the 74HCT125. Only use that chip. Don't use
the "HC" chip. It must be HCT (or AHCT). Only 1/4 section of the
74HCT125 is used. The other 3 sections are not used.
Code: |
+5v
|
|Vdd
To SDI /-|
pin ----< |------- From DO pin on
on PIC \-| MAX31855
|OE
|
_|_
\ / Ground
-
|
You will still need the resistor voltage divider's going to SCK and \CS
on the 31855. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sun Sep 14, 2014 8:43 am |
|
|
Wait a sec...
I did a MAX31855 project (connected to a PIC18F97J60) -- which runs entirely on +3.3. Why?
I just double-checked the datasheet for the MAX...
The MAX31855 has a max of +4V -- and it's being powered at +5?
I dunno --- exceed the max ratings of the datasheets max voltage and I would say without an oscilloscope, how can you know any of the circuit is still working.
I would *assume* this project to have smoked parts until verified otherwise. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9291 Location: Greensville,Ontario
|
|
Posted: Sun Sep 14, 2014 10:31 am |
|
|
Some chips are more 'tolerant' of 'high' voltages...for awhile ....then the 'magic smoke' seems to come out !
I have, in the past installed 16C84s the wrong way,then reinstalled correctly and they've worked fine !!
But the EASY,SIMPLE, 100% will work solution to this project is to use a 3V PIC (LF version) when using a 3V device.
For the amount of R&D time wasted in debugging the hardware, the OP could have bought a tube full of 3V PICs and had the project completed.
jay |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sun Sep 14, 2014 11:44 am |
|
|
temtronic wrote: | Some chips are more 'tolerant' of 'high' voltages...for awhile ....then the 'magic smoke' seems to come out !
|
But the smoke doesn't need to come out to damage a chip.
Unless the OP has verified communication (with a scope) to the chip, I would assume at this point the chip is dead.
it may not be -- but without validation of signalling.. "it doesn't work. help me." cannot move forward without that validation.
*I* would not spend another moment analyzing the OP's problem without that validation.
Quote: |
I have, in the past installed 16C84s the wrong way,then reinstalled correctly and they've worked fine !!
|
You got lucky -- in the sense that the amount of current available wasn't enough to smoke the chip!
I had a client with a newly proto'd board that was dragging down a +3.3V rail -- couldn't figure out why. I asked him if he had any caps plugged in backwards - sure enough a tantalum was in reversed.... but the design of the 3.3V rail didn't supply enough current to smoke it.
Quote: |
But the EASY,SIMPLE, 100% will work solution to this project is to use a 3V PIC (LF version) when using a 3V device.
For the amount of R&D time wasted in debugging the hardware, the OP could have bought a tube full of 3V PICs and had the project completed.
|
Amen to that! _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
soymoe
Joined: 04 Aug 2014 Posts: 13
|
|
Posted: Sun Sep 14, 2014 6:29 pm |
|
|
I have another chip to try. Thanks for the advice, I will modify the circuit with the recommendations they made me, but I'll have to buy the buffer and do not know if I'll get in the store |
|
|
|