Show Posts
Pages: [1] 2 3 ... 20
1  Using Arduino / General Electronics / Re: attiny84 freezing on: June 13, 2014, 12:37:02 pm
hi there thanks for all your feedback
yes I would agree it is the 3 phase what is playing me up, still having issues so I am all out of ideas?

I have look into the watchdog timer but just seem to reset like every 10s so I don't no if I have dun something wrong?

Code:
//         ***  INPUT'S  ***
const int HeatIn1   =  7;    // input from PC 1
const int HeatIn2   =  8;    // input from PC 2
const int overload1 =  9;    // overload cut out 1
const int overload2 = 10;    // overload cut out 2
const int reverse   =  6;   // reverse swich for heat's

//          *** OUTPUT'S  ***
const int valve     =  11;    // valve in pooler room       // not being used
const int LED       =  5;    // lock out led
const int pump      =  4;    //  pump in pooler room
const int heater1   =  3;    // heater 1 output forwch
const int heater1R  =  2;    // heater 1 output revus
const int heater2   =  1;    // heater 2 output forwch
const int heater2R  =  0;    // heater 2 output revus


#include <avr/wdt.h>

unsigned long resetTime = 0;
#define TIMEOUTPERIOD 10000             // You can make this time as long as you want,
                                       // it's not limited to 8 seconds like the normal
                                       // watchdog
#define doggieTickle() resetTime = millis();  // This macro will reset the timer
void(* resetFunc) (void) = 0; //declare reset function @ address 0

void watchdogSetup()
{
cli();  // disable all interrupts
wdt_reset(); // reset the WDT timer
MCUSR &= ~(1<<WDRF);  // because the data sheet said to
/*
WDTCSR configuration:
WDIE = 1 :Interrupt Enable
WDE = 1  :Reset Enable - I won't be using this on the 2560
WDP3 = 0 :For 1000ms Time-out
WDP2 = 1 :bit pattern is
WDP1 = 1 :0110  change this for a different
WDP0 = 0 :timeout period.
*/
// Enter Watchdog Configuration mode:
WDTCSR = (1<<WDCE) | (1<<WDE);
// Set Watchdog settings: interrupte enable, 0110 for timer
WDTCSR = (1<<WDIE) | (0<<WDP3) | (1<<WDP2) | (1<<WDP1) | (0<<WDP0);
sei();
}


ISR(WDT_vect) // Watchdog timer interrupt.
{
  if(millis() - resetTime > TIMEOUTPERIOD){
  doggieTickle();                                          // take these lines out
  resetFunc();     // This will call location zero and cause a reboot.
  }
}


void setup()
{
  watchdogSetup();
  //        ***  OUTPUT'S  ***
  pinMode(valve   ,    OUTPUT);
  pinMode(LED     ,    OUTPUT);
  pinMode(pump    ,    OUTPUT);
  pinMode(heater1 ,    OUTPUT);
  pinMode(heater1R,    OUTPUT);
  pinMode(heater2 ,    OUTPUT);
  pinMode(heater2R,    OUTPUT);


  //        ***  INPUT'S  ***
  pinMode(HeatIn1,     INPUT);
  pinMode(HeatIn2,     INPUT);
  pinMode(reverse,     INPUT);
  pinMode(overload1,   INPUT);
  pinMode(overload2,   INPUT);

}

int firstTime = true;

enum LoopOneStates {
  Heating, NotHeating, ReverseMode, ReverseModeOn,  ReverseModeOff, WaitingToHeat};

enum LoopTwoStates {
  EitherHot, OpenValve, StartPump, NeitherHot,  CloseValveStopPump};

void loop() {
    if (firstTime){
    firstTime = false;
  }
  if(millis() - resetTime > 2000){
    doggieTickle();  // if you uncomment this line, it will keep resetting the timer.
  }
 
 
  unsigned long currentTime = millis();
 
  //  LoopOne for Heater 1
if (digitalRead(overload1)) {
  static enum LoopOneStates state1 = Heating;
  static unsigned long state1EntryTime = 0;
  switch (state1) {
  case Heating:
    digitalWrite(heater1, HIGH);
    if (!digitalRead(HeatIn1))
      state1 = NotHeating;
    break;

  case NotHeating:
    digitalWrite(heater1, LOW);
    if (digitalRead(reverse)) {
      state1 = ReverseMode;
      state1EntryTime = currentTime;
    }
    if (digitalRead(HeatIn1))
      state1 = Heating;
    break;

  case ReverseMode:
    if (currentTime - state1EntryTime > 30000) {
      digitalWrite(heater1R, HIGH);
      state1 = ReverseModeOn;
      state1EntryTime = currentTime;
    }
    break;

  case ReverseModeOn:
    if (currentTime - state1EntryTime > 10000) {
      digitalWrite(heater1R, LOW);
      state1 = ReverseModeOff;
      state1EntryTime = currentTime;
    }
    break;

  case ReverseModeOff:
    if (currentTime - state1EntryTime > 30000) {
      state1 = WaitingToHeat;
    }
    break;

  case WaitingToHeat:
    if (digitalRead(HeatIn1)) {
      state1 = Heating;
    }
    break;
  }
}
else {
  digitalWrite(heater1,  LOW);
  digitalWrite(heater1R, LOW);
}


  //  LoopOne for Heater 2
  if (digitalRead(overload2)) {
  static enum LoopOneStates state2 = Heating;
  static unsigned long state2EntryTime = 0;
  switch (state2) {
  case Heating:
    digitalWrite(heater2, HIGH);
    if (!digitalRead(HeatIn2))
      state2 = NotHeating;
    break;

  case NotHeating:
    digitalWrite(heater2, LOW);
    if (digitalRead(reverse)) {
      state2 = ReverseMode;
      state2EntryTime = currentTime;
    }
    if (digitalRead(HeatIn2))
      state2 = Heating;
    break;

  case ReverseMode:
    if (currentTime - state2EntryTime > 30000) {
      digitalWrite(heater2R, HIGH);
      state2 = ReverseModeOn;
      state2EntryTime = currentTime;
    }
    break;

  case ReverseModeOn:
    if (currentTime - state2EntryTime > 10000) {
      digitalWrite(heater2R, LOW);
      state2 = ReverseModeOff;
      state2EntryTime = currentTime;
    }
    break;

  case ReverseModeOff:
    if (currentTime - state2EntryTime > 30000) {
      state2 = WaitingToHeat;
    }
    break;

  case WaitingToHeat:
    if (digitalRead(HeatIn2)) {
      state2 = Heating;
    }
    break;

  }
  }
else {
  digitalWrite(heater2,  LOW);
  digitalWrite(heater2R, LOW);
}

  //                                                        **loop two**
  //  LoopOne for Heater 1
  static enum LoopTwoStates state3 = EitherHot;
  static unsigned long state3EntryTime = 0;
  switch (state3) {
  case EitherHot:
    if (digitalRead(HeatIn1) || digitalRead(HeatIn2)) {
      state3 = OpenValve;
      state3EntryTime = currentTime;
    }
    break;

  case OpenValve:
    digitalWrite(valve, HIGH);
    // Fifteen seconds later, starty the pump
    if (currentTime - state3EntryTime > 5000) {
      state3 = StartPump;
      state3EntryTime = currentTime;
    }
    break;

  case StartPump:
    digitalWrite(pump, HIGH);
    state3 = NeitherHot;
    state3EntryTime = currentTime;
    break;

  case NeitherHot:
    // Wait for a full 30 minutes with neither heat indicators on
    if (digitalRead(HeatIn1) || digitalRead(HeatIn2)) {
      // Reset the timer if either heater is on
      state3EntryTime = currentTime;
    }
    if (currentTime - state3EntryTime > 1000UL*60UL*30UL) {
      state3 = CloseValveStopPump;
    }
    break;

  case CloseValveStopPump:
    digitalWrite(valve,       LOW);
    digitalWrite(pump,        LOW);
    state3 = EitherHot;
    break;
  }
  //     Lock out LED
  if (!digitalRead(overload1) || !digitalRead(overload2)) {
     digitalWrite(LED,     HIGH);
  }
     else {
     digitalWrite(LED,     LOW);   
  }
}

2  Using Arduino / Programming Questions / digital read on stat up questions on: June 05, 2014, 03:44:56 pm
Hi there
What I am trying to do is when the arduino starts up I want it to look at a state of a digital pin and choose to do one piece of code or another depending on the state of the input pin being high or low. So in other words in set up to choose to do one loop or another.
But I don't want it to continuously look at the input pin just on start up.

I hope that makes sense, any help would be appreciated.

thanks Joe
3  Using Arduino / General Electronics / Re: regulating 45v to 35v on: April 03, 2014, 02:55:04 pm
 literally 45 to 35V

the 45v is being used for something else so going to pick of that. need to drop it down for a battery charging circuit
4  Using Arduino / General Electronics / Re: attiny84 freezing on: April 03, 2014, 02:32:42 pm
hi there I have test the caps and they seem fine
here is the code


Code:
---------------------------------------------
Set heater1 to match HeatIn1.
 
 If HeatIn1 is low and reverse is high:
 delay 30sec
 write heater1R high
 delay 10sec
 write heater1R low
 delay 30sec
 Wait for HeatIn1 to come on
 
 Set heater2 to match HeatIn2.
 
 If HeatIn2 is low and reverse is high:
 delay 30sec
 write heater2R high
 delay 10sec
 write heater2R low
 delay 30sec
 Wait for HeatIn1 to come on
 
 if HeatIn1 or HeatIn2 are high:

 delay 5sec
 write pump high (Start pump)
 
 if HeatIn1 and HeatIn2 have been low for a full 30 minutes:

 write pump low (Stop pump)
 
 If overload 1 or 2 are high
 write LED high
 */

//         ***  INPUT'S  ***
const int HeatIn1   =  7;    // input from PC 1
const int HeatIn2   =  8;    // input from PC 2
const int overload1 =  9;    // overload cut out 1
const int overload2 = 10;    // overload cut out 2
const int reverse   =  6;   // reverse swich for heat's

//          *** OUTPUT'S  ***
const int valve     =  11;    // valve in pooler room       // not being used
const int LED       =  5;    // lock out led
const int pump      =  4;    //  pump in pooler room
const int heater1   =  3;    // heater 1 output forwch
const int heater1R  =  2;    // heater 1 output revus
const int heater2   =  1;    // heater 2 output forwch
const int heater2R  =  0;    // heater 2 output revus



void setup()
{
  //        ***  OUTPUT'S  ***
  pinMode(valve   ,    OUTPUT);
  pinMode(LED     ,    OUTPUT);
  pinMode(pump    ,    OUTPUT);
  pinMode(heater1 ,    OUTPUT);
  pinMode(heater1R,    OUTPUT);
  pinMode(heater2 ,    OUTPUT);
  pinMode(heater2R,    OUTPUT);


  //        ***  INPUT'S  ***
  pinMode(HeatIn1,     INPUT);
  pinMode(HeatIn2,     INPUT);
  pinMode(reverse,     INPUT);
  pinMode(overload1,   INPUT);
  pinMode(overload2,   INPUT);

}
enum LoopOneStates {
  Heating, NotHeating, ReverseMode, ReverseModeOn,  ReverseModeOff, WaitingToHeat};

enum LoopTwoStates {
  EitherHot, OpenValve, StartPump, NeitherHot,  CloseValveStopPump};

void loop() {
  unsigned long currentTime = millis();
 
  //  LoopOne for Heater 1
if (digitalRead(overload1)) {
  static enum LoopOneStates state1 = Heating;
  static unsigned long state1EntryTime = 0;
  switch (state1) {
  case Heating:
    digitalWrite(heater1, HIGH);
    if (!digitalRead(HeatIn1))
      state1 = NotHeating;
    break;

  case NotHeating:
    digitalWrite(heater1, LOW);
    if (digitalRead(reverse)) {
      state1 = ReverseMode;
      state1EntryTime = currentTime;
    }
    if (digitalRead(HeatIn1))
      state1 = Heating;
    break;

  case ReverseMode:
    if (currentTime - state1EntryTime > 30000) {
      digitalWrite(heater1R, HIGH);
      state1 = ReverseModeOn;
      state1EntryTime = currentTime;
    }
    break;

  case ReverseModeOn:
    if (currentTime - state1EntryTime > 10000) {
      digitalWrite(heater1R, LOW);
      state1 = ReverseModeOff;
      state1EntryTime = currentTime;
    }
    break;

  case ReverseModeOff:
    if (currentTime - state1EntryTime > 30000) {
      state1 = WaitingToHeat;
    }
    break;

  case WaitingToHeat:
    if (digitalRead(HeatIn1)) {
      state1 = Heating;
    }
    break;
  }
}
else {
  digitalWrite(heater1,  LOW);
  digitalWrite(heater1R, LOW);
}


  //  LoopOne for Heater 2
  if (digitalRead(overload2)) {
  static enum LoopOneStates state2 = Heating;
  static unsigned long state2EntryTime = 0;
  switch (state2) {
  case Heating:
    digitalWrite(heater2, HIGH);
    if (!digitalRead(HeatIn2))
      state2 = NotHeating;
    break;

  case NotHeating:
    digitalWrite(heater2, LOW);
    if (digitalRead(reverse)) {
      state2 = ReverseMode;
      state2EntryTime = currentTime;
    }
    if (digitalRead(HeatIn2))
      state2 = Heating;
    break;

  case ReverseMode:
    if (currentTime - state2EntryTime > 30000) {
      digitalWrite(heater2R, HIGH);
      state2 = ReverseModeOn;
      state2EntryTime = currentTime;
    }
    break;

  case ReverseModeOn:
    if (currentTime - state2EntryTime > 10000) {
      digitalWrite(heater2R, LOW);
      state2 = ReverseModeOff;
      state2EntryTime = currentTime;
    }
    break;

  case ReverseModeOff:
    if (currentTime - state2EntryTime > 30000) {
      state2 = WaitingToHeat;
    }
    break;

  case WaitingToHeat:
    if (digitalRead(HeatIn2)) {
      state2 = Heating;
    }
    break;

  }
  }
else {
  digitalWrite(heater2,  LOW);
  digitalWrite(heater2R, LOW);
}

  //                                                        **loop two**
  //  LoopOne for Heater 1
  static enum LoopTwoStates state3 = EitherHot;
  static unsigned long state3EntryTime = 0;
  switch (state3) {
  case EitherHot:
    if (digitalRead(HeatIn1) || digitalRead(HeatIn2)) {
      state3 = OpenValve;
      state3EntryTime = currentTime;
    }
    break;

  case OpenValve:
    digitalWrite(valve, HIGH);
    // Fifteen seconds later, starty the pump
    if (currentTime - state3EntryTime > 5000) {
      state3 = StartPump;
      state3EntryTime = currentTime;
    }
    break;

  case StartPump:
    digitalWrite(pump, HIGH);
    state3 = NeitherHot;
    state3EntryTime = currentTime;
    break;

  case NeitherHot:
    // Wait for a full 30 minutes with neither heat indicators on
    if (digitalRead(HeatIn1) || digitalRead(HeatIn2)) {
      // Reset the timer if either heater is on
      state3EntryTime = currentTime;
    }
    if (currentTime - state3EntryTime > 1000UL*60UL*30UL) {
      state3 = CloseValveStopPump;
    }
    break;

  case CloseValveStopPump:
    digitalWrite(valve,       LOW);
    digitalWrite(pump,        LOW);
    state3 = EitherHot;
    break;
  }
  //     Lock out LED
  if (!digitalRead(overload1) || !digitalRead(overload2)) {
     digitalWrite(LED,     HIGH);
  }
     else {
     digitalWrite(LED,     LOW);   
  }
}
5  Using Arduino / General Electronics / regulating 45v to 35v on: April 03, 2014, 01:58:13 pm
hi there what is the best way I can regulate 45v DC to 35v DC 2A?
or if it is any help I could do it on the AC side? maybe us a x capacitor?

thanks Joe
6  Using Arduino / General Electronics / Re: selecting a temp sensor on: March 19, 2014, 04:02:15 pm
ok thanks

so any one have any experience with  DS18B20 over long lengths?

3 wire or 2 wire?
7  Using Arduino / General Electronics / Re: selecting a temp sensor on: March 19, 2014, 03:00:20 pm
I'm ok with the cable

and don't think the Cat and Kitten would be a good idea for me as we don't wont anything in there just the sensor
8  Using Arduino / General Electronics / selecting a temp sensor on: March 19, 2014, 01:58:31 pm
hi there I'm looking for a temp sensor that I can use with my arduino couple of things I need to bear in mind is the lengths of the cable run could be up to 100m and there is a chance that the sensor could get paled out and the cable being shoed.
I have looked at the DS18B20 I presume I would have to run all 3 cause because of the length? and the volt regulator would not like being shoed?
did look at this:
 http://uk.mouser.com/ProductDetail/Vishay/NTCLP100E3472H/?qs=%2fha2pyFaduhmWE0I5%2f0lUWtfX8rOgM2KbyZFmBhB%252bYgmKCZRDfj59w%3d%3d

but don't no if they are any good?

any suggesting or ideas please say

thanks Joe
9  Using Arduino / Programming Questions / Re: encoder on: March 06, 2014, 02:41:10 pm
top people thanks  smiley-grin
10  Using Arduino / Programming Questions / encoder on: March 06, 2014, 02:11:46 pm
hi there I have this code what I got from here:  http://bildr.org/2012/08/rotary-encoder-arduino
what worked fine but in stead of counting in 1's I want to count in 0.1  how can I do this?

Code:

//these pins can not be changed 2/3 are special pins
int encoderPin1 = 2;
int encoderPin2 = 3;

volatile int lastEncoded = 0;
volatile long encoderValue = 0;

long lastencoderValue = 0;

int lastMSB = 0;
int lastLSB = 0;

void setup() {
  Serial.begin (9600);

  pinMode(encoderPin1, INPUT);
  pinMode(encoderPin2, INPUT);

  digitalWrite(encoderPin1, HIGH); //turn pullup resistor on
  digitalWrite(encoderPin2, HIGH); //turn pullup resistor on

  //call updateEncoder() when any high/low changed seen
  //on interrupt 0 (pin 2), or interrupt 1 (pin 3)
  attachInterrupt(0, updateEncoder, CHANGE);
  attachInterrupt(1, updateEncoder, CHANGE);

}

void loop(){
  //Do stuff here

  Serial.println(encoderValue);
  delay(1000); //just here to slow down the output, and show it will work  even during a delay
}


void updateEncoder(){
  int MSB = digitalRead(encoderPin1); //MSB = most significant bit
  int LSB = digitalRead(encoderPin2); //LSB = least significant bit

  int encoded = (MSB << 2) |LSB; //converting the 2 pin value to single number
  int sum  = (lastEncoded << 2) | encoded; //adding it to the previous encoded value

  if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++;
  if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue --;

  lastEncoded = encoded; //store this value for next time
}
11  Using Arduino / General Electronics / Re: attiny84 freezing on: March 06, 2014, 01:43:46 pm
hi there no I don't text them but when I'm next at site I will and we will see what we have
thanks again
Joe
12  Using Arduino / General Electronics / Re: attiny84 freezing on: March 01, 2014, 07:13:19 am
hi there I said I would post a pic and here we go





but I'm still having issues with it freezing so doe's any one have other suggesting?
only doing it about every 3-4 weeks
13  Using Arduino / General Electronics / Re: smd optocoupler on: February 23, 2014, 02:00:07 pm
ok thanks just looking at this one
http://uk.farnell.com/vishay-semiconductor/tcmd4000/optocoupler-transistor-o-p-3-75kv/dp/1469505RL
14  Using Arduino / General Electronics / smd optocoupler on: February 23, 2014, 01:14:34 pm
hi there
I have been using one of these Optocouplers and seem to work fine, but looking for a SMD Optocoupler now I no they do a smd of that opto but would like something smaller, does any one no of anything I could use?

http://uk.rs-online.com/web/p/products/6935952/
15  Using Arduino / General Electronics / Re: 3phase mains faliure circuit on: January 14, 2014, 04:20:56 pm
hehe I'm think im ok with 3 phase was I work with it 5 day a week.
just that I don't understand using a capacitor with a opto, and other people schematics I have seen have the phase going on to the opto and have the other leg of the opto go to the capacitor then the GND 

would you see any issues with using this opto as the PS2505-4 is not as available for me
http://uk.rs-online.com/web/p/optocouplers/6912218/
Pages: [1] 2 3 ... 20