jmlabuac
Newbie level 5
Hi guys...
I'm creating a program which is for a parking stall.... I wanted to count the number of pulses from the multicoin slot and then save it on the eeprom every second which we will define as p_amount... Also, this program increments around 3 every 5 minutes or every 300 pulses from the RTC which we will define as p_fee... Each pulse from the multicoin slot decrements the p_fee... If the system is suddenly experiences a power interruption, when it resumes operation, it will check the rtc values and compute accordingly, it will also check the p_amount and deduct it to the p_fee...
My problem is this... when I have generated pulses (let's say p_amount = 2 and p_fee = 4) from the microcontroller, after interrupting its power and resuming it... It seems that the value saved in the EEPROM is not what I expected... It should have a value of around p_fee = 2 since the p_amount should be subtracted from p_fee... But the value of p_fee becomes 4... It does not subtract but rather increases the value of p_fee... I'm confused. I tried it with type casting and without type casting...
I'm creating a program which is for a parking stall.... I wanted to count the number of pulses from the multicoin slot and then save it on the eeprom every second which we will define as p_amount... Also, this program increments around 3 every 5 minutes or every 300 pulses from the RTC which we will define as p_fee... Each pulse from the multicoin slot decrements the p_fee... If the system is suddenly experiences a power interruption, when it resumes operation, it will check the rtc values and compute accordingly, it will also check the p_amount and deduct it to the p_fee...
My problem is this... when I have generated pulses (let's say p_amount = 2 and p_fee = 4) from the microcontroller, after interrupting its power and resuming it... It seems that the value saved in the EEPROM is not what I expected... It should have a value of around p_fee = 2 since the p_amount should be subtracted from p_fee... But the value of p_fee becomes 4... It does not subtract but rather increases the value of p_fee... I'm confused. I tried it with type casting and without type casting...
Last edited: