How can I convert serial data to a binary sequence?
22 views (last 30 days)
> The sequence is 01011010 how can I change from the square wave shown here to a square wave that shows just 01011010? The data rate is 600 bits per second and I am sampling at about 3 times that. Thank you.
John BG on 24 Jun 2021
Edited: MathWorks Support Team on 24 Jun 2021
There are a couple ways to do this. The comments below are referring to John's initial Answer (Approach 2).
For the first approach, we've included a Simulink model.
Convert this analog serial signal into a digital signal, we will use a comparator. This will generate a series of 1s and 0s at “around 1800 Samples/second.” Then we will down-sample, but since we don’t know the exact original sample rate we have used interp1() instead of downsample(). This has the added benefit of handling nonuniform input sample rates but requires a time value for each sample. It generates our stream of 1s and 0s at 600 S/s. We can get away with this because the incoming symbol rate is exactly 600 b/s, therefore sampling at that rate guarantees us one sample per symbol (bit). More care may be needed to apply this approach to jittery signals. Finally, we can do digital processing to recover the input signal. In this case, we know the first 8 elements of this sequence will be our input data word. Additionally, we can plot the first 9 elements to see a graphical representation (the extra element helps the graph look as expected).
1) square the signal the time reference is not really needed. Clipping
2) Brendan, please let know if the following reasoning is consistent with your question:
in order to use the 600bps rate one has to know the time reference.
Visual observation reveals that about 15 samples make the 8 pulses of the basic sequence.
7 bursts take the whole scope shown, that comprises 2840-2640, 200 samples
200 samples are (approximately) 7*8=56 pulses
If you have assigned 1 bit per pulse, an estimate of the presented time span would be:
it would be safer to assign at least 3 samples per pulse.
3) synchronisation, how do want to sync?
4) can you present a time based graph? with the time vector, not the numerals. Meaning, can you, instead of
If you find this answer useful would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer
please click on the thumbs-up vote link
thanks in advance