Five Wire Automation using MBScript

The Five Wire GUI provides easy to understand interface for each of the five tools. It also allows you to save your complete setup or the setup of individual tools. However, for some applications automating the setup provides big advantages. Five Wire provides a ‘C’ like scripting language, MBScript, which allows you to take your tests to the next level. With MBScript you can:

  • Create custom digital and analog waveforms
  • Execute tests repeatedly, evaluating and storing results
  • Evaluate test results for application specific characteristics
  • Develop automated tests with user prompts

Each of the Five Wire tools includes a human readable command set. Scripts can use these commands to configure the tool and read back acquired data. For example, you can create a custom Waveform Source output by calculating the set of points that make up the waveform shape within a script. To execute the script just select File Run Script.

Here is an example script that creates a square wave by combining sine waves up to the 9th harmonic:

You can also create digital pattern sequences this way. For example, if you want to generate a series of random 8 bit values you can write a script with a for loop with the line value = rand(0, 255); and write that vector to the Logic Source using the library function LSvector(sequence, value, duration).

Capturing and evaluating data is just as easy. To start a Live Logic acquisition, include LL(“run”); in your script. To check that the acquisition is complete include if( !LLisStopped() ) sleep(100); . To retrieve the acquired data include data = LLgetWaveform(“CH1”, time[], data[]); which returns 2 arrays, one with the time of each sample and a second with the value sampled at that time. You can write for, while, and do-while loops to iterate over the data. Standard math and logic operations can be employed to search for the characteristic of interest. Results can be displayed in one of the easy to use dialog windows such as textWindow(value); or written to a text file.

MBScript looks very ‘C’ like. There are a few notable exceptions to this. Variables are not strongly typed; they are created automatically when encountered. Data arrays are associative not numeric. You can use a number index or a string to index the array. You can declare your own functions by inserting function funcName(param1, param2) {function body} .

The MBScript reference is included when the Five Wire application is installed. Just click Help Open MBScript Reference to open the PDF document. The reference includes a complete description of the script language, a description of the tool commands, and example scripts.

 

Using Five Wire Events

Five Wire provides 5 unique tools that address different needs of digital designers. Each tool operates independently providing its capabilities in tandem with other tools. For example, you can generate digital stimulus with the Logic Source while capturing test results with the Logic Analyzer. The tools can also interact with each other and the outside world using events or triggers.

Each tool provides an event input and an event output. For example, the Logic source can generate an event on a particular output vector. The Logic Analyzer can be configured to receive that event as a trigger input to terminate its acquisition. The trigger protocol tool provides trigger inputs and outputs that interface the event system with the outside world such as an oscilloscope. Linking the Five Wire tools using events extends their capabilities. Here we will show a few examples of what you can do with events.

Examples

The Logic Source tool can both source and accept events. To generate an output event, you specify event to be produced when a selected vector is output. For example, here we show a simple count output pattern where an event is output each time the zero vector is output.

This event could be used to trigger the Logic Analyzer tool to capture the current state of the system. First we must select the Logic Source event as an input to the Logic Analyzer tool.

Next we configure the Logic Analyzer trigger to use the input event.

The Logic Analyzer will now trigger on the event generated by the Logic Source as shown below.

The Logic Source can also receive events. In this example the Logic Source is configured to send its count pattern each time an event is received. We will use the Waveform Source to create an event once each millisecond. We will use the Logic Analyzer to capture the waveform.

First we select the On Event mode for the Logic Source keeping the same count pattern as before.

We select the Waveform source as the event input. The Waveform Source is configured to generate the default 1 KHz sine wave. It will generate an event each millisecond at the start of each cycle. We then capture the Logic Source output using the Logic Analyzer as shown below.

Zooming in we can see the count pattern burst that occurs when the event is received.

We can reverse the roles making the Logic Source provide an event each millisecond that the Waveform source will use to trigger its sine wave output. We exported the Logic Source event using the Trigger Protocol probe so we could also capture the event on the scope as shown in screen capture below.

Events can also be sourced by the System. Pressing the front panel button labeled System or by clicking the SYSTEM button in the Five Wire System window, an event is generated which can be used by any of the tools. This allows you to generate a waveform on-demand at the press of a button.

The Trigger Protocol tool allows you to input events from an external source or to output an internal event from its probe. Here is the configuration we used above to export the Logic Source event to the scope.

In this case the probe output O-TRIG1 was selected to output the Logic Source event. Up to 3 different events can be output. There are 3 event inputs that can drive up to 2 internal events, Protocol A and B. Protocol A can be sourced from any of the 3 inputs. Protocol B can select any of the inputs or a logical combination of the 3 inputs.

Five Wire events give you more control and extend the capabilities of each tool. They leverage the high level of tool integration making it easy to create the test that you need.

 

 

Working with I2C protocol

The I2C protocol provides a lightweight and convenient interface for sensors and controllers connected to microcontroller systems. Five Wire provides a number of tools that support hardware and firmware development using I2C. The Live Logic and Logic Analyzer tools can capture and decode I2C traffic providing a human friendly description of each I2C transaction. The I2C protocol tool can emulate an I2C master or slave device allowing you to take control of the I2C bus to better understand a peripheral devices behavior or provide direct control over the system.

Live Logic provides 2 channels of digital capture using scope probes. This makes it easy to probe SCK and SDA to capture I2C traffic. For example, here is an I2C read of a real-time clock (RTC) date/time value.

To read the RTC, the master must first write the address to read, 0x00, and then read 7 bytes which encode the date and time using the BCD format. We can zoom in on the waveform and inspect the timing or individual bits. However, for this example we want to know the contents of the transaction. First we must select a decoder for the protocol.

We select the I2C decoder using the default settings. Once selected, marks will be placed over the data describing the transaction.

The decoder shows that the RTC was accessed at I2C address 68 and a zero was written. Then 7 bytes were read. These bytes are BCD encoded so you can read them directly. 26 seconds, 42 minutes, 9 hours, day of the week 4 (Thursday), day 27, month 9, year 18.

Although this is a great improvement you can go further by customizing the decoder. Five Wire provides the ability to write your own decode (dcd) scripts which determine how the data is converted into human readable strings. If you browse the Documents/Anewin/FiveWire/decoders folder you will find the i2c.dcd decoder that was used to decode this transaction. The dcd scripts are simple text files. When you load the I2C decoder you can select your custom decoder. Here is an example of a custom dcd used with the RTC.

Now the read is decoded to show the contents of the transaction so you don’t have to mentally decode the bytes.

The Logic Analyzer provides more capture channels so you can observe other activity while capturing I2C transactions. The Logic Analyzer provides the same decode capability and dcd scripts but also supports loading multiple decoders. For example, you can load an I2C decoder on channels 0 and 1, monitor a digital output on channel 2 and load an RS232 decoder on channel 3 as in this example.

With the Five Wire I2C Protocol tool you can take control of the I2C bus as shown in the example below. By entering a few lines to define the desired I2C transaction, the Five Wire Protocol tool can emulate an I2C master doing reads and writes to retrieve the date/time from the RTC.

On line 1 we wrote a zero to the RTC. On line 2 we read 7 bytes (14:55:10 Thursday 09/27/18). In addition to read and write transactions you can include commands that insert delays between transactions, pause execution and wait for an event from another tool or an external trigger source, and form infinite loops to provide a repeated transactions.

The I2C Protocol tool can also act as a slave device. This allows emulation of a missing device or provide exact control over the I2C responses. In the example below the system makes an access to a emulated RTC at address 2. The slave has been programmed to return the date Monday, Sept 1, 2018, 12:00:00. A microcontroller was programmed to access the I2C address 2 and send the response out on its RS232 output. Here is the captured transaction using the Logic Analyzer tool.

Five Wire provides broad support for the I2C protocol. Because of the wide adoption of I2C as a peripheral interface, the capture/decode and protocol emulation capabilities can simplify debug and evaluation of I2C device operation and firmware development.