Hello, I am a new user of Analog Discovery 2 device. I would like to output a pattern at DIO1 (for example) wherein the duty ratio is selected from a look-up table. I am trying to use the Script Editor. However, I am unsure what function/variable I should use to increment the index for the look-up table such that at the beginning of every cycle, the clock has the updated duty ratio. Here is a snapshot of my dummy code:
clear()if(!('Patterns' in this))throw"Please open a Patterns instrument";var values =[10,20,30,40,50,60,70,80,90,95];Patterns.run();for(var idx =0; idx <10; idx++){var d = values[idx];
wait(FOR AN EDGE-TRIGGER OR SOME SIMILAR CLOCK EVENT)// I am unsure if wait is the correct choice. Patterns.Channels.DIO1.Duty.value = d;
idx = idx+1;}// Assuming that DIO1 has a set frequency of 1kHz, the duty should change from 10% to 95% every 1kHz in steps as listed in variable 'values'.
Question
gupta
Hello, I am a new user of Analog Discovery 2 device. I would like to output a pattern at DIO1 (for example) wherein the duty ratio is selected from a look-up table. I am trying to use the Script Editor. However, I am unsure what function/variable I should use to increment the index for the look-up table such that at the beginning of every cycle, the clock has the updated duty ratio. Here is a snapshot of my dummy code:
Any insights would be helpful.
Link to comment
Share on other sites
8 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.