The tMPC-04 is a 4-input pulse counter designed for use with any meters with pulse outputs. It communicates via Modbus RTU to provide pulse counts, calculated energy and estimated power. Other measures can also be measured, e.g. flows from water or gas meters. Conversion to these units is based on user-entered coefficients (e.g. pulses per kWh), the default is 1000 pulses per unit.
Power supply | 5-12 V DC (connector) 5 V (USB) |
---|---|
Pulse inputs | 4 |
Maximum counting speed | ~2000 Hz (up to 4000 Hz without power estimation) |
Interfaces | Serial (over USB; 115200 baud), Modbus |
Dimensions | 71 x 42 x 37 mm |
Weight | 40 g |
Out of the box, the tMPC-04 is pre-configured with:
If these settings match your energy meters, the device is ready for immediate use. Otherwise, for setups with multiple pulse counters or different pulse conversion factors, refer to the Advanced Configuration section.
The tMPC-04 can be easily used with LK4 or LK3. The counter can be powered directly from LK's 5V and GND outputs. Then you connect them to one Modbus bus. Next, configure the custom Modbus module on LK with the configuration preset available in Downloads - you can modify it to read only the desired parameters.
To update the firmware, either use the bootloader
command or press the physical FLASH button on the device before powering it on (to access the button you need to open the case). The new firmware can then be uploaded by copying the firmware file to the RPI-RP2 storage, which is available when the device is in bootloader mode. Shortly after the device will restart and resume its normal operation.
The firmware files can be found at Downloads.
To modify the settings, you will need to connect the tMPC-04 to a computer via USB. The device can be powered through USB, so no additional power connections are necessary.
To establish a connection with the pulse counter, you'll need an application that can handle serial communication. Popular choices include:
List Available Ports:
Run pyserial-ports to list the available COM ports before connecting the device. The output might look like:
COM1
COM3
COM15
COM16
COM17
Connect the Device
Plug in the tMPC-04 and run the command again. The new COM port (e.g., COM11) will represent the connected device.
Connect to tMPC-04
Use the following connection parameters:
Example command:
pyserial-miniterm COM11 115200
Send Commands
Once connected, you can issue commands to the device. Each command must be followed by the Enter key. A useful command is ?
or help
, which provides a list of all available commands (described below).
Command | Description |
---|---|
bootloader | Reboot the device into bootloader mode to update the firmware. When connected to a computer, it will appear as a storage device named `RPI-RP2`, to which you should copy the firmware file with the extension `uf2`. Then the device will reboot into normal operation mode. |
restart | Restart the device. |
address? | a? | Get the Modbus address (Slave ID). |
address=X | a=X | Set the Modbus address. Parameters: X - address to set, number <1, 255>. |
debounce_time? | d? | Get debounce time for pulse counters (in ms). |
debounce_time=X | d=X | Set the debounce time for pulse counters. Defines the minimum pulse length, shorter ones will be ignored and not counted. Parameters: X - value in ms, number <0, 65_535>, for 0 the function is disabled. |
power_estimation? | pe? | Get power estimation flag for pulse counters (0 - OFF, 1 - ON). |
power_estimation=X | pe=X | Set power estimation flag for pulse counters. Defines whether the power estimation is enabled. It can be disabled if not needed or to improve the measurement range of pulse frequency from ~2 kHz to ~4 kHz (the limitation due to the pulse duration and shape remains). Parameters: X - value 0 - OFF / 1 - ON, number <0, 1>. |
auto_save? | as? | Get the value of the auto-save function. This is the interval in seconds at which the counters are saved. |
auto_save=X | as=X | Set the value of the auto-save function. Parameters: X - value in seconds, number <0, 65_535>, for 0 the function is disabled. |
counter_cfX? | ccfX? | Get conversion factor for pulse counter. Parameters: X - counter number <1, 4>. |
counter_cfX=Y | ccfX=Y | Set the conversion factor for the pulse counter: the number of pulses per unit, e.g. imp/kWh. Parameters: X - counter number <1, 4>; Y - number of pulses, number <1, 65_535>. |
counterX? | cX? | Get the value of the pulse counter, i.e. the number of pulses it counted. Parameters: X - counter number <1, 4>. |
counterX=Y | cX=Y | Set the pulse counter value. Parameters: X - counter number <1, 4>; Y - number of pulses, number <0, 1_073_741_823>. |
read_status | rs | Read the saved status of the counters. |
read_registers | rr | Read Modbus register values. |
read_definitions | rd | Read Modbus register definitions (name, address, type). |
save_config | sc | Save configuration to Flash memory. It should be called after changing the Modbus address, counters' conversion factors, debounce time, and auto-save function to keep them after a restart. |
save_status | ss | Save the status of the pulse counters to Flash memory. It should be called after changing the value of the pulse counters (the number of pulses) to keep them after a restart. |
verbose=X | Turn on or off verbose mode, which displays more messages. |
help | ? | Display this help message with a list of available commands. |
Some commands are useful only in special cases, which I present below.
address=X
command to change it to a unique one.
debounce_time=X
can be used, which will cause the shorter pulses to be ignored.
auto_save=X
should be used, resulting in their state being periodically saved to permanent memory. Be mindful of flash memory wear, as it has a limited number of writes (rated for 100k). Therefore, when using this feature you need to choose a value that is an acceptable compromise. For example, the value of `300` (seconds) should allow for about a 1 year of operation, and `1800` should allow for more than 5.5 years.
address=X
, debounce_time=X
, power_estimation=X
, auto_save=X
, counter_cfX=Y
, you must use save_config
to save changes to permanent memory. Otherwise, they will be lost upon power loss or device restart.
The accuracy of pulse measurement depends on the frequency, pulse duration, and rise/fall times. In normal operation with power estimation, the pulse duration should be no shorter than 0.34 ms. In high-speed mode (without power estimation), the pulse duration can be as short as 0.19 ms.
For most applications, measurement errors should not exceed 0.1%. In our tests, if it was inaccurate it was 1 or 2 pulses too many or too few.
Name | Addr | Type | Func | Divisor
------------------------------ | ---- | ------ | ------------ | -------
uptime | 3000 | uint32 | 0x04 (IREG) |
counter1 | 3002 | uint32 | 0x04 (IREG) |
counter2 | 3004 | uint32 | 0x04 (IREG) |
counter3 | 3006 | uint32 | 0x04 (IREG) |
counter4 | 3008 | uint32 | 0x04 (IREG) |
counter1_energy | 3010 | uint32 | 0x04 (IREG) | 1000
counter2_energy | 3012 | uint32 | 0x04 (IREG) | 1000
counter3_energy | 3014 | uint32 | 0x04 (IREG) | 1000
counter4_energy | 3016 | uint32 | 0x04 (IREG) | 1000
counter1_power | 3018 | uint32 | 0x04 (IREG) | 1000
counter2_power | 3020 | uint32 | 0x04 (IREG) | 1000
counter3_power | 3022 | uint32 | 0x04 (IREG) | 1000
counter4_power | 3024 | uint32 | 0x04 (IREG) | 1000
version_major | 3100 | uint16 | 0x04 (IREG) |
version_minor | 3101 | uint16 | 0x04 (IREG) |
version_patch | 3102 | uint16 | 0x04 (IREG) |
address | 4000 | uint16 | 0x03 (HREG) |
debounce_time | 4001 | uint16 | 0x03 (HREG) |
counter1_conversion_factor | 4002 | uint16 | 0x03 (HREG) |
counter2_conversion_factor | 4003 | uint16 | 0x03 (HREG) |
counter3_conversion_factor | 4004 | uint16 | 0x03 (HREG) |
counter4_conversion_factor | 4005 | uint16 | 0x03 (HREG) |
auto_save | 4006 | uint16 | 0x03 (HREG) |
power_estimation | 4007 | uint16 | 0x03 (HREG) |