• 0

Go to solution Solved by attila,

Question

I'm trying to write a script to custom define signals on the Patterns tool by following the code in the reference manual. However, these are not working:

  • Patterns1.Channels.DIO1.name = "Testing" <- Doesn't change the name of the signal, but once I click on the edit button the pop window shows it as "Testing". Once I run the program a second time it get an error for "Patterns1.Channels.DIO1.name = "Testing"" and it's not resolved until I change it to "Patterns1.Channels.Testing.name = "Testing""
  • Patterns1.Channels.DIO1.DIO.value <- Returns: " Result of expression 'Patterns1.Channels.DIO1.DIO' [undefined] is not an object."

Additionally, the reference manual doesn't show how to automatically set up the signals from the start using the script. For example, how to select the output as PP or Type as Custom. Do I have to set this up manually every time?

Thank you in advance!

Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0
  • Solution

Hi @Nick

The Script tool is intended to automate things, to extend the GUI features.

What can be done in the GUI, is easier to do there, like: setup channels, naming, static configuration...
Then, use the Script to adjust parameters that need to be changed, write log... like: changing PWM duty based on some scope measurements.
You can save the Script together with the other instruments in workspace, so there is no need to make all the setup in Script.

Regarding your script questions:

  • set both label and name, in certain cases the label is show in other one the name:
    Patterns1.Channels.DIO0.label = Patterns1.Channels.DIO0.name = "Testing"
  • use .Pin
    Patterns1.Channels.DIO0.Pin.value = 1 or 
    Patterns1.Channels.DIO0.Pin.text = "DIO 1"

  • press Ctrl+Space to see the object children, like the DIO parameters:
    use: Patterns1.Channels.DIO0.Output.text = "PP"
    i6.png.c505db6eeeff2a09b36dd0a90ec91646.png

Link to post
Share on other sites
  • 0

Hi @attila,

Once I've created a Pattern, how do I get it to show in the scripts window? The scripts window always shows a sample code that has to do with StaticIO. The file saved when I save the Pattern also has a different extension as what the script would normally open.

 

Thanks in advance.

 

Link to post
Share on other sites
  • 0

Hi @Poseidon

If you want to set a custom a pattern for a Pattern signal or bus use .custom parameter.

The exported data to csv or txt are saved with new line separator. Such can be converted to array in Script with the split function.

image.png.db94dc451840d1d85b58287c1f6a86c6.png

var rg1 = [0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1]
Patterns1.Channels.DIO0.custom = rg1
var rg2 = (""+FileRead("~/Desktop/default.csv")).split("\n")
Patterns1.Channels.DIO1.custom = rg2

 

Link to post
Share on other sites
  • 0

Hi @Attila,

What Pattern type should I set the DIO to if I want to be able to manually set what the pin outputs? Ideally I would want to do something like the code below

Patterns1.Channels.PIN1.value = 1;

wait(0.000000015);

Patterns1.Channels.PIN1.Value = 0;

Is this possible?

Link to post
Share on other sites
  • 0

Hi @Attila,

I tried the constant type and it seems like it isn't fast enough to bit-bang a display signal out using constants.

If I were to do it with patterns, what would be the trigger to know if a pattern has finished so I can load the next pattern since we are only limited to 32k samples.

If you were to try and output a VGA signal, would you have suggestions on how to go about it with the Digital Discovery device?

Many thanks for the prompt replies.

Link to post
Share on other sites
  • 0

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