Hi there, I'm fairly new to the PICAXE world and I've built a system that in simple terms counts in real time when an input pin pulses above a certain speed. However I'm having some issues with it, I've built it on a 28X2 module.
This count is stored as variables in Hours, Minutes and Seconds for the duration of the device running. There are certain stages in the code where it checks the input voltage to check it isn't falling below a certain level, if it does it writes the Hrs, Mins and Secs variable values to the EEPROM to save them so on the next power up it continues counting in real time from the same saved time. I have a big capacitor to hold the voltage in the system when the power goes out to give the PICAXE time to run through the program to save.
Now I also have a check at the start for the value of a digital input which can be connected with a serial display attached so i can then plug in and read the time that is stored on the device. For the PICAXE to pick this display up I obviously need to power cycle it as the reading of the digital input is the first part of the main code.
The problem that I'm having is that the EEPROM seems to be getting corrupted, and the values for Hrs, Mins and Secs end up being 255. This can happen in a few ways from what I've found, from disconnecting the digital input and display while its on to the device loosing power and it coming back suddenly, or while unplugging the aux jack when connected to the PC. I think the route of the problem lies in the serial connections and that something happens when it is disconnected while the PICAXE is still on.
I've managed to minimize the chance of it happening by pulling the inputs that are connected to ground if they are disconnected, also by turning off the power supplies before plugging in or unplugging any of the connections. The device runs in a reasonably harsh environment, its within the tolerances for the chip but its hot and there is quite a lot of vibration, although the PICAXE is AV mounted to reduce this and all wire connections are silicon sealed to prevent movement.
Now I need the device to be robust software wise and this is a major bug because as soon as 255 shows up in the EEPROM the count is ruined. It needs to be able to survive the power losses and the display being plugged in while its on. I didn't think these things would be a problem when I designed the system and really its to late to change the PCB that they are connected on. (not that I know what I would change).
Has anyone had any issues like this before? I've searched but haven't turned up anything...
I can add code if need be, but apart from writing the hrs, mins and secs value to the EEPROM and reading them at the start there is nothing else using the EEPROM.
My biggest feeling is its serial related and the chip cant handle the sudden disconnect of it.
This count is stored as variables in Hours, Minutes and Seconds for the duration of the device running. There are certain stages in the code where it checks the input voltage to check it isn't falling below a certain level, if it does it writes the Hrs, Mins and Secs variable values to the EEPROM to save them so on the next power up it continues counting in real time from the same saved time. I have a big capacitor to hold the voltage in the system when the power goes out to give the PICAXE time to run through the program to save.
Now I also have a check at the start for the value of a digital input which can be connected with a serial display attached so i can then plug in and read the time that is stored on the device. For the PICAXE to pick this display up I obviously need to power cycle it as the reading of the digital input is the first part of the main code.
The problem that I'm having is that the EEPROM seems to be getting corrupted, and the values for Hrs, Mins and Secs end up being 255. This can happen in a few ways from what I've found, from disconnecting the digital input and display while its on to the device loosing power and it coming back suddenly, or while unplugging the aux jack when connected to the PC. I think the route of the problem lies in the serial connections and that something happens when it is disconnected while the PICAXE is still on.
I've managed to minimize the chance of it happening by pulling the inputs that are connected to ground if they are disconnected, also by turning off the power supplies before plugging in or unplugging any of the connections. The device runs in a reasonably harsh environment, its within the tolerances for the chip but its hot and there is quite a lot of vibration, although the PICAXE is AV mounted to reduce this and all wire connections are silicon sealed to prevent movement.
Now I need the device to be robust software wise and this is a major bug because as soon as 255 shows up in the EEPROM the count is ruined. It needs to be able to survive the power losses and the display being plugged in while its on. I didn't think these things would be a problem when I designed the system and really its to late to change the PCB that they are connected on. (not that I know what I would change).
Has anyone had any issues like this before? I've searched but haven't turned up anything...
I can add code if need be, but apart from writing the hrs, mins and secs value to the EEPROM and reading them at the start there is nothing else using the EEPROM.
My biggest feeling is its serial related and the chip cant handle the sudden disconnect of it.