[AmpeROSE] User Interface

Hello everyone,

Lately I was working on the User Interface. The software that will run on the PC must receive measurements from AmpeRose, send commands to AmpeRose (through Ethernet or USB) and display the received measurements in the UI. The user can decide if he wants to display all the data he received, display the data that satisfies a certain trigger, display the spectrum … Another critical role of the PC software is data correction. During the initial phase, all the calibration data will be sent to PC and during the normal stream of measurements, the software will correct the received measurements accordingly.

In a previous post, we presented the class diagrams that will be implemented. As a first step, Michel & I implemented the skeleton (with some modifications judged necessary). As discussed in the mentioned post, the software has 3 main components:


The back-end will handle all the connections with AmpeRose. It must implement 2 main methods: Send Command and Receive Measurement.

In order to implement these methods, I had to implement first the Ethernet Connection class. Since AmpeRose will be the server of two TCP connections (Data – Commands), the PC software will then implement 2 TCP clients that run in 2 different threads. Ethernet receiver will read packets of measurements and place them in a queue. Ethernet sender will read from the commands queue and send them to AmpeRose.

The words sent / received in the connection component of the back-end are raw 32 bit words that currently have no significance. That’s why we have to implement a command translator and a data translator. The command translator will make a mapping between 32 bit words and commands we defined in our protocol. The data translator will take the 32 bit words and extract the value, caliber and GPIO status.

The final component of the back-end is the Data Corrector. The data corrector implements 2 methods. The first will add calibration measurements and the second will apply the correction on a given measurement. We are planning to use a linear regression for correction however this component is not implemented yet.

To sum up, in order to send a command we will have to translate it first (using Command Translator) and send it then to AmpeRose using the chosen connection (by placing it in the commands queue in the Ethernet case and the Ethernet sender thread will then get the command from the queue and send it). In order to receive a measurement, we will read a value from the chosen connection (in the Ethernet case, we will read from the queue filled by the Ethernet receiver thread). The read value will be then expanded into useful information and the correction will be applied. In order to test these functionalities, I wrote a simple AmpeRose emulator and we can successfully send commands and receive measurements (generated with a frequency of 100KHz).

Data View

Data view is an intermediary layer between back-end and the main UI. It handles how this data will be viewed. In this class we can chose the view mode: Normal View Mode where data are viewed as a normal continuous stream – Trigger View Mode where only data that obey to a certain trigger are shown. (We can also chose the trigger that will be applied: a threshold – a certain slope …). The main thread of the data view calls the receive measurement of the back-end and store the data in a data container with a capacity specified by the user.

User Interface

Unlike what I thought, the graph display of the received measurements turned out to be the trickiest part of the PC software. The UI is composed of 2 main parts: Control and Graph (as planned in this post). The user will control when he wants to start and stop the acquisition and how the data will be displayed. Initially, in the case of many connected components AmpeRose, the user will also chose to which specific one he wants to connect.

The tricky part is how we are going to display 100,000 points / second. Receiving the measurements at this rate is not a problem however displaying them is. In the current version we are applying a down-sampling and once we zoom in more and more points will be restored. PyQtGraph (the library we are using) supports 3 methods for down-sampling: ‘subsample’ where we take the first of N samples, ‘mean’ where we calculate the mean of N samples and ‘peak’ where we down-sample by drawing a saw wave that follows the min and max of the original data. For now we are using the ‘peak’ method because we are interested in the extreme values.

Next Week

For now, we have a basic working UI ready to be used with the micro-controller. The UI for now can start and stop acquisition, receive measurements and display them. This week I will continue working on the UI. I will start by the implementation of the data correction and statistics. I already implemented the trigger view mode but it needs a lot of improvements that I will work on too. I will try to improve the performance of the graph display (Normally the down-sampling calculations are done in the main thread that may cause lagging when more and more data are received that’s why I will try to implement the down-sampling in a separate thread). Finally, on another note, if we receive our card this week I will also work on testing it.

Until next week 🙂


[AmpeROSE] A little bit of everything


Last week I was supposed to start working on the UI that will receive data from Amperose and display them. However since we were finalizing the design of our circuit and its schematics, I had to work on other tasks (Given that finishing the PCB has the highest priority).

First of all, we solved the last few problems we faced (with the help of M. Polti) so Momo and I worked on the simulations (LTSpice again 🙁 ) to make sure we have an operating circuit.

Second, since the schematics were done, every single member had to review the schematics to find all the errors. Reviewing the schematics includes reviewing ALL the datasheets of the elements we used.

Right now, while my teammates are working on the PCB, I am helping them with the switching circuitry. I am trying to distribute the logical elements packaging and pins to make routing easier. I am still far from finding the optimal assignment but there are a lot of advancements.

Back to my original task, when I was not working on the previous tasks, I started implementing – with the help of Michel – the class diagram he made for the backend of UI. As for the display part, since we are going to use PyQtGraph, I followed the given examples and I wrote some myself to get familiar with this awesome library. In addition I implemented a simple server – client program. The server (UI) makes a broadcast to find a client listening on a specific port (Amperose). Then a connection between them is established, and the client code starts sending random numbers. The server reads these numbers and displays them on a graph. Nothing too fancy, but still useful.

This week, after we finish the PCB, I will go back to my original task and get it working by the end of the week.

[AmpeROSE] A Tale of Two Calibration Methods

Hello everyone

In the past two weeks, I was involved mainly in simulating the measurement circuit using LTSpice. In previous posts, problems related with switching and amplifying were discussed. In this post, I am going to share the results of the simulation of the calibration method we are going to use.

Brief Recap

In a previous post we discussed the 3 options we had regarding the calibration. Back then, we were considering 4 measurement intervals. Due to the problem with the parasitic capacitance of switches, we decided to use 3 measurement intervals. This will simplify the calibration circuitry because we have to drive only 2 switches.

The basic idea of the calibration logic is the following:

  • If the measured voltage is too small (smaller than a reference OFF voltage) we have to use a shunt resistor with a bigger value and thus turn off the corresponding switch.
  • If the measured voltage is too high (Higher than a reference ON voltage) we have to use a shunt resistor with a smaller value (to avoid high burden voltages) and thus turn on the corresponding switch.

To implement the following logic, 2 methods were considered, simulated and will be discussed in the following

RS Latches

The first circuit we used was based on RS Latches. SW1 is the switch connected to the smallest resistor while SW2 is connected to the resistor of the medium interval.

Then we applied a sine wave at the input of the comparators. Note that in this simulation our goal was to test the logic and thus driving switches will have no impact on the input wave. This was done later when we put the circuit together.

The results of the SPICE simulation are the following

The logic works exactly as needed : When the signal is below OFF reference voltage both switches must be turned off (Note that we are using PMOS transistors). When the signal is above ON reference voltage both switches must be turned on.

However this circuit has a major disadvantage. Since we are using latches, once a switch is turned on/off, the circuit has no time to stabilize the measurements (Switching time – Amplifying …). This will cause the second switch to turn on/off immediately. This is problematic especially for values in the second interval: We will never have stable measurements because we are switching on and off all the time.

Shift Registers

Our second option was using the 74HC194 shift register. We can use this register to implement our calibration state machine. The main advantage of this switch is that time can be controlled using the clock.

We simulated the following circuit

The results – presented in the following picture – are exactly as expected

We were considering using the 74HC194 circuit in our final design because we can easily control the time between switching.

However the major drawback of this circuit is that it does not follow the comparators output instantly. In the worst case scenario, we had a voltage higher than the ON reference voltage right after the clock edge. The burden voltage will increase significantly before we can change the measurement interval.

Going back to RS Latches

We actually have to be able to follow any exceeding fast enough and thus RS latch must be used. However we have to insert a delay in order to give the circuit the time needed to react to these changes.

A simple way to do that is to use RC delay followed by a buffer. The use of a simple buffer will give however a higher delay when SW1 passes from High to Low than when it passes from Low to High. We can then use a comparator with VDD/2. Another method is to use a single component proposed by linear tech LTC6994-2. Note that if we used a simple 74 buffer it would be better to use a RC delay however with the introduction of a comparator, RC has no advantages over the use of a simple single component. That’s why we are going with LTC6994-2.


Another issue we faced was the very fast transition between the lowest possible value (10n) and the highest possible value (300mA) of current. This will introduce a huge burden voltage for a very small amount of time (before the calibration circuit reacts). A decoupling capacitor must be used by the DUT to ensure that we do not have a big voltage drop. This capacitor must be small to not alter our measurements and thus we must guarantee that the drop lasts the minimum possible time.

To do that, we will add a logic that switch directly from the lowest interval to the highest one – without using the intermediate one – in case of a sudden exceeding of the maximal allowed drop voltage. This can be done by comparing the voltage seen by the DUT and the “DUT supply voltage – maximum burden voltage 100mV”.  The output of the comparator will reset both switches instantly. This will not eliminate the voltage drop instantly (as we hoped …) but it would certainly help reducing the time of that drop.

The final calibration circuit we are going to use will look something like

The final results combine the advantages of both circuits: Immediate response with a controlled delay as shown in the following figure

Next Week

In this week we also put last touches to the entire design (for example, we gave the microprocessor direct access to the calibration switches that may be used in the initial calibration or in emergency cases).

FINALLY I am done with LTSpice. Next week my main tasks are related to the PC software that will receive data from our device. I will implement the communication interface and the graph display.

Until next week 🙂

[AmpeROSE] Current Measurement

Hello Everyone !!

This week the whole team was focusing on the measurement part of the project. We studied existing architectures, proposed new ideas based on our specs and read a lot of datasheets to get – finally – a first version of the circuit we are going to use.

The measurement part will consist of the following components:

  • Current Voltage Conversion (using shunt resistors)
  • Amplification
  • Anti-Aliasing Filtering
  • Analog to Digital Conversion
  • Shunt Selector (Continuous Calibration)
  • Calibration Current Generator (Initial Calibration)

This can be summed up in the following figure:(Click for larger image)

In addition to the components present in this figure, we will have a battery power supply and an on-board recharging circuit. But we will discuss the power supply in upcoming weeks.

In the following sections, we will go into the details of each part and discuss its circuitry and its components choice.

Here we go 🙂

Current – Voltage Conversion

The first step of current measurement is to convert current into voltage. As discussed in previous weeks, this can be done using either shunt resistors or feedback ammeters. In our application, we will be using shunt resistors.

The input for this level can come from either the Device Under Test (DUT) or the internal current generator used to calibrate the device.

The current will flow into 4 parallel resistors (R1, R2, R3, R4). The resistor R4 is always connected and it is the only one connected when we are using the fourth range. Each time we want to use a lower range (toward range 1), we switch on the corresponding transistor to use one more resistor and when we want to use a higher range we switch it off.

Recall that the ranges are given as:

Current range Active resistors
1 739 µA   →    303 mA R1+R2+R3+R4
2 7.39 µA   →    3,03 mA R2+R3+R4
3 73.9 nA   →    30,3 µA R3+R4
4 1 nA   →    303 nA R4


Recall that these calculations were based on:

  • Maximum burden voltage directly on shunt resistors of 50 mV in order to reduce the effect of the measurements as much as possible.
  • Minimal voltage at the output of the amplifiers of 10 mV, because smaller values will be more prone to noise errors.

In order to choose the right measurement interval, each resistor will be controlled by an automatic switch manipulated in the calibration circuitry.

A potential problem arises: the ON impedance of these switches is not always negligible and thus must be taken into account (in measurement interval calculations AND in the calibration process).

Finally, we get the following circuit for this stage:


Regarding the switches, the main criterion is the ON resistance. Another useful criterion is switching time. Given these criteria, we have compiled a list of possible switches to use:


Reference ON Resistance (mΩ) Switching Time (ns)
ADG 801 / 802 (CMOS SPST Switches) 400 55
FDC606P (P-Channel MOSFET) 35 250
SI2333DDS (P-Channel MOSFET) 28 115
DMP2035U (P-Channel MOSFET) 35 135
DMG3415U (P-Channel MOSFET) 42.5 1150


From the list above, we have chosen the SI2333DDS MOSFET as our best switch candidate.

We get that the values of resistors in the above figure are as follow:

R1 = 145 mΩ , R2 = 16.5 Ω, R3 = 1.65 kΩ, R4 = 165 kΩ.

Note that the value of the equivalent resistor is based on the datasheet and is not necessarily the value in the real case. That’s why the initial calibration is crucial to take all these effects into consideration.


The output of the current – voltage conversion stage is a small voltage signal. The Amplification stage will then amplify the signal in order to adapt it to the ADC input.

The main specifications for this stage are as follows:

  • A Gain of 82 with a Bandwidth of 100 kHz.
  • A circuit that blocks any current flowing from the measurement stage

Note that the only current flowing into this stage are bias currents of the operational amplifiers if the shunt output are connected to the operational amplifiers inputs.

Amplification will be done using the following feedback circuit:

The choice of the Op-Amps is critical. They must satisfy the following criteria:

  • Ultra Low Bias Currents
  • Gain Bandwidth Product >= 8 MHz
  • Ultra Low Noise
  • High CMRR (High Side Configuration)
  • Low Offset Voltage

Given these criteria, a possible list of op-amps is given as follows:


Reference GBW (MHz) Noise (nV/√Hz) Offset Max (µV) Bias Current Max (pA) CMRR Min (dB)
AD8618 24 8 60 1 80
AD8067 54 6.6 1000 5 106
ADA4500 10 14.5 120 2 95
AD8655 28 2.7 250 10 85
MAX44251 10 5.9 6 1300 130
MAX44242 10 5 600 10 90
MAX4488 42 4.5 750 150 90


Clearly our criteria specifications will result in a trade-off. It is somehow difficult to find an op-amp that satisfies all the criteria perfectly.

Anti Aliasing Filter

Since we are sampling at 100 kHz, high frequency noises will be aliased into the desired frequency range. To prevent this problem, we must use a low pass anti aliasing filter whose cutoff frequency is equal to the maximal frequency of the signal (50 kHz).

A simple passive RC filter will do the job. Recall that the cut-off frequency of a RC filter is Fc = 1/(2*Pi*R*C).

Given these specifications we get R = 1.45 KΩ and C = 2.2nF.

The anti-aliasing filter will then be as follow:

Analog to Digital Conversion

The amplified and filtered voltage representing the current flowing into the DUT will be placed at the input of an ADC in order to send the current measurement to the microcontroller.

The main criteria for the ADC are:

  • Resolution = 24 Bits
  • Sampling Rate >= 100 kHz

Other criteria include signal to noise ratio, distortion, linear and nonlinear errors…

Given these specifications, the following ADCs may be used:

Reference Number of Bits Output Data Rate Output Format Number of Channels
AD7176-2 24 250 KSPS Serial 2 – 4
AD7760 24 2.5 MSPS Parallel 1
AD7764 24 312 KSPS Serial 1
AD7766 24 128 KSPS Serial 1
AD7768-4 24 256 KSPS Serial 4
ADS127L01 24 512 KSPS Serial 1
ADS1274 24 128 KSPS Serial 4
ADS1672 24 625 KSPS Serial 1
ADS131A02 24 128 KSPS Serial 2


We are considering for now AD7176-2. This ADC guarantees > 17 noise free bits when we are sampling at 250 kHz.

This will require a reference voltage of 4.1V. We will then use an adjustable voltage regulator.

Shunt Selection & Calibration

Now for the tricky part. Our first approach was to use a microcontroller to do the calibration. However this approach will result in latency and potentially – for high variations – disastrous effects on the measurement.

Our second approach was to use the fast (2.4 MSPS) but not so accurate internal ADC of the microcontroller as a comparator and performing the calibration in the associated interrupt routine.

This approach is somewhat appealing, however it is not the best. The problem with this approach is that calibration time may take up to 3 us each period (Note that this value is calculated as the sum of a conversion time of a 500 ns and the time taken for each instruction in the ISR, as well as the latency for interrupt handling)

The most efficient approach, it seems, is to use hardware logic for the calibration. We are currently discussing and finalizing the calibration logic. We are thinking of two different ways to approach the hardware logic. The first one is to use a circuit similar to the one used in Nordic PPK. The second approach is to use RS latches.

That’s why we will discuss the calibration logic in detail in next week’s post.

Current Generation & Initial Calibration

Another problem that must be taken into consideration is drifts, offsets and all other errors in the used electronic components. That’s why we must generate a precise current, measure the output measurement of our circuit, and then correct the “correctable errors” in the software.

To generate a current we will use a current mirror. Reference voltage applied to a numeric potentiometer (we will go through the complete range of values) will generate a reference current.

This current will be copied using a current mirror (We can use for example wilson current mirror with 3 transistors or even improved wilson mirror with 4 transistors). This current – with controlled value – will be the input of the measurement stage, during the calibration phase.

By comparing the received and expected values, we can partially correct subsequent measurements. The current generation circuit will be as shown in this figure:

For the digital potentiometer, a possible component is MCP 4351. For the NPN transistors a lot of choices are possible. We can also use MOSFET transistors in Wilson current mirror.

At the beginning of the measurement process, the DUT selector will place our calibration current as input, and then the DUT will be placed as input when this phase is complete.

Note that the switches placed in these figures have been discussed in the current voltage conversion part.

That’s All !!

That concludes our current measurement stage. Since this is a primary design, it is always subject to modifications and improvements.

This week we will finalize the calibration logic and we will have a primary idea on the measurement stage PCB.

Please feel free to give suggestions 🙂

Until next week.


AmpeROSE Team

[AmpeROSE] Unveiling the dark side of feedback ammeters

Hello everyone,

In the bibliographic review momo and I made last week about low current measurements, two main designs were mainly considered : Shunt Ammeters & Feedback Ammeters. We also mentioned a third design that we were studying.

In this post, we will start by discussing that third design, then we will present its disadvantages and the disadvantages of feedback ammeters in general and finally we will conclude that shunt ammeters are the way to go.

So here we go …

General Impedance Converters

Let us consider the following circuit (Widely known as General Impedance Converter):

We will label nodes 1-5 from top to bottom. We have the same voltage at nodes 1, 3 & 5 (Inputs of Op-amps). The input current is the current traversing the impedance Z1 while the output current is the current traversing the impedance Z4 (and then the load impedance Z5). In addition the current traversing Z2 is the same current traversing Z3.

Combining all these information we get the following results:

Therefore by choosing Z1 = Z4 and Z2 = Z3, we have a circuit capable of measuring the current while maintaining a very small burden voltage. Cool !!

But wait ?! The simple feedback ammeter does the same thing ! What is then the advantage of such design ?

When we started studying that design, we thought that feedback ammeters can only be used in low side configuration (How deluded we were !). But in fact, both designs can be used in both low side and high side configurations.

However, the main advantage of GIC based ammeter is actually that it can be used to measure current flowing in both directions while simple feedback ammeters can only measure current flowing from the source to the DUT. But since we are measuring IoT devices, bidirectional measurement is not a necessary feature. Thus this design will only complicate our lives. It was interesting however considering and studying new ideas.

Back to Feedback Ammeters

For now, feedback ammeters look like the perfect match for our specifications. Very low burden voltage, used in both low side & high side configurations, used in all pico-ammeters. Awesome ! However, following a discussion with Alexis Polti, we found out that feedback ammeters are not that awesome.

In the low side configuration, the current that passes through the feedback resistor will re-enter the op-amp (it will sink the current to the ground). In the high side configuration, it is the op-amp who will source current to the DUT. In both cases, current will pass through the op-amp and will be modified by the op-amp consequently. The problem comes from the fact that operational amplifiers act like low pass filters. Thus all current peaks (or even smaller variations) will go undetected. This type of ammeters cannot be used in applications where high dynamic range is needed (our application for example 🙂 ).

Shunt Ammeters … Again …

Finally, after taking all these facts into consideration, we found out that shunt ammeters are actually the most adapted design to AmpeROSE. The main challenge for now is to choose the right shunt resistors (and choosing the right intervals) in order to have an acceptable burden voltage.

Next week, we should have the final schematics of the measurement part. We are looking forward to sharing it with you !!

Until next week !!

[AmpeROSE] How to measure the current – Part 2

Hello everyone!!

This week’s goal was to go through existing articles and bibliography, and discuss low current measurement. After doing a lot of reading, we now have a clearer vision of the methods used for current sensing and the main challenges in low current measurement.

Mmomo already discussed, in a separate post the two main methods used in current sensing (shunt & feedback – Spoiler: other methods exist: we are currently studying a third method in depth. We hope to share it later on this blog , so stay tuned!!).

In this post, I am going to present you with the main challenges that face low current ammeter designers. Accuracy is, evidently, crucial, when it comes to measuring low currents. That’s why I firmly believe that studying potential error sources in advance is extremely important in order to avoid getting to an impasse. Note that many articles found online study this issue in depth. Our main references are application notes from Keithley and National Instruments.

So here we go …

Measurement error sources

Leakage currents

Leakage currents are usually generated by stray resistance paths between the measurement circuit and nearby voltage sources. These currents can degrade the accuracy of current measurements considerably. This kind of errors is generally remedied by using good insulators (such as Teflon or polyethylene) and avoiding materials such as phenolic and nylon.

Zero Drift

Zero drift is the change of indicated zero offset when no input signal is applied. This offset must be corrected by “zeroing”, which means pulling the mass value back to zero(surprise!). Most electrometers include a means to correct zero drift. AmpeRose will make no exception of this rule!

Generated Currents

Any current generated in the measurement device will add up to the measured current and will introduce measurement errors. These currents include triboelectric effect currents and piezoelectric effect currents.

AC Interference

In order to solve this problem, we will use electrostatic shielding, and a battery.

To sum up, choosing the right measurement method is crucial but one must not ignore all the errors and negative effects that appear when measuring low currents. Some of these errors can be reduced by using appropriate shielding and proper cabling. Others must be resolved with more “tailored” methods. In all cases, we will have to take these errors into consideration in our design.

Next Week

Now that we have a better view on the subject, we will choose the appropriate current measurement method as well as the circuit to implement it. Stay tuned!

We would love to hear any suggestions or tips you might have concerning the current measurement step 🙂