JayAuckland
New Member
I'm blundering my way through writing data to a 24LC256 eeprom then retrieving the data but finding I have corruption issues.
The data is currently sampled by a 20M2 from two sources and written in real time into the eeprom as two 'tracks' of data.
Track 1 data (used to control a servo motor) originates with a potentiometer which is read then scaled to keep within servo control range. This scaled value is recorded into eeprom address 1. Next time it is sampled it is recorded to eeprom address 5, subsequently to addresses 9, 13, 17, 21... etc. Recording this Track 1 data and replaying it to a servo works just fine.
Track 2 data (used to capture control code numbers in the range 0 = 255) is received from time to time, through an Interrupt/serin function connected to a control bus (called TSB2) to which various bits of Picaxe-operated equipment are connected. When a non-0 code number is detected on this TSB serial control bus this number is written into Track 2 of the eeprom at addresses 2, 6, 10, 14, 18, 22... etc. When no control code number is being received a default 0 value is recorded into Track 2 addresses. On playback of Track 1 data to the servo the Track 2 code numbers are outputted back to the TSB2 bus to trigger some of the other pieces of equipment. This Track 2 playback function is working just fine.
THE PROBLEM I am stumped by is that if I then go back and re-record the Track 1 servo data (eg. to refine the servo movement) the Track 2 data becomes corrupted, with the occasional 0 -255 code numbers previously recorded now being replaced by a constantly changing stream of numbers in the tens of thousands range.
(Please ignore provision in the posted code for Tracks 3 and 4 which essentially will work identically to the Track 1 pot/servo arrangement... it was only as I started to introduce and fine-tune the Track 3 write/record and read/replay coding that I ran into this mini-disaster which no end of trial and error, reading, searching, strong tea, etc over several weeks has helped resolve.)
Currently I am only using enough eeprom to record about 15 seconds of data, it should be capable of recording a couple of minutes or more once I get things running. The occasional large pauses in the code are a way of synchronising the record and playback processes so the real-time data as replayed more or less matches the real time data as captured. The 'Mimic' and 'Startpos' functions built into the code are to assist the operator and should have no bearing on this issue. Ditto the detection of operator control pushbuttons via a resistor ladder and serial outputting to an indicator LED controller (IC4).
If anyone has time to help I'd appreciate it hugely and will check this thread several times a day to answer any questions or clarify what I'm trying to do, etc.
I've had to put the code in an attached file as is seems this message plus the length of the code is to long for the Forum system to accept.
Jay.
The data is currently sampled by a 20M2 from two sources and written in real time into the eeprom as two 'tracks' of data.
Track 1 data (used to control a servo motor) originates with a potentiometer which is read then scaled to keep within servo control range. This scaled value is recorded into eeprom address 1. Next time it is sampled it is recorded to eeprom address 5, subsequently to addresses 9, 13, 17, 21... etc. Recording this Track 1 data and replaying it to a servo works just fine.
Track 2 data (used to capture control code numbers in the range 0 = 255) is received from time to time, through an Interrupt/serin function connected to a control bus (called TSB2) to which various bits of Picaxe-operated equipment are connected. When a non-0 code number is detected on this TSB serial control bus this number is written into Track 2 of the eeprom at addresses 2, 6, 10, 14, 18, 22... etc. When no control code number is being received a default 0 value is recorded into Track 2 addresses. On playback of Track 1 data to the servo the Track 2 code numbers are outputted back to the TSB2 bus to trigger some of the other pieces of equipment. This Track 2 playback function is working just fine.
THE PROBLEM I am stumped by is that if I then go back and re-record the Track 1 servo data (eg. to refine the servo movement) the Track 2 data becomes corrupted, with the occasional 0 -255 code numbers previously recorded now being replaced by a constantly changing stream of numbers in the tens of thousands range.
(Please ignore provision in the posted code for Tracks 3 and 4 which essentially will work identically to the Track 1 pot/servo arrangement... it was only as I started to introduce and fine-tune the Track 3 write/record and read/replay coding that I ran into this mini-disaster which no end of trial and error, reading, searching, strong tea, etc over several weeks has helped resolve.)
Currently I am only using enough eeprom to record about 15 seconds of data, it should be capable of recording a couple of minutes or more once I get things running. The occasional large pauses in the code are a way of synchronising the record and playback processes so the real-time data as replayed more or less matches the real time data as captured. The 'Mimic' and 'Startpos' functions built into the code are to assist the operator and should have no bearing on this issue. Ditto the detection of operator control pushbuttons via a resistor ladder and serial outputting to an indicator LED controller (IC4).
If anyone has time to help I'd appreciate it hugely and will check this thread several times a day to answer any questions or clarify what I'm trying to do, etc.
I've had to put the code in an attached file as is seems this message plus the length of the code is to long for the Forum system to accept.
Jay.
Attachments
-
61.7 KB Views: 8