Hi everyone
I think I may have bitten off more than I can chew. I wanted to build a torch height controller (THC) for my cnc plasma cutter. I found a guy who had already built one, and he was nice enough to document the build and upload it to github here: GitHub - regeg/ArdunioTHC: Arduino-based CNC Plasma torch system Torch Height Controller
So I built the hardware but that is as far as I got. When I tried to verify the code for the Arduino, I got an 'EEPROM' was not declared in this scope error with the following lines under it:
NonVolatile.cpp:16:20: error: EEPROM.h: No such file or directory
NonVolatile.cpp: In member function 'void NonVolatileStorage::InitializeStorage(unsigned char)':
NonVolatile.cpp:78: error: 'EEPROM' was not declared in this scope
NonVolatile.cpp: In member function 'void NonVolatileStorage::DataLoad()':
NonVolatile.cpp:115: error: 'EEPROM' was not declared in this scope
NonVolatile.cpp: In member function 'void NonVolatileStorage::DataSave()':
NonVolatile.cpp:186: error: 'EEPROM' was not declared in this scope
NonVolatile.cpp: In member function 'unsigned char NonVolatileStorage::setBlock(unsigned char)':
NonVolatile.cpp:439: error: 'EEPROM' was not declared in this scope
I asked him about the error, but he couldn't suggest anything other than he used the Arduino 1.0.5 IDE, but I d/l and installed Arduino 1.0.5-r2.
I'm no programmer and have spent the last week or so googling that error, but everything I've found is not helping me.
Maybe someone here can have a look and point something out?
BTW, I had to break the code up into several posts as it exceeded the maximum allowed length of 9500 characters.
/*
* COPYRIGHT 2013 - Regis M. George
*
* License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
*
*/
/*
* NonVolatile.cpp
*
* Created on: Sep 22, 2012
* Author: Rege
*/
#include "Arduino.h"
#include "EEPROM.h"
#include "NonVolatile.h"
#include "THC.h"
//
// NonVolatileStorage Constructor
//
// When created, just set the flag to denote that no data is loaded.
//
NonVolatileStorage::NonVolatileStorage()
{
initialized = false;
// None of the following need initialized, but do
// it anyway to prevent uninitialized variable warnings.
addrOffset = 1;
scale = DEFAULT_SCALE;
voltSetPoint = DEFAULT_SET_POINT;
pilotArcCount = 0;
pierceCount = 0;
tipHours = 0;
tipMinutes = 0;
tipSeconds = 0;
writeCount = 0;
defaultState = THC_STATE_ENABLED;
}
//
// InitializeStorage
//
// This call if used to reset all values and then write
// those reset values to the flash. It is typically used when
// the flash is blank or if the flash data is corrupt (determined
// based on a magic number).
//
//
void NonVolatileStorage::InitializeStorage(unsigned char addrOffsetParam)
{
unsigned int addrOffsetValue;
// Initialize all the EEPROM memory assuming this
// is a new system.
addrOffset = addrOffsetParam;
scale = DEFAULT_SCALE;
voltSetPoint = DEFAULT_SET_POINT;
pilotArcCount = 0;
pierceCount = 0;
tipHours = 0;
tipMinutes = 0;
tipSeconds = 0;
writeCount = 0;
defaultState = THC_STATE_ENABLED;
addrOffsetValue = (addrOffset * MEMORY_BLOCK_SIZE) + 1;
//
// Now save the initialized data.
//
// Save the offset value
EEPROM.write(ADDR_OFFSET, addrOffset);
// Save the values that had defaults.
EEPROM.write(REL_ADDR_VOLT_SCALING + addrOffsetValue, scale);
EEPROM.write(REL_ADDR_VOLT_SETPOINT_B1 + addrOffsetValue, (unsigned char) (voltSetPoint & 0xff));
EEPROM.write(REL_ADDR_VOLT_SETPOINT_B2 + addrOffsetValue, (unsigned char) (voltSetPoint & 0xff00) >> 8);
EEPROM.write(REL_ADDR_DEFAULT_STATE + addrOffsetValue,
(unsigned char) defaultState);
// Save all the values that are just zeroed.
EEPROM.write(REL_ADDR_CHECK_BYTE + addrOffsetValue, EEPROM_MAGIC_NUMBER);
EEPROM.write(REL_ADDR_PILOT_ARC_COUNT_BYTE1 + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_PILOT_ARC_COUNT_BYTE2 + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_PIERCE_COUNT_BYTE1 + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_PIERCE_COUNT_BYTE2 + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_TIP_HOURS_BYTE + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_TIP_MINUTES_BYTE + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_TIP_SECONDS_BYTE + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_WRITE_COUNT_BYTE1 + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_WRITE_COUNT_BYTE2 + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_WRITE_COUNT_BYTE3 + addrOffsetValue, 0);
EEPROM.write(REL_ADDR_WRITE_COUNT_BYTE4 + addrOffsetValue, 0);
}
//
// DataLoad
//
// This method will load all the data from EEPROM. If there
// is no valid data (determined by an invalid check byte),
// then it will initialize everything and save it.
//
void NonVolatileStorage::DataLoad(void)
{
unsigned char byte1, byte2;
unsigned int addrOffsetValue;
// Read the offset value to see where the data is in RAM
addrOffset = EEPROM.read(ADDR_OFFSET);
addrOffsetValue = (addrOffset * MEMORY_BLOCK_SIZE) + 1;
// Get the magic number.
byte1 = EEPROM.read(REL_ADDR_CHECK_BYTE + addrOffsetValue);
// If the magic number is not right, assume the
// EEPROM has not been initialized.
if (byte1 != EEPROM_MAGIC_NUMBER)
{
InitializeStorage(0);
return;
}