Show Posts
Pages: [1] 2
1  Using Arduino / Sensors / Re: Dual lead (4 wire) type K thermocouple on: January 20, 2014, 05:45:57 pm
You need to read a bit more carefully. The Omega guide very clearly says (bold face added):

Quote
Tip-branched and leg-branched thermocouples are four-wire thermocouple circuits that allow redundant measurement of temperature, noise, voltage and resistance for checking wire integrity.

It is can be extremely important to know if your thermocouple leads are intact, otherwise you could melt down some very expensive equipment.

I guess I should say then, for my purposes, this is a closed circuit used only for logging data.
There isn't any operational behavior based on these measurements.

But I do appreciate the slap in the face, what type of measurement from the reference would I be looking for? An increase in resistance and decrease in voltage?
2  Using Arduino / Sensors / Re: Dual lead (4 wire) type K thermocouple on: January 19, 2014, 12:05:04 am
All those references say it's not for fault protection, but for noise. I tried to find the elusive "REF. 8" Omega says goes in more depth, but I can't find anything at all other than these descriptions. I haven't seen an application, but Omega says... on Z-32

"One pair is used as a thermocouple to determine the temperature level, and one pair is used to determine the temperature difference between two points."

So if I have the tip-branched type I'll be reading temperatures from both sides of the probe basically, and I've read to put the "hot end" as the compensation line.

I'm wondering what the implications of this being the alternative leg-branched type as I can't find their "respective merits" in REF. 8.
3  Using Arduino / Sensors / Dual lead (4 wire) type K thermocouple on: January 17, 2014, 01:34:58 pm
I'm installing a few extra thermocouples into a Dedrich IR-5 coffee roaster and so I contacted the manufacturer for any information I could get from them. They do not have an exploded view to help with placement within the machine (problem for another time) and the representative also informed me they were using a dual lead, 4 wire, type K thermocouple. I've been trolling the internet for information regarding this and haven't come across a wiring diagram showing a thermocouple with 4 wires for the Arduino.

I'm simply asking if anyone has experience with 4 wire thermocouples and if anyone has any ideas as to how to wire it into a board with access to 4 thermocouple connects with 2 connects apiece (8 terminal block connections) as I'd ideally like to use manufacturer provided parts to match the resolution and response time of those already in use.
4  Using Arduino / Sensors / Re: 1 Wire DS18B20 Minimal Coding on: June 09, 2013, 03:56:58 pm
Quote
That will only work correctly when mask == 1.  For all other values of mask (2, 4, 8, etc) the results of (mask & 1) is 0.

Yeah I noticed that. Can anyone recommend a very small SD library?

BTW here's my devastated new LCD library.

If you notice I've been trying to use SPI to replace write4Bits. If anyone has any suggestions for how to do this... smiley-grin

Code:
#include "MyLiquidCrystal.h"
#include "Arduino.h"

LiquidCrystal::LiquidCrystal(){
  SPI.begin();
  initSPI();
  init();  
  begin();
}

void LiquidCrystal::initSPI(){
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
}

void LiquidCrystal::init(){
  _rs_pin = 1;
  _rw_pin = 255;
  _enable_pin = 3;  
  _data_pins[0] = 4;
  _data_pins[1] = 5;
  _data_pins[2] = 6;
  _data_pins[3] = 7;

  pinMode(_rs_pin, OUTPUT);
  pinMode(_enable_pin, OUTPUT);  
}

void LiquidCrystal::begin() {
  // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
  // according to datasheet, we need at least 40ms after power rises above 2.7V
  // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
  delayMicroseconds(50000);
  // Now we pull both RS and R/W low to begin commands
  digitalWrite(_rs_pin, LOW);
  digitalWrite(_enable_pin, LOW);
  
  //put the LCD into 4 bit mode
    // this is according to the hitachi HD44780 datasheet
    // figure 24, pg 46

    // we start in 8bit mode, try to set 4 bit mode
/*_bitString=3;
    spiSendOut();
pulseEnable();*/
write4bits(0x03);
    delayMicroseconds(4500); // wait min 4.1ms

    // second try
    write4bits(0x03);
    delayMicroseconds(4500); // wait min 4.1ms
    
    // third go!
    write4bits(0x03);
    delayMicroseconds(150);

    // finally, set to 4-bit interface
    write4bits(0x02);

  // finally, set # lines, font size, etc.
  command(LCD_FUNCTIONSET | LCD_2LINE);  

  // turn the display then clear
  command(LCD_DISPLAYCONTROL | LCD_DISPLAYON);
  command(LCD_CLEARDISPLAY);
}

/********** high level commands, for the user! */

void LiquidCrystal::home()
{
  command(LCD_SETDDRAMADDR);
}

/*********** mid level commands, for sending data/cmds */

inline void LiquidCrystal::command(uint8_t value) {
  send(value, LOW);
}

inline size_t LiquidCrystal::write(uint8_t value) {
  send(value, HIGH);
  return 1; // assume sucess
}

/************ low level data pushing commands **********/

// write either command or data, with automatic 4/8-bit selection
void LiquidCrystal::send(uint8_t value, uint8_t mode) {
    bitWrite(_bitString, _rs_pin, mode); //set RS to mode
    spiSendOut();
    
//we are not using RW with SPI so we are not even bothering
//or 8BITMODE so we go straight to write4bits
    write4bits(value>>4);
    write4bits(value);    
}

void LiquidCrystal::pulseEnable(void) {
    bitWrite(_bitString, _enable_pin, LOW);
    spiSendOut();
delayMicroseconds(1);
bitWrite(_bitString, _enable_pin, HIGH);
    spiSendOut();
delayMicroseconds(1);    // enable pulse must be >450ns
bitWrite(_bitString, _enable_pin, LOW);
    spiSendOut();
delayMicroseconds(40);   // commands need > 37us to settle
}

void LiquidCrystal::write4bits(byte value) {
    for (byte i = 4; i < 8; i++)
{
 //we put the four bits in the _bit_string
 bitWrite(_bitString, i, ((value >> (i - 4)) & 0x01));
}
//and send it out
spiSendOut();
  pulseEnable();
}

void LiquidCrystal::spiSendOut() //SPI #############################
{
  initSPI();
  
  digitalWrite(_latchPin, LOW);
  SPI.transfer(_bitString);
  digitalWrite(_latchPin, HIGH);
}
5  Using Arduino / Sensors / Re: 1 Wire DS18B20 Minimal Coding on: June 09, 2013, 02:09:05 pm
A paltry 32 bytes is the kind of thing I need. I've changed all my int's to unsigned ints... I'm tearing every library function I'm using to pieces...

I'm down to 5.2k, and I had dreams of putting this on an ATTiny45, but I'm afraid that's probably not possible.

I need to get another 1.2k to fit it, but I'll probably be switching to the ATTiny85.
6  Using Arduino / Sensors / Re: 1 Wire DS18B20 Minimal Coding on: June 08, 2013, 08:17:53 pm
http://www.adafruit.com/datasheets/DS18B20.pdf is a great resource...

I recoded the functions I need and I'm still trying to squeeze anything at all out I can. Here is what I'm using as of now.

Code:
float getTemp(){
  resetDS();
  writeByte(0x44); // start conversion, without parasite power on at the end
 
  resetDS();
  writeByte(0xBE); // Read Scratchpad
 
  return (readByte()|(readByte() << 8))*0.1125+32;//convert to deg f
}

void resetDS()
{
  pinMode(DS18S20_Pin, OUTPUT);
  digitalWrite(DS18S20_Pin, LOW);
  delayMicroseconds(255);//480u reqd
  pinMode(DS18S20_Pin, INPUT);
  delayMicroseconds(255);//480u reqd
  writeByte(0xCC);//ROM skip as only one sensor
}

void writeByte(byte data){
  pinMode(DS18S20_Pin, OUTPUT);
  for (byte mask = 00000001; mask>0; mask <<= 1){
    if (data & mask ){ // send 1
      digitalWrite(DS18S20_Pin,LOW);
      delayMicroseconds(10);//15u reqd
      digitalWrite(DS18S20_Pin,HIGH);
      delayMicroseconds(45);//60u total
    }
    else{ //if bitwise and resolves to false
      digitalWrite(DS18S20_Pin,LOW); // send 0
      delayMicroseconds(50);
      digitalWrite(DS18S20_Pin,HIGH);
      //delayMicroseconds(5);//60u total is slow enough to negate needing this
    }
  }
}

byte readByte(){
  byte r = 0;
  for (byte mask = 00000001; mask>0; mask <<= 1){
    pinMode(DS18S20_Pin, OUTPUT);
    digitalWrite(DS18S20_Pin, LOW);
    //delayMicroseconds(3);//1u reqd pinMode() is slow enough to negate needing this
    pinMode(DS18S20_Pin, INPUT); // let pin float, pull up will raise
    delayMicroseconds(10);//15u reqd
    if(digitalRead(DS18S20_Pin))r|=mask;
    delayMicroseconds(40);//60u complete cycle
  }
  return r;
}
7  Using Arduino / Sensors / Re: 1 Wire DS18B20 Minimal Coding on: June 08, 2013, 05:50:38 pm
I have it down to the three functions
ds.reset()
ds.write()
ds.read()

I'm in the process of combing through those functions in the OneWire library to reduce their footprint.
8  Using Arduino / Sensors / Re: 1 Wire DS18B20 Minimal Coding on: June 07, 2013, 06:33:18 pm
That did get me quite a bit, I appreciate it.
I've switched my code over to an SPI variant as the library code is smaller and easier to rummage through, and I'm exploring the possibility of adding an SD to log my temperature.
I'm still interested in any other size reductions anyone has.
9  Using Arduino / Displays / Re: LiquidCrystal_SR3W Wiring E to the Strobe Pin on: June 07, 2013, 01:03:37 pm
I just want to know why I can't hook my E pin from my HD44780 to the strobe line between the Arduino and the 74HC595. If I hook it up as I've always seen it it works, but not when those 3 are together.
10  Using Arduino / Sensors / 1 Wire DS18B20 Minimal Coding on: June 07, 2013, 12:44:58 pm
I'm working on paring a sketch for space as I'm placing it on an ATTiny45, and so I've been deleting code left and right, replacing function calls with hard coded data.

Also... the data byte array in the example says it needs 9 bytes, but it only utilizes 2? I chopped it down to a 2 byte array and it worked, but I don't know if I'm somehow wrong for doing that.

One more thing... when I first plug in my sensor (doesn't happen when it's simply reset) I get a junk reading of 185.0f for my first reading. Not a big problem, but annoying.

I've come to the point where I'm not sure I can do any more. Help me chop!
Here is the getTemp function:
Code:
float getTemp(){
  resetDS();
  writeByte(0x44); // start conversion, without parasite power on at the end
 
  resetDS();
  writeByte(0xBE); // Read Scratchpad
 
  return (readByte()|(readByte() << 8))*0.1125+32;//convert to deg f
}

void resetDS()
{
  pinMode(DS18S20_Pin, OUTPUT);
  digitalWrite(DS18S20_Pin, LOW);
  delayMicroseconds(255);//480u reqd
  pinMode(DS18S20_Pin, INPUT);
  delayMicroseconds(255);//480u reqd
  writeByte(0xCC);//ROM skip as only one sensor
}

void writeByte(byte data){
  pinMode(DS18S20_Pin, OUTPUT);
  for (byte mask = 00000001; mask>0; mask <<= 1){
    if (data & mask ){ // send 1
      digitalWrite(DS18S20_Pin,LOW);
      delayMicroseconds(10);//15u reqd
      digitalWrite(DS18S20_Pin,HIGH);
      delayMicroseconds(45);//60u total
    }
    else{ //if bitwise and resolves to false
      digitalWrite(DS18S20_Pin,LOW); // send 0
      delayMicroseconds(50);
      digitalWrite(DS18S20_Pin,HIGH);
      //delayMicroseconds(5);//60u total is slow enough to negate needing this
    }
  }
}

byte readByte(){
  byte r = 0;
  for (byte mask = 00000001; mask>0; mask <<= 1){
    pinMode(DS18S20_Pin, OUTPUT);
    digitalWrite(DS18S20_Pin, LOW);
    //delayMicroseconds(3);//1u reqd pinMode() is slow enough to negate needing this
    pinMode(DS18S20_Pin, INPUT); // let pin float, pull up will raise
    delayMicroseconds(10);//15u reqd
    if(digitalRead(DS18S20_Pin))r|=mask;
    delayMicroseconds(40);//60u complete cycle
  }
  return r;
}

Here is the rest of the program...
Code:
#include <SPI.h>
#include <MyLiquidCrystal.h>
int DS18S20_Pin = 5; //DS18S20 thermometer pin*/

byte heatingStage=0;

const int q0 = 1;//first unused 74HC595 pin
const int q2 = 4;//second unused 74HC595 pin

LiquidCrystal lcd(0);// initialize LCD with the number of the ss/latch
     
void setup() { 
  lcd.begin(16, 2);// set up the LCD's number of columns and rows:
}
     
void loop() {
  noInterrupts();
  float temperature = getTemp();//temperature data
  interrupts();
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(temperature,1);
  lcd.print("f"); 
 
  if(temperature < 72 && heatingStage!=q0+q2){//stage two heating
    lcd._bitString=heatingStage=q0+q2;
    lcd.spiSendOut();
    lcd.setCursor(0,1);
    lcd.print("Stage 2 Heating ");
  }
  if(temperature < 78 && temperature > 72 && heatingStage!=q0){//stage one heating
    lcd._bitString=heatingStage=q0;
    lcd.spiSendOut();
    lcd.setCursor(0,1);
    lcd.print("Stage 1 Heating"); 
  } 
  if(temperature > 78){//heat off
    lcd._bitString=heatingStage=0;
    lcd.spiSendOut();
    lcd.setCursor(0,1);
    lcd.print("Heating Off    ");
  }
}
11  Using Arduino / Displays / LiquidCrystal_SR3W Wiring E to the Strobe Pin on: June 06, 2013, 10:59:59 pm
First of all... man the documentation is just not right ... the pinout on the schematic doesn't match the library pinout at all,
which is where I got my wiring instructions.
This is from the library:
Code:
//   +--------------------------------------------+
//   |                 MCU                        |
//   |   IO1           IO2           IO3          |
//   +----+-------------+-------------+-----------+
//        |             |             |
//        |             |             |
//   +----+-------------+-------------+-----------+
//   |    Strobe        Data          Clock       |
//   |          8-bit shift/latch register        | 74HC595N
//   |    Qa0  Qb1  Qc2  Qd3  Qe4  Qf5  Qg6  Qh7  |
//   +----+----+----+----+----+----+----+----+----+
//        |    |    |    |    |    |    |   
//        |11  |12  |13  |14  |6   |5   |4   (LCD pins)
//   +----+----+----+----+----+----+----+----+----+
//   |    DB4  DB5  DB6  DB7  E    Rw   RS        |
//   |                 LCD Module                 |

My problem is according to the schematic...


... you can hook up the "E" line from a HD44780 to the strobe pin, which is pin 2 on my Teensy.

I tried this and had no luck. I would VERY much like to use the schematic pinout for "E" as it frees yet another pin on the shift register.

Here is my code, it's just the example code, so you can see my pinouts.
Code:
#include <LCD.h>
#include <LiquidCrystal_SR3W.h>

// constructor prototype parameter: data, clk, strobe, E, RW, RS, D4, D5, D6, D7
// Notice that E in this schematic is driven by the strobe pin so we will use a free
// pin Qa (0) and that R/!W is hardwired to GND, so we donĀ“t care for driving it,
// use another free pin Qb (1).
// Assuming that the header is connected to the same digital IO pin.
// Schematic also available in the LiquidCrustal_SR3W.(h|c)
LiquidCrystal_SR3W iLCD(0, 1, 2, 4, 5, 6, 0, 1, 2, 3);
void setup ( )
{
   iLCD.begin ( 16, 2 );

   iLCD.print("Hello");
}

void loop ()
{
   // your code here ...
}
12  Using Arduino / LEDs and Multiplexing / Re: 3 wire SPI, HD44780 and 74HC595 Toggling 595 Pins 14/Q0, 2/Q2 on: June 01, 2013, 05:40:37 pm
I've found a workaround with the library.

Modify the LiquidCrystal.h by making the _bitString variable and spiSendOut() functions public.
Code:
public: uint8_t _bitString; //for SPI  bit0=not used, bit1=RS, bit2=RW, bit3=Enable, bits4-7 = DB4-7
  void spiSendOut();      // SPI

Then by setting the value of bitString and sending it you can set the register values; 1 = q0, 4=q2, 5=q0+q2

Code:
lcd._bitString=VALUE;
lcd.spiSendOut();

This is really useful of you don't want to waste those pins on your 74HC595!
13  Using Arduino / LEDs and Multiplexing / 3 wire SPI, HD44780 and 74HC595 Toggling 595 Pins 14/Q0, 2/Q2 on: May 31, 2013, 07:17:49 pm
I've setup my Teensy 2.0 with the configuration and code found here http://playground.arduino.cc/Main/LiquidCrystal#Information.

I'm trying to find a solution to use the other two pins not used by the LCD on the 74HC595 to toggle some solid state relays.

My final product will be on an ATTiny45 and I want to leave the other three pins on the Tiny available for future possible functionality.
I'm open to looking at other libraries since I'm pretty sure this one doesn't have that functionality.
14  Using Arduino / Microcontrollers / Re: Teensy 2.0 Teensy Loader Error on: February 26, 2013, 05:17:43 am
I found the program that was causing the problem. It didn't like some of Auslogics BoostSpeed's settings.
15  Using Arduino / Microcontrollers / Re: Teensy 2.0 Teensy Loader Error on: February 24, 2013, 11:12:15 pm
It is not a problem with the boards, it's the software.
It can't be the last sketch I uploaded doing this, I ALREADY SAID I'VE UPLOADED A BUNCH OF DIFFERENT SKETCHES.
If it could be a background application, and you have any idea of how that could be possible, let me know.

I know I'm asking you guys for help here, but seriously if you have anything I can TRY to do, please let me know.

I've posted my problem on the PJRC forums, they have alot less traffic than this forum does, and I don't honestly know if it's a problem on the Arduino side, or the Teensy side, so I'm looking in both places.
Pages: [1] 2