Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
avandalen committed Nov 15, 2017
1 parent 7570fc3 commit d163c05
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class Eeprom: public EEPROMClassEx
void write();
bool initialized();

unsigned storedInitValue, preweld_ms, pause_ms, weld_ms; // EEPROM addresses
unsigned storedInitValue_addr, preweld_ms_addr, pause_ms_addr, weld_ms_addr; // EEPROM addresses
};
29 changes: 15 additions & 14 deletions Eeprom.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@ const unsigned initValue = 12342; // take another value for new initialization
void Eeprom::init()
{ setMemPool(0, EEPROMSizeATmega328);
setMaxAllowedWrites(maxWrites);
storedInitValue = getAddress(sizeof(unsigned));
preweld_ms = getAddress(sizeof(unsigned));
pause_ms = getAddress(sizeof(unsigned));
weld_ms = getAddress(sizeof(unsigned));
orientation = getAddress(sizeof(unsigned));
storedInitValue_addr = getAddress(sizeof(unsigned));
preweld_ms_addr = getAddress(sizeof(unsigned));
pause_ms_addr = getAddress(sizeof(unsigned));
weld_ms_addr = getAddress(sizeof(unsigned));
orientation_addr = getAddress(sizeof(unsigned));
if(!initialized()) write(); // fill an empty EEPROM
}

void Eeprom::read()
{ menuItems[0].upDownVal.value = readInt(preweld_ms);
menuItems[1].upDownVal.value = readInt(pause_ms);
menuItems[2].upDownVal.value = readInt(weld_ms);
{ menuItems[0].upDownVal.value = readInt(preweld_ms_addr);
menuItems[1].upDownVal.value = readInt(pause_ms_addr);
menuItems[2].upDownVal.value = readInt(weld_ms_addr);
orientation = readInt(orientation_addr);// v6.2
}

void Eeprom::write()
{ writeInt(storedInitValue, initValue); // todo with update()?
writeInt(preweld_ms, menuItems[0].upDownVal.value);
writeInt(pause_ms, menuItems[1].upDownVal.value);
writeInt(weld_ms, menuItems[2].upDownVal.value);
writeInt(orientation, 0);
{ writeInt(storedInitValue_addr, initValue); // todo with update()?
writeInt(preweld_ms_addr, menuItems[0].upDownVal.value);
writeInt(pause_ms_addr, menuItems[1].upDownVal.value);
writeInt(weld_ms_addr, menuItems[2].upDownVal.value);
writeInt(orientation_addr, orientation);// v6.2
}

bool Eeprom::initialized()
{ return readInt(storedInitValue) == initValue;
{ return readInt(storedInitValue_addr) == initValue;
}

10 changes: 7 additions & 3 deletions Functions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ void selectContinuously()

void TFTinit()
{ tft.begin();
tft.setOrientation(eeprom.readInt(orientation));
//tft.setOrientation(eeprom.readInt(orientation_addr));
tft.setOrientation(orientation); // v6.2
tft.setFont(Terminal12x16);
}

Expand All @@ -113,8 +114,11 @@ void printValuesToSerial()
void setOrientation()
{ pollAll(); // works without too
if(upButton.on() && downButton.on())
{ if(eeprom.readInt(orientation)==0) eeprom.writeInt(orientation, 2);
else eeprom.writeInt(orientation, 0);
{ //if(eeprom.readInt(orientation_addr)==0) eeprom.writeInt(orientation_addr, 2);
//else eeprom.writeInt(orientation_addr, 0);
if(orientation==0) orientation=2; // v6.2
else orientation=0;
eeprom.write();
}
}

Expand Down
80 changes: 80 additions & 0 deletions Spotwelder-6.2.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
bool sinMaxDisabled = 1; // for test without transformer, must be 0

/*
Note: use the latest Arduino software and install the libraries.
Arduino spot welder controller
http://www.avdweb.nl/arduino/hardware-interfacing/spot-welder-controller.html
Copyright (C) 2012 Albert van Dalen
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at http://www.gnu.org/licenses .
Version 5.2 1-02-2015
Version 6.0 2-01-2017 added menu with TFT display
Version 6.1 22-05-2017 added set display orientation
Version 6.2 15-11-2017 orientation buf fixed
Program with FTDI programmer, Extra > Board > Arduino Uno
< 20ms >< >sinusMax_us
_____ _____ _____
zeroCross __| |_____| |_____| |__
_____________
weld __________________| |____
*/

#include <Arduino.h>
#include <Streaming.h>
#include <SPI.h>
#include <TFT_22_ILI9225.h>
#include <Albert.h>
#include <Switch.h>
#include <EEPROMex.h>
#include "Definitions.h"
#include "Classes.h"
#include "Eeprom.h"

Switch weldButton(weldButtonPin);
Switch upButton(upButtonPin);
Switch downButton(downButtonPin);
Switch selectButton(selectButtonPin);
TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RSTpin, TFT_RSpin, TFT_CSpin, 0); // hardware SPI
MenuItem preweldTimeItem = MenuItem("Preweld time", UpDownValue(50, 50, 0, 1000)); // value, step, minValue, maxValue
MenuItem pauseTimeItem = MenuItem("Pause", UpDownValue(500, 100, 0, 1000));
MenuItem weldTimeItem = MenuItem("Weld time", UpDownValue(250, 50, 50, 1000));
MenuItem menuItems[] = {preweldTimeItem, pauseTimeItem, weldTimeItem};
UpDownValue upDownItemNr = UpDownValue(0, 1, 0, 2); // 3 items 0 1 2
Menu menu;
Eeprom eeprom;

bool TFTused;
bool continuously;
unsigned orientation_addr, orientation; // v6.2

void setup()
{ Serial.begin(9600);
eeprom.init();
eeprom.read();
setpinModes();
TFTused = TFTusedJumper();
setOrientation(); // after eeprom.init()
if(TFTused) TFTinit();
if(!TFTused) blinkLed(4);
digitalWrite(ledPin, 1); // power on indication
selectContinuously();
printValuesToSerial();
if(TFTused) menu.displayAll();
}

void loop()
{ pollAll();
if(TFTused)
{ menu.control();
weldControlTFT();
} else
weldControlNoTFT();
}


0 comments on commit d163c05

Please sign in to comment.