Show Posts
Pages: [1] 2 3
1  Using Arduino / Project Guidance / Re: Peltier (TEC) based Temperature controller on: August 06, 2012, 03:51:04 am
Measured the voltage across the arduino, it stays at 5.13V throughout. The voltage doesn't drop below this value irrespective of whether the peltier is on or off.

Tried reducing the PWM and for some odd reason, it seems to work without any problems whenever the current is below 0.7Amps. As soon as the current is more than 0.7 amps, arduino freezes in a couple of seconds, even though the arduino voltage is still ~5.13V.
2  Using Arduino / Project Guidance / Re: Peltier (TEC) based Temperature controller on: August 03, 2012, 01:41:17 pm
I am supplying power through a DC power adapter rated for 12V, 5Amp. This supplies power to both arduino & L298 individually.

The arduino's vcc (5V) is connected to the logic supply of the L298. The power supply of L298 is 12V from the adapter. They all share a common ground. I've connected both the channels of L298 together, so that it can supply 4A max. Although I have never exceeded the current more than 2.5Amp.

Even I thought it could be power issues, but the strange part is the arduino freezes/resets after roughly 10 secs after the TEC module is turned on. It starts the TEC and then displays the temp for a couple of seconds and then out of nowhere it freezes leaving the TEC turned on. I don't change anything, no button press, no turning TEC on/off.

Really can't seem to figure out what could be wrong here.
3  Using Arduino / Project Guidance / Re: Peltier (TEC) based Temperature controller on: August 03, 2012, 08:03:53 am
Thanks a lot Riva for going through my code.

I am using this peltier http://in.element14.com/multicomp/mchpe-127-10-08-e/peltier-cooler-55w/dp/1639737

I din't refer any circuit, just connected the elements in the usual way. For L298, I referred the datasheet. I have given the circuit description in the beginning of the code.

I agree, the call to setup() could create problems, but arduino freezes even before I press the stop button, so setup() is actually never called in the execution. I'll try to remove it anyways and incorporate your suggestions but I doubt this will correct the arduino from freezing/reseting.
4  Using Arduino / Project Guidance / Re: HID RFID and ARDUINO etherten on: August 03, 2012, 05:30:57 am

The first part is simple, just have a look at the native SD card library for simple read/write operations.

The 2nd part involving editing over ethernet could be a bit complex but achievable. Complex because the SD Card and the ethernet shield both use the same SPI communication port. Just make sure to open and close the files on the SD card everytime you read/write.
5  Using Arduino / Project Guidance / Re: Powering a standalone ATMega project at 3.6V on: August 03, 2012, 05:26:37 am
Use a coin cell, CR2032. Its a 3V cell, is small, cheap and perfect for battery operated circuits.

And yes, you can power up the RF module from the arduino pin itself to save further power.

Make sure to use a 8Mhz crystal/oscillator in place of a 16 Mhz, as it can't operate below 4.5V as per the datasheet.
6  Using Arduino / Project Guidance / Re: Issue moving to standalone board on: August 03, 2012, 05:23:25 am
Make sure your connections are as per here, http://arduino.cc/en/Main/Standalone

Don't forget the 0.1uF capacitor across vcc and ground of the atmega. I also had a hard time making it run standalone without the capcaitor. For best results, put a big capacitor (10uF) and a smaller one (1nF) across the vcc and ground and as close to the atmega chip as possible.
7  Using Arduino / Project Guidance / Peltier (TEC) based Temperature controller on: August 03, 2012, 05:18:56 am
I have made a Peltier based Temperature controller. I have used L298 to control the current.

PWM signal from arduino is fed to the enable pin of the L298. I have written the following code to control the temperature of a box which is connected to the petlier. There is a LM35 temperature sensor inside the box.

When I test this code on my hardware without the load (peltier), everything seems to work as it is expected to, but when I connect the peltier to the L298, the arduino seems to freeze or reset after 10 seconds. I can't seem to figure out what could be wrong.

Code:
/*

    Thermo Electric Cooler (TEC)
   ````````````````````````````````
 
   
Circuit Description:
  Serial Communication  - Pin 0,1
  Input Buttons         - Pins 2,3,4
  TEC Module (H Bridge) - Pins 5,6,7
  LCD                   - Pins 8,9,10,11,12,13
  LED                   - Pin A0
  Current Sensor        - Pin A1
  LM35                  - Pin A3
 
 
H Bridge Description (L298)

  Enable Pin - Controls the votlage (indirectly current) applied across load.
 
  Digital Inputs:
      For positive voltage (cooling)
            Pin 6 - HIGH
            Pin 7 - LOW
      For negative voltage (heating)
            Pin 6 - LOW
            Pin 7 - HIGH     
 
_____________________________________________________________*/


#include <math.h>
#include <Button.h>
Button start_stop_button = Button(4,PULLUP);
Button dec_button = Button(3,PULLUP);
Button inc_button = Button(2,PULLUP);

#include <LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
char blank[] = "    ";                 // to earase 4 characters

double Tref = 20, Tmeas = 30;
int button_time = 0;
unsigned long lcd_time = 0, I_tym = 0;
float Imeas = 0;


//----------------------------Variables-----------------

float step_size = 1;         // Inc/Dec Button step size
float I_calib = 1;             // Current sensor calibration
float T_delta = 2;             // +- 3 degree Celsius
int Imax_dutyCycle = 120;      // 100 -> ~1.8 Amps of current

//------------------------------------------------------


void setup()
{
  Serial.begin(9600);
 
  pinMode(5,OUTPUT);    digitalWrite(5,LOW);
  pinMode(6,OUTPUT);    digitalWrite(6,LOW);
  pinMode(7,OUTPUT);    digitalWrite(7,LOW);
 
  lcd.begin(16, 2);
  lcd.print("Enter Tref: 20");
 
a:
 if(millis() - lcd_time > 2000)  //update lcd every 2 sec
    {
      float Tmeas = analogRead(3);
      for(int i=1;i<10;i++)
          Tmeas = (Tmeas + analogRead(3) ) / 2;   // take 10 samples avg value
      Tmeas = Tmeas * 500 / 1024;   
 
      lcd.setCursor(0,1);
      lcd.print("Tmeas : ");
      lcd.print(Tmeas);
      lcd_time = millis();
    } 

 if(inc_button.isPressed())
      {
        Tref += step_size;
        lcd.setCursor(12,0);
        lcd.print(Tref);
        delay(200);
      }
     
  if(dec_button.isPressed())
       {
        Tref -= step_size;
        lcd.setCursor(12,0);
        lcd.print(Tref);
        delay(200);
      }
 
  if(start_stop_button.isPressed())
      {
          lcd.clear();
          lcd.print("Starting...");
          goto b;
          delay(100);   
      }
 
  goto a;     
b:
   delay(1000);
}


void loop()
{
 //_____________________Temp_______________________ 
 
  float Tmeas = analogRead(3);
  for(int i=1;i<10;i++)
        Tmeas = (Tmeas + analogRead(3) ) / 2;   // take 10 samples avg value

  Tmeas = Tmeas * 500 / 1024;                     // convert to temp
 
//_______________________Current____________________
/*
  if(millis() - I_tym > 100)       // every 100 ms
  {
    calc_current();
    I_tym = millis();
  }
 */
 
//______________________LCD______________________
 
  if(millis() - lcd_time > 1000)  //update lcd every 1 sec
    {
      lcd.clear();
      lcd.print("Tr:");
      lcd.print(Tref);
//      lcd.setCursor(9,0);
    //  lcd.print("I:");
     // lcd.print(Imeas);
      lcd.setCursor(0,1);
      lcd.print("Tm:");
      lcd.print(Tmeas);
      lcd_time = millis();
    }

// ________________________Buttons________________________   
   
  if(inc_button.isPressed())
      {
        Tref += step_size;
        lcd.setCursor(3,0);
        lcd.print(Tref);
        lcd.print(blank);
        delay(200);
      }
     
  if(dec_button.isPressed())
       {
        Tref -= step_size;
        lcd.setCursor(3,0);
        lcd.print(Tref);
        lcd.print(blank);
        delay(200);
      }
       
  if(start_stop_button.isPressed())    // Used only to stop the controller
      {
       
        digitalWrite(5,LOW);       
        digitalWrite(6,LOW);
        digitalWrite(7,LOW);
        lcd.clear();
        delay(1000);
        setup();            // start all over again
        }
       
   
// ________________________Controller________________________

 
   float E = Tmeas - float(Tref);
   
   if( E > T_delta)    // cooling at max  - positive voltage
       {
            //positive voltage   
          digitalWrite(6,HIGH);
          digitalWrite(7,LOW);
         
          analogWrite(5,Imax_dutyCycle);
          lcd.setCursor(9,1);
          lcd.print("Max-C");
          lcd.setCursor(9,0);
          lcd.print("D:");
          lcd.print(Imax_dutyCycle *100/255); 
          lcd.print("%   ");
       }
 
    if( E < -T_delta)
        {
          //negative voltage
          digitalWrite(6,LOW);
          digitalWrite(7,HIGH);
          analogWrite(5,Imax_dutyCycle);
          lcd.setCursor(9,1);
          lcd.print("Max-H");
          lcd.setCursor(9,0);
          lcd.print("D:");
          lcd.print(Imax_dutyCycle *100/255); 
          lcd.print("%   ");
        }
       
     if( (E > - T_delta)  &&  (E < T_delta))
        {
          // PID or other control
         
          if( E >= 0   )  // cooling
            {
              digitalWrite(6,HIGH);
              digitalWrite(7,LOW);
             
              int d =  fscale( 0, T_delta, 0, Imax_dutyCycle, E, 0);           
              constrain(d,0,Imax_dutyCycle);
              analogWrite(5,d);
             
              lcd.setCursor(9,1);
              lcd.print("PID-C");
              lcd.setCursor(0,1);
              lcd.print("Tm:");
              lcd.print(Tmeas);
              lcd.setCursor(9,0);
              lcd.print("D:");
              lcd.print(d*100/255);
              lcd.print("%   ");           
            }
           
           else if(E < 0)
            {  // heating
              digitalWrite(6,LOW);
              digitalWrite(7,HIGH);
             
              int d =  fscale( (-1* T_delta), 0, Imax_dutyCycle, 0, E, 0);           
              constrain(d,0,Imax_dutyCycle);
              analogWrite(5,d);
             
              lcd.setCursor(9,1);
              lcd.print("PID-H");
              lcd.setCursor(0,1);
              lcd.print("Tm:");
              lcd.print(Tmeas);
              lcd.setCursor(9,0);
              lcd.print("D:");
              lcd.print(d*100/255);
              lcd.print("%   ");
            }
           
       }     
     
  delay(50);   
 
 Serial.print("Error ");
 Serial.print(E);
 Serial.print("   T : ");
 Serial.println(Tmeas);

 delay(500);
}


float fscale( float originalMin, float originalMax, float newBegin, float
newEnd, float inputValue, float curve){

  float OriginalRange = 0;
  float NewRange = 0;
  float zeroRefCurVal = 0;
  float normalizedCurVal = 0;
  float rangedValue = 0;
  boolean invFlag = 0;


  // condition curve parameter
  // limit range

  if (curve > 10) curve = 10;
  if (curve < -10) curve = -10;

  curve = (curve * -.1) ; // - invert and scale - this seems more intuitive - postive numbers give more weight to high end on output
  curve = pow(10, curve); // convert linear scale into lograthimic exponent for other pow function

  /*
   Serial.println(curve * 100, DEC);   // multply by 100 to preserve resolution 
   Serial.println();
   */

  // Check for out of range inputValues
  if (inputValue < originalMin) {
    inputValue = originalMin;
  }
  if (inputValue > originalMax) {
    inputValue = originalMax;
  }

  // Zero Refference the values
  OriginalRange = originalMax - originalMin;

  if (newEnd > newBegin){
    NewRange = newEnd - newBegin;
  }
  else
  {
    NewRange = newBegin - newEnd;
    invFlag = 1;
  }

  zeroRefCurVal = inputValue - originalMin;
  normalizedCurVal  =  zeroRefCurVal / OriginalRange;   // normalize to 0 - 1 float

  /*
  Serial.print(OriginalRange, DEC); 
   Serial.print("   "); 
   Serial.print(NewRange, DEC); 
   Serial.print("   "); 
   Serial.println(zeroRefCurVal, DEC); 
   Serial.println(); 
   */

  // Check for originalMin > originalMax  - the math for all other cases i.e. negative numbers seems to work out fine
  if (originalMin > originalMax ) {
    return 0;
  }

  if (invFlag == 0){
    rangedValue =  (pow(normalizedCurVal, curve) * NewRange) + newBegin;

  }
  else     // invert the ranges
  {   
    rangedValue =  newBegin - (pow(normalizedCurVal, curve) * NewRange);
  }

  return rangedValue;
}

8  Using Arduino / Project Guidance / GSM Shield + FSK Modulation/Demodulation on: July 06, 2012, 05:54:02 am
hi!

I was thinking of transferring digital data using my GSM Shield (based on SIM900 Module). I know the GSM Module can do a data call (CSD call) but my network operator has blocked it (I guess so). Every time I try to dial a number for data call, it says "No Carrier" but for a voice call, it connects.

So I thought of transferring my data on the voice channel itself, using FSK Modulation to send 2 different frequencies for 0 & 1 (binary). I generated a waveform from my picoscope and gave it to the mic input of the shield and connected a probe to the speaker out of the shield just to check the feasibility of the setup.

I tried sending a square wave but received a sine wave, then sent a sine wave and received a sine wave. Although the frequency of the sent and received sine wave matches but there is significant noise and the frequency jumps in between to random values.

With the noise its not possible to demodulate the signal. I don't have much knowledge about tele-communications, so if anyone could figure out what is wrong it would be a great help.

Regards

9  Using Arduino / Microcontrollers / Re: problem bootloading atmega8 on breadboard with arduino as ISP on: May 16, 2011, 12:40:54 pm

hey,

So did you finally get the bootloader working on Atmega8L ?

Even I've some of these lying around, could you share your settings please.
10  Using Arduino / Microcontrollers / Re: Serial USB Board for Standalone on: April 10, 2011, 12:54:45 pm

hey, thanks a lot...cleared my doubts!  smiley
11  Using Arduino / Microcontrollers / Serial USB Board for Standalone on: April 10, 2011, 11:22:02 am
hi,

I want to program my standalone arduino using the Arduino Serial USB Board which i got from sparkfun, http://www.sparkfun.com/products/8165.

According to Arduino site, its the revised mini USB adapter, http://arduino.cc/en/Main/MiniUSB

Now my question here is,
1. Can I use the DTR pin as shown in the circuit on arduino page to auto reset (via a capacitor).

2. What is the purpose of the jumper given on the top?
12  Using Arduino / Programming Questions / Re: Float over Serial Port on: April 04, 2011, 01:37:36 pm
Thanks for the quick reply!

But I think, my question is not clear.

I actually need help in using the serial commands like the Serial.read() and Serial.available().
Receiving int values is simple but how should I go about for multiple float values..?
13  Using Arduino / Programming Questions / Float over Serial Port on: April 04, 2011, 01:30:16 pm

hey, its my second consecutive post in this category.

I want to transmit data to Arduino via the Serial Monitor in the IDE.
The data is float values separated by a comma.

data -     12.291,5.612,1.9821,5.921,1.3,1.4,1.5

I want the arduino to read it and store it in a char array.
How should I go about it?
14  Using Arduino / Programming Questions / Re: Char to float conversion on: April 04, 2011, 08:07:49 am

hey, it works....thanks a lot! smiley
15  Using Arduino / Programming Questions / Re: Char to float conversion on: April 04, 2011, 07:44:22 am

hey Paul, I tried the following code, please let me know if it's my mistake...

Code:
char data[] = "231.065792";
float temp;

void setup()
{
  Serial.begin(9600);
  temp = atof (data);
  Serial.println(temp);
}

void loop()
{
}

Quote
Output = 231.07
Pages: [1] 2 3