How to give digital high/low from DIO pins from MATLAB

Moku model: Moku Delta
Operating system: Windows 11
Software version: 4.1.1

**Bug or support request description: I can give an arbitrary DIO pin High or Low from Logic Analyzer Instrument on GUI. But from MATLAB, every function regrading setting a pin yields an error.
**
logic_analyzer.set_pin_mode(9,‘PG1’)

I want to set the pin 9 High, what should I do?

Hello @alkmbozkurt ,

Thank you for reaching out to Liquid Instruments! What is the error that you are getting? The way to set the pin ‘high’ would be to generate a pattern of 1s, like we do in this example. Namely, this section

patterns = [struct('pin', 1, 'pattern', repmat([1],1,1024)), ...
        struct('pin', 2, 'pattern', repmat([0],1,1024)), ...
        struct('pin', 3, 'pattern', repmat([1 0],1,512)), ...
        struct('pin', 4, 'pattern', repmat([0 1],1,512))];
    
    
    m.set_pattern_generator(1, patterns, 'divider', 8);
    
    m.set_pin_mode(1, "PG1");
    m.set_pin_mode(2, "PG1");
    m.set_pin_mode(3, "PG1");
    m.set_pin_mode(4, "PG1");

where Pin1 is set to be ‘high’ by creating a pattern of 1s. I hope this helps!

-Dylan

the set_pin_mode function yields an error saying DigitalO is not the source. And when I try to set the source as DigitalIO from set_source, it says that is not a valid source. This happens in MiM, but standalone works fine.

@alkmbozkurt ,

This error comes from the fact that in single instrument mode, the source can be either the DIO, or the analog inputs. When using the DIO as the source, the ‘pin mode’ (input or output) is configured in the Logic Analyzer UI. You select each Pin and assign it to be either an input or an output (this is what the set_pin_mode() command does), and configure the pattern.

In Multi-Instrument mode, the source can be the DIO, the analog outputs, another instrument output, etc. Because of this, the input/output source is not determined in the Logic Analyzer UI, but rather in the Multi-Instrument UI. Whatever you have connected to the input/output of the Logic Analyzer is going to be the ‘source’. The configuration of the DIO will be done in the Multi-Instrument UI.

This means that the set_pin_mode() function isn’t used in the Multi-instrument context. To set the ‘pin mode’, you will use the set_dio() command to set the direction of the pins (equivalent of set_pin_mode()). Here is an example with Python where I set Pin 1 to be an output with a ‘high’ pattern configured.

i=MultiInstrument('192.168.2.37', force_connect=True, platform_id=3)

la=i.set_instrument(1, LogicAnalyzer)

connections=[dict(source='Slot1OutA', destination='DIO1')]

i.set_connections(connections=connections)

## Set Pin1 as output and Pins2-16 as inputs
direction=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

i.set_dio(direction=direction)

patterns=[{'pin': 1, 'pattern': [1]*8}]

la.set_pattern_generator(1, patterns=patterns, divider=250)


i.relinquish_ownership()

I hope this makes sense!

-Dylan