Is there a simple (and preferably quick) way of copying the contents on an entire array into another (same sized) array?
I'm trying to make a very basic oscilloscope. I have this working, but of course the LCD display can't display the signal quickly enough. This isn't a problem as I'm storing the display data in an array, then if the signal is removed for more than 10 cycles at the start of the buffer filling routine, the contents of the buffer are played out (slowly) onto my display. This is all working well. The problem is that to ensure the buffer is full, capture continues from the moment the signal is removed until it has been filled. As it is difficult to judge when to ground the probe to initiate the 'playback' the buffer may contain mostly null contents, depending on when during the fill routine, the signal was removed.
My thought was that I could wait until the 'Capture_Array' was filled, then copy that into a second 'Playback_Array', if the playback was initiated part way through the 'Capture_Array' fill, it would be abandoned, with the filled contents from the 'Playback_Array' being used to update the display.
Hope I've explained my self.
I've tried something similar to this:
#DefineSignalPortB.5DirSignalIn#DefineStorLen128'Length of display storage bufferDimStorageArray(StorLen)DimPrintArray(StorLen)DimStorIdxAsWordDimBufferFullAsByteDimStop_PrintAsByte...CapturecontentsLetCapture_Array(StorIdx)=SignalLetStorIdx=StorIdx+1IfStorIdx>StorLenThen'We've filled the Capture_ArrayLetStorIdx=1LetBufferFull=1LetStop_Print=0LetPlayback_Array=Capture_ArrayEndIf
This leaves Playback array containing gibberish.
I had thought of copying the contents byte by byte (Let Playback_Array(1) = Capture_Array(1) etc.) but thought that would be rather slow and hold up the capture.
Last edit: mkstevo 2016-09-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I used a similar scheme to playback data captured during a data logging session. Adapted to the needs of a buffer fill, look for when the session ends, which seems to be done here, copy the address, and reset original address to start playback, like this:
Second thought is to load the shadow buffer during the inherent wait period during the adc conversion process. Take the first sample, during the next sample load the shadow buffer from the first result and so on, during the wait period. This is commonly known as the tad period for Pics. This would mean manual manipulation of the readAD() sub and storing locally in the gcb program.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I came up with a solution similar to your second suggestion. I load the buffer at full speed. Pause the buffer loading. Then create an abreviated display from the buffer contents. Display the abreviated data. Pause the display to give time to view the data. Then capture an entire buffer again.
As the playback can only be initiated during a wait period at the start of the buffer loading routine and the buffer loading is done at full speed (previously I wrote to the display in between each sample, moving the contents of the display each time), I'm now reasonably sure of getting a full buffer. The down side (sigh) is that the samples are taken so fast, that for slow signals the buffer is full of either highs or lows. To counter this I simply truncate long sequences as the playback display is generated. That allows me to display various frequencies within a frame of my sixteen pixels, though clearly, innacurately.
The 'project' is to make a simple 'oscilloscope', using a standard 1602 HD4480 type 16x2 LCD display. As it isn't feasible to show sine waves on such a display, I'm simply displaying square waves indicating a 'High' or a 'Low'. Once I get my LCD display connected, I'll upload a picture.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A second (slower) capture of a signal. Due to the compression of the 'playback' there isn't a whole lot of difference in the played waveform. (Though the backlight makes the display look better?)
Is there a simple (and preferably quick) way of copying the contents on an entire array into another (same sized) array?
I'm trying to make a very basic oscilloscope. I have this working, but of course the LCD display can't display the signal quickly enough. This isn't a problem as I'm storing the display data in an array, then if the signal is removed for more than 10 cycles at the start of the buffer filling routine, the contents of the buffer are played out (slowly) onto my display. This is all working well. The problem is that to ensure the buffer is full, capture continues from the moment the signal is removed until it has been filled. As it is difficult to judge when to ground the probe to initiate the 'playback' the buffer may contain mostly null contents, depending on when during the fill routine, the signal was removed.
My thought was that I could wait until the 'Capture_Array' was filled, then copy that into a second 'Playback_Array', if the playback was initiated part way through the 'Capture_Array' fill, it would be abandoned, with the filled contents from the 'Playback_Array' being used to update the display.
Hope I've explained my self.
I've tried something similar to this:
This leaves Playback array containing gibberish.
I had thought of copying the contents byte by byte (Let Playback_Array(1) = Capture_Array(1) etc.) but thought that would be rather slow and hold up the capture.
Last edit: mkstevo 2016-09-02
I used a similar scheme to playback data captured during a data logging session. Adapted to the needs of a buffer fill, look for when the session ends, which seems to be done here, copy the address, and reset original address to start playback, like this:
Second thought is to load the shadow buffer during the inherent wait period during the adc conversion process. Take the first sample, during the next sample load the shadow buffer from the first result and so on, during the wait period. This is commonly known as the tad period for Pics. This would mean manual manipulation of the readAD() sub and storing locally in the gcb program.
Thanks for your kind suggestions.
I came up with a solution similar to your second suggestion. I load the buffer at full speed. Pause the buffer loading. Then create an abreviated display from the buffer contents. Display the abreviated data. Pause the display to give time to view the data. Then capture an entire buffer again.
As the playback can only be initiated during a wait period at the start of the buffer loading routine and the buffer loading is done at full speed (previously I wrote to the display in between each sample, moving the contents of the display each time), I'm now reasonably sure of getting a full buffer. The down side (sigh) is that the samples are taken so fast, that for slow signals the buffer is full of either highs or lows. To counter this I simply truncate long sequences as the playback display is generated. That allows me to display various frequencies within a frame of my sixteen pixels, though clearly, innacurately.
The 'project' is to make a simple 'oscilloscope', using a standard 1602 HD4480 type 16x2 LCD display. As it isn't feasible to show sine waves on such a display, I'm simply displaying square waves indicating a 'High' or a 'Low'. Once I get my LCD display connected, I'll upload a picture.
I was inspired by this oscilloscope: LCDscope by Bruno Gavand.
Here is my attempt to do something similar:
A data capture, and a partial 'playback' of the captured data.
A second (slower) capture of a signal. Due to the compression of the 'playback' there isn't a whole lot of difference in the played waveform. (Though the backlight makes the display look better?)
Last edit: mkstevo 2016-09-03