+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Newbie level 5
    Points: 191, Level: 2

    Join Date
    Apr 2015
    Posts
    8
    Helped
    0 / 0
    Points
    191
    Level
    2

    N bit Adc vams model

    I am modelling a 12 bit ADC in vams.
    The input range is 0.3 to 1.5V. i.e 0.3 = 000'H and 1.2V = FFF'H.

    Need your help in selecting midpoint values
    max= 1.5;
    min=0.3
    fullscale = max-min;
    midpoint = fullscale/2.0;

    This logic doesnt work.

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 260,224, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,441
    Helped
    13826 / 13826
    Points
    260,224
    Level
    100

    Re: N bit Adc vams model

    In case "midpoint" refers to the voltage level between min and max, I suggest

    midpoint = (min + max)/2.0, or 0.9 V



    •   AltAdvertisement

        
       

  3. #3
    Newbie level 5
    Points: 191, Level: 2

    Join Date
    Apr 2015
    Posts
    8
    Helped
    0 / 0
    Points
    191
    Level
    2

    Re: N bit Adc vams model

    Code:
    analog
    begin
    V(VREF)<+ 0.7 + (TRIM * 0.0266667);
    max_1=V(VREF) + 0.6;
    min_1=V(VREF) - 0.6;
    
    //	min_1=0;
    fullscale_1=max_1+min_1;
    midpoint1=fullscale_1/2.0;
    end
    
    
    always@( posedge (CLK_IN) or !(fault_avdd) )
    begin
    
    //if (!(fault_avdd))
    //	begin
    sample1=V(VIN);
    //sample1=sample1-dummy;
    	$display("INSIDE LOOP");
    		for (i=0;i<`BITS;i=i+1)
    		begin
    		if(sample1 >= midpoint1)
    		begin
    		V_DOUT[`BITS-1-i]=1;
    		sample1=sample1-midpoint1;
    		$display("VALUE OF Sample inside if %f",sample1);
    		$display("VALUE OF MIDPOINT inside if %f",midpoint1);
    		$display("VALUE OF DUMMY %f", dummy); 
    		$display("VALUE OF MAX %f", max_1);
    		
    		end
    
    		else
    		begin
    		V_DOUT[i]=0;
    		$display("VALUE OF Sample inside else %f",sample1);
    		$display("VALUE OF MIDPOINT inside else %f",midpoint1);
    		$display("VALUE OF DUMMY %f", dummy); 
    		$display("VALUE OF MAX %f", max_1);
    		end
    		sample1 = 2.0*sample1;
    		end
    //	end
    	
    	
    	if (fault_avdd)
    	begin
    	for (i=0;i<`BITS;i=i+1)
    	begin
    	V_DOUT[i]=0;
    	end
    	end
    
    
    end

    VREF keeps on changing based on TRIM bits
    Last edited by FvM; 25th September 2015 at 07:44. Reason: Added code tags



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 77,782, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,763
    Helped
    3590 / 3590
    Points
    77,782
    Level
    68

    Re: N bit Adc vams model

    Hi,

    fullscale_1=max_1+min_1;
    midpoint1=fullscale_1/2.0;
    fullscale should be "max - min", but as long as you don´t use the value for other calculation it is OK.
    The midpoint calculation is correct.

    Klaus



  5. #5
    Super Moderator
    Points: 260,224, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,441
    Helped
    13826 / 13826
    Points
    260,224
    Level
    100

    Re: N bit Adc vams model

    The calculation seems to mix absolute and relative voltage levels, which might cause confusion and unexpected results.

    It's difficult to guess the meaning of the code without knowing the related hardware.



--[[ ]]--