Jump to content

Empower

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by Empower

  1. Awesome! A new beta feature. Great support @attila.
  2. @attila The specs for this custom 1-wire are still internal, so let me share the relevant specifics instead. There are 3 "symbols per the table below. Each symbol requires >=25 ns low signal between them. Generic timing for the symbols is shown in the image below. Data is sent in byte (8-bit) increments. Here is an example transmission of byte value 0b00000001. Transmission can be continuous; for example, 4-bytes can be sent without an "end" between each byte.
  3. I'd like to create a logic analyzer decoder for a custom 1-wire protocol. Are there any custom example scripts available for 1-wire protocol? My protocol is basically a 25 nsec high pulse is a logic "0" and 75 ns high pulse is a logic "1" pulse. The wire is normally high. I've found the SPI and UART examples but am not sure how to make these useful for time-based 1-wire protocols.
  4. After double checking my digital_out on a scope, I see it is running at 25 MHz, not 2 MHz. So my 4 samples per period is sampling at 100 MHz. This issue is closed due to my error. Thanks for the help.
  5. I added this line to the setup. The sample rate is still slow (2 MHz). Is this expected? digital_in.dividerSet(int(clock_frequency/100e6)) Another odd behavior, if I change the internal clock, the first run of the script shows the correctly-changed internal clock value and the second run of the same, unmodified script shows the internal clock is 1/2 of what it is set to. Here I set the internal from 80 MHz to 100 MHz and the script correctly reports 100 MHz. The script output is shown below. Then, on my second run of the same script, the device unexpectedly reports 50 MHz. The output of second run of the same script is shown below.
  6. Hi, using the GUI I'm able to sample at 100 MHz. I'd like to replicate this is software using pydwf or the SDK. Here is my example using pydwf. I have two questions when running this code. 1. This is sampling at 2 MHz, but I expect 50 MHz or 100 MHz. How to I sample at 100 MHz? I'm not setting the divider, so I thought this would sample as fast as possible. 2. This is driving out at 1 MHz (measured externally). I expect this should be 25 MHz. How is the 1 MHz determined? # %% Digilent Waveform Digital In import pydwf from time import sleep import matplotlib.pyplot as plt from pydwf import DwfState, DwfTriggerSource from pydwf.utilities import openDwfDevice CH = {'out': 0, 'in': 0} def main(): device = openDwfDevice(pydwf.DwfLibrary()) device.paramSet(pydwf.DwfDeviceParameter.Frequency, int(100e6)) digital_out = device.digitalOut digital_in = device.digitalIn # Configure for 1 MHz out digital_out.enableSet(CH['out'], True) digital_out.dividerSet(CH['out'], 1) digital_out.counterSet(CH['out'], low_count=2, high_count=2) digital_in.inputOrderSet(dio_first=True) clock_frequency = digital_in.internalClockInfo() divider_count = digital_in.dividerGet() digital_in.sampleFormatSet(num_bits=1) # 1 bit per sample format number_samples = 64 digital_in.bufferSizeSet(number_samples) digital_in.triggerSourceSet(DwfTriggerSource.DetectorDigitalIn) digital_in.triggerPositionSet(0) digital_in.triggerSet(level_low=0, level_high=0, edge_rise=1<<CH['in'], edge_fall=0) print(f'clock frequency: {clock_frequency/1e6} MHz') print(f'sample frequency: {clock_frequency/divider_count/1e6} MHz') digital_in.configure(reconfigure=False, start=True) digital_out.configure(start=True) while True: status = digital_in.status(read_data_flag=True) print(f'status: {status}') if status == DwfState.Done: print("done") break sleep(0.1) data = digital_in.statusData(number_samples) device.close() plt.plot(data, marker='.') plt.show() # %% Main if __name__ == '__main__': main()
  7. @attila thanks. That did the trick. I figured it might be something simple.
  8. I have a custom serial bus that I've modified the SPI logic analyzer example script to create a nearly-working decoder. Referring to the image below, I'd like the decoded `0x08b` to extend full width of the yellow box. How do I do this? Decoder // This scripted is intended for use with Digilent Analog Discovery 3. // Refer to https://digilent.com/reference/test-and-measurement/guides/waveforms-script-editor // rgData: input, raw digital sample array // rgValue: output, decoded data array // rgFlag: output, decoded flag array var sample_count = rgData.length // sample_count = number of raw samples var previous_clock = false; // previous cock signal level var start_index = 0; // used to keep track on word start index var sbus_bit_count = 0; // byte count per transmission var bit_count = 0; // bit counter var bit_value = 0; // bit value var byte_value = 0; // byte value var sbus_bit = 0; // sbus bit var num_sbus_bits = 0; var sbus_byte_count = 0; for (var sample_index = 0; sample_index < sample_count; sample_index++) { // for each sample var current_sample = rgData[sample_index]; // current sample var clock_pin = 1 & (current_sample >> 1); // pin1 is the clock signal var data_pin = 1 & (current_sample >> 2); // pin2 is the data signal if (previous_clock == 0 && clock_pin != 0) { // sample on clock rising edge bit_value <<= 1; // serial data bit, MSBit first if (data_pin) bit_value |= 1; bit_count++; if (bit_count == 2) { // when got the 2nd bit of the word store it sbus_bit_count++; if (bit_value == 0) { num_sbus_bits = 1; sbus_bit = 0; // "S" Start } else if (bit_value == 1) { num_sbus_bits = 8; sbus_bit = 1; } else if (bit_value == 2) { num_sbus_bits = 8; sbus_bit = 0; } else { num_sbus_bits = 1; sbus_bit = 1; // "P" Stop, End of Message } byte_value = (sbus_bit << (7 - (sbus_bit_count - 1))) | byte_value; if (sbus_bit_count == num_sbus_bits) { // when got the 2nd bit of the word store it sbus_byte_count++; // store rgValue/Flag from word start index to current sample position for (var j = start_index; j < sample_index; j++) { // rgFlag and rgValue used in Value2Text() // Flag change will be visible on plot even when data remains constant. // This is useful in case we get more consecutive equal bit_values. rgFlag[j] = sbus_bit_count; // If rgFlag[] is > 0, waveform is displayed rgValue[j] = byte_value; } byte_value = 0; sbus_bit_count = 0; } bit_value = 0; // reset bit_value variable bit_count = 0; // reset bit count for the next byte start_index = sample_index + 1; // next word might start after this sample } } previous_clock = clock_pin; // previous clock level } Value2Text // This scripted is intended for use with Digilent Analog Discovery 3. // Refer to https://digilent.com/reference/test-and-measurement/guides/waveforms-script-editor // value: value sample // flag: flag sample - the flag is the counter function Value2Text(flag, value){ var sbus_value = ""; var this_flag = flag; switch(flag){ case 0: return "X"; default: if (this_flag == 1) { if (value == 0) { sbus_value += "S"; // Start of message, hold } else { sbus_value += "P"; // End of message } } else { sbus_value += "0x" + value.toString(16).toUpperCase(); } return sbus_value; } } Value2Text(1,1) Sbus Pattern 20240112.dwf3patterns SBus Logic Analyzer 20240112.dwf3logic
  9. Losing @reddish's pydwf is a major blow to Digilent. This library was our only method of communication with compatible Diligent devices.
  10. @attila losing pydwf is a major blow to Digilent. This library was our only method of communication with compatible Diligent devices.
  11. @reddish and @attila thanks for your timely responses. Both of you show a repeating "Custom" pattern, so while I cannot run a continuous "clock" while only running a single Custom pattern. However in my use case, extending the buffer to 32k, will get me to a solution. @attila How do I run dwf.FDwfParamSet(DwfParamOnClose, c_int(0)) # 0 = run, 1 = stop, 2 = shutdown using pydwf? I can't find FDwfParamSet.
  12. @Fausto This code generates the embedded captured waveform. In this example, I would like channel 0 to run continuously. import pydwf from pydwf.utilities import openDwfDevice # Define "Custom" waveform pattern = '1' * 100 + ('0' * 5 + '1' * 5 + '0' * 5 ) * 100 + '1' * 100 clock = 80e6 # MHz # Initialize DigitalWaveForm device dwf = pydwf.DwfLibrary() device = openDwfDevice(dwf) device.paramSet(pydwf.DwfDeviceParameter.Frequency, int(clock)) digital_out = device.digitalOut # Initialize DigitalOut channels for channel in [0, 1]: digital_out.enableSet(channel, True) digital_out.outputSet(channel, pydwf.DwfDigitalOutOutput.PushPull) digital_out.idleSet(channel, pydwf.DwfDigitalOutIdle.High) # Configure channel 0 as a "Pulse" for a clock digital_out.typeSet(0, pydwf.DwfDigitalOutType.Pulse) digital_out.dividerSet(0, 32) digital_out.counterSet(0, 1, 1) # Configure channel 1 as a "Custom" waveform digital_out.typeSet(1, pydwf.DwfDigitalOutType.Custom) duration = 1 / clock * len(pattern) # max 3518437.2088832 # Set duration. If this is longer the pattern loops digital_out.runSet(duration) digital_out.dataSet(1, pattern) # Start the waveform digital_out.configure(start=True)
  13. How do I set up the digital output such that I have a continuous clock and then periodically send a custom waveform? I'm using Python pydwg. The closest I've been able to get is to set up the DigitalOutput Counter to create the clock and setup DigitalOutput Custom for the pattern. However, when the pattern ends, so does the counter. The image shows an example my intended behavior.
  14. @reddish works great. Thanks. (I looked all over for that.) Here is the complete snippet. from pydwf.utilities import openDwfDevice from pydwf import DwfLibrary, DwfDeviceParameter dwf = DwfLibrary() device = openDwfDevice(dwf) # Set a 100 MHz frequency. device.paramSet(DwfDeviceParameter.Frequency, 100000000)
  15. With the GUI I can change Analog Discovery 3's clocking options (see image). How do I do this with python's pydwf?
×
×
  • Create New...