sábado, 10 de fevereiro de 2018

SwissMicros DM42 Scientific Calculator

Long time ago (1987?) HP released the now famous among collectors 42S RPN based calculator.
In december-2017 SwissMicros have released its DM42 calculator, based on the popular Free42 simulator

The DM42 functions are well documented, as it is easy to find the HP-42S user guides here and here and the Free42 simulator has its own user guide.
SwissMicros have created its own user guide as well, to document the specific features unique to its hardware platform.

Currently (2018, February), there is little information on the hardware platform besides the processor type and memory, as a service guide is not available at the manufacturer. The same applies to the software environment used to develop the operating system where the free42 application runs.

From the point of engineering view, it is essential to know what is the hardware design in order to fully understand the other project ares like the software code built into the firmware.

So far no one have published reverse engineering or an analysis work by visual inspection of the calculator internals. In fact it is almost impossible to find high resolution photos of the PCB to learn what components were included in the hardware design.

Recently I found this medium resolution pictures, and it allowed to uncover some more details.

I understand that there are several hardware versions, and this PCB would be the most recent version, marked with "calcbase3b (c) SwiddMicros GmbH 2017".

I am publishing here a copy of the picture in question.

So far, i could identify the following hardware components:

Integrated Circuits:
- IC1: MX25R6435F M2ILO - Serial NOR FLASH ROM, 64Mbit (8M x 8), 80MHZ, 8-SOP package.
- IC3: STM32L476 VGT6 - SoC Processor (V = 100/104 pins, G = 1Mbyte Flash, T = LQFP 100-pin, 6 = -40°C to 85°C).
- IC4: 6-pin, Identification not readable in the picture
- IC5: 6-pin, Identification not readable in the picture
- IC7: D3985 - LDO VR Ultra low drop and low noise BiCMOS voltage regulator.

Active components:
- UD1: UL46 - ST USBLC6-4 SOT23-6L package, very low capacitance ESD protection. 
- D1: Diode, Identification not readable in the picture
- D2: Diode, Identification not readable in the picture
- Q2: Transistor, Identification not readable in the picture

Passive Components:
- Q1: 32.768K-E - CRYSTAL 32.768kHz, ±20ppm, 6pF, 50kOhms, 4-SOJ package. 

Not listing here the capacitors and resistors.

The total count of visible IC's are  5.
The total count of visible active components are  4.

This drawing (not to scale) list the above components in the PCB.


A few initial observations from the above:

- Q1: This is a high precision crystal and curiously was marked with a transistor label in the PCB silkscreen (it should be marked as X1 imho).

- UD1: The USB connector (JP1) I/O data lines connected to the Processor, are protected against external ESD or over-voltage by UD1, a fast high current low capacitance Diode/Zener based integrated circuit.
This is good engineering from SwissMicros and they didn't cut costs to do a proper design here.

- IC7:  Michael's comments on the LDO 3Volt regulator helped to identify IC7 that is not readable in the published picture, but from the IC pinout configuration it was easy to guess what this IC is.
So IC7 will be used when the calculator is connected via USB port to a computer, to regulate the external USB 5Volt down to 3Volt used to power the calculator, disabling the use of the internal CR2032 battery cell.
This allows to run the Processor at 80MHz instead of the regular 24MHz when the calculator runs on the battery.

-  IC1 and IC3: These two are the most obvious integrated circuits, but they are not alone. This is not a two IC's design.

- IC5 and L1:  IC5 is not readable in the published picture. However, it is close to the LCD connector.
Assuming that the LCD in use is a  LS027B7DH01 from Sharp Microelectronics (is it?), then it requires a 5Volt supply line to operate.
As the internal battery cell supplies just 3Volt, a step-up converter is needed and the IC5 and L1 combination may be in use for this purpose.
IC5 could be a single opamp on a 6-pin package, like the MAX4401.
Although a more conventional charge pump IC and capacitor (no inductor required) could be used here.
Just guessing.

- IC4 and Q2: IC4 is not readable in the published picture. But its close proximity to the buzzer would make it an audio driver (again, a MAX4401) using Q2 transistor to connect to the buzzer.
Again, just guessing.
Any corrections or even better, additional information on the hardware design and high resolution pictures of both sides of the PCB, is very welcome!

Estimate for battery current consumption:

Since SwissMicros is omitting the average current consumption on the DM42, here is a rough estimate for worst case scenarios:

- 11.4uA in power Off mode on average.
- 5.25mA in Power On state and running a non stop program
(Note that the power on state value will be higher when writing to the Flash ROM).

Can anyone with a current meter, an external 3VDC battery and a couple of wires take measurements for the benefit of all?

How did I get the above estimates:

Power On sate worst case scenario (running a non stopping program):
Avg: 45uA + 2400uA + 2800uA = 5.25mA
Max: 70uA + 2400uA + 4500uA = 6.97mA

LS027B7DH01: 1Hz refresh rate
35uA avg to 70uA max at 5V
3 to 5V step-up converter efficiency of 70% (guess value): 45uA to 91uA

STM32L476VGT6: on low power run mode:
100 μA/MHz x 24MHz = 2400uA

MX25R6435F: 100% reading mode only
2800uA avg to 4500uA max.

Power Off sate worst case scenario:
Avg. 10uA + 1.4uA = 11.4uA
Max. 25uA + 1.4uA = 26.4uA

LS027B7DH01: 1Hz refresh rate
10uA avg to 25uA

STM32L476VGT6: Stop 2 mode, with RTC:
1.4 μA

The larger consumer when in power off state would be the LCD display.

Input/Output interfaces visible on the PCB

Besides the standard USB I/O port and the InfraRed LED, at least two additional I/O ports are apparently available providing they are routed to the SoC STM32L476 VGT6 processor:

SPI2: This is an obvious standard Serial Peripheral Interface bus.
Located close to the battery cell and Reset/Pgm buttons.
This port is cleared labeled on the silkscreen close to the 32.768K-E Crystal.

Identified connector terminals:
GND: Ground
SPI2_SCK: Serial Clock
SPI2_CS: Slave select
SPI2_MOSI: Master Output / Slave Input
SPI2_MISO: Master Input / Slave Output
VCC: Power Supply

The STM32L476 provides three SPI buses and one Quad SPI bus.

LPUART1: This seems to be the Low Power Universal Asynchronous Receiver Transmitter interface provided by the SoC STM32L476 VGT6 processor.
Located close to the buzzer wires solder joints.

Identified connector terminals:
VDD: Power Supply
RX: Receiver Data line
TX:Transmitter Data line
GND: Ground

Two additional unidentified PCB interfaces are visible close to the buzzer:
J4 with 4 pins.
J1 with 6 pins.

The the SoC STM32L476 VGT6 processor provides a Serial Wire JTAG debug port (SWJ-DP).
According to the ST documentation, this is an ARM standard CoreSight debug port that combines a JTAG-DP (5-pin) interface and a SW-DP (2-pin) interface.
J4 could be used as the development/debug interface, but from the picture it is not possible to see where the PCB traces are going to. 
Estimate for battery current consumption - Take 2:

According to a video presentation of the DM42P prototype by Günter Schink at the HHC2016 published on youtube on Sept 21, 2016, the power consumption values were measured for a "few test runs" in these conditions (please check the video at 25:43):

DM42P Hardware

Power consumption:

- At 27MHz, continuous ops: 50h

- Screen ON but idle: 2000h (~80 days)

- While OFF ??

I don't know what battery capacity was used for the above test runs.
So, assuming a standard nominal 210mAh CR2032 battery cell, the current consumption for the above hours of operation would be:

- At 27MHz, continuous ops: 50h Translates to 4.2mA average (my estimate in a previous post above was 5.25mA avg in worst case scenario)

- Screen ON but idle: 2000h (~80 days) (This means Power ON, idling) Translates to 0.1mA average

- While OFF ?? Current consumption while in power OFF state remains unknown until a good soul can take some readings and share the results

One note on heavy loads on the CR2032 battery cells:

The DM42 figure of 4.2mA current consumption when running a looping program for long periods of time is above the recommended standard continuous current supply for any CR2032 battery cell if we want to be able to consume all the cell nominal capacity.

This applies also to other machines like the HP-35S, HP-20B, and HP-30B (however HP have designed two CR2032 cells in parallel in the power supply to reduce the heavy current loads imposed per battery cell).

The standard continuous current discharge for a CR2032 is 0.2mA (this corresponds to a 15Kohm load, and that is the value used by the manufacturers to test its CR2032 products in order to evaluate the actual available capacity).

Of course the CR2032 can supply above the 0.2mA, typically up to 10mA on extreme heavy loads (or even more, depending on brand/model), but the battery will be stressed and its life (meaning, its capacity) will be shortened accordingly.

Those extreme 10mA heavy loads may typically result in 1 Volt dropped in the battery internal impedance, meaning that for many processors the cut-off voltage is very close to happen in these conditions.

So, I would expect to see a single, good quality (lower internal impedance over time among other factors), above average 220mAh ~ 240mAh capacity, CR2032 battery cell powering the DM42 for a good amount of time (up to a maximum of 2000 Hours), as long as continuous looping programs are not run all the time (and the amount of write operations to flash kept to a minimum).  

 Notes on flash ROM performance

The STM Reference manual for the processor contains huge information on the subject, but we do not know how the system was implemented by SwissMicros, as many working parameters must be set by the operating system to set the hardware intended behavior.

As far as I know, the STM processor uses a linear 4GB address space divided in eight 512MByte blocks, where all memory and peripherals are mapped.

I would expect a performance degradation when accessing the external Flash memory when compared to the internal Flash.
By how much, probably only after exhaustive testing can be determined.

This is a complex processor architecture, and there are many parameters that need to be set at low level in the O.S. depending on the designer goals.

For instance, the memory latency (wait cycles) must be set depending on the intended processor operation/speed/voltage settings and this applies to the internal Flash as well.
On the internal Flash a variable number of cycles is required depending on the type of code. Also STM offers instruction prefetch and cache to increase efficiency when accessing the Flash at higher clock speeds. These features need to be configured by software as well.

On the other hand the external Flash connected to the Quad-SPI processor interface can be accessed in a number of different ways, namely direct memory-mapped or indirect using registers or interrupt driven, different data word sizes can be accessed, etc.
Anyhow, the QUADSPI interface talks to the external Flash using 5-phase commands, and any one of these 5 phases needs to be set/skipped, so this introduce more indeterminacy on the performance. For example, the dummy cycles phase (wait cycles) can be used when operating the processor at higher speeds to let the Flash be ready for the processor.

Notes on power consumption when powered off

grsbanks Wrote:  Power consumption when off is in the region of 3uA.
Thanks for your information, Godwin.

Assuming that the DM42 O.S. leaves the STM32L476VGT6 processor in Stop 2 mode with RTC when the calculator is powered off, then only 1.4μA should be accounted for the processor as documented by the manufacturer.
The remaining 1.6μA are consumed by one or more of the other calculator components that will not be totally shutdown during the power off state.

So, concerning the power consumption, here is what we can assume at this point:

1. Assuming a standard 210mAh 3Volt CR2032 battery cell as the power supply.
2. Power ON state, continuous operation: 50h (~2 days) or 4.2mA average.
3. Power ON state, idle: 2000h (~80 days) or 0.1mA average.
4. Power OFF state, battery left inside: 70000h (~8 years) or 3 µA average.

8 years would be a nice lifespan for any coin cell battery if they could survive that long. Maybe they can if the environment conditions are ideal and a good brand advertising expiration dates is chosen. Otherwise battery internal current leakage would usually prevent a CR2032 to maintain its ability to supply current for that long.