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

MAX6675

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
ALI_726



Joined: 15 Aug 2012
Posts: 4
Location: Pakistan

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

MAX6675
PostPosted: Wed Aug 15, 2012 4:20 am     Reply with quote

hi i am sending this original code for max6675 Enjoy.....!
just copy and paste this code in to the editor

Code:
#include <18F452.h>
#device adc=10
#FUSES NOWDT, WDT128, HS, NOPROTECT, NOOSCSEN, BROWNOUT, BORV45, PUT, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#define TC_CLK    PIN_B0
#define TC_CS     PIN_B1
#define TC_DATA   PIN_B2



   int1 thermocouple_error;    //a handy dandy global error flag to
                               //tell you if a thermocouple is connected or not
   int16 data;
   char msg[32];
   
void init_TC(void)
{
   output_low(TC_CLK);
   output_low(TC_DATA);
   output_high(TC_CS);            //if we idle high, the chip keeps doing conversions. Change this if you like
}

int16 read_TC(void)               //It takes 200ms (ish) for the MAX6675 to perform a conversion
{
   int8 i;

   output_low(TC_CS);            //stop any conversion processes
   for (i=0;i<16;i++){
   
      output_high(TC_CLK);
      output_low(TC_CLK);
      shift_left(&data,2,input(TC_DATA));      //reads in 2 bytes to data from the pin TC_DATA
       
   }

   thermocouple_error = bit_test(data,2);      //this is the thermocouple status bit
       
   output_high(TC_CS);
   return(data);
}

int16 sortout(int16 raw)
{
    return(0x0FFF & (raw>>3));      //returns only the bits converning temperature
}

float toFloat_TC(int16 tmp)
{
   return((float)tmp/4.0);      //adjusts data to floating point format, and accounts for the decimal point
}

float do_everything(void)
{
   init_TC(); 
   return(toFloat_TC(sortout(read_TC())));
}
 

void main()
{
   
   port_b_pullups(TRUE);
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   
   while(TRUE){
      delay_ms(800);
      sprintf(msg,"%01.2f%cC\r\n",do_everything(),0xB0);
       
      if(thermocouple_error)
         printf("Thermocouple not connected\r\n");   
      else
         printf("%s",msg);
   }
}


compile this code and Enjoy...!
jruibarroso



Joined: 07 Jan 2006
Posts: 64
Location: Braga

View user's profile Send private message Send e-mail MSN Messenger

code for MAX31855
PostPosted: Thu Aug 16, 2012 4:23 am     Reply with quote

Hi, i'm searching long time for code (driver) for MAX31855 that is very like this MAX6675 , can you please design a code to control MAX31855 ?

thank you very much
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

Re: code for MAX31855
PostPosted: Sat Aug 18, 2012 2:45 am     Reply with quote

jruibarroso wrote:
Hi, i'm searching long time for code (driver) for MAX31855 that is very like this MAX6675 , can you please design a code to control MAX31855 ?


I don't think you'll find anyone to do your work for you.

Why not just take this driver, modify it as needed and be thankful most of the work was already done for you?

I've written drivers for the 31855... and it's not that hard.

Cheers,

-Ben

p.s. No. I can't give you the code since it was written for a client.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
jruibarroso



Joined: 07 Jan 2006
Posts: 64
Location: Braga

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Fri Aug 24, 2012 9:13 am     Reply with quote

Thank you so much for your reply and I understand your reasons.
My problem is that I don't have enough knowledge to design a driver for this IC, so my "cry for help Very Happy "
Anyway, if you find something may help me, please let me know.

Greetings
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Aug 24, 2012 9:43 am     Reply with quote

jruibarroso wrote:
Thank you so much for your reply and I understand your reasons.
My problem is that I don't have enough knowledge design a driver for this IC, so my "cry for help Very Happy "
Anyway, if you find something may help me, please let me know.


That's the joy of learning! I'm assuming you're a student...

If you work at a company, I'm sure there are many here willing to write such a driver for you as a contractor.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
ALI_726



Joined: 15 Aug 2012
Posts: 4
Location: Pakistan

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Sat Aug 25, 2012 3:26 am     Reply with quote

jruibarroso wrote:
Thank you so much for your reply and I understand your reasons.
My problem is that I don't have enough knowledge to design a driver for this IC, so my "cry for help Very Happy "
Anyway, if you find something may help me, please let me know.

Greetings


dear don't worrry, I write the code for students and others. Also your code is almost ready, within a few days it will be on forum.
ALI_726



Joined: 15 Aug 2012
Posts: 4
Location: Pakistan

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

driver for MAX31855
PostPosted: Mon Aug 27, 2012 5:07 am     Reply with quote

jruibarroso wrote:
Thank you so much for your reply and I understand your reasons.
My problem is that I don't have enough knowledge to design a driver for this IC, so my "cry for help Very Happy "
Anyway, if you find something may help me, please let me know.

Greetings


hello dear this is driver for you.........!
Code:

#include <18F452.h>
#device adc=10
#FUSES NOWDT, WDT128, HS, NOPROTECT, NOOSCSEN, BROWNOUT, BORV45, PUT, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#define TC_CLK    PIN_E0
#define TC_CS     PIN_E1
#define TC_DATA   PIN_E2

   int1 thermocouple_error,Short_to_Gnd,Short_to_Vcc,Open_Circuit;   
   //a handy dandy global error flag to
   //tell you if a thermocouple is connected or not
   int32 data;
   char msg[32];
   
void init_TC(void)
{
   output_low(TC_CLK);
   output_low(TC_DATA);
   output_high(TC_CS);            //if we idle high, the chip keeps                                   //doing conversions. Change this if you like
}

int32 read_TC(void)               
{
   int8 i;
   output_low(TC_CS);            //stop any conversion processes
   for (i=0;i<32;i++){   
      output_high(TC_CLK);
      output_low(TC_CLK);
      shift_left(&data,4,input(TC_DATA));      //reads in 4 bytes to data from the pin TC_DATA       
   }
   thermocouple_error = bit_test(data,16); //this is the thermocouple status bit
   Open_Circuit = bit_test(data,0);       //this is the thermocouple status bit
   Short_to_Gnd = bit_test(data,1);       //this is the thermocouple status bit
   Short_to_Vcc = bit_test(data,2);       //this is the thermocouple status bit
   
   output_high(TC_CS);
   return(data);
}

int32 sortout(int32 raw)
{
    return(0x00003FFF & (raw>>18));      //returns only the bits converning temperature
}

float toFloat_TC(int32 tmp)
{
   return((float)tmp/4.0);      //adjusts data to floating point format, and accounts for the decimal point
}

float do_everything(void)
{
   init_TC(); 
   return(toFloat_TC(sortout(read_TC())));
}
 

void main()
{
   
   port_b_pullups(TRUE);
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   
   while(TRUE){
      delay_ms(800);
      sprintf(msg,"%03.2f%cC\r\n",do_everything(),0xB0);
       
      if(thermocouple_error)
         printf("Thermocouple not connected\r\n");
         if(Open_Circuit)
            printf("Thermocouple not open\r\n");
            if(Short_to_Gnd)
               printf("Thermocouple short to Ground\r\n");
               if(Short_to_Vcc)
                  printf("Thermocouple short to Vcc\r\n");
      else
         printf("%s",msg);
   }
}
jruibarroso



Joined: 07 Jan 2006
Posts: 64
Location: Braga

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Mon Sep 03, 2012 6:03 am     Reply with quote

bkamen wrote:
jruibarroso wrote:
Thank you so much for your reply and I understand your reasons.
My problem is that I don't have enough knowledge design a driver for this IC, so my "cry for help Very Happy "
Anyway, if you find something may help me, please let me know.


That's the joy of learning! I'm assuming you're a student...

If you work at a company, I'm sure there are many here willing to write such a driver for you as a contractor.


No, I'm not a student, only a self learning person and yes, I work in a company that's mine.
jruibarroso



Joined: 07 Jan 2006
Posts: 64
Location: Braga

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Tue Sep 04, 2012 5:18 am     Reply with quote

I wrote this code with some changes to show results on a LCD
Now it's all ok but if temperature readings go along 32.768 ÂșC , readings go crazy , seems mcu is dealing with a 16bit variable but data is int32

can you help me one more time ??

Thank you
Code:


#include <18F252.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=20000000)

#define TC_CLK    PIN_C6
#define TC_CS     PIN_C5
#define TC_DATA   PIN_C4


#include <Display_2x16 Detector manual CE.c>
#include <lcd_symbols.c>


   int1 thermocouple_error,Short_to_Gnd,Short_to_Vcc,Open_Circuit;     //a handy dandy global error flag to
//tell you if a thermocouple is connected or not

   int32 data;
 // char msg[32];
   
void init_TC(void)
{
   output_low(TC_CLK);
   output_low(TC_DATA);
   output_high(TC_CS);            //if we idle high, the chip keeps                                                               //doing conversions. Change this if you like
}

int32 read_TC(void)               
{
   int8 i;
   output_low(TC_CS);            //stop any conversion processes
   for (i=0;i<32;i++){   
      output_high(TC_CLK);
      output_low(TC_CLK);
      shift_left(&data,4,input(TC_DATA));      //reads in 4 bytes to data from the pin TC_DATA       
   }
  // thermocouple_error = bit_test(data,16); //this is the thermocouple status bit
   Open_Circuit = bit_test(data,0);       //this is the thermocouple status bit
   Short_to_Gnd = bit_test(data,1);       //this is the thermocouple status bit
   Short_to_Vcc = bit_test(data,2);       //this is the thermocouple status bit
   
   output_high(TC_CS);
   return(data);
}

int32 sortout(int32 raw)
{
    return(0x00003FFF & (raw>>18));      //returns only the bits converning temperature
}

float toFloat_TC(int32 tmp)
{
   return((float)tmp/4.0);      //adjusts data to floating point format, and accounts for the decimal point
}

float do_everything(void)
{
   init_TC(); 
   return(toFloat_TC(sortout(read_TC())));
}
 


void main()
{
   
  // port_b_pullups(TRUE);
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
  // setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   
   lcd_init();
   delay_ms(80);
   init_user_chars();
   delay_ms(80);
   
   while(TRUE){
      delay_ms(100);
     // sprintf(msg,"%03.2f%cC",do_everything(),0xB0);
       
      //if(thermocouple_error) {printf(lcd_putc,"\fThermocouple not connected");DELAY_MS(200);}
      if(Open_Circuit) {printf(lcd_putc,"\fThermocouple open");DELAY_MS(200);}
      if(Short_to_Gnd) {printf(lcd_putc,"\fThermocouple shrt GND");DELAY_MS(200);}
      if(Short_to_Vcc) {Printf(lcd_putc,"\fThermocouple shrt Vcc");DELAY_MS(200);}
     
         printf(lcd_putc,"\f %5.3w %cC",do_everything(),223);
       
   }
}
[/code]
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
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