Jump to content
  • 0

AD2 Simulator Sonar Echo Ping


RichSCorp

Question

Looking for some help.

I have an Analog Discovery 2 and trying to create a sonar simulator response echo signal.  Let me explain the sequence of what I‘m trying to do.  Use the AD2 ch1 analog scope input to receive an external burst (sonar transmission) which the AD2 can trigger on.  I’ll call this time “T0” which should be near the rising edge of the first cycle of the sinewave.  Once triggered, I want the WG #1 to output a echo burst signal at a DELAYED time from the trigger that occurred on the scope input.    This simulated echo pulse sonar transmission can be 10kHz with a pulse length of 50msec (N cycles = 500).  It will start at the DELAYED time which I’ll call “Techo” which is a variable. The range of Techo can be between 11 msec to 3 sec or there about from the initial T0 time.  The external signal is manually generated by pressing a button to start the sequence. 

So using the SDK, able to trigger on the external burst signal.  But need help in setting the echo time Techo .  I’m thinking of using the AnalogOutTriggerSourceSet as ch1 and then use the AnalogOutWaitSet as the Techo time.  Would this work?  Trying to understand what AnalogOutWaitSet does?  Would this call give me an accurate Techo time of when the WG#1 would output a burst??  I’m looking for an accuracy of 5% for the Techo time when measuring between T0 and Techo.  

Thanks for any help is setting this up.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Hi @RichSCorp

See the following:

image.thumb.png.92c55d90e5ed76e96b703338781dc364.png

# analog-in
dwf.FDwfAnalogInFrequencySet(hdwf, c_double(1e6)) # 1MHz sampling rate
dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0), c_int(1)) # channel 1 enable
dwf.FDwfAnalogInChannelOffsetSet(hdwf, c_int(0), c_double(0.0)) 
dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(0), c_double(5.0)) # 5 Vpk2pk range

# trigger detector
dwf.FDwfAnalogInTriggerChannelSet(hdwf, c_int(0)) # channel 1
dwf.FDwfAnalogInTriggerTypeSet(hdwf, trigtypeEdge)
dwf.FDwfAnalogInTriggerLevelSet(hdwf, c_double(0.0)) 
dwf.FDwfAnalogInTriggerHysteresisSet(hdwf, c_double(0.1))
dwf.FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive) 
dwf.FDwfAnalogInTriggerFilterSet(hdwf, filterAverage) # use average samples in trigger detector

# analog-out 1: trigger->wait->run->repeat from trigger, rearm
dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_int(1))
dwf.FDwfAnalogOutIdleSet(hdwf, c_int(0), DwfAnalogOutIdleOffset)
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(0), AnalogOutNodeCarrier, funcSine)
dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(20e3))
dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(1.0)) 
dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(0))
dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(0), c_int(trigsrcDetectorAnalogIn))
dwf.FDwfAnalogOutWaitSet(hdwf, c_int(0), c_double(20e-3)) # wait length
dwf.FDwfAnalogOutRunSet(hdwf, c_int(0), c_double(50e-3)) # pulse length
dwf.FDwfAnalogOutRepeatSet(hdwf, c_int(0), c_int(0)) # repeat forever
dwf.FDwfAnalogOutRepeatTriggerSet(hdwf, c_int(0), c_int(1)) # repeat waiting trigger

dwf.FDwfAnalogInConfigure(hdwf, c_int(1), c_int(0)) # just configure analog-in
dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_int(1)) # start analog-out

image.png.a187b49990c0f6b357c3ff6441411370.png

Edited by attila
Link to comment
Share on other sites

  • 0

Hello @attila ,

 

I ran the above code in C++(down below) with @RichSCorp utilizing the SDK and it doesn't seem to work. Can you please look it over and help us identify the error.


   

    FDwfAnalogInFrequencySet(this->hdwf, 1000000);
    FDwfAnalogOutNodeEnableSet(this->hdwf, this->outBNC1, 0, true);
    FDwfAnalogOutNodeOffsetSet(this->hdwf, this->outBNC1, 0, 0);
    FDwfAnalogOutNodeAmplitudeSet(this->hdwf, this->outBNC1, 0, 1.0);

    FDwfAnalogInTriggerChannelSet(this->hdwf, this->inBNC1);
    FDwfAnalogInTriggerTypeSet(this->hdwf, trigtypeEdge);
    FDwfAnalogInTriggerLevelSet(this->hdwf, 0.0);
    FDwfAnalogInTriggerHysteresisSet(this->hdwf, 0.1);
    FDwfAnalogInTriggerConditionSet(this->hdwf, trigcondRisingPositive);
    FDwfAnalogInTriggerFilterSet(this->hdwf, filterAverage);

    FDwfAnalogOutNodeEnableSet(this->hdwf, this->outBNC1, AnalogOutNodeCarrier, true);
    FDwfAnalogOutIdleSet(this->hdwf, this->outBNC1, DwfAnalogOutIdleOffset);//
    FDwfAnalogOutNodeFunctionSet(this->hdwf, this->outBNC1, AnalogOutNodeCarrier, funcSine);
    FDwfAnalogOutNodeFrequencySet(this->hdwf, this->outBNC1, AnalogOutNodeCarrier, 20000);
    FDwfAnalogOutNodeAmplitudeSet(this->hdwf, this->outBNC1, AnalogOutNodeCarrier, 1.0);
    FDwfAnalogOutNodeOffsetSet(this->hdwf, this->outBNC1, AnalogOutNodeCarrier, 0.0);
    FDwfAnalogOutTriggerSourceSet(this->hdwf, this->outBNC1, trigsrcAnalogIn);

    FDwfAnalogOutWaitSet(this->hdwf, this->outBNC1, 0.02);
    FDwfAnalogOutRunSet(this->hdwf, this->outBNC1, 0.05);
    FDwfAnalogOutRepeatSet(this->hdwf, this->outBNC1, 0);
    FDwfAnalogOutRepeatTriggerSet(this->hdwf, this->outBNC1, 1);

    FDwfAnalogInConfigure(this->hdwf, 1, 0);
    FDwfAnalogOutConfigure(this->hdwf, this->outBNC1, true);

 

 

Your help is greatly appreciated.

 

Willard Joseph

Edited by Will_SC
Link to comment
Share on other sites

  • 0

Thanks for getting back to Will_SC.   I think he was asking why his C++ code was not working.  He followed all the SDK API calls that were in your script.  Is there some differences that we're missing when using C++?? Could it be the Type Def? Or ... what?

We're able to get it working in the Waveforms App.  But we want it running in C++ code using the SDK.

Link to comment
Share on other sites

  • 0

Hi @RichSCorp

The C code looks good if the hdwf and outBNC1 are correct, but what is before and after this?
By default on the device close it is stopped.
- You can use wait in the application until it is needed.
- Or call the following before opening to continue running after close, see the earlier script
dwf.FDwfParamSet(DwfParamOnClose, c_int(0))

I just notice the following 3 mistakes but this is not a showstopper.
# analog-in
dwf.FDwfAnalogInFrequencySet(hdwf, c_double(1e6)) # 1MHz sampling rate
dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), c_int(0), c_int(1)) # channel 1 enable
dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0), c_int(1)) # channel 1 enable

dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(0), c_int(0), c_double(0.0)) 
dwf.FDwfAnalogInChannelOffsetSet(hdwf, c_int(0), c_double(0.0)) 

dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(0), c_int(0), c_double(5.0)) # 5 Vpk2pk range
dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(0), c_double(5.0)) # 5 Vpk2pk range

Link to comment
Share on other sites

  • 0

Hi @attila,

Just wanted to say thank you! @RichSCorp and I were able to get the C Code working perfectly. The AD2 is an absolute great tool. There were some other issues that we wanted to run by you as we are in the development stages of a project. 

We are very well aware of the preloaded settings for the AD2's configuration, which allows us to have certain amounts of memory allocated to the Scope, WaveGen, Patterns, etc. What we are hoping is for the ability to set these parameters for ourselves. We would like to have settings of 2 x 8K for the scope and 2 x 16K for the WaveGen. Is there anyway that this can be accomplished? Does Digilent Inc. offer special firmware packages/updates that can get this accomplished?


We are also looking to have the device send out continuous signals to be recorded on a CPU. Is the ability to have a continuous reading dependent at all on the maximum amount of samples that are set by the scope's configuration. For Example, the default setting I believe gives us the ability to have 4K samples on the Scope, with continuous would we  be able to surpass that amount?

Are we also able to have a continuous signal being sent out for Noise? I noticed with in the SDK Documentation, the noise needs to be sent to a buffer, which is much smaller than what is needed. How, would we go about having it stream continuously and simultaneously as we are sending out a separate signal on a different channel?

As always, your help is greatly appreciated. Looking forward to hearing from you soon.

 

Regards,

@Will_SC

Link to comment
Share on other sites

  • 0

Hi @Will_SC

Such configuration would not fit but you can use the Record mode to capture more ('unlimited') samples at up to 1-2MHz with Analog Discovery.
The Wavegen can generate noise, 167bit LFSR random in the device. You can also use Custom pattern filled with random or the Play mode to generate more ('unlimited') samples.

image.png.a76fe185cf2d73d1c6c2dd59d2ee47bc.png

 

The ADP3X50 can perform Recording in DDRAM at up to 128MiS X 125MHz x 1 channel.

image.thumb.png.e08276a3fd1bc5c03636126c8d13cbf4.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...