Jump to content
  • 0

Waveforms script for controlling Logic1 and Patterns1 instruments with Digital Discovery


J.J.

Question

Hi.

I am trying to write a script that enables two DIO pins to be used as a 30 MHz clock source(seems that DD only supports frequencies like 50M, 25M, 12.5M) and a piece-wise linear enable signal & thirteen DIN pins to get a timing signal (negative edge will be used for logic analyzer trigger) and twelve digital output signals from DUT. I referred to Waveforms help manual and help page, but examples utilizing logic analyzer and pattern generator were not available. 

I wrote a practice code, but Patterns feature only works when I manually add corresponding DIO pin to Patterns window in GUI. Otherwise, output log says, 'TypeError: Result of expression 'Patterns1.Channels.DIO33' [undefined] is not an object.' 

Also, I am also having hard time setting logic analyzer details with a script. Which properties should be defined in the script for activating thirteen DIN pins is not clear.

Could someone advise me how to write a proper script based on the following block diagram and my code?

 

Thanks in advance!

Best, J.J.

 

Code:

clear();

print("Fresh start");

 

if(!('Logic1' in this) || !('Patterns1' in this)) throw "Please open a Logic analyzer and a pattern generator instrument";

 

// patterns window should be opended already

// required signal IO pin should be assigned in GUI. if not, error evoked: Patterns1.Channels.DIO## 'undefined' is not an object

// PP: push-pull (0 and 1); OD: open drain (0 and Z); OS: open source (Z and 1); TS: three state (0 and 1 and Z)

 

// pins used in patterns window need to be created in GUI. failed to activate ceratin pins

Patterns1.Channels.DIO33.setEnable();

Patterns1.Channels.DIO33.Output.text = "PP"; // output type is push-pull (allowed pattern values are 0 and 1)

Patterns1.Channels.DIO33.Type.text = "Clock";

Patterns1.Channels.DIO33.Frequency.value = 25E6; // 20 MHz clock (scientific notation works)

 

Patterns1.run();

 

Logic1.Trigger.Trigger.text = "Auto";

//Logic1.Trigger.Clock.text = "Internal";

Logic1.Channels.DIN23.Trigger.text = "Fall"; // falling edge of CLK_S will be the sampling timing

 

print("End of code.");

 

 

 

upload1.png

upload2.png

upload3.png

Edited by J.J.
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Hi @J.J.,

I apologize for the delay (and earlier ping from when I hit reply too early) I have moved your question to a more appropriate section of the Forum where the engineer much more familiar with WaveForms and the Digital Discovery hardware will be able to see and respond to your questions.

My understanding is that you can get the clock rate to change by adjusting the base clock frequency, as mentioned in this thread starting here:

I'm not sure on the proper syntax for the script to set up an an array of pins for the logic analyzer.

Thanks,
JColvin

Link to comment
Share on other sites

  • 0

Hi @JColvin,

Thank you for moving my thread to a proper place. 

Yes, a part of my first objective includes adjusting base clock frequency. I will check the thread you recommended and apply to my work.

Thanks for your help!

 

Best, 

J.J.

Link to comment
Share on other sites

  • 0

Hi @attila,

Thanks for showing me how to adjust system frequency. I checked that the system frequency ranges in between 50 MHz and 120 MHz.

I read through a few Waveforms SDK Python sample codes, but it seems that an interactive Waveforms GUI window won't open in that workflow, so I would like to stick to JS workflow for now.

Could you provide a sample Waveforms JS script that can assign digital output pins in Patterns1 and sample a few data signals in Logic1 sync mode?

 

Best, 

J.J.

upload4.png

Link to comment
Share on other sites

  • 0

Hi @attila,

Thanks for letting me know that. Many things are clear now.

Could you go over my test plan and check whether it's feasible or not? A Digital Discovery (DD) will be paired with Waveforms installed in my laptop.

I want my Script code to assign a clock (CLK), an enable, a calibration-start (CAL_START), and a rising digital step signal (Signal A) to DUT, wait a couple of seconds, make Signal A logical '0', and then start capturing samples synchronized with falling edges of a digital signal (TIMING) generated inside DUT.

upload5.thumb.png.f041862a0bc58b5132f96d81fbbf3770.png

  • Assign a 30 MHz CLK to DUT with Waveforms Pattern1
  • Assign an enable signal to DUT with Waveforms Pattern1
  • Assign CAL_START and Signal A to DUT with Waveforms Pattern1
  • Wait 2 seconds (DUT calibration time)
  • Make Signal A as logical '0'
  • As DUT receives the clock and enable signal, a 10 MHz cyclic signal TIMING, whose duty cycle is less than 50%, is generated and passed to Waveforms Logic1 to capture samples synchronized with falling edge of TIMING (because of internal delay of DUT, falling edges of TIMING are not necessarily aligned with CLK)
  • Logic1 needs to start synchronous acquire using falling edge of TIMING, as soon as the calibration ends (Signal A falling edge)

Since operating frequency surpasses my clicking speed, Logic1 acquire triggered by the falling edge of Signal A is a crucial point.

I configured the test environment in GUI by directly connecting digital outputs of DD to digital inputs of DD. DUT is omitted for a quick verification.

upload6.thumb.png.838fd2721807f1a2cc0599bef9fe9f29.png

upload7.thumb.png.9a1e41f15b19b4fd46e049a6200be4c7.png

Is there any logic analyzer sample code that I can use to write appropriate Script code?

 

Thanks in advance.

Best,

J.J.

Edited by J.J.
replaced the last photo
Link to comment
Share on other sites

  • 0

Hi @attila,

Thank you for building a complete configuration!

After updating my Waveforms to the latest beta, synchronous config in Logic1 lets me choose Enable and Clock pins from DIN0 to DIN7.

Is there something I'm missing?

Waveforms version is 3.18.30.

upload8.thumb.png.d7b2fd76a544c2cf750bb2a556325ea6.pngupload9.png.05ea48a14febaa8db35727e716d3437e.png

Edited by J.J.
Added version info
Link to comment
Share on other sites

  • 0

Hi @attila,

Oh yes, by selecting my DD in the device manager manually, now I can choose from the whole range of DIN0..23 and DIO24..31.

Would you mind explaining a few things related to the sample code in Script?

Patterns.run();
StaticIO.Channel0.CAL_START.value = 1;
StaticIO.config();
StaticIO.Channel0.SignalA.value = 1;
wait(2);
Logic.single();
StaticIO.Channel0.SignalA.value = 0;
Logic.wait();

StaticIO.Channel0.SignalA.value = 0;
StaticIO.Channel0.CAL_START.value = 0;
Patterns.stop();

1. In line 3, StaticIO.config(); comes in between assigning CAL_START and SignalA. In help page, it says that Instrument#.config(); applies configuration immediately. Could you explain why config() is executed before assigning SignalA? What kind of configuration is applied with that method?

2. In line 6, Logic.single(); performs a single acquisition. If acquiring mode is set to synchronous in GUI, does the single acquisition work as synchronized mode? From Logic1 GUI, it seems that one synchronous sampling is done by running the code.

 

Thank you for your support.

 

Best,

J.J.

 

Link to comment
Share on other sites

  • 0

Hi @J.J.

1. The settings in the application are not immediately executed but with a few ms delay. When running a Script are executed during wait or immediately on instrument's config, run, single or stop call.
With the "CAL_START=1; config();" you make sure the cal_start is set before SignalA=1 This, according your timing diagram.
You can also use the following to have certain timing between cals_start and SignalA
StaticIO.Channel0.CAL_START.value = 1;
StaticIO.config(); // apply CAL_START now
wait(0.02);
StaticIO.Channel0.SignalA.value = 1;
StaticIO.config(); // apply SignalA now
wait(2);

2. Yes. For synchronized and record modes both single and run will perform one capture.

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...