# How to select parameters for Equivalent Time Sampling

Status
Not open for further replies.

#### wannaknow

##### Junior Member level 2
Hi,
I have a Nios system with Qsys components such as Interval timer, UART, SDRAM and some PIOs. My system specifications are DE0 Nano, Quartus 12.1 sp1, Altera monitor program. Nios II system are interfacing with several VHDL blocks.
I am able to read data from FPGA to Nios processor, then transmit this data to Uart component created in Qsys using direct register method (IORD_ALTERA_AVALON_UART_STATUS (UART_BASE); IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE, txdata);etc).
I am using USB-to-Serial interface to the board FTDI UM245R module.
I am able to read serial port and plot the graph real time in Matlab. However, I am having the issue where there is aliasing when I tried to reconstruct a sinusoidal waveform. This is because the incoming signal is 50Hz and the serial port receive rate is just 8 Hz.
I added a timer in my C code and I am able to get a perfect sinusoidal waveform with no aliasing, but I can't explain why. I googled and I know that what I was doing is actually "Equivalent Time Sampling" (ETS) concept which is very common in sampling oscilloscope where incoming signal has a higher sampling frequency than oscilloscope's sampling rate and can only be used on repetitive signal such as sinusoidal waveform. Basically, the ETS requires a first trigger, take first sample, wait for for rearm time, second trigger, delay, take second sample... but i failed to find a way to calculate those rearm time and delay...

This is the timer code in C code where i can get a perfect sinusoidal after i added this timer as delay.

Code:
int counter = 0x305600;
IOWR_ALTERA_AVALON_TIMER_PERIODL( TIMER0_BASE, (counter & 0xFFFF) );//lower significant bits for start value
IOWR_ALTERA_AVALON_TIMER_PERIODH( TIMER0_BASE, ((counter>>16) & 0xFFFF) ); //higher significant bits for start value
IOWR_ALTERA_AVALON_TIMER_STATUS( TIMER0_BASE, 0 ); //clear timeout

IOWR_ALTERA_AVALON_TIMER_CONTROL( TIMER0_BASE, 0x4 );//start timer

while((IORD_ALTERA_AVALON_TIMER_STATUS( TIMER0_BASE ) & ALTERA_AVALON_TIMER_STATUS_TO_MSK) == 0 )
{

}

#### wannaknow

##### Junior Member level 2
The reason I am asking this question is that, I think I am doing the ETS in some sense, resulting in correct output being plotted in Matlab. But I have no idea whether ETS is implemented in Nios ii or in Matlab?

I am sending data from fpga (nios ii processor) to serial port and Matlab access the serial port and plot real time graph. The Nios II is 50MHz, so it has no issue to receive the data from fpga which is 50Hz

If the serial port receive rate is just 8Hz, but the data sent to serial port is 50Hz, what approach is Nios II using to digitize the samples? Does it have anything to do with equivalent time sampling (ETS)? I could not find any links between Nios II and ETS, correct me if I am wrong.

Appreciate any inputs.. thank you

Status
Not open for further replies.