0
$\begingroup$

I found this code in a book to generate polar RZ for a bpsk modulation, if someone can explain to me how the upfirdn function is used here to generate it:

Function to modulate an incoming binary stream using BPSK (baseband)

 def bpsk_mod(ak,L):
   
 #ak : input binary data stream (0's and 1's) to modulate
    
 #L : oversampling factor (Tb/Ts)
  
   from scipy.signal import upfirdn
   
   s_bb = upfirdn(h=[1]*L, x=2*ak-1, up 
                  = L) # NRZ encoder
  
   t=np.arange(start = 0,stop = 
           len(ak)*L) #discrete timebase
  
   return (s_bb,t)
$\endgroup$

1 Answer 1

1
$\begingroup$

First, the multiplication by 2 and subtraction of 1 transforms the 01-stream to +1 and -1. Then, as you can easily see in the function's documentation, an upsampling by factor L is performed with h being a sample-and-hold-filter. The output will be a stream of +1 and -1 with L samples per original bit and no zeros in it. Thus, an NRZ representation of the the signal.

$\endgroup$
4
  • $\begingroup$ I'm trying to send 10 bits between two pc's via their jack ports. My problem is how to define the time of a bit. During the digital-to-analog conversion, what will allow me to say that I have a bit duration equal to 5ms, for example? Do I define the oversampling factor L in relation to the sampling frequency of the receiving sound card? $\endgroup$ Commented Apr 2 at 10:53
  • $\begingroup$ Leave the DA- and AD-conversion to the soundcards and don't worry about it. Just make sure that your carrier sine's frequency is well below half their sampling frequency (e.g. 48kHz/2=24kHz) and well above your signals bps-rate. Use the same parameters for both upsampling at the sender and downsampling at the receiver. For synchronisation purposes, you could add a distinct sync-sequence at the beginning. $\endgroup$
    – Max
    Commented Apr 2 at 11:11
  • $\begingroup$ Please correct me if my reasoning is wrong: the oversampling factor L is used here to create a copy of bit 1 or zero during a time Tb. And since on reception we receive a modulated signal at a frequency Fc this factor must be adequate with Fc $\endgroup$ Commented Apr 2 at 11:44
  • $\begingroup$ That's correct. Usually one full period of the carrier represents one bit. $\endgroup$
    – Max
    Commented Apr 2 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.