Last active
          September 26, 2017 13:48 
        
      - 
      
 - 
        
Save linnil1/98b26746c01685720e7e026274a43fc3 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import numpy as np | |
| import matplotlib.pyplot as plt | |
| f = 5 # frequence | |
| A = 10 # amplitude | |
| sf = 50 // f # sampling frequence | |
| t = np.linspace(0, 1/f, 10 * sf) | |
| fun = A * np.sin(f * 2 * np.pi * t) | |
| bit = 12 # bits for coding | |
| Q = A * 2 / ( 2 ** bit - 1) # quantization interval | |
| ADCout = [] | |
| for i in range(sf): | |
| code = np.floor((fun[i * 10]) / Q) * Q | |
| ADCout.extend([code] * 10) | |
| plt.rc('text', usetex=True) | |
| plt.plot(t, fun, label=r"10\sin(10\pi t)") | |
| plt.plot(t, ADCout, label="ADCoutput(250Hz)") | |
| plt.legend() | |
| plt.show() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment