Jump to content
  • 0

XADC demo


Manas

Question

Recommended Posts

@Manas,

Sam is trying to turn voltage = (12-bit-code)/4096 into microvolts = (1000)*(1000)*(12-bit-code)/4096, and he's trying to avoid division.  Rearranging:

1000*1000/4096 = 500*500/1024 (just by dropping common factors of two from both numerator and denominator)

Shifting right by ten is equivalent to dividing by 1024, and then he multiplies by 500*500.  Looks like it works alright.

I might be concerned personally about losing any precision in the divide by 1024 (i.e. shift right by 10), especially since it is being done before the multiply if I understand correctly--leaving you with only 2-bits of precision (did I read that right?).  Looking at the above, you might simplify it further into a shift right by 6, followed by a multiply of 15625.  To get here, all I did was cancel out any factors of two that were in both the numerator and denominator.  Then --- rearrange your order of operations, so the multiply is done first.  What makes this choice special is that 15625 can fit within an 18-bit multiplier.  Hence you can do:

A = 15625*(12-bit-voltage-code)

inside a DSP multiplier, and hence inside one clock.  The result of this multiply will be a 30-bit number.  If you ignore the bottom six bits, the 24-bit number that remains will be the number of microvolts that you are looking for.

Converting this to a decimal display might take some more work though.  ;)

Dan

Link to comment
Share on other sites

Hi Sam

I keep getting same error as shown in attached file after generating the  XADC IP. I'm using vivado 2015.2. I have made necessary changes to the XADC IP still I'm getting the same error. Could you please help me out?

Regards

Manas

Capture.JPG

Link to comment
Share on other sites

Hi

I have found out that the binary data obtained from the VAUXP[11] can be converted to its corresponding voltage value using below equation..

Voltage = 12-bit_ADC_code/4096.

I'm interested in setting up a fixed voltage level to be compared with the data from VAUXP[11] so as to generate an external alarm. I have calculated with 0.2V and got the corresponding binary representation. I was wondering if its better to set up comparison between the XADC reading and fixed voltage level using the binary representation or the corresponding voltage value. Please help me out.

Regards

Manas 

Link to comment
Share on other sites

I would do your comparison in binary since you can use non floating point numbers. This will allow the tools to do a simple binary comparison which should be faster.

 I am pretty sure the timing error stems from the /10 %10 logic used to decipher the digits to send to the display. I didn't see the timing error as a huge issue since my eyes cant realize an error and nothing else is calculated off of those values.

 

I think you are getting zeroes because you instantiate voltage as a reg, any reading you get divided by 4096 = 0. You either need to pull some verilog trickiness to allow these decimal numbers or do what I did and only shift right 10 (/1024)  and multiplying it by 250000 gets you your  voltage = (12-bit_ADC_code/4096)*100000. This gave me the voltage in microvolts

Also your .5 sin wave should be biased at .5 V to start with. Your wave should still have a range of 0 to 1 with .5 being your virtual reference. I would expect that you would still see half of the wave(positive half) with this method though.

-Sam

Link to comment
Share on other sites

Hi Sam,

I have manually solved the math behind the conversion to get the voltage using your logic but I'm still unable to figure out the multiplication of 250000. Could you please share light on this? I took 0.2V for the calculation, 0.2V in decimal comes out to be (819)10. (819)10  = (00110110011)2.   After following your logic, I compared the voltage i got after using your logic and following the formula i.e. voltage = (12-bit_ADC_code)/4096 and it comes out be same. I

Thanks

Regards

Manas

 

Link to comment
Share on other sites

Hi Sam

I'm not able to re instantiate the IPs with the same settings. I'm using Vivado 15.2 to regenerate the IPs. Could u please explain the the logic behind code as shown :

if(count == 20000000)begin
        
        decimal = data >> 4;
        //looks nicer if our max value is 1V instead of .999755
        if(decimal >= 4093)
        begin
            dig0 = 0;
            dig1 = 0;
            dig2 = 0;
            dig3 = 0;
            dig4 = 0;
            dig5 = 0;
            dig6 = 1;
            count = 0;
        end
        else 
        begin
            decimal = decimal * 250000;
            decimal = decimal >> 10;

I'm having difficulty understanding the last two lines of this code. Also can the decimal be not checked whether its greater than or equal to 4096?

Thanks 

Manas

Link to comment
Share on other sites

Yea I think there may have been a more clear way to do that math. Maybe I'll add a comment above that line. In the project I do the multiply before shifting right which avoids the two bit precision which would be a big problem. 

Also in the project is the gross /10, &10 chain that calculates the decimal values but that will throw timing errors. I think what needs to be done is some sort of BCD conversion to evaluate those digits faster. Or spread the process over multiple clock cycles since the display doesn't need to be updated as fast as values are coming in.

-Sam

Link to comment
Share on other sites

Hi @Manas,

Are you asking if there is any resources for a uart tx controller connecting to an external device? If so, Here is a project done by @hamster that has a uart tx.  Here is our PmodRS232 resource page that has a VHDL project that uses UART as well. Also, if you are wanting to use microblaze we have multiple IP's that use uart to connect to an external devices here.

cheers,

Jon

Link to comment
Share on other sites

Another good way to fix the timing of all this. I thought I would add this since it seems relevant. (I may use this project for something in the future)

Although I'm curious why Vivado can't synthesize the /10 %10 procedure to something better. Maybe the real solution is to pipe the process and just introduce a couple clock cycles of lag.

Link to comment
Share on other sites

This error has something to do with having different versions of Vivado. It may be a couple things. Have you tried resetting your implementation run and rebuilding? 

I forgot to actually add the github link to the wiki. I have now. It seems like it is not liking the simulation runs since I was using Vivado 2016.2 to generate the IPs. 

I would first try right clicking on the IP's and choosing regenerate output products. If your IPs are locked, you may need to take note of your IP settings and delete and re instantiate these IPs with the same settings as your project earlier. 

If you cant get this I can help you with getting a project going with your version of Vivado.

-Sam

 

Link to comment
Share on other sites

Hi 

In IP catalog we can set for OT and VAUXP, using the individual register location by accessing the value using  daddr. In the same way I was thinking of setting a Voltage threshold in such a way that i can generate a warning by setting up a comparison from the reading given by the AD11P and AD11N pins.

Thanks

Regards

Manas

Link to comment
Share on other sites

Hey I think you are really close. Try using this .xdc in your project. My project is working now with this xdc. If you are getting .12 that seems to be the floating value. The project uses switches to select the channel. ad11 is connected to the display when sw0 and sw1 are both up. 

I will also reupload the project to the wiki. Thanks for the catch!

-Sam

# Clock signal
#Bank = 35, Pin name = IO_L12P_T1_MRCC_35,					Sch name = CLK100MHZ
set_property PACKAGE_PIN E3 [get_ports CLK100MHZ]							
	set_property IOSTANDARD LVCMOS33 [get_ports CLK100MHZ]
	create_clock -add -name sys_clk_pin -period 10.00 -waveform {0 5} [get_ports CLK100MHZ]
 
# Switches
#Bank = 34, Pin name = IO_L21P_T3_DQS_34,					Sch name = SW0
set_property PACKAGE_PIN U9 [get_ports {sw[0]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {sw[0]}]
#Bank = 34, Pin name = IO_25_34,							Sch name = SW1
set_property PACKAGE_PIN U8 [get_ports {sw[1]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {sw[1]}]

# LEDs
#Bank = 34, Pin name = IO_L24N_T3_34,						Sch name = LED0
set_property PACKAGE_PIN T8 [get_ports {led[0]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[0]}]
#Bank = 34, Pin name = IO_L21N_T3_DQS_34,					Sch name = LED1
set_property PACKAGE_PIN V9 [get_ports {led[1]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[1]}]
#Bank = 34, Pin name = IO_L24P_T3_34,						Sch name = LED2
set_property PACKAGE_PIN R8 [get_ports {led[2]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[2]}]
#Bank = 34, Pin name = IO_L23N_T3_34,						Sch name = LED3
set_property PACKAGE_PIN T6 [get_ports {led[3]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[3]}]
#Bank = 34, Pin name = IO_L12P_T1_MRCC_34,					Sch name = LED4
set_property PACKAGE_PIN T5 [get_ports {led[4]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[4]}]
#Bank = 34, Pin name = IO_L12N_T1_MRCC_34,					Sch	name = LED5
set_property PACKAGE_PIN T4 [get_ports {led[5]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[5]}]
#Bank = 34, Pin name = IO_L22P_T3_34,						Sch name = LED6
set_property PACKAGE_PIN U7 [get_ports {led[6]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[6]}]
#Bank = 34, Pin name = IO_L22N_T3_34,						Sch name = LED7
set_property PACKAGE_PIN U6 [get_ports {led[7]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[7]}]
#Bank = 34, Pin name = IO_L10N_T1_34,						Sch name = LED8
set_property PACKAGE_PIN V4 [get_ports {led[8]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[8]}]
#Bank = 34, Pin name = IO_L8N_T1_34,						Sch name = LED9
set_property PACKAGE_PIN U3 [get_ports {led[9]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[9]}]
#Bank = 34, Pin name = IO_L7N_T1_34,						Sch name = LED10
set_property PACKAGE_PIN V1 [get_ports {led[10]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[10]}]
#Bank = 34, Pin name = IO_L17P_T2_34,						Sch name = LED11
set_property PACKAGE_PIN R1 [get_ports {led[11]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[11]}]
#Bank = 34, Pin name = IO_L13N_T2_MRCC_34,					Sch name = LED12
set_property PACKAGE_PIN P5 [get_ports {led[12]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[12]}]
#Bank = 34, Pin name = IO_L7P_T1_34,						Sch name = LED13
set_property PACKAGE_PIN U1 [get_ports {led[13]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[13]}]
#Bank = 34, Pin name = IO_L15N_T2_DQS_34,					Sch name = LED14
set_property PACKAGE_PIN R2 [get_ports {led[14]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[14]}]
#Bank = 34, Pin name = IO_L15P_T2_DQS_34,					Sch name = LED15
set_property PACKAGE_PIN P2 [get_ports {led[15]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {led[15]}]
    
#7 segment display
#Bank = 34, Pin name = IO_L2N_T0_34,						Sch name = CA
set_property PACKAGE_PIN L3 [get_ports {seg[0]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {seg[0]}]
#Bank = 34, Pin name = IO_L3N_T0_DQS_34,					Sch name = CB
set_property PACKAGE_PIN N1 [get_ports {seg[1]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {seg[1]}]
#Bank = 34, Pin name = IO_L6N_T0_VREF_34,					Sch name = CC
set_property PACKAGE_PIN L5 [get_ports {seg[2]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {seg[2]}]
#Bank = 34, Pin name = IO_L5N_T0_34,						Sch name = CD
set_property PACKAGE_PIN L4 [get_ports {seg[3]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {seg[3]}]
#Bank = 34, Pin name = IO_L2P_T0_34,						Sch name = CE
set_property PACKAGE_PIN K3 [get_ports {seg[4]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {seg[4]}]
#Bank = 34, Pin name = IO_L4N_T0_34,						Sch name = CF
set_property PACKAGE_PIN M2 [get_ports {seg[5]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {seg[5]}]
#Bank = 34, Pin name = IO_L6P_T0_34,						Sch name = CG
set_property PACKAGE_PIN L6 [get_ports {seg[6]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {seg[6]}]

#Bank = 34, Pin name = IO_L16P_T2_34,						Sch name = DP
set_property PACKAGE_PIN M4 [get_ports dp]							
	set_property IOSTANDARD LVCMOS33 [get_ports dp]

#Bank = 34, Pin name = IO_L18N_T2_34,						Sch name = AN0
set_property PACKAGE_PIN N6 [get_ports {an[0]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {an[0]}]
#Bank = 34, Pin name = IO_L18P_T2_34,						Sch name = AN1
set_property PACKAGE_PIN M6 [get_ports {an[1]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {an[1]}]
#Bank = 34, Pin name = IO_L4P_T0_34,						Sch name = AN2
set_property PACKAGE_PIN M3 [get_ports {an[2]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {an[2]}]
#Bank = 34, Pin name = IO_L13_T2_MRCC_34,					Sch name = AN3
set_property PACKAGE_PIN N5 [get_ports {an[3]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {an[3]}]
#Bank = 34, Pin name = IO_L3P_T0_DQS_34,					Sch name = AN4
set_property PACKAGE_PIN N2 [get_ports {an[4]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {an[4]}]
#Bank = 34, Pin name = IO_L16N_T2_34,						Sch name = AN5
set_property PACKAGE_PIN N4 [get_ports {an[5]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {an[5]}]
#Bank = 34, Pin name = IO_L1P_T0_34,						Sch name = AN6
set_property PACKAGE_PIN L1 [get_ports {an[6]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {an[6]}]
#Bank = 34, Pin name = IO_L1N_T034,							Sch name = AN7
set_property PACKAGE_PIN M1 [get_ports {an[7]}]					
	set_property IOSTANDARD LVCMOS33 [get_ports {an[7]}]

#Pmod Header JXADC
#Bank = 15, Pin name = IO_L9P_T1_DQS_AD3P_15,				Sch name = XADC1_P -> XA1_P
set_property PACKAGE_PIN A13 [get_ports {vauxp3}]				
	set_property IOSTANDARD LVCMOS33 [get_ports {vauxp3}]
#Bank = 15, Pin name = IO_L8P_T1_AD10P_15,					Sch name = XADC2_P -> XA2_P
set_property PACKAGE_PIN A15 [get_ports {vauxp10}]				
	set_property IOSTANDARD LVCMOS33 [get_ports {vauxp10}]
#Bank = 15, Pin name = IO_L7P_T1_AD2P_15,					Sch name = XADC3_P -> XA3_P
set_property PACKAGE_PIN B16 [get_ports {vauxp2}]				
	set_property IOSTANDARD LVCMOS33 [get_ports {vauxp2}]
#Bank = 15, Pin name = IO_L10P_T1_AD11P_15,					Sch name = XADC4_P -> XA4_P
set_property PACKAGE_PIN B18 [get_ports {vauxp11}]				
	set_property IOSTANDARD LVCMOS33 [get_ports {vauxp11}]
#Bank = 15, Pin name = IO_L9N_T1_DQS_AD3N_15,				Sch name = XADC1_N -> XA1_N
set_property PACKAGE_PIN A14 [get_ports {vauxn3}]				
	set_property IOSTANDARD LVCMOS33 [get_ports {vauxn3}]
#Bank = 15, Pin name = IO_L8N_T1_AD10N_15,					Sch name = XADC2_N -> XA2_N
set_property PACKAGE_PIN A16 [get_ports {vauxn10}]				
	set_property IOSTANDARD LVCMOS33 [get_ports {vauxn10}]
#Bank = 15, Pin name = IO_L7N_T1_AD2N_15,					Sch name = XADC3_N -> XA3_N 
set_property PACKAGE_PIN B17 [get_ports {vauxn2}]				
	set_property IOSTANDARD LVCMOS33 [get_ports {vauxn2}]
#Bank = 15, Pin name = IO_L10N_T1_AD11N_15,					Sch name = XADC4_N -> XA4_N
set_property PACKAGE_PIN A18 [get_ports {vauxn11}]				
	set_property IOSTANDARD LVCMOS33 [get_ports {vauxn11}]

 

Link to comment
Share on other sites

Hi Sam,

I have made the changes you suggested. When 1V amplitude sine sine wave fed to AD11P, the output in 7-segment display is "00.12". I have fed the sine wave using analog discovery kit. I was expecting output to be as 1V. I also tried changing the frequency of the wave but I keep getting output less than 1V.

Please suggest where to make changes to get the result.

Thanks

Manas 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...