laitimes

Perform custom transient fault detection using ChatGPT and Moku Cloud Compilation

author:Spectral Line Technology

You can still implement custom VHDL with Moku Cloud Compile without having to be an expert. Learn how to use ChatGPT to implement complex functions in MCC.

When performing real-time fault detection, you typically have two options: you can sample at a high rate but face long dead times, or you can sample nearly continuous data at a very low rate. Obviously, neither approach is ideal. However, there is a better way to optimize your test equipment – using VHDL and customizable test equipment and writing your own transient fault detection program. Doing so allows you to detect faults in real time in the FPGA, even in the test and validation equipment you're already using. We know that writing FPGA code is rightly more challenging than more traditional procedural programming. However, a new generation of large language models, such as ChatGPT, can easily increase productivity in the language without knowing the details.

The traditional way

Test benches are not very good at transient fault detection. There are generally two monitoring and detection methods:

  1. High rate but intermittent
  2. Low rate but continuous

Option 1 uses an oscilloscope. Oscilloscopes typically have dead time between 20% and >99.9%, so it is highly impossible to rely on "seeing" transient faults on the screen. One way to solve this problem is to set up triggers that enable the oscilloscope to detect failures for you and show you the results. This approach has several drawbacks: firstly, the fault must be something that can be triggered, and second, it can only reliably tell you whether the failure has happened once. It cannot determine the failure count, failure rate, total time under fault conditions, etc.

Option 2: Use a data logger or data acquisition device. In this case, the computer monitors all relevant signals in real time and can calculate intermediate values. The system detects faults and related parameters. However, this approach has its own set of drawbacks. This approach requires a computer with a proper programming environment, but more importantly, it can only monitor the signal at a certain maximum rate, limited by computer power, the complexity of any calculations, and the throughput of the connection between the data acquisition device and the computer.

It is best to combine these two approaches: detect complex transient fault conditions and measure their parameters in real time, not limited to low sampling rates. Conveniently, Moku devices utilize an on-chip instrument architecture and user-programmable FPGAs. Moku Cloud Compilation (MCC), along with up to 12 other instruments on Moku devices (Figure 1), provides a programming environment for custom instruments. MCC provides all the infrastructure needed to write your own FPGA code and deploy it to Moku.

Perform custom transient fault detection using ChatGPT and Moku Cloud Compilation

Figure 1: Moku lineup with iPad and desktop interface

Example: Transient power detection

Suppose your testers need to monitor the transient power of a power system. The system is rated for total power, but in practice, it can withstand transient overpower as long as the event rate, event time, and total time under fault conditions are below the threshold. In other words, we want to design a company that:

  1. Power is monitored through a point in the system, i.e. voltage and current are monitored, and then the power is calculated.
  2. Calculate the number of times, if any, the power exceeds the threshold.
  3. Record the total time that the power exceeds the threshold.

We can also record the maximum duration of any one failure, the total energy under the fault condition, and so on, but we will limit ourselves to these three steps.

This is not suitable for intermittent monitoring like oscilloscopes. When the input of the oscilloscope is voltage and current, it needs the oscilloscope to trigger at the power level. Few systems can use real-time calculations as input to trigger circuits.

Depending on the system parameters, it is also not suitable for data acquisition methods. Modern power systems can be damaged by high-speed transients, requiring high acquisition rates; But power systems like these are often designed for long, continuous use, so the time for which the system needs to be monitored to increase confidence in its behavior can also be long. This results in a very large amount of data, increasing cost and complexity.

The custom on-chip instrument deployment is a great fit, let's see how we can use ChatGPT to help us build one.

ChatGPT is used for custom fault detection

First of all, ChatGPT performs best when given very specific instructions. Break down large problem statements into more manageable iterations. In this way, it is quite user-friendly!

Next, we ask for a VHDL entity to calculate the number of failure events in Figure 2.

Perform custom transient fault detection using ChatGPT and Moku Cloud Compilation

Figure 2: Hint of VHDL-based fault counter ChatGPT.

Next, we add a counter that shows the total time in the fault state (Figure 3).

Perform custom transient fault detection using ChatGPT and Moku Cloud Compilation

Figure 3: Prompting ChatGPT to add counters to our program.

Finally, we make the fault condition threshold configurable at runtime by adding it as a port to the VHDL entity (Figure 4). In the final MCC implementation, this threshold will be connected to the control register, so it can be set without having to rebuild the entire instrument.

Perform custom transient fault detection using ChatGPT and Moku Cloud Compilation

Figure 4: Prompting ChatGPT to modify our entity.

Find the full list of final VHDLs at the end of this post.

Note that we haven't solved the problem of calculating the input power. We can achieve this by simply multiplying the voltage and current inputs before they enter the VHDL entity. Figure 5 shows an example of how to instantiate this entity in an MCC, with power as input.

Perform custom transient fault detection using ChatGPT and Moku Cloud Compilation

Figure 5: Calculate the power of the input signal in VHDL

Note that this does increase the width of the input port from 16 bits to 32 bits. Either the incariation here can throw out the lower 16 bits (if the loss of precision is acceptable), or the entity is updated to accept 32-bit input directly. Either way, all you need to do is ask! See the tips at the end of this article.

Review: Perform custom transient fault detection using ChatGPT and Moku cloud compilation

We ran into a problem that required real-time, high-rate, dead-zone-free fault detection for computation rather than something that could be measured directly. With just three prompts, ChatGPT gave us all the code we need to make this happen in VHDL, a language specifically designed for high-speed data processing on FPGAs. A simple cut-and-paste operation and a little glue code, along with Moku cloud compilation from Liquid Instruments, turned it into a custom instrument that can be deployed to Moku's instrument-on-chip. 10 minutes of work is not bad!

Appendix 1: Code Listing

Perform custom transient fault detection using ChatGPT and Moku Cloud Compilation

Attachment 2: Port connection tips

Perform custom transient fault detection using ChatGPT and Moku Cloud Compilation

Read on