Optical port meter reader

Avatar

sdg.john
2020-09-08 10:39
Last Edited 2022-09-11 19:16

Aim:

To design and build a working optical probe to communicate with electricity meters with the IEC 1107 standard. The probe will send the data to an Orange Pi Lite, which in turn sends it to the PNPSCADA database.

 

Design method:

In accordance with the IEC 1107 (62056) standard, the optical probe should function in the infrared spectrum, with a wavelength of 700nm to 1000nm. In order to satisfy this, an infrared emitting diode was used to transmit, and an infrared-sensitive photodiode is used to act as a receiver. 

The figure below shows the circuit diagram for the transmit part of the transceiver. The value of R1 is chosen to be 1 kilo-ohm, because of the low current needed to activate the bipolar junction transistor. This limits the current through the TX pin of the microcontroller to safe operating levels. The activation of the bipolar junction transistor pulls the voltage across the IR LED low by shorting the circuit to ground. This implies that the voltage across the IR LED is usually high, and pulled low upon activation. This configuration of the BJT circuit creates a logic inverter that inverts the signal level as seen on the base of the BJT introduced by the TX pin of the microcontroller. The IEC 1107 standard requires a normally high signal level across the IR LED, with the signal level pulled low for data transmission. The value of R2 is chosen such that the current through the IR LED is enough to illuminate the LED, but not damage the components in the circuit.


The figure below illustrates the circuit diagram for the receiving part of the transceiver. The receiver consists of an infrared-sensitive photodiode, a BJT, and current limiting resistors. The values of R2 and R3 are chosen to limit the currents in the circuit to a level that cannot damage or short the microcontroller, ensuring the operations of all components in the circuit. The value of R4 is chosen such that the base of the BJT is pulled low, meaning that a zero voltage will be detected by the base pin of the BJT while there is no infrared light detected by the IR LED.


The figure below shows the Jellyfish optical probe on the right-hand side, featuring thin colour-coded conductors that keep a low profile while being aesthetically pleasing. The IR LED and the IR PD are fixed in place with a clear epoxy that provides some rigidity and prevents the transceiver from twisting. The figure below on the left-hand side shows a prototype hat made with Veroboard. 


The figure below shows the circuit schematic for the hat shown above. It features a watchdog that intercepts the power supplied to the microcontroller. An input pin to the watchdog IC has to be regularly toggled to prevent the watchdog from disrupting the power supplied to the microcontroller, thus hard resetting the microcontroller in the event of a malfunction in the form of unresponsiveness. This ensures that the device will be reset if a problem occurs and prevents the need for a manual reset in the case of a remotely situated device. 

The figure below shows the connector that connects the colour-coded conductors to the component hat. It can be seen that Vcc is red, the ground is blue, the feed to the IR LED (TX) is pink, and the feed from the IR PD (RX) is purple.


The figure below shows the VeeCAD design for the prototype component hat that is shown above. VeeCAD is software that allows the user to plan a prototype layout using Veroboard.



Python executable optical port reader:

With all the research done about the IEC 1107 infrared communication protocol and the hardware involved, it was found viable to develop a program that can be run on any windows machine that connects a USB optical probe to the pc, and the pc to pnpScada. This creates a portable solution that enables the user to read a meter with pnpScada through their windows machine. 

When launching the program, the user is met with the home screen shown in the figure below. This asks the user for input while also showing the supported inputs in the parenthesis. 


If the user requires more clarity on what each action command does, the user can then enter 'Help'' to display the information shown in the figure below. Each action command is then briefly explained. If an empty input is received ('Enter'' button pressed) five consecutive times, the Help menu will automatically be displayed.


In order to read a meter, the meter details have to be entered into the program. These details include the meter serial number, the meter type, and the relevant port. The figure below shows the 'AddNew'' function. The meter serial number can be found on the front of most meters, and as such was chosen as the method of identification for meter reads. Currently, only two-meter types are supported, the Hexing HXE 110-KP and the Landis + Gyr E460S. The port refers to the port of the communication device on pnpScada.


To list all the available meters stored in the text file, the user can use the 'List'' command as shown in the figure below. The meter details are stored in a specific format and thus manually editing the text file is not recommended.


In the scenario that there have been added hundreds of meters to the text file, the user can use the 'Find'' command to determine if the required meter is indeed already entered into the text file. This is shown in the figure below.


If a meter is removed or unused, and the user wants to remove the meter from the program database, the 'Delete'' command can be used as shown in the figure below.


In order to connect to the serial communication device, the optical probe, the user does have to specify the com port on which the device is connected. The user can display all available com ports on the device with the 'ListComPorts'' command, as shown in the figure below.


Once the target serial device has been identified, the user can connect to the serial device by using the 'ComPort'' command. A valid com port is required to enable communication between the pc and the meter. The 'ComPort'' command is shown in the figure below.


Finally, but the most important is the 'Connect'' command. This command establishes the connection between the PC and the pnpScada server. A working internet connection is required for this. Once the connection is established, communication between the server and the meter can begin. The connection can be initiated in 'Continuous'' mode or 'Single'' mode. In 'Single'' mode, the connection attempt only happens once, whether it is successful or not. In 'Continuous'' mode, the connection will keep trying to reconnect, whether the connection is successful or not. Once no data has been received from the pnpScada server for one minute, the connection will time out, and depending on the connection mode ('Single'' or 'Continuous''), the connection will either be terminated or restarted. An example of the 'Continuous' mode is shown in the figure below.


Note: For 'Single'' mode operation, ensure the pnpScada connection is initiated before the connection on the pc program. Once the pnpScada connection is initiated, it will timeout within one minute if no response is received from the pc program. If the pc program cannot connect to the pnpScada server, it will print out 'Could not connect'', and the connection would have to be reinitiated.

Now that the basic operation of the program is thoroughly explained, one can automate the program running by using windows batch files. This will enable the user to simply double-click on a shortcut, and the commands are all executed without the user input required. For example, if the user wants to read a meter in continuous mode, they can create a windows batch file with the syntax shown in the figure below.


To create a windows batch file, simply open notepad on windows, type out the command as shown in figure \
ef{fig:709} with the actual values needed, and save the file as a 'filename.bat'' in the same directory as the .exe file. The figure below shows the correct Save procedure.



ESP32 Web Server and optical port reader:

The ESP32 presents a cheaper alternative to the Linux box. The ESP32 board comes with built-in WiFi and Bluetooth, which enables it to connect to the internet. An external WiFi network is needed in the form of a hot spot or home network for the ESP32 to connect to. The WiFi network SSID and password can be hard-coded onto the ESP32 firmware, but it can prove to be problematic for a remote unit when the WiFi network or password changes. This prompted the design of a web server which enables the user to connect to and disconnect from a WiFi network. This is done with the local WiFi network hosted on the ESP32, to which a device can connect to. The local IP address can then be browsed on the device, which shows the web server home page where the available WiFi networks are shown. The figure below shows the local IP address of the ESP32 device.


To access the WiFi network home screen, the local IP address followed by '/scan' has to be entered into a web browser's search bar. The figure below shows the WiFi network browser home screen.


To connect to a WiFi network, one can simply click on the required WiFi network SSID whereupon a drop-down will appear where the password can be entered as well as an auto connect function. The figure below shows the drop-down menu.


Once connected to a WiFi network, the SSID of the connected network is displayed at the top of the page. It can be disconnected by clicking on the connected network to activate the drop-down. The figure below shows the connected WiFi network.


The ESP32 device had to be placed in a ventilated case to house the power supply, the ESP32 device, the component hat, and the portable wifi modem. A CAD design can be seen in the figure below of the ventilated case. The pedestals shown are used to mount the ESP32 board, with the hat fitted on top op the ESP32. The component hat also features three status LEDs that protrude through the top of the case, which will show the power status of the device, the WiFi connection status of the device, and the PnPScada connection status.

The figure below shows the top of the upper portion of the case as shown above. The LED holes can be seen more clearly from this angle.


The figure below shows the lower portion of the case that the power supply mounts to.



Conclusion:

This report has shown multiple methods of implementing the IEC1107 standard for optical port communication, being a Linux-based single-board computer-based solution, an ESP32 web server embedded solution, and a USB implemented windows machine solution.



Tags: infrared transceiveroptical probeoptical reader
Please log in to post a comment