Hi guys, I am sitting with a strange problem. I built a prototype circuit, wrote the code in arduino IDE and it works 100%.
OK , let me start off with a description of what my circuit does. I have a H.D.C 1080 humidity / temp sensor connected to Arduino UNO. It gives out a 0-10 Volt and 4-20 mA control signal to a P.L.C ( this set point is set by the user.)Also have a 16x2 LCD and 2 push buttons to increment or decrement the setpoint. There is calculations done on my code regarding how to get the setpoint etc. This will al be done on the PLC
On my vero board prototype, it works great, no problems. Then I went one step further and designed the pcb on KiCAD, my very first, but definitely not my last design. Very chuffed with myself for going this far already.
OK, so I built the prototype pcb, burned the bootloader and flashed my code onto the target. And it works…sort off.
I initialized my “int SPCounter= 25;” and on the vero board proto UNO it displays that SPcounter as 25. Which is correct,exactly what I wanted…but on my prototype, the SPCounter is initialized at 256. Which is not correct…Somehow, somewhere my SPcounter got lost in translation… What is going on ? Any suggestions ?
I have used command prompt avrdude to erase the flash and eeprom, but everytime my SPcounter starts at 256.
If you need me to post the code, please just let me know…I think I have tried just about everything,my final try is going to be to write the code over in C and load it like that…but my C skills is close to non existent at the moment…
Ill attach the code anyways…
Thanks for taking time out to help me
Here is my code:
//21-03-2018 Correct code for prototype PCB
LiquidCrystal lcd (7,6,5,4,3,2);
const int up = 8;
const int down = 9;
const int LED = 13;
const int OutV = 10;
const int OutmA = 11;
int upState = 0;
int downState = 0;
int SPCounter= 25;
int addr = 0;
void setup() //Setup to run once at startup
lcd.print (“NEW 2 Anstan”);
lcd.print (“Humidistat Ver2”);
NewSp = EEPROM.read (addr);
SPCounter = NewSp;
if( upState == HIGH || downState == HIGH )
lcd.print ("Setpoint: ");
if( upState != NewSp )
if ( upState == HIGH )
NewSp = SPCounter;
if( downState != NewSp )
if ( downState == HIGH )
NewSp = SPCounter;
lcd.print ("New SP: ");
lcd.print(“Rel Hum: “);
analogWrite(OutV, NewSp * 2.55);
analogWrite(OutmA, NewSp * 2.55);
lcd.print(“Device Serial Number=”);
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
sprintf(format, “%02X-%04X-%04X”, sernum.serialFirst, sernum.serialMid, sernum.serialLast);