Jump to content
43oh

Chuckymonkey

Members
  • Content Count

    18
  • Joined

  • Last visited

Posts posted by Chuckymonkey

  1. It's almost like the chip is quitting.  If I unplug the sensor from the chip and then plug it back in it'll work, otherwise it just reads nothing.  What I mean by that is that it'll work for a little while and then it won't, if I remove the 5V it'll register the same as if I had not done anything.

  2. I did as you suggested and copied the text in.  It's working now with the pinMode being set in the constructor of the library.  I didn't know about that problem with it, so excellent call on that.  The readings are still way off from what I get out of the Arduino, but I'm going to play with that for a little bit and see if I can fix it.

  3. As requested here's the original Main.cpp file:

    #include <Energia.h>
    #include "inc/hw_gpio.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/prcm.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/systick.h"
    #include <driverlib/utils.h>
    #include "inc/hw_hib1p2.h"
    #include "inc/hw_hib3p3.h"
    
    extern void (* const g_pfnVectors[])(void);
    
    int main(void)
    {
    	IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
    
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);
    
    	MAP_IntMasterEnable();
    	PRCMCC3200MCUInit();
    	MAP_SysTickIntEnable();
    	MAP_SysTickPeriodSet(F_CPU / 1000);
    	MAP_SysTickEnable();
    
    	setup();
    
    	for (; {
    		loop();
    		if (serialEventRun) serialEventRun();
    	}
    }
    

    Here's the one that was sent to me and throws the error:

    #include <Energia.h>
    #include "inc/hw_gpio.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/prcm.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/systick.h"
    #include <driverlib/utils.h>
    #include "inc/hw_hib1p2.h"
    #include "inc/hw_hib3p3.h"
    
    extern void (* const g_pfnVectors[])(void);
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    void _init(void)
    {
    	IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
    
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
    	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);
    
    	MAP_IntMasterEnable();
    	PRCMCC3200MCUInit();
    	MAP_SysTickIntEnable();
    	MAP_SysTickPeriodSet(F_CPU / 1000);
    	MAP_SysTickEnable();
    } /* void _init(void) */
    
    #ifdef __cplusplus
    } /* extern "C" */
    #endif
    
    int main(void)
    {
    	setup();
    
    	for (; {
    		loop();
    		if (serialEventRun) serialEventRun();
    	}
    }
    
    
  4. W00t!  Doing what I said above worked!  I'm getting readings now!  They're not correct, but they're readings so I'm on the right track finally!  Thank you from the depths of my soul to Spirillis.  I may try to modify the Adafruit code and see if I get better results with that.  For now though I have beer to brew, if any of you that helped are in Colorado you are welcome to message me and drop in for a pint of homebrew.  Here's the modified code so far:

    /*******************************************************************************
    * MAX31855 Library
    * Version: 1.10
    * Date: 24-07-2012
    * Company: Rocket Scream Electronics
    * Website: www.rocketscream.com
    *
    * This is a MAX31855 library for Arduino. Please check our wiki 
    * (www.rocketscream.com/wiki) for more information on using this piece of 
    * library.
    *
    * This library is licensed under Creative Commons Attribution-ShareAlike 3.0 
    * Unported License.
    *
    * Revision  Description
    * ========  ===========
    * 1.10			Added negative temperature support for both junction & thermocouple.
    * 1.00      Initial public release.
    *
    *******************************************************************************/
    #include	"MAX31855.h"
    
    MAX31855::MAX31855(unsigned char SO, unsigned	char CS, unsigned char SCK)
    {
    	so = SO;
    	cs = CS;
    	sck = SCK;
    	
    	// MAX31855 data output pin
        //pinMode(so, INPUT);
    	// MAX31855 chip select input pin
        //pinMode(cs, OUTPUT);
    	// MAX31855 clock input pin
        //pinMode(sck, OUTPUT);
    
    	// Default output pins state
        //digitalWrite(cs, HIGH);
        //digitalWrite(sck, LOW);
    }
    
    /*******************************************************************************
    * Name: readThermocouple
    * Description: Read the thermocouple temperature either in Degree Celsius or
    *							 Fahrenheit. Internally, the conversion takes place in the
    *							 background within 100 ms. Values are updated only when the CS
    *							 line is high.
    *
    * Argument  	Description
    * =========  	===========
    * 1. unit   	Unit of temperature required: CELSIUS or FAHRENHEIT
    *
    * Return			Description
    * =========		===========
    *	temperature	Temperature of the thermocouple either in Degree Celsius or 
    *							Fahrenheit. If fault is detected, FAULT_OPEN, FAULT_SHORT_GND or
    *							FAULT_SHORT_VCC will be returned. These fault values are outside
    *							of the temperature range the MAX31855 is capable of.
    *******************************************************************************/	
    double	MAX31855::readThermocouple(unit_t	unit)
    {
    	unsigned long data;
    	double temperature;
    	
    	// Initialize temperature
    	temperature = 0;
    	
    	// Shift in 32-bit of data from MAX31855
    	data = readData();
    	
    	// If fault is detected
    	if (data & 0x00010000)
    	{
    		// Check for fault type (3 LSB)
    		switch (data & 0x00000007)
    		{
    			// Open circuit 
    			case 0x01:
    				temperature = FAULT_OPEN;
    				break;
    			
    			// Thermocouple short to GND
    			case 0x02:
    				temperature = FAULT_SHORT_GND;
    				break;
    			
    			// Thermocouple short to VCC	
    			case 0x04:
    				temperature = FAULT_SHORT_VCC;
    				break;
    		}
    	}
    	// No fault detected
    	else
    	{
    		// Retrieve thermocouple temperature data and strip redundant data
    		data = data >> 18;
    		// Bit-14 is the sign
    		temperature = (data & 0x00001FFF);
    
    		// Check for negative temperature		
    		if (data & 0x00002000)
    		{
    			// 2's complement operation
    			// Invert
    			data = ~data; 
    			// Ensure operation involves lower 13-bit only
    			temperature = data & 0x00001FFF;
    			// Add 1 to obtain the positive number
    			temperature += 1;
    			// Make temperature negative
    			temperature *= -1; 
    		}
    		
    		// Convert to Degree Celsius
    		temperature *= 0.25;
    		
    		// If temperature unit in Fahrenheit is desired
    		if (unit == FAHRENHEIT)
    		{
    			// Convert Degree Celsius to Fahrenheit
    			temperature = (temperature * 9.0/5.0)+ 32; 
    		}
    	}
    	return (temperature);
    }
    
    /*******************************************************************************
    * Name: readJunction
    * Description: Read the thermocouple temperature either in Degree Celsius or
    *							 Fahrenheit. Internally, the conversion takes place in the
    *							 background within 100 ms. Values are updated only when the CS
    *							 line is high.
    *
    * Argument  	Description
    * =========  	===========
    * 1. unit   	Unit of temperature required: CELSIUS or FAHRENHEIT
    *
    * Return			Description
    * =========		===========
    *	temperature	Temperature of the cold junction either in Degree Celsius or 
    *							Fahrenheit. 
    *
    *******************************************************************************/
    double	MAX31855::readJunction(unit_t	unit)
    {
    	double	temperature;
    	unsigned long data;
    	
    	// Shift in 32-bit of data from MAX31855
    	data = readData();
    	
    	// Strip fault data bits & reserved bit
    	data = data >> 4;
    	// Bit-12 is the sign
    	temperature = (data & 0x000007FF);
    	
    	// Check for negative temperature
    	if (data & 0x00000800)
    	{
    		// 2's complement operation
    		// Invert
    		data = ~data; 
    		// Ensure operation involves lower 11-bit only
    		temperature = data & 0x000007FF;
    		// Add 1 to obtain the positive number
    		temperature += 1;	
    		// Make temperature negative
    		temperature *= -1; 
    	}
    	
    	// Convert to Degree Celsius
    	temperature *= 0.0625;
    	
    	// If temperature unit in Fahrenheit is desired
    	if (unit == FAHRENHEIT)
    	{
    		// Convert Degree Celsius to Fahrenheit
    		temperature = (temperature * 9.0/5.0)+ 32; 	
    	}
    	
    	// Return the temperature
    	return (temperature);
    }
    
    /*******************************************************************************
    * Name: readData
    * Description: Shift in 32-bit of data from MAX31855 chip. Minimum clock pulse
    *							 width is 100 ns. No delay is required in this case.
    *
    * Argument  	Description
    * =========  	===========
    * 1. NIL
    *
    * Return			Description
    * =========		===========
    *	data				32-bit of data acquired from the MAX31855 chip.
    *				
    *******************************************************************************/
    unsigned long MAX31855::readData()
    {
    	int bitCount;
    	unsigned long data;
    	
    	// Clear data 
    	data = 0;
    
    	// Select the MAX31855 chip
    	digitalWrite(cs, LOW);
    	
    	// Shift in 32-bit of data
    	for (bitCount = 31; bitCount >= 0; bitCount--)
    	{
    		digitalWrite(sck, HIGH);
    		
    		// If data bit is high
    		if (digitalRead(so))
    		{
    			// Need to type cast data type to unsigned long, else compiler will 
    			// truncate to 16-bit
    			data |= ((unsigned long)1 << bitCount);
    		}	
    		
    		digitalWrite(sck, LOW);
    	}
    	
    	// Deselect MAX31855 chip
    	digitalWrite(cs, HIGH);
    	
    	return(data);
    }
    
    /*******************************************************************************
    * MAX31855 Library
    * Version: 1.10
    * Date: 24-07-2012
    * Company: Rocket Scream Electronics
    * Website: www.rocketscream.com
    *
    * This is a MAX31855 library for Arduino. Please check our wiki 
    * (www.rocketscream.com/wiki) for more information on using this piece of 
    * library.
    *
    * This library is licensed under Creative Commons Attribution-ShareAlike 3.0 
    * Unported License.
    *
    * Revision  Description
    * ========  ===========
    * 1.10			Added negative temperature support for both junction & thermocouple.
    * 1.00      Initial public release.
    *
    *******************************************************************************/
    #include	"MAX31855.h"
    
    MAX31855::MAX31855(unsigned char SO, unsigned	char CS, unsigned char SCK)
    {
    	so = SO;
    	cs = CS;
    	sck = SCK;
    	
    	// MAX31855 data output pin
        //pinMode(so, INPUT);
    	// MAX31855 chip select input pin
        //pinMode(cs, OUTPUT);
    	// MAX31855 clock input pin
        //pinMode(sck, OUTPUT);
    
    	// Default output pins state
        //digitalWrite(cs, HIGH);
        //digitalWrite(sck, LOW);
    }
    
    /*******************************************************************************
    * Name: readThermocouple
    * Description: Read the thermocouple temperature either in Degree Celsius or
    *							 Fahrenheit. Internally, the conversion takes place in the
    *							 background within 100 ms. Values are updated only when the CS
    *							 line is high.
    *
    * Argument  	Description
    * =========  	===========
    * 1. unit   	Unit of temperature required: CELSIUS or FAHRENHEIT
    *
    * Return			Description
    * =========		===========
    *	temperature	Temperature of the thermocouple either in Degree Celsius or 
    *							Fahrenheit. If fault is detected, FAULT_OPEN, FAULT_SHORT_GND or
    *							FAULT_SHORT_VCC will be returned. These fault values are outside
    *							of the temperature range the MAX31855 is capable of.
    *******************************************************************************/	
    double	MAX31855::readThermocouple(unit_t	unit)
    {
    	unsigned long data;
    	double temperature;
    	
    	// Initialize temperature
    	temperature = 0;
    	
    	// Shift in 32-bit of data from MAX31855
    	data = readData();
    	
    	// If fault is detected
    	if (data & 0x00010000)
    	{
    		// Check for fault type (3 LSB)
    		switch (data & 0x00000007)
    		{
    			// Open circuit 
    			case 0x01:
    				temperature = FAULT_OPEN;
    				break;
    			
    			// Thermocouple short to GND
    			case 0x02:
    				temperature = FAULT_SHORT_GND;
    				break;
    			
    			// Thermocouple short to VCC	
    			case 0x04:
    				temperature = FAULT_SHORT_VCC;
    				break;
    		}
    	}
    	// No fault detected
    	else
    	{
    		// Retrieve thermocouple temperature data and strip redundant data
    		data = data >> 18;
    		// Bit-14 is the sign
    		temperature = (data & 0x00001FFF);
    
    		// Check for negative temperature		
    		if (data & 0x00002000)
    		{
    			// 2's complement operation
    			// Invert
    			data = ~data; 
    			// Ensure operation involves lower 13-bit only
    			temperature = data & 0x00001FFF;
    			// Add 1 to obtain the positive number
    			temperature += 1;
    			// Make temperature negative
    			temperature *= -1; 
    		}
    		
    		// Convert to Degree Celsius
    		temperature *= 0.25;
    		
    		// If temperature unit in Fahrenheit is desired
    		if (unit == FAHRENHEIT)
    		{
    			// Convert Degree Celsius to Fahrenheit
    			temperature = (temperature * 9.0/5.0)+ 32; 
    		}
    	}
    	return (temperature);
    }
    
    /*******************************************************************************
    * Name: readJunction
    * Description: Read the thermocouple temperature either in Degree Celsius or
    *							 Fahrenheit. Internally, the conversion takes place in the
    *							 background within 100 ms. Values are updated only when the CS
    *							 line is high.
    *
    * Argument  	Description
    * =========  	===========
    * 1. unit   	Unit of temperature required: CELSIUS or FAHRENHEIT
    *
    * Return			Description
    * =========		===========
    *	temperature	Temperature of the cold junction either in Degree Celsius or 
    *							Fahrenheit. 
    *
    *******************************************************************************/
    double	MAX31855::readJunction(unit_t	unit)
    {
    	double	temperature;
    	unsigned long data;
    	
    	// Shift in 32-bit of data from MAX31855
    	data = readData();
    	
    	// Strip fault data bits & reserved bit
    	data = data >> 4;
    	// Bit-12 is the sign
    	temperature = (data & 0x000007FF);
    	
    	// Check for negative temperature
    	if (data & 0x00000800)
    	{
    		// 2's complement operation
    		// Invert
    		data = ~data; 
    		// Ensure operation involves lower 11-bit only
    		temperature = data & 0x000007FF;
    		// Add 1 to obtain the positive number
    		temperature += 1;	
    		// Make temperature negative
    		temperature *= -1; 
    	}
    	
    	// Convert to Degree Celsius
    	temperature *= 0.0625;
    	
    	// If temperature unit in Fahrenheit is desired
    	if (unit == FAHRENHEIT)
    	{
    		// Convert Degree Celsius to Fahrenheit
    		temperature = (temperature * 9.0/5.0)+ 32; 	
    	}
    	
    	// Return the temperature
    	return (temperature);
    }
    
    /*******************************************************************************
    * Name: readData
    * Description: Shift in 32-bit of data from MAX31855 chip. Minimum clock pulse
    *							 width is 100 ns. No delay is required in this case.
    *
    * Argument  	Description
    * =========  	===========
    * 1. NIL
    *
    * Return			Description
    * =========		===========
    *	data				32-bit of data acquired from the MAX31855 chip.
    *				
    *******************************************************************************/
    unsigned long MAX31855::readData()
    {
    	int bitCount;
    	unsigned long data;
    	
    	// Clear data 
    	data = 0;
    
    	// Select the MAX31855 chip
    	digitalWrite(cs, LOW);
    	
    	// Shift in 32-bit of data
    	for (bitCount = 31; bitCount >= 0; bitCount--)
    	{
    		digitalWrite(sck, HIGH);
    		
    		// If data bit is high
    		if (digitalRead(so))
    		{
    			// Need to type cast data type to unsigned long, else compiler will 
    			// truncate to 16-bit
    			data |= ((unsigned long)1 << bitCount);
    		}	
    		
    		digitalWrite(sck, LOW);
    	}
    	
    	// Deselect MAX31855 chip
    	digitalWrite(cs, HIGH);
    	
    	return(data);
    }
    
  5. So, I'm in the middle of brewing a batch of beer right now but I'll try taking the pinMode settings out of the constructor and moving those into the setup code in Energia.  I'll post the results back here when I'm done.

  6. That patch cause this NPE.

     

    java.lang.NullPointerException

    at processing.app.debug.Compiler.execAsynchronously(Compiler.java:725)

    at processing.app.debug.Compiler.compileFiles(Compiler.java:597)

    at processing.app.debug.Compiler.compile(Compiler.java:240)

    at processing.app.Sketch.build(Sketch.java:1594)

    at processing.app.Sketch.exportApplet(Sketch.java:1617)

    at processing.app.Sketch.exportApplet(Sketch.java:1603)

    at processing.app.Editor$DefaultExportHandler.run(Editor.java:2520)

    at java.lang.Thread.run(Thread.java:745)

     

    Second try, I got this

     


    core.a(startup_gcc.c.o): In function `zero_loop':

    startup_gcc.c:(.text.ResetISR+0x56): undefined reference to `_init'

    collect2: error: ld returned 1 exit status

  7. I really think it's going to be a fun project.  I'm going to mount all of this in a plastic project box with a power tail as the exposed power source.  The idea being that you take this box, plug power input to one end, output to the other, and then jack in a few sensors(thermocouple initially) to jacks I'm going to mount in the box.  You put it in learning mode so the PID algorithm can figure out how your temperatures rise and fall and then after that you use the thing.  Trying to make it so anyone can build one and attach it to pretty much any electric smoker. 

  8. I've also tried this code:

    /*******************************************************************************
    * MAX31855 Library
    * Version: 1.10
    * Date: 24-07-2012
    * Company: Rocket Scream Electronics
    * Website: www.rocketscream.com
    *
    * This is a MAX31855 library for Arduino. Please check our wiki 
    * (www.rocketscream.com/wiki) for more information on using this piece of 
    * library.
    *
    * This library is licensed under Creative Commons Attribution-ShareAlike 3.0 
    * Unported License.
    *
    * Revision  Description
    * ========  ===========
    * 1.10			Added negative temperature support for both junction & thermocouple.
    * 1.00      Initial public release.
    *
    *******************************************************************************/
    #include	"MAX31855.h"
    
    MAX31855::MAX31855(unsigned char SO, unsigned	char CS, unsigned char SCK)
    {
    	so = SO;
    	cs = CS;
    	sck = SCK;
    	
    	// MAX31855 data output pin
    	pinMode(so, INPUT);
    	// MAX31855 chip select input pin
    	pinMode(cs, OUTPUT);
    	// MAX31855 clock input pin
    	pinMode(sck, OUTPUT);
    	
    	// Default output pins state
    	digitalWrite(cs, HIGH);
    	digitalWrite(sck, LOW);
    }
    
    /*******************************************************************************
    * Name: readThermocouple
    * Description: Read the thermocouple temperature either in Degree Celsius or
    *							 Fahrenheit. Internally, the conversion takes place in the
    *							 background within 100 ms. Values are updated only when the CS
    *							 line is high.
    *
    * Argument  	Description
    * =========  	===========
    * 1. unit   	Unit of temperature required: CELSIUS or FAHRENHEIT
    *
    * Return			Description
    * =========		===========
    *	temperature	Temperature of the thermocouple either in Degree Celsius or 
    *							Fahrenheit. If fault is detected, FAULT_OPEN, FAULT_SHORT_GND or
    *							FAULT_SHORT_VCC will be returned. These fault values are outside
    *							of the temperature range the MAX31855 is capable of.
    *******************************************************************************/	
    double	MAX31855::readThermocouple(unit_t	unit)
    {
    	unsigned long data;
    	double temperature;
    	
    	// Initialize temperature
    	temperature = 0;
    	
    	// Shift in 32-bit of data from MAX31855
    	data = readData();
    	
    	// If fault is detected
    	if (data & 0x00010000)
    	{
    		// Check for fault type (3 LSB)
    		switch (data & 0x00000007)
    		{
    			// Open circuit 
    			case 0x01:
    				temperature = FAULT_OPEN;
    				break;
    			
    			// Thermocouple short to GND
    			case 0x02:
    				temperature = FAULT_SHORT_GND;
    				break;
    			
    			// Thermocouple short to VCC	
    			case 0x04:
    				temperature = FAULT_SHORT_VCC;
    				break;
    		}
    	}
    	// No fault detected
    	else
    	{
    		// Retrieve thermocouple temperature data and strip redundant data
    		data = data >> 18;
    		// Bit-14 is the sign
    		temperature = (data & 0x00001FFF);
    
    		// Check for negative temperature		
    		if (data & 0x00002000)
    		{
    			// 2's complement operation
    			// Invert
    			data = ~data; 
    			// Ensure operation involves lower 13-bit only
    			temperature = data & 0x00001FFF;
    			// Add 1 to obtain the positive number
    			temperature += 1;
    			// Make temperature negative
    			temperature *= -1; 
    		}
    		
    		// Convert to Degree Celsius
    		temperature *= 0.25;
    		
    		// If temperature unit in Fahrenheit is desired
    		if (unit == FAHRENHEIT)
    		{
    			// Convert Degree Celsius to Fahrenheit
    			temperature = (temperature * 9.0/5.0)+ 32; 
    		}
    	}
    	return (temperature);
    }
    
    /*******************************************************************************
    * Name: readJunction
    * Description: Read the thermocouple temperature either in Degree Celsius or
    *							 Fahrenheit. Internally, the conversion takes place in the
    *							 background within 100 ms. Values are updated only when the CS
    *							 line is high.
    *
    * Argument  	Description
    * =========  	===========
    * 1. unit   	Unit of temperature required: CELSIUS or FAHRENHEIT
    *
    * Return			Description
    * =========		===========
    *	temperature	Temperature of the cold junction either in Degree Celsius or 
    *							Fahrenheit. 
    *
    *******************************************************************************/
    double	MAX31855::readJunction(unit_t	unit)
    {
    	double	temperature;
    	unsigned long data;
    	
    	// Shift in 32-bit of data from MAX31855
    	data = readData();
    	
    	// Strip fault data bits & reserved bit
    	data = data >> 4;
    	// Bit-12 is the sign
    	temperature = (data & 0x000007FF);
    	
    	// Check for negative temperature
    	if (data & 0x00000800)
    	{
    		// 2's complement operation
    		// Invert
    		data = ~data; 
    		// Ensure operation involves lower 11-bit only
    		temperature = data & 0x000007FF;
    		// Add 1 to obtain the positive number
    		temperature += 1;	
    		// Make temperature negative
    		temperature *= -1; 
    	}
    	
    	// Convert to Degree Celsius
    	temperature *= 0.0625;
    	
    	// If temperature unit in Fahrenheit is desired
    	if (unit == FAHRENHEIT)
    	{
    		// Convert Degree Celsius to Fahrenheit
    		temperature = (temperature * 9.0/5.0)+ 32; 	
    	}
    	
    	// Return the temperature
    	return (temperature);
    }
    
    /*******************************************************************************
    * Name: readData
    * Description: Shift in 32-bit of data from MAX31855 chip. Minimum clock pulse
    *							 width is 100 ns. No delay is required in this case.
    *
    * Argument  	Description
    * =========  	===========
    * 1. NIL
    *
    * Return			Description
    * =========		===========
    *	data				32-bit of data acquired from the MAX31855 chip.
    *				
    *******************************************************************************/
    unsigned long MAX31855::readData()
    {
    	int bitCount;
    	unsigned long data;
    	
    	// Clear data 
    	data = 0;
    
    	// Select the MAX31855 chip
    	digitalWrite(cs, LOW);
    	
    	// Shift in 32-bit of data
    	for (bitCount = 31; bitCount >= 0; bitCount--)
    	{
    		digitalWrite(sck, HIGH);
    		
    		// If data bit is high
    		if (digitalRead(so))
    		{
    			// Need to type cast data type to unsigned long, else compiler will 
    			// truncate to 16-bit
    			data |= ((unsigned long)1 << bitCount);
    		}	
    		
    		digitalWrite(sck, LOW);
    	}
    	
    	// Deselect MAX31855 chip
    	digitalWrite(cs, HIGH);
    	
    	return(data);
    }
    

    With this sketch:

    /*******************************************************************************
    * Thermocouple to serial for MAX31855 example 
    * Version: 1.00
    * Date: 26-12-2011
    * Company: Rocket Scream Electronics
    * Website: www.rocketscream.com
    *
    * This is an example of using the MAX31855 library for Arduino to read 
    * temperature from a thermocouple and send the reading to serial interfacec. 
    * Please check our wiki (www.rocketscream.com/wiki) for more information on 
    * using this piece of library.
    *
    * This example code is licensed under Creative Commons Attribution-ShareAlike 
    * 3.0 Unported License.
    *
    * Revision  Description
    * ========  ===========
    * 1.00      Initial public release.
    *
    *******************************************************************************/
    // ***** INCLUDES *****
    #include  <MAX31855.h>
    
    // ***** PIN DEFINITIONS *****
    const  unsigned  char thermocoupleSO = 19;
    const  unsigned  char thermocoupleCS = 18;
    const  unsigned  char thermocoupleCLK = 17;
    
    MAX31855  MAX31855(thermocoupleSO, thermocoupleCS, thermocoupleCLK);
    
    void  setup()
    {
      Serial.begin(115200);
      Serial.println("Setup Complete");
      
    }
    
    void  loop()
    {
      Serial.println("Starting Up");
      double  temperature;
      
      // Retrieve thermocouple temperature in Degree Celsius
      //temperature = MAX31855.readThermocouple(CELSIUS);
      Serial.print("Thermocouple temperature: ");
      Serial.print(temperature);
      Serial.println(" Degree Celsius");
      
      // Retrieve cold junction temperature in Degree Celsius
      //temperature = MAX31855.readJunction(CELSIUS);
      Serial.print("Junction temperature: ");
      Serial.print(temperature);
      Serial.println(" Degree Celsius");
      
      delay(1000);
    }
    

    and have gotten the same result.  The system just hangs, no output on the serial monitor.  I double checked the serial monitor with a simple looping text ouput and it works fine. If I take out the MAX31855  MAX31855(thermocoupleSO, thermocoupleCS, thermocoupleCLK); it works as far as printing something to the console.  I'm not really even sure why that is.

  9. So, I just spent a couple more hours messing with it and met with exactly zero success.  I've tried using the hardware SPI, I have the DO pin on the MAX plugged into pin 14, CS to pin 18, and CLK to pin 7.  All I ever get back for values are 0 or 255.  I set pin 18 to HIGH, do SPI.transfer(0x00) and then set it to low.

  10. I'm going to monkey around with it some more over the next few days based on all your advice. Unfortunately I'm not made of time(school, full time job, family). The eventual goal of this project is to create a network enabled smoker controlled via MQTT with an Android device. I eventualy want to integrate humidity and smoke density controls.

  11. I should mention that I have the MAX pins connected just like it shows in the sketch. I also have the 5v and GND connected to 5v and GND on device. I've tested it again with a new thermocouple on Arduino so I know the MAX and thermocouple work.

  12. I should mention that I have the MAX pins connected just like it shows in the sketch. I also have the 5v and GND connected to 5v and GND on device. I've tested it again with a new thermocouple on Arduino so I know the MAX and thermocouple work.

  13. Ok, so here's some code.  What's going on now is that nothing appears to be happening.  Everything compiles, it uploads the sketch, I pull the header and reset and...... nothing.

     

    Here's the modified Adafruit Code:

    /*************************************************** 
      This is a library for the Adafruit Thermocouple Sensor w/MAX31855K
    
      Designed specifically to work with the Adafruit Thermocouple Sensor
      ----> https://www.adafruit.com/products/269
    
      These displays use SPI to communicate, 3 pins are required to  
      interface
      Adafruit invests time and resources providing this open source code, 
      please support Adafruit and open-source hardware by purchasing 
      products from Adafruit!
    
      Written by Limor Fried/Ladyada for Adafruit Industries.  
      BSD license, all text above must be included in any redistribution
     ****************************************************/
    
    #include "Adafruit_MAX31855.h"
    #include <stdlib.h>
    #include <SPI.h>
    
    
    Adafruit_MAX31855::Adafruit_MAX31855(int8_t SCLK, int8_t CS, int8_t MISO) {
      sclk = SCLK;
      cs = CS;
      miso = MISO;
      hSPI = 0;
    
      //define pin modes
      pinMode(cs, OUTPUT);
      pinMode(sclk, OUTPUT); 
      pinMode(miso, INPUT);
    
      digitalWrite(cs, HIGH);
    }
    
    Adafruit_MAX31855::Adafruit_MAX31855(int8_t CS) {
      cs = CS;
      hSPI = 1;
    
      //define pin modes
      pinMode(cs, OUTPUT);
      
      //start and configure hardware SPI
      SPI.begin();
      SPI.setBitOrder(MSBFIRST);
      SPI.setDataMode(SPI_MODE0);
      SPI.setClockDivider(SPI_CLOCK_DIV4);
      
      digitalWrite(cs, HIGH);
    }
    
    double Adafruit_MAX31855::readInternal(void) {
      uint32_t v;
    
      v = spiread32();
    
      // ignore bottom 4 bits - they're just thermocouple data
      v >>= 4;
    
      // pull the bottom 11 bits off
      float internal = v & 0x7FF;
      // check sign bit!
      if (v & 0x800) {
        // Convert to negative value by extending sign and casting to signed type.
        int16_t tmp = 0xF800 | (v & 0x7FF);
        internal = tmp;
      }
      internal *= 0.0625; // LSB = 0.0625 degrees
      //Serial.print("\tInternal Temp: "); Serial.println(internal);
      return internal;
    }
    
    double Adafruit_MAX31855::readCelsius(void) {
    
      int32_t v;
    
      v = spiread32();
    
      //Serial.print("0x"); Serial.println(v, HEX);
    
      /*
      float internal = (v >> 4) & 0x7FF;
      internal *= 0.0625;
      if ((v >> 4) & 0x800) 
        internal *= -1;
      Serial.print("\tInternal Temp: "); Serial.println(internal);
      */
    
      if (v & 0x7) {
        // uh oh, a serious problem!
        return NAN; 
      }
    
      if (v & 0x80000000) {
        // Negative value, drop the lower 18 bits and explicitly extend sign bits.
        v = 0xFFFFC000 | ((v >> 18) & 0x00003FFFF);
      }
      else {
        // Positive value, just drop the lower 18 bits.
        v >>= 18;
      }
      //Serial.println(v, HEX);
      
      double centigrade = v;
    
      // LSB = 0.25 degrees C
      centigrade *= 0.25;
      return centigrade;
    }
    
    uint8_t Adafruit_MAX31855::readError() {
      return spiread32() & 0x7;
    }
    
    double Adafruit_MAX31855::readFarenheit(void) {
      float f = readCelsius();
      f *= 9.0;
      f /= 5.0;
      f += 32;
      return f;
    }
    
    uint32_t Adafruit_MAX31855::spiread32(void) { 
      int i;
      uint32_t d = 0;
    
      if(hSPI) {
        return hspiread32();
      }
    
      digitalWrite(sclk, LOW);
      delay(1);
      digitalWrite(cs, LOW);
      delay(1);
    
      for (i=31; i>=0; i--)
      {
        digitalWrite(sclk, LOW);
        delay(1);
        d <<= 1;
        if (digitalRead(miso)) {
          d |= 1;
        }
    
        digitalWrite(sclk, HIGH);
        delay(1);
      }
    
      digitalWrite(cs, HIGH);
      //Serial.println(d, HEX);
      return d;
    }
    
    uint32_t Adafruit_MAX31855::hspiread32(void) {
      int i;
      // easy conversion of four uint8_ts to uint32_t
      union bytes_to_uint32 {
        uint8_t bytes[4];
        uint32_t integer;
      } buffer;
      
      digitalWrite(cs, LOW);
      delay(1);
      
      for (i=3;i>=0;i--) {
        buffer.bytes[i] = SPI.transfer(0x00);
      }
      
      digitalWrite(cs, HIGH);
      
      return buffer.integer;
      
    }
    
    

    Here's the header:

    #ifndef ADAFRUIT_MAX31855_H
    #define ADAFRUIT_MAX31855_H
    
    #if (ARDUINO >= 100)
     #include "Arduino.h"
    #else
     #include "WProgram.h"
    #endif
    
    class Adafruit_MAX31855 {
     public:
      Adafruit_MAX31855(int8_t SCLK, int8_t CS, int8_t MISO);
      Adafruit_MAX31855(int8_t CS);
    
      double readInternal(void);
      double readCelsius(void);
      double readFarenheit(void);
      uint8_t readError();
    
     private:
      int8_t sclk, miso, cs, hSPI;
      uint32_t spiread32(void);
      uint32_t hspiread32(void);
    };
    
    #endif
    

    Here's the test sketch:

    
    #include <SPI.h>
    #include "Adafruit_MAX31855.h"
    
    // Default connection is using software SPI, but comment and uncomment one of
    // the two examples below to switch between software SPI and hardware SPI:
    
    // Example creating a thermocouple instance with software SPI on any three
    // digital IO pins.
    #define DO   15
    #define CS   16
    #define CLK  17
    Adafruit_MAX31855 thermocouple(CLK, CS, DO);
    
    // Example creating a thermocouple instance with hardware SPI (Uno/Mega only)
    // on a given CS pin.
    //#define CS   10
    //Adafruit_MAX31855 thermocouple(CS);
    
    void setup() {
      Serial.begin(115200);
      
      Serial.println("MAX31855 test");
      // wait for MAX chip to stabilize
      delay(500);
    }
    
    void loop() {
      // basic readout test, just print the current temp
       Serial.print("Internal Temp = ");
       //Serial.println(thermocouple.readInternal());
    
       //double c = thermocouple.readCelsius();
       //if (isnan(c)) {
       //  Serial.println("Something wrong with thermocouple!");
       //} else {
       //  Serial.print("C = "); 
       //  Serial.println(c);
       //}
       //Serial.print("F = ");
       //Serial.println(thermocouple.readFarenheit());
     
       delay(1000);
    }
    
  14. I do realize this, I'm reading the serial data from the USB plugged into energia.  I'm trying something different now, I think I've managed to port the Adafruit C++ library over to the MSP.  I think I was confused between software and hardware SPI.  I'm having some trouble getting energia to see the device right now(Linux) but once I have that I'll post the results.

  15. Launchpad noob from Arduino here.  I'm having trouble figuring out how to get a MAX31855 from Adafruit to work with the CC3200.   I've tried this library https://github.com/rocketscream/MAX31855 running the example code with no luck, when I open the serial monitor after initializing the sensor it's blank.  I know that everything is working correctly as far as uploading a sketch because I've ran several different sketches, including wifi, ones on this board with no problems so far.  I've tried the Adafruit library directly in this and that got me nowhere.  The issue with that library is that it makes specific calls to AVR code for Arduino which will not work with Energia as far as I can tell.  I tried hand porting the library and met with a little success, but that success was short lived as I was able to address the chip via SPI but all I ever received from it was 0.  In trying to port the Adafruit library I modified their code and removed the includes for avr and delay.  I replaced all of the _delay_ms calls with delay for this system.  I then plugged in the DO port from the MAX31855 to pin 14, CS to pin 18, and CLK to pin 7.  So far nothing.  I can't even get a readout on the serial monitor.  I tested the MAX and it's working with my Arduino just fine, the thermocouple that I have is crap but it does at least provide something.

×
×
  • Create New...