| fjp@micrel.no 
 
		New Member  Offline   
		Posts: 1 
		Oslo, Norway
		
		
		 | 
			Hi,
 I'm making a C++ model for an amplifier for simulation using CppSim. By reading "Modeling RF Systems", I can make a model that takes IIP2 and IIP3 into account, but I'm not sure how to model noise using the rand() function. Any suggestions?
 
 What I got so far is shown below. The code and syntax adhers to CppSim rules.
 
 init:
 a = pow(10, gain/20);
 b = a/(pow(10, iip2/10)*2*50*0.001);
 c = a*(4/3)/(pow(10, iip3/10)*2*50*0.001);
 rnf = pow(10, nf/10);
 noise_voltage_squared = 2*(rnf-1)*1.3806504e-23*300*50;
 code:
 in_noisy = ((rand()/RAND_MAX)*noise_voltage_squared) - 0.5 + in;
 out = dcout + (a*in_noisy) - (b*in_noisy*in_noisy) - (c*in_noisy*in_noisy*in_noisy);
 
 Best regards,
 Fred-J.
 |