I am amazed by RB's work, especially the BTc encoder!
I have been meaning to decode and graph BTc encoded data (arrays generated by his encoder) on a COMPUTER.
I have modelled a RC filter using PERL as this allows quick prototyping and, unfortunately, the kind of graphs I get is not exact (maybe similar to my un trained eye, except at extreme ends).
Also unlike the BTc encoder drawn waveform, the waveform I see from my data starts to oscillate between the power rail and ground after some time.
Here is how I model the RC filter :
The value of RC is the value suggested by RB's application :
R = 2966E
C = 0.22uF
Hence, in my code I have
This is exactly what the subroutine "V" in my code returns:
I put RB's encoded data in an array called 'sound_data' and I have a loop that iterates through it a byte (element) at a time (outer for loop), extracting a bit for every time period (inverse of the sampling frequency) from the MSB to the LSB (inner for loop) before progressing to the next bit.
This loop writes out the time and amplitude in comma separated format that I later load into Excel and graph the data, and try and match it with the graph shown by RB's Encoder application.
My final target is to create WAV file from the encoded data (arrays of data).
This should be easy to do once I have a 1:1 match of my generated graph with RB's graph. .. the place where I need some help right now![Confused :confused: :confused:](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Whole package up for grabs at :
https://sites.google.com/site/vimalsshankar/btc
I also attached images of "What it should be"(RB's BTC graph) and "What It is" (What Excel shows my data as)
As you can see, my data shows that my filter starts osciallting widly just after a few samples and does not follow RB's BTC waveform as shown as all!![Eek! :eek: :eek:](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I have been meaning to decode and graph BTc encoded data (arrays generated by his encoder) on a COMPUTER.
I have modelled a RC filter using PERL as this allows quick prototyping and, unfortunately, the kind of graphs I get is not exact (maybe similar to my un trained eye, except at extreme ends).
Also unlike the BTc encoder drawn waveform, the waveform I see from my data starts to oscillate between the power rail and ground after some time.
Here is how I model the RC filter :
Code:
V(t) = V_FINAL + (V_INITIAL - V_FINAL) * (e ** (-t / RC ));
where,
VFINAL will be 0V if bit to be sent is low. It will be VCC if bit to be sent is high
The value of RC is the value suggested by RB's application :
R = 2966E
C = 0.22uF
Hence, in my code I have
Code:
my $RC = ( 2966 ) * ( 0.22 / ( 10 ** 6 ));
This is exactly what the subroutine "V" in my code returns:
Code:
my $samplingFreq = 11000; # In Hz
my $samplingPeriod = ( 1 / $samplingFreq ); # In seconds
my $e = 2.7186362391351841722168029758227;
my $RC = ( 2966 ) * ( 0.22 / ( 10 ** 6 ));
my $numberOfSamples = 17464;
# Returns V(t) = V_FINAL + (V_INITIAL - V_FINAL) * (e ** (-t / RC ));
# VFINAL will be 0V if bit to be sent is low. It will be VCC if bit to be sent is high
my $OUTPUT_AMPLITUDE = 5;
sub V
{
my ( $t, $BIT_TO_BE_SENT, $V_INITIAL ) = @_;
my $V_FINAL = $OUTPUT_AMPLITUDE * $BIT_TO_BE_SENT;
$t *= -1;
return ( $V_FINAL + (( $V_INITIAL - $V_FINAL ) * ( $e ** ( $t / $RC )))); # Models rise as well as decay
}
I put RB's encoded data in an array called 'sound_data' and I have a loop that iterates through it a byte (element) at a time (outer for loop), extracting a bit for every time period (inverse of the sampling frequency) from the MSB to the LSB (inner for loop) before progressing to the next bit.
This loop writes out the time and amplitude in comma separated format that I later load into Excel and graph the data, and try and match it with the graph shown by RB's Encoder application.
Code:
my $V = 0;
for( my $dx = 0; $dx < @sound_data; ++$dx )
{
my $t = (8 * $dx) * $samplingPeriod;
#for(my $bit = 1; $bit <= ( 2 ** 7 ); $bit <<= 1)
for(my $bit = ( 2 ** 7 ); $bit > 0 ; $bit >>= 1)
{
$V = V( $t, (( $bit & $sound_data[$dx] ) ? 1 : 0 ), $V);
printf "%f, %f\n", $t, $V;
$t += $samplingPeriod;
}
}
My final target is to create WAV file from the encoded data (arrays of data).
This should be easy to do once I have a 1:1 match of my generated graph with RB's graph. .. the place where I need some help right now
Whole package up for grabs at :
https://sites.google.com/site/vimalsshankar/btc
I also attached images of "What it should be"(RB's BTC graph) and "What It is" (What Excel shows my data as)
As you can see, my data shows that my filter starts osciallting widly just after a few samples and does not follow RB's BTC waveform as shown as all!
Attachments
Last edited: