PIC Waveform Recorder
In this article I’ll show you how you can use PIC microcontroller to record and store waveform patterns in its EEPROM memory and replay the sequence later. For this purpose we’ll need a signal/waveform generator to produce the signal, PIC internal A/D converter to sample and digitize the incoming signal, external I2C 8-bit D/A PCF8591 to convert it back to analog form and a simple PIC programmer to download the code into microcontroller FLASH memory. Up to 256 discreet 8 bit words then will be stored in PIC EEPROM memory. Source code can be downloaded at the bottom of the page.
Few words about the code: The source code is written in assembly language and uses Microchip EEPROM writing/reading sequence as a basis for signal recording. For simplicity reason only 128 of 256 available bytes are used. To test circuit functionality connect the signal source to AN1 input and Scope to digital to analog converter output. I’ve used RIGOL DG4062 waveform generator and DS2072 oscilloscope to test this design. Press Record push button to record one cycle of the wave. Now you can disconnect the generator. Press Play to output one cycle of the recorded waveform. Signals in the lower KHz range seem to work OK. Next figure shows the schematic of this simple design.
Limitations and possible future improvements of current design: A better synchronization routine is needed in order to avoid glitches while reproducing the recorded waveform. The beginning of the next cycle should start exactly were the previous cycle has stopped. The best way to improve the quality of the signal is to increase the memory size so you can store more waveform values in one cycle, also signal frequency range is limited due to I2C speed limit for A/D converter, currently set at 100KHz. Faster D/A should be used to increase the frequency range. Source code is here.
For more detail: PIC Waveform Recorder