UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Participant timurgepard
Participant
13,504 Views
Registered: ‎12-13-2013

Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Dear Xilinx community,

 

As I promised while ago, if I find way to  convert Analog signal to Digital using VHDL on Spartan I would publish my work here for users.

 

Not only I publish it here, but I am going to revelal how I realized Lock-in amplifier on Spartan 3E FPGA board and used LCD display on board to show all necessary data.

 

 I ask you to check my source and include it in basic tutorials if code is reliable. I am not genius guy, I like very straightforward things. So I believe it could help beginners.

 

 

 

 

 

 

19 Replies
Participant timurgepard
Participant
13,499 Views
Registered: ‎12-13-2013

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

I am attaching my Master Thesis, which received 70% mark, and VHDL source code with averaging and exponential filters.

 

This work is combination of different examples and methods I found on the Internet.

 

I advice you try to run it first. But at the end not only copy and paste, but try to understand all parts, since it needs time to fully recover  it.

 

Analog way of realization is also included.

0 Kudos
Visitor laurii01
Visitor
13,028 Views
Registered: ‎04-06-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Thank you very much for your contribution !! I was just needing how to implement a lock-in amplifier in FPGA and I came across your contribution. Could you upload, please, the code for the Test Bench?
Thank you very much!! and I'll be waiting for you answer.
Greetings!!

0 Kudos
Highlighted
Participant timurgepard
Participant
12,916 Views
Registered: ‎12-13-2013

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hi,

 

here it is.

 

 looked back at it. 

 

I used series of For loops to create sine wave from sine array. The last one has 200 shift from time axis. So I subtract 200 everytime. delay between signals I believe was explained in thesis.

 

Good Luck!

Visitor kroova
Visitor
12,625 Views
Registered: ‎06-04-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Thanks so much for posting this! 

 

I tried compiling this using the ISE Design Suite 14.7 (with free WebPack license); however, I got the following error:

 

ERROR:HDLParsers:3014 - "C:/Users/.../Lock_in/REF_FREQUENCY.vhd" Line 23. Library unit funct is not available in library work.

 

I'm a student just learning how to use this software so any help is greatly appreciated!

0 Kudos
Visitor kroova
Visitor
12,143 Views
Registered: ‎06-04-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

After examining the code, it seems that it is missing a package - named "func" - that defines at least two functions: "divide" and "to-bcd".

Without the package, the source code will not work.
0 Kudos
Participant timurgepard
Participant
12,103 Views
Registered: ‎12-13-2013

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

HI!!!

 

You first who noticed that. It means that nobody really checked this archive.

 

Thank you too, It was mistake to choose only certain files. All you need is inside attached archive

 

 

Explorer
Explorer
8,235 Views
Registered: ‎05-31-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello,

 

    I am using the code you have uploaded here to realize lock in amplifier. The code is working with your testbench. I was using example.vhd as testbench . But when I try to implement it with  a slightly different set of values  for same sine wave , I dont get any result properly. Any suggestions on this issue.

 

Your sine values: (200,202,204,206,208,210,211,213, --scale to 4194304
215,217,219,221,223,225,227,229,
230,232,234,236,238,240,242,244,
245,247,249,251,253,255,257,258,
260,262,264,266,267,269,271,273,
275,276,278,280,282,283,285,287,
288,290,292,294,295,297,299,300,
302,304,305,307,308,310,312,313,
315,316,318,319,321,322,324,325,
327,328,330,331,333,334,336,337,
338,340,341,342,344,345,346,348,
349,350,351,353,354,355,356,358,
359,360,361,362,363,364,365,366,
368,369,370,371,372,373,374,374,
375,376,377,378,379,380,381,381,
382,383,384,385,385,386,387,387,
388,389,389,390,390,391,392,392,
393,393,394,394,395,395,395,396,
396,397,397,397,398,398,398,398,
399,399,399,399,399,399,400,400,
400,400,400,400,400,400,400,400,
400,400,400,400,399,399,399,399,
399,399,398,398,398,398,397,397,
397,396,396,395,395,395,394,394,
393,393,392,392,391,390,390,389,
389,388,387,387,386,385,385,384,
383,382,381,381,380,379,378,377,
376,375,374,374,373,372,371,370,
369,368,366,365,364,363,362,361,
360,359,358,356,355,354,353,351,
350,349,348,346,345,344,342,341,
340,338,337,336,334,333,331,330,
328,327,325,324,322,321,319,318,
316,315,313,312,310,308,307,305,
304,302,300,299,297,295,294,292,
290,288,287,285,283,282,280,278,
276,275,273,271,269,267,266,264,
262,260,258,257,255,253,251,249,
247,245,244,242,240,238,236,234,
232,230,229,227,225,223,221,219,
217,215,213,211,210,208,206,204,
202,200,198,196,194,192,190,189,
187,185,183,181,179,177,175,173,
171,170,168,166,164,162,160,158,
156,155,153,151,149,147,145,143,
142,140,138,136,134,133,131,129,
127,125,124,122,120,118,117,115,
113,112,110,108,106,105,103,101,
100,98,96,95,93,92,90,88,
87,85,84,82,81,79,78,76,
75,73,72,70,69,67,66,64,
63,62,60,59,58,56,55,54,
52,51,50,49,47,46,45,44,
42,41,40,39,38,37,36,35,
34,32,31,30,29,28,27,26,
26,25,24,23,22,21,20,19,
19,18,17,16,15,15,14,13,
13,12,11,11,10,10,9,8,
8,7,7,6,6,5,5,5,
4,4,3,3,3,2,2,2,
2,1,1,1,1,1,1,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,1,1,1,
1,1,1,2,2,2,2,3,
3,3,4,4,5,5,5,6,
6,7,7,8,8,9,10,10,
11,11,12,13,13,14,15,15,
16,17,18,19,19,20,21,22,
23,24,25,26,26,27,28,29,
30,31,32,34,35,36,37,38,
39,40,41,42,44,45,46,47,
49,50,51,52,54,55,56,58,
59,60,62,63,64,66,67,69,
70,72,73,75,76,78,79,81,
82,84,85,87,88,90,92,93,
95,96,98,100,101,103,105,106,
108,110,112,113,115,117,118,120,
122,124,125,127,129,131,133,134,
136,138,140,142,143,145,147,149,
151,153,155,156,158,160,162,164,
166,168,170,171,173,175,177,179,
181,183,185,187,189,190,192,194,
196,198

 

 

My sine values: 200,202,204,206,208,210,211,213,
215,217,219,221,223,225,227,229,
230,232,234,236,238,240,242,244,
246,247,249,251,253,255,257,258,
260,262,264,266,268,269,271,273,
275,276,278,280,282,283,285,287,
289,290,292,294,295,297,299,300,
302,304,305,307,309,310,312,313,
315,316,318,320,321,323,324,326,
327,329,330,331,333,334,336,337,
339,340,341,343,344,345,347,348,
349,350,352,353,354,355,357,358,
359,360,361,362,363,365,366,367,
368,369,370,371,372,373,374,375,
376,376,377,378,379,380,381,382,
382,383,384,385,385,386,387,387,
388,389,389,390,391,391,392,392,
393,393,394,394,395,395,395,396,
396,397,397,397,398,398,398,398,
399,399,399,399,399,400,400,400,
400,400,400,400,400,400,400,400,
400,400,400,400,399,399,399,399,
399,399,398,398,398,397,397,397,
396,396,396,395,395,394,394,393,
393,392,392,391,391,390,390,389,
388,388,387,386,386,385,384,384,
383,382,381,380,380,379,378,377,
376,375,374,373,372,371,370,369,
368,367,366,365,364,363,362,361,
359,358,357,356,355,354,352,351,
350,349,347,346,345,343,342,341,
339,338,336,335,334,332,331,329,
328,326,325,323,322,320,319,317,
316,314,313,311,309,308,306,305,
303,301,300,298,296,295,293,291,
289,288,286,284,283,281,279,277,
276,274,272,270,268,267,265,263,
261,259,258,256,254,252,250,248,
246,245,243,241,239,237,235,233,
231,230,228,226,224,222,220,218,
216,214,212,211,209,207,205,203,
201,199,197,195,193,191,189,188,
186,184,182,180,178,176,174,172,
170,169,167,165,163,161,159,157,
155,154,152,150,148,146,144,142,
141,139,137,135,133,132,130,128,
126,124,123,121,119,117,116,114,
112,111,109,107,105,104,102,100,
99,97,95,94,92,91,89,87,
86,84,83,81,80,78,77,75,
74,72,71,69,68,66,65,64,
62,61,59,58,57,55,54,53,
51,50,49,48,46,45,44,43,
42,41,39,38,37,36,35,34,
33,32,31,30,29,28,27,26,
25,24,23,22,21,20,20,19,
18,17,16,16,15,14,14,13,
12,12,11,10,10,9,9,8,
8,7,7,6,6,5,5,4,
4,4,3,3,3,2,2,2,
1,1,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,1,1,1,
1,1,2,2,2,2,3,3,
3,4,4,5,5,5,6,6,
7,7,8,8,9,9,10,11,
11,12,13,13,14,15,15,16,
17,18,18,19,20,21,22,23,
24,24,25,26,27,28,29,30,
31,32,33,34,35,37,38,39,
40,41,42,43,45,46,47,48,
50,51,52,53,55,56,57,59,
60,61,63,64,66,67,69,70,
71,73,74,76,77,79,80,82,
84,85,87,88,90,91,93,95,
96,98,100,101,103,105,106,108,
110,111,113,115,117,118,120,122,
124,125,127,129,131,132,134,136,
138,140,142,143,145,147,149,151,
153,154,156,158,160,162,164,166,
168,170,171,173,175,177,179,181,
183,185,187,189,190,192,194,196,
198,200

 

 

Please suggest a solution as soon as possible.

 

With regards

Shalini

0 Kudos
Participant timurgepard
Participant
8,163 Views
Registered: ‎12-13-2013

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hi!

 

Did you read doc file? It is hard to remember after 2 years. But it worked with real signals with introduced noise. There is sinewave generator inside logic. And use averaging filter. It is much simplier...

0 Kudos
Explorer
Explorer
8,080 Views
Registered: ‎05-31-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello,

 

I was able to give sine values from LUT and get correct output after making a clock crossing circuit of 2 FF synchronizer in REF_FREQUENCY.vhd for ref_period_int for crossing from spartan clock to clk_in. But when I give real time sine values from ADC and probe at the Zero crossing detector out , it is Ok. At the same time if I probe the REF_FREQUENCY ,vhd 's DDS_feedback_out it is not correct value jumps abruptly from one value to other. Note it , I have not changed any components heirachically from lock_in_amp.vhd for interfacing to ADC. Still this error occurs. I am struggling with this for 2 weeks. Please help.

Attached is my project.

 

As far as I understood in REF_FREQUENCY.vhd if reference_sync_wave,SPARTAN_clk,clk_in is correct then DDS_feedback_out should be correct ..Right?

 

With Regards

Shalini

 

Tags (1)
0 Kudos
Explorer
Explorer
6,561 Views
Registered: ‎05-31-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello,

 

   Finally I solved the issue. Bit tricky, but was still effective.. there was some timing issue in REF_FREQUENCY.vhd. Solved it with debounce circuit. Attached is the project.

0 Kudos
Explorer
Explorer
6,557 Views
Registered: ‎05-31-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello,

 

     Any idea how to get back original sine wave from noise using I and Q out from lock in amplifier and DAC? That is how to use I and Q outputs from lock in amplifier to reconstruct original sine wave of frequency?

 

With Regards

Shalini

0 Kudos
Explorer
Explorer
6,547 Views
Registered: ‎05-31-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello,

 

           Can't we measure phase of signal with respect to reference from the I and Q outputs of lock in amplifier from this design?

i understood we can measure the amplitude of the signal taking root of squared sum of I and Q values. please reply.

 

With regards

shalini

0 Kudos
5,223 Views
Registered: ‎11-27-2016

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Dear @timurgepard

 

Thanks for your uploaded code. I tested the code with actual hardware but which gave perfect I and Q values. But when I introduced noise in the signal it was not able to detect the signal.

Can you please look into the matter and tell if you have uploaded the latest code or not?

Thanks again.

 

Regards.

0 Kudos
Explorer
Explorer
5,216 Views
Registered: ‎05-31-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello,

 

              I have uploaded the updated code only.

 

0 Kudos
4,988 Views
Registered: ‎11-27-2016

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hi,

I saw that your uploaded code is of Spartan 6 FPGA. I just wanted to ask if you are using evaluation Spartan board? and which ADC are you using for conversion of signals.
Thanks for reply.
0 Kudos
Explorer
Explorer
4,985 Views
Registered: ‎05-31-2015

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello,

 

   I am not using any evaluation board. I am using saturn spartan6 board from numato and my ADC is TI ADS1278 evaluation board.

 

With Regards

Shalini

0 Kudos
Visitor krishna_k
Visitor
3,258 Views
Registered: ‎09-14-2017

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello @timurgepard,

Thank you so much for your code. I am a student. I read your master thesis. I tried to run your code on spartan 3E FPGA. But LCD only shows the 0 value as out put. I give V reference = 0.525V, offeset= 1.64V with 1000Hz frequency. and signal is 1.255V, offeset= 1.64V with 1000Hz frequency. But it's not giving output as you showed in your thesis.

I simulate all modules individually and they works. I am not getting where the problem is. Can you help me in this?

even I cannot simulate whole LIA with your given testbench in forum as per your thesis. 

Please help me.

0 Kudos
Newbie koisamai
Newbie
3,103 Views
Registered: ‎02-09-2018

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hallo Krishna_k,

 

I am a student too,and  I want to learn to use FPGA, but also to use Spartan 3e. However I can not download or open the file EEE2014-MSc.docx
If you can see his master's thesis, can you send me a copy, so that we can learn together and exchange

E-mail:koisamai2015@gmail.com

 

Thank you very much!

 

0 Kudos
Visitor krishna_k
Visitor
2,989 Views
Registered: ‎09-14-2017

Re: Complete Lock-in amplifier with Sine wave generator and analod-digital conversion and LCD display interface.

Hello,

sha@hys If I am not wrong you used chipscop pro to check the output.

I also want to see the output of spartan 3E Lock-in amplifier but dont know how.

Can you please help me?

0 Kudos