Connection refused...

Placement, modules, components and accessories; the ones that exist and the the nice-to-be's
Post Reply
adam.polak
Posts: 37
Joined: Mon Jul 28, 2014 11:32 am

Connection refused...

Post by adam.polak » Tue Apr 28, 2015 2:38 pm

Hi Everybody!
I'm struggling with connection of Redpitaya to Matlab with use of SCPI commands and TCP/IP communication. I have redpitaya board V1.1 and I have just upgraded DC card image with ecosystem-0.92-65-35575ed. I'm trying to use the code examples but even before anything can be done, while trying to execute 'fopen' function I'm getting and error

Error using icinterface/fopen (line 83)
Unsuccessful open: Connection refused: connect

I tried to use 'tmtool' just to connect but the same result.
the only connection possible is with default port (port 80) when Matlab is saying that it is connected, but with that port nothing is happening - I cannot generate or acquire anything.. when I'm back on pot 5000 - connection refused again....

I tired connections through local network connection and with direct network connection and with configuration of network settings and adequate IP for redpitaya I'm always able to get on web interface and run scope or generate, but I cannot connect redpitaya with Matlab.... and I'm now lost with ideas what I'm missing

( I checked the firewall and port 5000 is open)

If anybody have any ideas what can be wrong I will be very grateful!!
Adam

User avatar
redpitaya
Site Admin
Posts: 883
Joined: Wed Mar 26, 2014 7:04 pm

Re: Connection refused...

Post by redpitaya » Tue Apr 28, 2015 9:31 pm

Hi,

Have you start scpi-server on RP before
Matlab script is run?
http://redpitaya.com/make-your-app/

Regards

adam.polak
Posts: 37
Joined: Mon Jul 28, 2014 11:32 am

Re: Connection refused...

Post by adam.polak » Wed Apr 29, 2015 5:16 pm

Hi!

Thank you for prompt reply!! I don't know how I did it but indeed I missed setting up scpi-server. - Now it works fine!! Thank you!! Please be patient with beginner type of questions :)

BTW - without opening new topic - I tried to generate from Matlab triangle signal - on Channel1 with frequency of 1Hz and on Channel2 with 100Hz - by my logic I should have 100 cycles on channel 2 by the time when 1 cycle will pass on channel 1... but it's not - it's about 95 cycles. I observed the same when generating pulses in 'for' loop - if I want to put pause command for first pulse to pass before second is created, for 1Hz signal I need to put pause of 0.95sec to keep (almost) continuous train of pulses(instead of logical 1sec) . Is it something related with the hardware , software or communication ? any ideas?

Thank you!!

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Connection refused...

Post by Nils Roos » Sat May 02, 2015 9:11 pm

Hi,

What you are observing is the consequence of a suboptimal implementation of the conversion from frequency to AWG parameters. When you set a frequency of 1Hz for any waveform other than arbitrary, the generator will actually generate a frequency of ~1.048Hz .

The code in question is this:

Code: Select all

    awg->step = round(65536.0 * freq/c_awg_smpl_freq * ((float) AWG_SIG_LEN));
    awg->wrap = round(65536 * (AWG_SIG_LEN - 1));
with c_awg_smpl_freq = 125000000 , AWG_SIG_LEN = 16384

The precise "step"-value for 1Hz would be 8.58... , which is being rounded up to 9, which in turn leads to a frequency of 1.047... Hz .

It is possible to get a better precision at low frequencies by modifying both the algorithm that transforms frequency to "step" and "wrap" values and the signal synthesis. If you were to always round down the "step" and then modify "wrap" and the length of the synthesized signal, you could get to within 0.0015% of 1Hz .

adam.polak
Posts: 37
Joined: Mon Jul 28, 2014 11:32 am

Re: Connection refused...

Post by adam.polak » Thu May 07, 2015 5:28 pm

Thank you for this explanation! that makes sense.. but also brings me with another questions
- how the step rounded to 9 in this example can be calculated to the frequency of 1.047...Hz (sorry if I keep asking some basic questions :oops: )

- actually I do not need to generate exactly 1Hz, but what I need to generate two triangle functions on channel 1 and channel 2 that have exact "multiplication of frequency", meaning they cross zeros at the same place (like in 1Hz period of triangle function one would fit exactly 100 periods of 100Hz function) ..with this rounding I'm wondering how to calculate this properly

..I'm sure that I see now only the top of an iceberg of problems with my application.. ;)

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Connection refused...

Post by Nils Roos » Thu May 07, 2015 6:50 pm

The answers to both of your questions are related:

To calculate the frequency from a given step value, apply basic algebra:

Take the equation
  • awg->step = round(65536.0 * freq/c_awg_smpl_freq * AWG_SIG_LEN)
and put in the constants, then solve for freq. The constants are
  • c_awg_smpl_freq = 125000000 (DAC clock)
  • AWG_SIG_LEN = 16384 (signal length for sine / tri / rect is always the full buffer size of 16384)
  • awg->step = 9
The round() function can be omitted if you constrain awg->step to integral values, the rest is simple multiplication / division.

Once you know which frequency can be generated without incurring rounding errors, simply multiply that by 100 to achieve your desired 1:100 ratio.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 26 guests