Dear all,
I'm using a joystick to control some stepper motors, and I'd like to be able to record the joystick so that I can repeat motions exactly. I'd like to know how best to save this real-time stream of data.
(Click to enlarge?)
View attachment 41968
I'm using 18F4620 @20MHz.
1. The joystick (two axis analogue, connected to 10-bit AD pins on MCU) and a couple of slider pots are sampled 30 times/sec.
2. This generates a block >10 bytes in size.
3. Doing this 30 times/sec = 300 bytes/s.
4. Recording for, say, 30s means a total of about 10KBytes.
I'm sure this is fairly standard stuff, but I've searched online for a discussion of real-time data logging MCU techniques, and not found anything really satisfying or tailored to PIC18F peripherals etc.
Some issues:
1) On 18F PICs, variables in RAM have a nominal size limit of 256 bytes. Although linker script can be modified for larger vars, this is not doable when a large 10KB block is required.
2) Internal EEPROM of 18F4620 (256bytes) is not large enough.
Options considered:
1) External EEPROM I2C. Writing each block of 10Bytes takes about 1ms on 100kHz I2C bus.
2) External EEPROM SPI. Much faster than I2C.
3) Buffer largish blocks of data in RAM and write whole pages to external EEPROM, either I2C or SPI. Presumably this is more efficient than 1). or 2).
4) SRAM? No idea. Volatile is okay.
The process has to be reversible, as I need to eventually read this data for real-time playback.
Words from the wise?
Millions of thanks in advances,
Tom.