Show Posts
|
|
Pages: [1] 2 3 4
|
|
1
|
Using Arduino / Programming Questions / Re: Function Return
|
on: March 28, 2011, 07:56:49 am
|
|
Rob,
Thanks so much for explaining this. I have it working now.
Just so I understand the binary number is actually degrees C / 4 to get the 0.25C resolution? So the part about multiplying that number by 0.25 converts it to degrees C with a precision of 0000.00.
So before the multiplication a raw number of say 105 is what the SPI brings back which is 105 quarters of degrees C. So 105 * 0.25 = 26.25C
This is so much fun...
Thanks John
|
|
|
|
|
2
|
Using Arduino / Programming Questions / Re: Function Return
|
on: March 28, 2011, 06:14:55 am
|
|
Is it because the SPI is in BIN the shift bits just pushes the unwanted bits off?
I'm not sure I understand how the bit shift divides the number... and how can I get the 0.25C resolution?
Thanks for the help. John
|
|
|
|
|
3
|
Using Arduino / Programming Questions / Function Return
|
on: March 27, 2011, 02:31:22 pm
|
I have a function that I copied from the internet to return the temperature from a MAX6675. I don't understand what the return line is doing to the value obtained from the spi. return((int)(temp_reading >> 5)); Is it converting the variable temp_reading to an int? then what does the >> 5 do to the variable temp_reading? Thanks John
|
|
|
|
|
4
|
Using Arduino / Sensors / Re: Thermocouple
|
on: March 27, 2011, 02:20:17 pm
|
The A0:1 lines appear to be floating, if so what MUX IO is being selected?
______ Rob
Bingo Rob! You were correct the A0 and A1 lines can not be left floating. I connected them up and set them to low in my setup loop and walla she works... A big thanks for spotting that. Onward and forward... Thanks John
|
|
|
|
|
5
|
Using Arduino / Sensors / Re: Thermocouple
|
on: March 24, 2011, 07:02:19 pm
|
|
I've not tried with the thermocouple connected directly to the MAX6675 yet, but that seems like a logical step in trouble shooting.
As I understand the data sheet on the ADG609 putting 5v on the EN leg will "connect" the S1A to DA and S1B to DB, putting 5v on combination of A0 and A1 bring the other pairs to DA and DB. Perhaps A0 and A1 "must" be connected and pulled low?
I'm really new at this stuff and really appreciate the help.
Thanks John
|
|
|
|
|
6
|
Using Arduino / Sensors / Re: Thermocouple
|
on: March 24, 2011, 05:12:07 pm
|
|
Ok, I understand that using a multiplexer is not the best way. Barring that and the fact that it may not be as accurate as my lab grade thermometer does anyone see why the multiplexer is not passing the thermocouple on to the MAX6675. After further reading of the MAX6675 data sheet if the T- is not connected to ground the only thing this affects is the open thermocouple will not work so a -1 will NOT be returned. So can I assume the MAX6675 "thinks" that there is an open circuit. Is there something in my code that is not switching on the ADG609? Is there some way to see if the ADG609 is being switched on?
Thanks John
|
|
|
|
|
7
|
Using Arduino / Sensors / Re: Thermocouple
|
on: March 24, 2011, 10:08:12 am
|
kg4wsv, good catch on the ground but the schematic is wrong. I have the t- connected to ground on the MAX6675. Multiple MAX6675's cost a lot more than one ADG609. If that is correct why is one just like I'm prototyping available on the other side of the earth? http://www.oceancontrols.com.au/KTA-259.htmlI guess I don't have a clue what and "old school" thermocouple is compared to the one I purchased??? John
|
|
|
|
|
8
|
Using Arduino / Sensors / Thermocouple
|
on: March 24, 2011, 07:20:56 am
|
I'm trying to multiplex some thermocouples into a MAX6675. So far I have one channel connected for testing but I get a -1 reply from the MAX6675. This is how I have things connected up...  This is my code... /* Testing the Max6675 03/03/2011 */
#include <SPI.h>
#define CS_MAX 10 // MAX6675 Chip Select Line #define EN_ADG 9 // ADG609 Enable Line
//------------------------- int GetTemperature (void) { unsigned int temp_reading;
// stop any conversion process delay(5); digitalWrite(CS_MAX,LOW); // Set MAX7765 /CS Low delay(5); // initiate a new conversion digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High delay(250); // wait for conversion to finish.. // read result digitalWrite(CS_MAX,LOW); // Set MAX7765 /CS Low delay(1); temp_reading = SPI.transfer(0xff) << 8; temp_reading += SPI.transfer(0xff);
digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High delay(1); // Bit D2 is normally low and goes high if the thermocouple input is open. if(bitRead(temp_reading,2) == 1) // No Connection { return(-1); // No Connection Error } else { return((int)(temp_reading >> 5)); //Convert to Degc } }
//------------------------- //------------------------- void setup() { Serial.begin(9600);
pinMode(CS_MAX,OUTPUT); // MAX6675/6674 /CS Line must be an output for hardware SPI digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High
SPI.begin(); // Init SPI SPI.setBitOrder(MSBFIRST); // Sets the order of the bits shifted out of and into the SPI bus SPI.setDataMode(SPI_MODE1); // Base value of clock is 1, data is captured on clock's falling edge. SPI.setClockDivider(SPI_CLOCK_DIV4); // Set SPI data rate to 16mhz/4. IE: 4mhz. pinMode(EN_ADG,OUTPUT); digitalWrite(EN_ADG,HIGH); // Enable the ADG609 which connects S1A = DA and S1B = DB }
//-------------------------
void loop() { int temperature = 0;
while(1) { delay(1000); temperature = GetTemperature(); if(temperature == -1) { Serial.print(temperature); Serial.println(" No Connection"); } else { Serial.print(temperature,DEC); Serial.println(" DegC"); } } }
This is the reply on the serial monitor... -1 No Connection
I almost forgot the data sheets MAX6675ADG609I'm sorry for the crappy image it was the best I could do with Eagle... Thanks John
|
|
|
|
|
9
|
Using Arduino / Sensors / Re: Multiplexing a Thermocouple Input
|
on: March 15, 2011, 07:02:48 am
|
|
Synfinatic,
Thanks for the S/H coefficients. I'm still working on the MAX6675 ADG609N combination as time allows. I've almost got it wired up and ready to test. When I get done with that I'll test the Maverick thermocouples again. They would be more cost effective than the thermocouples and simpler to wire up.
John
|
|
|
|
|
10
|
Using Arduino / Sensors / Re: Connect a basic Reed switch?
|
on: March 08, 2011, 07:35:30 pm
|
Should be simple. Just treat it like any push button switch.
pinMode(pin#, INPUT); // define which pin you are going to use for the reed switch digitalWrite(pin#, HIGH); // turn on the internal pull-up resistor for this pin
Now wire the reed switch between the pin defined and a arduino ground pin.
Later when you do your digitalRead(pin#); statements, a LOW returned value means reed switch is on and a HIGH means it's off.
Lefty
Lefty, Thanks for this, you have also helped me with a switch input. Thanks John
|
|
|
|
|
13
|
Using Arduino / Networking, Protocols, and Devices / Re: SPI with a MAX6675
|
on: March 07, 2011, 08:15:08 am
|
One more bit of the puzzle... void setup() { Serial.begin(9600);
pinMode(CS_MAX,OUTPUT); // MAX6675/6674 /CS Line must be an output for hardware SPI digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High
SPI.begin(); // Init SPI SPI.setBitOrder(MSBFIRST); // Sets the order of the bits shifted out of and into the SPI bus SPI.setDataMode(SPI_MODE1); // Base value of clock is 1, data is captured on clock's falling edge. SPI.setClockDivider(SPI_CLOCK_DIV4); // Set SPI data rate to 16mhz/4. IE: 4mhz. }
Does it matter what order you have the SPI setup lines? Thanks John
|
|
|
|
|
15
|
Using Arduino / Networking, Protocols, and Devices / SPI with a MAX6675
|
on: March 06, 2011, 08:58:07 am
|
Ok, I've managed to get some code from searching the internet to communicate with the MAX6675. /* Testing the Max6675 03/03/2011 */
#include <SPI.h>
#define CS_MAX 10 // MAX6675 CS Line
//------------------------- int GetTemperature (void) { unsigned int temp_reading;
// stop any conversion process delay(5); digitalWrite(CS_MAX,LOW); // Set MAX7765 /CS Low delay(5); // initiate a new conversion digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High delay(250); // wait for conversion to finish.. // read result digitalWrite(CS_MAX,LOW); // Set MAX7765 /CS Low delay(1); temp_reading = SPI.transfer(0xff) << 8; temp_reading += SPI.transfer(0xff);
digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High delay(1); // check result if(bitRead(temp_reading,2) == 1) // No Connection { return(-1); // Failed / NC Error } else { return((int)(temp_reading >> 5)); //Convert to Degc } }
//------------------------- //------------------------- void setup() { Serial.begin(9600);
pinMode(CS_MAX,OUTPUT); // MAX6675/6674 /CS Line must be an output for SPI
digitalWrite(CS_MAX,HIGH); // Set MAX7765 /CS High
SPI.begin(); // Init SPI }
//-------------------------
void loop() { int temperature = 0;
while(1) { delay(1000); temperature = GetTemperature(); if(temperature == -1) { Serial.println("No Connection"); } else { Serial.print(temperature,DEC); Serial.println(" DegC"); } } }
In this line of code I don't understand what the Oxff and the << are doing in the first line and what the second line does. Any help is welcome... temp_reading = SPI.transfer(0xff) << 8; temp_reading += SPI.transfer(0xff);
|
|
|
|
|