Problem with pattern generator of Moku:Go LogicAnalyzer

Hello,

I am facing two problems when trying to generate digital signals with the pattern generator of the LogicAnalyzer instrument. I use the following Python API commands for configuring the pattern generator: Two patterns shall be sent simultaneously on two digital I/O pins in order to emulate a SPI MOSI and CLK communication signal:

la.set_defaults()
la.set_pin(3, “PG1”)
la.set_pin(4, “PG1”)
patterns = [{“pin”: 3, “pattern”: clk_pattern},

  •      {"pin": 4, "pattern": latch_function},*
    

la.set_pattern_generator(1, patterns = patterns, baud_rate = 500000, tick_count = 60, repeat = False, iterations = 100)

The two desired patterns are defined in the following lists:

clk_pattern:
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]

latch_function:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0]

Here are the two problems:

1. As observed with an oscilloscope, the output signals are only generated when the parameter “iterations” is larger than 500. It it is less or even just “1”, no signal is observed at all.

2. Although the documentation states that the baud_rate parameter can be in the range 125 to 125e6, I receive the following error message when this parameter is smaller than 1 Million:

---------------------------------------------------------------------------
InvalidParameterException Traceback (most recent call last)
Cell In[121], line 14

  •  8 la.set_pin(6, "PG1")*
    
  • 10 patterns = [{"pin": 3, "pattern": clk_pattern},*
    
  • 11             {"pin": 4, "pattern": latch_function},*
    
  • 12             {"pin": 5, "pattern": clk_pattern},*
    
  • 13             {"pin": 6, "pattern": latch_function}]*
    

—> 14 la.set_pattern_generator(1, patterns = patterns, baud_rate = 500000, tick_count = 60, repeat = False, iterations = 100)

File ~\Documents\StudiumMaster\WissenschaftlicheHilfskraft\MokuPro\Python\VirtualEnvironment\Lib\site-packages\moku\instruments_logicanalyzer.py:250, in LogicAnalyzer.set_pattern_generator(self, channel, patterns, baud_rate, divider, tick_count, repeat, iterations, strict)

  • 239 operation = “set_pattern_generator”*
  • 240 params = dict(*
  • 241 strict=strict,*
  • 242 channel=channel,*
  • (…)*
  • 248 iterations=iterations,*
  • 249 )*
    → 250 return self.session.post(
  • 251 f"slot{self.slot}/{self.operation_group}",*
  • 252 operation,*
  • 253 params)*

*File ~\Documents\StudiumMaster\WissenschaftlicheHilfskraft\MokuPro\Python\VirtualEnvironment\Lib\site-packages\moku\session.py:17, in handle_response..func_wrapper(self, *args, *kwargs)

  • 14 @wraps(func)*
    
  • 15 def func_wrapper(self, *args, **kwargs):*
    
  • 16     response = func(self, *args, **kwargs)*
    

—> 17 return self.resolve(response)

File ~\Documents\StudiumMaster\WissenschaftlicheHilfskraft\MokuPro\Python\VirtualEnvironment\Lib\site-packages\moku\session.py:166, in RequestSession.resolve(self, response)

  • 164 return data.data*
  • 165 elif data.success is False:*
    → 166 self.handle_error(data.code, data.messages)
  • 167 else:*
  • 168 self.handle_http_error(response)*

File ~\Documents\StudiumMaster\WissenschaftlicheHilfskraft\MokuPro\Python\VirtualEnvironment\Lib\site-packages\moku\session.py:122, in RequestSession.handle_error(code, messages)

  • 120 raise exceptions.NoInstrumentBitstream(messages)*
  • 121 elif code == “INVALID_PARAM”:*
    → 122 raise exceptions.InvalidParameterException(messages)
  • 123 elif code == “INVALID_REQUEST”:*
  • 124 raise exceptions.InvalidRequestException(messages)*

InvalidParameterException: [‘Unable to set baud_rate to desired value. Coerced value: 1000000’]

Could you please check if there is a bug in the Python API or whether I am doing something wrong?

Thank you very much in advance!

Hi @Felix. sorry for the slow reply! My engineering team are trying to reproduce this now and will let you know ASAP.

Hi Felix,
Instead of the baud_rate parameter you can use the divider parameter. The base frequency is 125MHz. A divider value of 1,000,000 will give you a baud rate of 125. You can use the divider value to set your desired baud rate. Using the divider parameter and your settings for PG1 I was able generate the 2 outputs. Below is a screen shot of the output captured on a scope for iterations = 2. The 2nd screen shot the divider value = 10,000, producing a baud rate of 12,500, and iterations = 7.

Hopefully this helps.

from moku.instruments import LogicAnalyzer

i = LogicAnalyzer('192.168.2.127', force_connect=True)

try:
    
    clk_pattern = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
                   0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 
                   0, 1, 0, 1, 0, 1, 0, 1, 0]

    latch_function = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 
                      0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0,
                      0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0]

    patterns3 = [{"pin": 1, "pattern": clk_pattern},
                 {"pin": 3, "pattern": latch_function}]
    
    i.set_pin(1, "PG1")
    i.set_pin(3, "PG1")
    i.set_pin(2, "I")
    
    i.set_pattern_generator(1, patterns=patterns3, divider=1000000,
                        repeat=False, iterations=2, tick_count=48)

    print(i.summary())

Hi Steve,
thank you for your hint! By using the “divider” parameter instead of the “baud_rate” parameter, it is indeed possible to set the communication frequency to an arbitrary value. So now I can use the pattern generator for my purpose.
Anyhow, don’t you think the behavior of this API function should be improved, as the “baud_rate” parameter only accepts the value 1e6 and not any value between 125 and 125e6 as specified in the API reference?

Hi Felix,
Agreed. We will report this as a bug and work to get it resolved. We appreciate you reporting this issue. Thanks,
Steve