PlcCapeElectronicFramework PDF
PlcCapeElectronicFramework PDF
Any: 2017
Design of a low-cost device for data transmission over power lines 3/181
Table of Contents
Resum del Projecte............................................................................................................................9
Resumen del Proyecto.....................................................................................................................10
Abstract.............................................................................................................................................11
1 Introduction...................................................................................................................................12
1.1 Context.................................................................................................................................12
1.2 Objectives.............................................................................................................................13
1.3 Solution proposed.................................................................................................................14
1.4 Main challenges....................................................................................................................15
1.5 Document structure..............................................................................................................16
1.6 Document styles...................................................................................................................17
2 Background....................................................................................................................................18
2.1 Power Line Communications (PLC)....................................................................................18
2.2 AFE031................................................................................................................................20
2.2.1 Main features............................................................................................................20
2.2.2 AFE031 blocks and pins..........................................................................................21
2.3 BeagleBone Black (BBB)....................................................................................................24
2.4 Arduino.................................................................................................................................26
2.5 Raspberry Pi.........................................................................................................................27
3 Implementation..............................................................................................................................28
3.1 Overview..............................................................................................................................28
3.2 Technical specifications.......................................................................................................29
3.3 The SUPERVISOR unit.......................................................................................................30
3.3.1 Overview..................................................................................................................30
3.3.2 Justification for the BeagleBone Black choice........................................................30
3.3.3 Justification for the AFE031 choice.........................................................................30
3.3.4 Design notes and limitations....................................................................................31
3.3.5 PlcCape versions......................................................................................................32
3.3.6 PlcCape-v1...............................................................................................................33
3.3.6.1 Overview....................................................................................................33
3.3.6.2 Schematics.................................................................................................33
3.3.6.3 Printed Circuit Board.................................................................................36
3.3.6.4 Bill of Materials.........................................................................................37
3.3.6.5 Final cape...................................................................................................38
3.3.6.6 Probing points............................................................................................38
3.3.6.7 AC coupling auxiliary module...................................................................39
3.3.7 PlcCape-v2...............................................................................................................41
3.3.7.1 Overview....................................................................................................41
3.3.7.2 Schematics.................................................................................................42
3.3.7.3 Printed Circuit Board.................................................................................46
3.3.7.4 Bill of Materials.........................................................................................46
3.3.7.5 Final cape...................................................................................................48
3.3.7.6 Probing points............................................................................................48
3.3.7.7 TX_F_OUT bridge.....................................................................................49
3.3.7.8 Future improvements.................................................................................49
4/181 Design of a low-cost device for data transmission over power lines
Figures
Figure 1. Proposed system for the REPORTING device.................................................................................14
Figure 2. Proposed system for the SUPERVISOR unit...................................................................................14
Figure 3. Proposed system with concrete modules.........................................................................................15
Figure 4. AFE031 Main features.....................................................................................................................20
Figure 5. AFE031 blocks and pins..................................................................................................................21
Figure 6. BeagleBone Black components.......................................................................................................24
Figure 7. BeagleBone Black connectors P8 & P9...........................................................................................25
Figure 8. Arduino Leonardo............................................................................................................................26
Figure 9. Raspberry Pi 3 Model-B..................................................................................................................27
Figure 10. Raspberry Pi Zero W.....................................................................................................................27
Figure 11. PlcCape-v1 SCH P9 connector......................................................................................................33
Figure 12. PlcCape-v1 SCH AFE031 core circuitry.......................................................................................34
Figure 13. PlcCape-v1 SCH JP1 connector....................................................................................................35
Figure 14. PlcCape-v1 SCH Power supplies...................................................................................................35
Figure 15. PlcCape-v1 PCB Top.....................................................................................................................36
Figure 16. PlcCape-v1 PCB Bottom...............................................................................................................36
Figure 17. PlcCape-v1 board - Top.................................................................................................................36
Figure 18. PlcCape-v1 board - Bottom...........................................................................................................36
Figure 19. PlcCape-v1 mounted board............................................................................................................38
Figure 20. PlcCape-v1 + AC coupling module + BBB...................................................................................38
Figure 21. PlcCape-v1 probing points............................................................................................................38
Figure 22. Auxiliary AC coupling module - Schematic..................................................................................39
Figure 23. Auxiliary AC coupling module - Top.............................................................................................39
Figure 24. Auxiliary AC coupling module - Bottom.......................................................................................39
Figure 25. Auxiliary AC coupling module connections..................................................................................40
Figure 26. PlcCape-v2 SCH P9 connector......................................................................................................42
Figure 27. PlcCape-v1 vs. PlcCape-v2 in the interfacing with the BBB.........................................................43
Figure 28. PlcCape-v2 SCH AFE031 core circuitry.......................................................................................43
Figure 29. PlcCape-v2 SCH AC coupling block.............................................................................................44
Figure 30. PlcCape-v2 SCH Zero Crossing block...........................................................................................44
Figure 31. PlcCape-v2 SCH LED monitoring block.......................................................................................45
Figure 32. PlcCape-v2 SCH Auxiliary connector...........................................................................................45
Figure 33. PlcCape-v2 SCH Power supplies...................................................................................................45
Figure 34. PlcCape-v2 PCB Top.....................................................................................................................46
Figure 35. PlcCape-v2 PCB Bottom...............................................................................................................46
Figure 36. PlcCape-v2 board - Top.................................................................................................................46
Figure 37. PlcCape-v2 board - Bottom...........................................................................................................46
Figure 38. PlcCape-v2 mounted board............................................................................................................48
Figure 39. PlcCape-v2 probing points............................................................................................................48
Figure 40. PlcCape-v2 TX_F_OUT bridge.....................................................................................................49
Figure 41. Arduino Leonardo - Simple transmitter test...................................................................................50
Figure 42. Arduino shield - Schematic............................................................................................................54
Figure 43. Arduino shield - Routing...............................................................................................................54
Figure 44. Arduino shield - Top......................................................................................................................55
Figure 45. Arduino shield - Bottom................................................................................................................55
Figure 46. Arduino shield - Test......................................................................................................................56
Figure 47. The temperature REPORTER device.............................................................................................59
Figure 48. Push-Pull amplifier - Basic circuit.................................................................................................61
Figure 49. Push-Pull amplifier - Basic circuit - SPICE analysis.....................................................................62
Figure 50. Push-Pull amplifier - Single power supply....................................................................................65
Figure 51. Push-Pull amplifier - Single power supply - SPICE analysis.........................................................65
Figure 52. Push-Pull amplifier - Voltage divider.............................................................................................67
Design of a low-cost device for data transmission over power lines 7/181
Figure 53. ATmega32U4 - I/O Pin Output Voltage vs. Source Current (Vcc = 5V)........................................67
Figure 54. Push-Pull amplifier - Voltage divider - SPICE analysis.................................................................68
Figure 55. Push-Pull amplifier - LED monitoring...........................................................................................70
Figure 56. Push-Pull amplifier - Final proposal - SPICE analysis..................................................................72
Figure 57. Push-Pull amplifier - Implementation on a breadboard.................................................................72
Figure 58. Eclipse IDE - Screenshot...............................................................................................................77
Figure 59. Eclipse IDE - Linked Folders........................................................................................................79
Figure 60. plc-cape-oscilloscope - Screenshot................................................................................................81
Figure 61. plc-cape-oscilloscope - Example of a SVG capture.......................................................................82
Figure 62. plc-cape-oscilloscope - Screenshot of a remote SSH session from Ubuntu...................................84
Figure 63. plc-cape-lab - Screenshot of a remote SSH session from Ubuntu..................................................84
Figure 64. plc-cape-lab - Screenshot...............................................................................................................90
Figure 65. encoder-wav - Test with a passive buzzer connected to PlcCape-v2..............................................91
Figure 66. RPI interoperability - Testing environment....................................................................................94
Figure 67. RPI interoperability - Screenshot of plc-cape-lab when playing a tone.........................................95
Figure 68. TX chain analysis - PlcCape - Testing environment......................................................................99
Figure 69. TX chain analysis - PlcCape to Push-Pull - Testing environment................................................104
Figure 70. RX chain analysis - TX_F_OUT to TXRX bridge.......................................................................109
Figure 71. RX chain analysis - PlcCape to Push-Pull without voltage divider..............................................113
Figure 72. RX chain analysis - PlcCape to Push-Pull with voltage divider...................................................113
Figure 73. RX chain analysis - PlcCape + Push-Pull + PlcCape - Testing environment...............................117
Figure 74. RX chain analysis - plc-cape-lab at transmission.........................................................................118
Figure 75. RX chain analysis - plc-cape-lab at reception..............................................................................118
Figure 76. RX chain analysis - TX_F_OUT on an isolated PlcCape-v2.......................................................118
Figure 77. Arduino to Push-Pull amplifier - Testing environment................................................................124
Figure 78. Arduino to Push-Pull amplifier - Testing environment with a low impedance.............................129
Figure 79. PlcCape to PlcCape communication - Testing environment........................................................131
Figure 80. PlcCape to PlcCape communication - plc-cape-lab at transmission.............................................132
Figure 81. PlcCape to PlcCape communication - plc-cape-lab at reception..................................................132
Figure 82. Arduino to PlcCape communication - Testing environment.........................................................135
Figure 83. Arduino to PlcCape communication - plc-cape-lab at reception..................................................136
Figure 84. AC coupling module - Testing environment................................................................................138
Figure 85. AC to PlcCape - Testing environment..........................................................................................140
Figure 86. AC to PlcCape - Testing environment with a laptop....................................................................141
Figure 87. 230VAC communication - The REPORTING device at transmission.........................................144
Figure 88. 230VAC communication - The SUPERVISOR unit at reception.................................................144
Figure 89. 230VAC communication - Transmitter configuration..................................................................146
Figure 90. 230VAC communication - Receiver configuration......................................................................146
Figure 91. 230VAC communication - plc-cape-lab capture from the laptop.................................................152
Figure 92. Final system - Push-Pull output probing......................................................................................154
Figure 93. Final system at TX - The REPORTING device...........................................................................155
Figure 94. Final system at RX - The SUPERVISOR unit.............................................................................155
Figure 95. Final system - ADC data captured from the 230VAC..................................................................156
Figure 96. Final system - Demodulated data from 230VAC.........................................................................156
Figure 97. Final system - ADC data captured from the 230VAC (voltage divider at TX skipped)................157
Figure 98. Final system - Demodulated data from the 230VAC (voltage divider at TX skipped).................157
Figure 99. Final system - ADC data captured from unpowered mains..........................................................158
Figure 100. Final system - Demodulated data from the mains when unpowered..........................................158
Figure 101. System proposal.........................................................................................................................159
Figure 102. ImageConditioner tool - Main screenshot..................................................................................164
8/181 Design of a low-cost device for data transmission over power lines
Tables
Table 1. Main project objectives.....................................................................................................................13
Table 2. Summary of topics covered per chapter............................................................................................16
Table 3. Document styles................................................................................................................................17
Table 4. Embedded pictures formats...............................................................................................................17
Table 5. CENELEC bands..............................................................................................................................19
Table 6. AFE031 main blocks.........................................................................................................................22
Table 7. AFE031 pins and signals...................................................................................................................23
Table 8: Summary of topics covered in the 'Implementation' chapter.............................................................28
Table 9. Main requirements............................................................................................................................29
Table 10. PlcCape-v1 Bill of Materials...........................................................................................................37
Table 11. PlcCape-v2 vs PlcCape-v1 modifications........................................................................................41
Table 12. PlcCape-v2 Bill of Materials...........................................................................................................47
Table 13. Changes in the software framework................................................................................................74
Table 14. Future improvements in the software framework............................................................................74
Table 15. Summary of tests performed...........................................................................................................96
Table 16. Signals involved in the PlcCape TX Chain.....................................................................................98
Table 17. Tools used in this project...............................................................................................................163
Design of a low-cost device for data transmission over power lines 9/181
En aquest projecte es proposa un sistema per a comunicar dades entre dos dispositius a través de la xarxa
elèctrica (230VAC en Europa) d'una forma simple, assequible i oberta.
En termes generals, aquest camp d’estudi es coneix com a Comunicació per Línies de Potència (PLC).
Un dels principals reptes del projecte és el procés de modulació/desmodulació requerit per a encabir les
dades dintre de la banda de freqüències permesa. Amb aquesta finalitat, s'utilitza una modulació simple de
tipus On-Off-Keying (OOK) amb una portadora de 110 kHz.
El capítol dedicat a les proves se centra en la comunicació entre endolls d’un habitatge, però el concepte es
pot aplicar també al camp de la indústria per a la supervisió de màquines des d'una ubicació remota dintre de
la planta d’una fàbrica.
1. Disseny d'un circuit auxiliar (cape) per a la plataforma BeagleBone Black (BBB). El dispositiu
resultant funciona com a unitat de SUPERVISIÓ que gestiona els dispositius intel·ligents connectats
a la línia de potència. El nucli del circuit auxiliar és un sistema frontal analògic (AFE)
específicament dissenyat per a PLC, l’integrat AFE031, que inclou un DAC d’alta velocitat controlat
mitjançant un bus SPI. Per a la recepció de dades, el sistema es basa en un ADC inclòs en el
microcontrolador de la BBB.
3. Disseny d’un circuit auxiliar (shield) per a la plataforma Arduino. El conjunt funciona com a
dispositiu intel·ligent de NOTIFICACIÓ periòdica. Com a exemple pràctic, el circuit mesura la
temperatura ambient, la mostra en un LCD de 2x16 i envia les dades per la línia d’alimentació en
OOK.
• Una exposició detallada de totes les proves efectuades, amb dos propòsits principals:
◦ Posar en relleu els principals problemes trobats en la comunicació a través de la línia elèctrica
per a esbossar una guia amb propostes de millora.
10/181 Design of a low-cost device for data transmission over power lines
En este proyecto se propone un sistema para comunicar datos entre dos dispositivos a través de la red
eléctrica (230VAC en Europa) de una forma simple, asequible y abierta.
En términos generales, este campo de estudio se conoce como Comunicación por Líneas de Potencia (PLC).
Uno de los principales retos del proyecto es el proceso de modulación/desmodulación requerido para alojar
los datos en la banda de frecuencias permitida. Con este fin, se usa una modulación simple de tipo On-Off-
Keying (OOK) con una portadora de 110 kHz.
El capítulo dedicado a las pruebas se centra en la comunicación entre enchufes de una vivienda, pero el
concepto se puede aplicar también en el campo de la industria para la supervisión de máquinas desde una
ubicación remota dentro de la planta de una fábrica.
3. Diseño de un circuito auxiliar (shield) para la plataforma Arduino. El conjunto funciona como
dispositivo inteligente de NOTIFICACIÓN periódica. A modo de ejemplo, el circuito mide la
temperatura ambiente, la muestra en un LCD de 2x16 y envía los datos por la línea de alimentación
en OOK.
• Una exposición detallada de todas las pruebas efectuadas, con dos propósitos principales:
Abstract
This project proposes a system to communicate data between two devices through the electrical network
(230VAC in Europe) in an easy, affordable and open way (DIY-oriented).
One of the main challenges of the project is the modulation/demodulation process required to accommodate
the data into the allowed frequency band. For that purpose, a simple On-Off-Keying (OOK) modulation with
a 110 kHz carrier is used.
The chapter dedicated to the tests is focused on the communication between electrical outlets at home, but
the concept can also be applied to the industrial scope to monitor machinery from a remote location within
the factory floor.
1. Design of an auxiliary board (cape) for the BeagleBone Black platform (BBB). The resulting
device works as a SUPERVISOR unit that manages the smart devices connected to the power line.
The core of the cape is an Analog Front End (AFE) specifically designed for PLC, the AFE031,
which includes a high-speed DAC operated by SPI. For data reception, the system relies on the ADC
embedded in the microcontroller of the BBB.
2. Development of some software tools in the supervisor unit (as an oscilloscope and a frequency-
response analyzer). They are used in the analysis phase. The source code (released under a
GPL-3.0 license) is based on Debian Wheezy, a Linux-based distribution compatible with the BBB.
3. Design of an auxiliary board (shield) for the Arduino platform. The resulting assembly works as
a smart device for periodic REPORTING. As a practical example, the shield senses the ambient
temperature, displays it in a 2x16 LCD, and sends the data through the mains in OOK.
• A detailed exposition of all the tests done, with two main purposes in mind:
◦ Highlight the main issues faced in the communication through the mains and propose some
guidelines for future evolutions.
12/181 Design of a low-cost device for data transmission over power lines
1 Introduction
1.1 Context
In today's modern society, smartphones have become indispensable. Time in which they were just used to
call contacts or send messages is over. Now we use them for much more things: we can read emails, consult
the news, surf the web, check our finances, do procedures with the administration, etc.
Nowadays, there is also a trend that is growing fast: the remote communication with any device from an
internet-connected-widget, the so called Internet Of Things (IoT).
On one hand, and due to the currently available inexpensive technology, devices are becoming smarter
each day. On the other, smartphones provide means to comfortable establish remote connections from
everywhere.
The remote control of devices is not new. At domestic scope, in home automated installations (aka Smart
Home or Home Automation), heaters can be remotely turned on before coming back to home, lighting points
can be controlled from the sofa, shutters can be automatically closed at night or on-demand, etc. But the
success and massive adoption of smartphones is opening this field to a myriad of new applications:
security warnings sent to the phone in case of anomalous events (excessive power consumption, water or gas
leakage, smoke/fire detection…), real-time temperature supervision to activate the heating depending on our
preferences at a given time, webcam monitoring, etc.
And this trend is also growing in the industrial scope. Plant supervisors need to get in real time the
maximum details of the ongoing production. They need to know if a machine in the production line is raising
some warning or if it is stopped because a failure. In the typical implementation there are visible or audible
notification means (traffics lights, horns) requiring the maintenance staff go where the problem is reported in
order to have more details. A more effective approach might be receiving a detailed report in the smartphone
in order to allow maintenance staff to optimize the actions to be done depending on the active faults and the
priorities.
Smart devices usually communicate with a central server through wireless technologies (Wi-Fi, Bluetooth,
ZigBee...) or through a wired Ethernet LAN. Both methods have pros and cons. For example, the extensive
use of Wi-Fi networks is leading to a more crowded shared band each day (specially due to video-based
content), requiring more complex designs for proper management. Furthermore, there are limitations and
regulations regarding the allowed RF power to avoid the abuse of the precious shared band.
In this project I am going to cover a different system: the data communication from a low-cost device to a
supervisor unit through the power line, in particular, through the 230VAC 50Hz mains at home.
PLC, which stands for Power Line Communications, is an old hugely analyzed topic. Plenty of PLC devices
can be found in the market. The added value of this project comes from the customization possibilities, the
DIY approach (Do It Yourself) and the Open Source design (licensed here under GPLv3). The system I am
proposing here can easily be built by any person with a basic electronic background.
This project (which is focused on electronics) is the continuation of the work started in
PlcCapeSoftwareFramework.pdf[1] (which was focused on software). In conjunction they constitute an
introductory framework to Power Line Communications.
Design of a low-cost device for data transmission over power lines 13/181
1.2 Objectives
The following table describes the main objectives of this project:
Principle Details
The main target is to develop a system for communication of data over the
power line. This means that:
Fulfill main PLC
▪ It must be able to modulate the data in the authorized CENELEC-B band,
requirements
which comprises the frequency range between 95 kHz and 125 kHz.
▪ It must couple low-voltage signals to the high-voltage in the AC line.
This project should give a simple overview of the PLC technology, just as an
introductory step to it (I am also a newbie on).
Focused on The project must fit in the DIY and open source principles. For example, a
experimentation simple low-cost device (with just the strictly required features for a specific
and learning test) is sometimes preferred to a powerful full-featured and more expensive
product. Have in mind that DIY is tied to experimentation and thus, prone to
electronic damage. So, low-cost is a highly appreciated characteristic.
Table 1. Main project objectives
14/181 Design of a low-cost device for data transmission over power lines
At transmission, a low-cost REPORTING device based on the Arduino platform will sense and transmit the
temperature to a central unit through the mains.
Figure 1. Proposed system for the REPORTING device
AC coupling
Arduino + Shield Push-Pull amplifier
module
At reception, a central SUPERVISOR unit based on the BeagleBone Black (BBB) will be in charge of
managing the connected devices. This involves the design of a BBB-cape (an auxiliary stackable board) with
an Analog Fron End (AFE). For that purpose, I am going to use the AFE031 integrated circuit, ideally suited
for PLC customized communications.
Figure 2. Proposed system for the SUPERVISOR unit
LINE 230VAC
SPI SPI DAC TX_PGA TX_LPF PA COUPLING
INTERFACE LINE
AFE031
BeagleBone
Black PlcCape
TX/RX Transmitter/Receiver
The coupling circuitry will superpose the modulated data (within the authorized CENELEC-B band) to the
230VAC 50Hz electrical energy.
Note that the Line Coupling Interface will allow establishing communication between both devices through
the AC mains but will also work over a direct unpowered couple of wires (a safer way for initial tests).
Design of a low-cost device for data transmission over power lines 15/181
If we replace the blocks above by real photos of the developed modules for this project (to have a better idea
of the proposed system), we will have this:
Figure 3. Proposed system with concrete modules
• the Arduino-based device which senses and reports the data (here the temperature) wrapped in an
OOK modulation with a 110 kHz carrier
• a Push-Pull amplifier used to supply more current than the provided by the Arduino pins
• the AC Coupling module superposing the low-voltage signal to the high-voltage electrical energy
• the 230VAC transmission line carrying both, the 230VAC 50Hz energy and the data at 110 kHz
• the PlcCape (with the integrated coupling module) stacked on a BBB working in reception mode
The first development stage of the whole PlcCape project[1] was focused on the development of the
software framework running in the SUPERVISOR unit (the BBB).
• the electronic design of the cape that will expand the functionality of the BeagleBone Black
• the electronic development and basic firmware of the low-cost Arduino-based device
• the evolution of the plc-cape software started in the first phase of the PlcCape project, with new
applications, plugins, features, improvements and bug corrections
• the detailed analysis of all the involved boards and the results in different configurations, with
the aim of acquiring a deep and complete knowledge of all the units composing the system and thus,
point the way for future evolutions
• Learn how the different platforms used in this project (BBB and Arduino) work
• Use free software for the electronic design (Eagle) and the electronic analysis (Spice-based tools)
• Learn how to develop GUIs based on third party libraries (as GTK/Cairo) with the aim of creating a
mini-oscilloscope tool to help in the analysis of the ADC captured data
16/181 Design of a low-cost device for data transmission over power lines
Introduction
Context, objectives, proposal, challenges and document structure
Page 12
Category Style
main.c
int main(int argc, char *argv[])
Source code {
printf("Hello world\n");
}
test.sh
Other file content #!/bin/bash
@echo Hello World
It is worth dedicating a small section to the types of pictures used in this document to make the most of them:
Format Comments
Lossy compression format ideal for photos. Do Copy/Paste from the PDF to get the
JPG original image size (usually bigger than the displayed one in the PDF).
Example: Figure 38. PlcCape-v2 mounted board.
Loss-less compression format ideal for graphic content as diagrams, charts, graphs,
PNG drawings, etc. Do Copy/Paste from the PDF to get the original image size.
Example: Figure 26. PlcCape-v2 SCH P9 connector.
Object-oriented format. You can zoom it in and get an accurate magnification of the
composing objects (as vectors) instead of a pixel-based expansion. This is the format
SVG exported by the plc-cape-oscilloscope tool.
Example: Figure 61. plc-cape-oscilloscope - Example of a SVG capture.
2 Background
2.1 Power Line Communications (PLC)
PLC covers the topics concerning the transmission of data superposed to the electrical energy through the
same line1.
It is a well known technology but not widely used because it has been superseded by the wireless
alternatives. But, the massive usage of the shared radio spectrum (to even reproduce HD video) is giving it a
new chance. Electronic stores are now plenty of PLC devices for data transmission at high speeds at home as
an alternative to the crowded radio band. For example, HomgePlug-based-devices can reach speeds greater
than 100 Mbps.
In the PLC domain, there is also a part dedicated to the transmission of data in the narrow low-frequency
band, with much lower baud rates, but ideally suited for some applications where the involved data consists
of small sporadic packets. We can find examples of use cases in Home Automation (aka Smart Home) or in
the Industrial scope.
Wi-Fi and Bluetooth (to mention the most popular) have evident advantages over PLC communications:
• The network can be accessed from everywhere in the covered area. PLC requires an electrical outlet.
Note however that any device will always require some amount of power (in addition to the WiFi
consumption) which usually comes from a power outlet (some low-consumption devices can be
operated through batteries but they will require a recharging from time-to-time).
• The wireless associated circuitry is inexpensive because the massive production of WiFi/BT
modules. PLC is not so common, and therefore, a bit more expensive.
But PLC has also some advantages that can make this technology more suitable for specific scenarios:
• PLC can reach higher distances by increasing the transmitted power. In WiFi we have strict
regulations in the maximum power to be radiated for the proper use of the shared radio spectrum.
• PLC can involve lower deployment costs because the reusability of the existing wires for power
distribution and data communication.
• As we are the owners of our electrical private network, we can customize the transmission protocol
pondering over cost and complexity.
• The isolation of electrical networks provides an additional security layer. While WiFi/BT
transmissions can be easily sniffed and thus require strong security protocols, PLC adds a physical
security level: an attacker needs a physical access point to our electrical network wires.
• PLC could also be a good alternative in industry: machines in the factory floor may report data to a
central server without requiring dedicated wires (expensive) or radio-waves (requiring repeaters to
cover the required distance or to cross huge concrete walls).
1 More detailed information about PLC can be found in PlcCapeSoftwareFramework.pdf [1]. Here I only highlights the
most important aspects
Design of a low-cost device for data transmission over power lines 19/181
CHALLENGES
• Transmitters must be ready to deliver relatively high currents to deal with the typical low
instantaneous impedance of the devices connected to the power supply network
• Power lines are not specifically designed for data transmission. Long wires are neither shielded nor
twisted. So, they can both, easily capture interferences from the environment, or easily radiate
energy.
• We must also consider the attenuation (due to the length of the wires), the reactance and other
effects.
• Power lines can also be quite noisy depending on the quality of the power supplies of the appliances
connected to.
CENELEC BANDS
CENELEC is the European Committee for Electrotechnical Standardization [15]. This organization has
regulated the way the low-frequency band can be used in power supply networks in the European Region:
CENELEC
Frequency Frequency Range Description
Band
Band A 9 kHz to 95 kHz Reserved for energy providers, mainly for telemetry
Band B 95 kHz to 125 kHz Available for customers use. No protocol defined
Band C 125 kHz to 140 kHz Available for customers use. Protocols must implement CSMA
Band D 140 kHz to 148.5 kHz Available for customers use. No protocol defined
Table 5. CENELEC bands
2.2 AFE031
The AFE031[16] is the core of the PlcCape board. It is an integrated circuit that includes most of the required
modules to build a communication system based on PLC.
The typical configuration is based on a powerful master CPU which generates the waveform of the
modulated data and sends it sample by sample to the DAC of the AFE031 through a SPI bus.
The specific reasons for the selection of this integrated circuit among others are given in the section 3.3.3
Justification for the AFE031 choice.
For this project the most interesting features provided by the AFE031 are:
• A high Speed Digitial-to-Analog Converter (DAC) up to 1.5 Msps, for innumerable customization
possibilities in data modulation.
• A Programmable Gain Amplifier (PGA) at transmission for some extra flexibility on the voltage
level of the generated signal.
• A couple of PGAs at reception to adjust the level of the signal before being captured by the ADC.
• A couple of low pass filters (LPF) to attenuate frequency content (interferences, noise, etc.) out of
the band of interest (CENELEC).
• A Power Amplifier (PA) to deliver enough current to drive low impedance values in the AC line.
• Multiple accessible points. This opens the customization possibilities. For example, we can replace
the integrated blocks (PGA, LPF, PA...) with our own versions.
2 The information in this section is a direct clone of the corresponding section in PlcCapeSoftwareFramework.pdf[1]
22/181 Design of a low-cost device for data transmission over power lines
The AFE031 comes in a mini 48-pin QFN package. That is good for miniaturization but it is something
tricky for manual soldering. It also makes the thermal dissipation a challenge, as it is based on a bottom pad
that must be soldered to a ground plane, which is impossible when using a manual solder.
Block Description
Generates the analog voltages (from 0 to 3.3V) corresponding to the digital samples coming
DAC
from the SPI block
Transmission (Tx) Programmable Gain Amplifier (PGA) for better output control. It allows
TxPGA
four programmable gains: 0.250, 0.500, 0.707, 1.000 (in V/V units)
Transmission Low Pass Filter (LPF). It filters the input signal at Tx_F_IN1 (usually the
output from the TxPGA) with a configurable cut-off frequency: 95kHz for CENELEC A,
Tx Filter 145kHz for CENELC B/C/D.
The output goes from 0 to VDD. The maximum continuous DC current for both sourcing
and sinking is about 25mA.
Amplifies the voltage of the input signal (limited to the voltage supply VDD <= 5.5V) to the
higher levels of another external power supply (PA_VS from +7V to +24V).
Power
The PA offers a nominal gain of 6.5 V/V.
Amplifier
The PA is able to deliver 1.5A.
This project is designed for a +15V power supply
First Programmable Gain Amplifier in the reception chain, before the integrated low-pass
RxPGA_1 filter.
If provides four programmable gains: 0.25, 0.50, 1.00, 2.00 (in V/V units)
It is a filter in the reception chain intended to remove the unwanted signals out of the
Rx Filter CENELEC band. The cut-off frequency is affected by the parametrization of the CENELEC
mode (A vs B/C/D)
Second Programmable Gain Amplifier in the reception chain, after the low-pass filter.
RxPGA_2
It provides four programmable gains: 1, 4, 16, 64 (in V/V units)
This block can be used for simple implementations of communications that use amplitude
Two-Wire shift keying (ASK) with on-off keying (OOK) modulation.
Rx/Tx It is not used in this project because this functionality is already covered by the DAC-based
implementation.
Zero Crossing module to easily detect the AC phase edges and thus allow a better use of the
channel:
Zero
• some protocols can relay on it for synchronization purposes
Crossing
• the data can be transmitted near the zero-pass-region where the consumption of
connected machines or appliances may be lower
Table 6. AFE031 main blocks
Design of a low-cost device for data transmission over power lines 23/181
DI Serial data sent from the BBB to the AFE031 (commands or DAC samples)
SPI Serial data sent back from the AFE031 to the BBB in response to BBB
DO
commands
Chip Select (Negated) used by the AFE031 as a strobe signal indicating the
CSN
end of a 10-bits DAC sample
Analog samples after the SPI to DAC conversion + TxPGA attenuation. This
TX_PGA_OUT
signal has a “step-shape” because the constant level between DAC samples
It is the input to the Power Amplifier. The PA requires the signal to do not
PA_IN have a DC component. To achieve this the TX_F_OUT traverses a
decoupling capacitor
PA
This is the output of the Power Amplifier which magnifies the input signal
PA_OUT
using the PA_VS power supply
Input signal coming from the AC decoupling stage + the external pass-band
Rx_PGA1_IN filter. A decoupling capacitor is also required to allow the AFE031 biasing
the level of the received AC signal
Rx_PGA2_OUT Output of the RxPGA_2 block after the last programmable amplification
Low-level “clone” of the 230VAC line for Zero Cross detection. The
ZC_IN1 230VAC can be converted to a low-level clone through high-impedance
ZC resistors or through an optocoupler
The BeagleBone Black conception allows the addition of stackable boards (called capes) through two
headers giving access to the generic purpose pins provided by the main SOC of the BBB, the SITARA
AM3358 from Texas Instruments.
The capes are products of the BeagleBoard.org community, which means they were designed by developers just like
you and, although a variety of capes exist today, we can’t wait to see what cool new cape concepts come next. You
have the chance to put your thinking cap on and tell us what we’ve missed by conceptualizing and designing your own
cape plug-in board! Register your idea today.
There are now over available 100 cape designs for display (DVI-D, HDMI, VGA, LCD, etc.), motor control, prototyping
and power supply (battery, solar, etc.) – among other functionalities – with more on the way. What will you create?
The most important point in the design of a BBB cape is the interface with the platform, which is carried out
through the P8 and P9 connectors:
Figure 7. BeagleBone Black connectors P8 & P9
This project proposes a BBB-cape design for the SUPERVISOR unit (instead of developing a whole system
from scratch) to take advantage of the BBB functionality and the underlying Linux operating system.
26/181 Design of a low-cost device for data transmission over power lines
2.4 Arduino
Arduino is an open-source platform based on inexpensive, multipurpose, and easy-to-use hardware, that suits
medium complexity projects very well.
• an IDE to program the sketches (scripts with the firmware). It relies on a custom language, Wire,
which is based on C and C++ but with some specific syntax
• auxiliary shields (stackable boards) that connect to the expansion headers and extend the
functionality of the platform
In this project I have chosen the Arduino framework for the REPORTING device because its popularity and
omnipresence, which lead to lower prices, readability and lots of reusable accessories.
I have used the Arduino Leonardo model because it is cheap and provides enough functionality to fulfill the
requirements. The main features concerning this project are:
• 5 V based logic, which can be supplied from the 2.1 Figure 8. Arduino Leonardo
• Flash Memory: 32 KB
• SRAM: 2.5 KB
• EEPROM: 1 KB
For more details go to the official website [8]. The schematics are also freely available online [9].
The Arduino Leonardo is similar to the Arduino Uno. The main difference is that the Leonardo includes
improved USB support which allows the board to simulate a HID device (as a mouse or a keyboard). This
feature is not used in this project, but the difference in cost is minor and it may be worth having it for other
future uses.
In this project I have used the PWM functionality to generate a square wave carrier of 110 kHz which is used
to modulate the data to be transmitted.
Design of a low-cost device for data transmission over power lines 27/181
2.5 Raspberry Pi
The Raspberry is a mini-PC similar to the BeagleBone Black but lacking an ADC. It is cheaper and more
popular. Its HDMI output and 3.5mm audio jack makes it ideal to be used as a low-cost (yet highly
customizable) media center to play content like HD videos (e.g. with the distribution https://libreelec.tv).
There are different Pi versions. There is even one specific version for the connected home, the Raspberry Pi
Zero W. A clear summary of its purpose can be found in the Raspberry Pi website 3:
Today is Raspberry Pi’s fifth birthday: it’s five years since we launched the Figure 10. Raspberry Pi Zero W
original Raspberry Pi, selling a hundred thousand units in the first day, and
setting us on the road to a lifetime total (so far) of over twelve million units.
To celebrate, we’re announcing a new product: meet Raspberry Pi Zero W,
a new variant of Raspberry Pi Zero with wireless LAN and Bluetooth,
priced at only $10.
3 Implementation
3.1 Overview
For the effective communication through the power line, in the most simplistic approach, we need to design
the electronics of a transmitter, the electronics of a receiver and some software/firmware for the logics
behind. This chapter will cover these areas:
Technical
Main requirements for the complete communication system.
specifications
Output stage They must be behind a transformer to couple the signal with the AC line.
The output stage at transmitting must be able to deal with low impedance
Output current
conditions in the AC line, in the order of the 100 Ω.
It is not a key factor. The target of the system is the communication of data
Baud rate
through short and sporadic packets.
SUPERVISOR UNIT
The SUPERVISOR unit must be able to transmit and receive data and with
different modulation schemes in order to communicate with several kind of
TX and RX devices.
versatility
It must be highly programmable to simplify the adaptation to different scenarios
and customizations.
REPORTING DEVICE
The electrical energy distributed through the mains is based on a low frequency alternating current with high
voltage (230 VAC 50 Hz in Europe). We can use higher frequencies to transmit low-voltage coupled data.
The proposal for the SUPERVISOR unit is to develop a cape (an auxiliary board) compatible with the
BeagleBone Black. The cape (that I have named PlcCape) will add the extra functionality not available in
that platform and required for Power Line Communications (PLC), like the Analog Front End (AFE) and the
coupling layer.
To meet the versatility goals of this project I have looked for an integrated circuit with a DAC (Digital-To-
Analog Converter). This way we should be able to implement different modulation schemes by software
(more or less complex depending on the specific scenario and the requirements). For the core of the PlcCape
I have chosen the AFE031 chip from Texas Instruments[16].
• It is multipurpose and featured with most common blocks (SPI, DMA, GPIO, ADC…).
• It is compatible with Linux-based distributions (Debian, Ubuntu, Ångström, etc.). We can benefit
from all the already existing functionality offered by the OS and the pre-installed packages.
• Being Linux-based, a lot of third party open software is available, as for example the GTK+/Cairo
framework in the GUIs area, or the FFTW library in the Engineering domain.
• Thanks to the open nature of Linux, the drivers can be customized to maximize the performance in
specific conditions.
• The pluggable and stackable conception of capes is a synonym of modularity and scalability.
• The use of a cape as an intermediary between the BBB and the “hostile” environment provides with
some kind of isolation: if the incoming signals exceed the supported levels, they can damage the
cape but probably will not reach the BBB. That is, the cape acts as a first shield or barrier stage that
protects the BBB.
• On the one hand, its DAC allows the implementation of very basic custom modulation schemes,
one of the goals of this project. For example, to emit short sporadic packets of data, we can use a
simple OOK modulation scheme (transmission speed would not be a decision criteria here).
• On the other hand, its DAC allows the implementation of more complex modulation schemes for
increased throughput (at the expense of more computational effort).
• Being able to implement any modulation scheme, the interoperability with other devices can be
carried out easily.
• Having full control on the modulation scheme allow us for the implementation of different error
control mechanisms: parity, checksum, CRC, ECC, etc. It also allows for different protocols:
master-slaves with turns, event-based, based on assigning predefined time slots or frequency carriers,
etc.
• The AFE031 is specifically targeted to power line communications within the CENELEC bands.
• Being an inexpensive chip and requiring few extra components, it is a cost-effective solution for a
Power Line Communications module.
• By integrating into the AFE031 the main blocks required (DAC, Power Amplifier, Programmable
Gain Amplifiers, Filters…), it simplifies the miniaturization of the board.
• It can be easily connected to the BeagleBone Black via its SPI bus.
• It is reusable for other purposes due to its extensive pin-out (48-pins) which gives access to the
different signals involved in the TX and RX paths.
In the AFE031 documentation[18] we have a good summary of the main features offered by the chip:
The AFE031 is the industry's first and most flexible analog front-end designed specifically to meet the rigorous
demands of power-line communication applications. Using the AFE031 saves design time, increases reliability, and
reduces risk. The AFE031 can connect to virtually all microprocessors. The device can be driven with both digital or
analog inputs; it conditions and filters the signals, and then transmits the signals to the power line through the
integrated power amplifier. The integrated, low-noise receiver can be configured to provide either attenuation or gain,
depending upon the signal and noise levels on the power line and drives the analog-to-digital converter found in most
microcontrollers. The AFE031 can work with multiple signal types, including FSK, SFSK, or OFDM. With proper line-
coupling circuit design, the AFE031 can be used in a wide variety of applications that range from dc busses to MV (7.2
kV) transmission lines.
Finally, just a mention to the different versions of this Analog Front End:
• There is an old version, the AFE030, a bit cheaper but with fewer features.
• There is a new version, the AFE032, which provides a better filtering by using an internal DSP. It is
not fully compatible at pin level with the AFE031. Thus, it will imply some adaptations in the PCB.
In this project I have used the AFE031 because it was the version with the largest availability in the main
distributors.
I have not included an EEPROM for identification purposes (which is a recommend practice when building
commercial capes) because I did not have enough room, nor time for. This results in a simpler cape but
special care should be taken if we stack it with others.
For the schematics and the PCB routing I have used EAGLE 7.5 which offers a free license for developing
boards of reduced dimensions4:
Download free version of EAGLE
For the schematic and the PCB layout of the BBB cape headers I have downloaded the Adafruit library
adafruit.lbr[6].
I have downloaded the layout of the AFE031 with a specific tool, UltraLibrarian (see 6 Annex I. Tools).
For some SMD components I have created custom PCB footprints because I neither found an exact match on
the pre-installed libraries, nor found a suitable installable package.
Finally, we also need to consider other specific limitations tied to the manufacturing process of the board
prototypes at the laboratory:
• The vias (through-hole connections from the top layer to the bottom layer) are not metalized. That
means that the connection between top and bottom layers must be done manually filling them with
solder paste. Therefore, we should minimize the use of vias to simplify the manual soldering phase.
• The no metalization of the vias imposes another constraint too: on through-hole components, only
the “back” layer must be used as the “front” layer (where the component package is exposed) is
likely going to be inaccessible.
For the pinout of the AFE031 and the corresponding signal meanings, take a look at 2.2.2 AFE031 blocks
and pins. For the interfacing with the BBB (pins in the connection headers), take a look at 2.3 BeagleBone
Black (BBB).
• PlcCape-v1: targeted to have an initial contact with the PLC technology. It includes many easily
accessible test points. The AC coupling block (transformer + protection + AC phase detection) is
implemented in an auxiliary board due to space constraints and also for modularity (it allows isolated
tests with it, it can be reused on different configurations, etc)
• PlcCape-v2: conceived to be the first final version. It contains all the required circuitry, including
the AC coupling block. It has fewer test points and they are more difficult to reach. Pluggable
connectors have been added to simplify the interfacing with the external power supply and with the
Power Line. It embeds some LEDs to simplify monitoring and troubleshooting.
3.3.6 PlcCape-v1
3.3.6.1 Overview
The main target of the first version of the PlcCape board is to test the functionality of the core integrated
circuit, the AFE031. For that purpose the board has been designed with many easily accessible probing
points on the most interesting signals. Some DIP sockets have been also included to simplify the
experimentation phase with through-hole components.
3.3.6.2 Schematics
To simplify the reading, this section is divided in four areas:
Expansion header Description of the connection interface between the BBB and the PlcCape
AFE031 Core AFE031 and surrounding logic providing the core functionality of the cape
Power supply
Connections and capacitors in the power supply network
network
EXPANSION HEADER
The expansion header connects the BBB to the PlcCape through the P9 connector. This is a summary of the
pins and signals involved:
INPUTS (PlcCape-to-BBB)
DOUT [SPI] Serial Data
(responses)
INT INTerrupt event
TX_FLAG TX block is ready
RX_FLAG RX block is ready
ADCIN Analog data
ZC_OUT Zero crossing of AC
34/181 Design of a low-cost device for data transmission over power lines
AFE031 CORE
• At top left we can see the SPI bus lines and associated pull-ups (R1 to R4).
• At bottom left there is the connection from the AFE031 RX chain to the ADC of the BBB (ADCIN).
Note that at the BBB-side the ADC voltage must not exceed 1.8 V (to avoid irreversible damage).
That is why I have placed a ½ voltage resistor divider (R14 and R15): the AFE031 output can go
from 0 to 3.3 V; after the ½ divider the signal is attenuated to a maximum of 1.65 V.
For a future version, we should use a more accurate and repeatable divider to avoid surprises with
the tolerance of the resistors. It would also be interesting to add some protection diode to avoid that
glitches over 1.8V reach the ADC of the BBB.
• At top right you can find the output of the Power Amplifier stage of the AFE031 (L3, D2, D3, R11,
C12).
• At bottom right we have a first band-pass filtering stage in the RX chain composed of a forth-order
passive RLC network (C11, L2, R12, R13, C8, L1, C7) which is in charge of eliminating frequency
content out of the band of interest. Its purpose is to do a first cleaning of the signal before reaching
the RX chain of the AFE031.
NOTE: the values specified in the above schematic for the RLC passive network correspond to the
CENELEC-A band. See 4.2.2 RX filtering for more details.
Remarks:
• You can find a SMD jumper in SJ2 to connect GND to GNDA. This is a trick in EAGLE to have two
different ground paths (I wanted GNDA to be routed with wider traces because they have to support
higher currents). In the physical board we have to put solder paste on it to interconnect both GNDs.
Design of a low-cost device for data transmission over power lines 35/181
AUXILIARY HEADER
The auxiliary header (JP1) is mainly intended to connect the TXRX signal with the coupling board:
V+ & GNDA Power Supply for the Power Amplifier block in the
AFE031. It accepts voltages from 7 V to 24 V,
(input) according to the datasheet[17]
+5V & GND Power Supply for the 5 V logic. This is connected to
(in or out) the external power supply rail (2.1mm jack)
Note that the +5V pin can be used for two purposes (due to the direct connection with the 2.1mm jack):
• to get the 5 V from an external power supply connected to the 2.1mm jack (and thus, be able to
comfortably power other 5 V based circuits)
Note, however, that if the BBB is powered through the USB, there is no voltage in the +5V pin. In fact, if
you look at the Figure 11 you will see that the P9 connector in the BBB offers two 5V pins:
• SYS_5V (not used in this project): which comes from the USB
For more details see the section 8.6 Cape Power of the reference manual[3]. Here an extract:
VDD_5V is the main power supply from the DC input jack. This voltage is not present when the board is powered via
USB. The amount of current supplied by this rail is dependent upon the amount of current available. Based on the
board design, this rail is limited to 1A per pin from the main board.
The SYS_5V rail is the main rail for the regulators on the main board. When powered from a DC supply or USB, this
rail will be 5V. The available current from this rail depends on the current available from the USB and DC external
supplies.
Finally, find below the schematic diagram corresponding to the power supplies:
Figure 14. PlcCape-v1 SCH Power supplies
For the 3V3 power rail (coming from a LDO on the BBB), I have just added the typical capacitors.
For the power supply that feeds the Power Amplifier in the AFE031, I have also added a diode (assuming a
+15 V power supply) to protect the logic against glitches (as recommended in the AFE031 technical note [16]).
36/181 Design of a low-cost device for data transmission over power lines
I have executed a tentative auto-routing operation to have an initial proposal from the tool, and then adjusted
the traces and vias manually having in mind these considerations:
• The vias need to be filled with solder paste (and with a mini wire to help in the process) because the
manufacturing equipment at the laboratory makes the hole but it does not place the metallic link
between top and bottom layers. So, try to minimize vias usage.
• In through-hole components, it would be difficult (or even impossible) to solder the pin-hole area in
the package-side. So, do not route any trace on the package-side of a pin-hole.
• The vias arranged under the AFE031 (the small square in the center of the board) are for better heat
dissipation[19]. We must fill these vias before soldering the AFE031 to set the link between top and
bottom layers. Otherwise, we would lose a connection to GND which will force us to make a
bridging patch somewhere else.
Figure 15. PlcCape-v1 PCB Top Figure 16. PlcCape-v1 PCB Bottom
This is the result of the manufactured board with the AFE031 core already soldered in the center:
Figure 17. PlcCape-v1 board - Top Figure 18. PlcCape-v1 board - Bottom
Design of a low-cost device for data transmission over power lines 37/181
Remarks:
• SOD-123[JMO] is a customized footprint for the 1N5819 SMD diodes. I modified an existing one
by increasing the contact area to simplify the manual soldering process.
38/181 Design of a low-cost device for data transmission over power lines
At right we have the PlcCape-v1 with the auxiliary coupling module attached, and the whole plugged into a
BBB.
I have soldered all the pins in the P9 header (even the not used ones) for simplicity. In the P8 header, though,
I have only soldered four pins (in the borders) for lesser insertion/extraction force, yet good enough for
proper placement and mechanical stability.
In green there are the easily accessible probing points (through a female pole); in yellow, the SMD-based
ones (requiring the oscilloscope probe to be manually held during the measurement).
Design of a low-cost device for data transmission over power lines 39/181
In the AC coupling module I have also added a ZC_IN line providing a low-voltage version of the AC wave,
intended for Zero Crossing detection. The given circuit (R2, R3, R4, D1, D2) converts the 230VAC sine
wave (~650VPP) to a ~3 VPP square waveform. Note that the X5 pole must be fed with 3.3V for this to work.
As this opens a direct path from the 230VAC to the digital logic, a jumper has been added (JP2) to isolate it
when not used (just as a safety measure). The Zero Crossing detection has neither been used nor evaluated in
this project because I have been short of time.
The connections in perfboards are usually carried out with short thin wires. Here, I have done the
connections directly with solder paste to make them easier to track.
40/181 Design of a low-cost device for data transmission over power lines
The mapping between the schematic and the top side of the perfboard is shown in the right figure:
GNDA Connection points for the 15 V power supply that will Figure 25. Auxiliary AC coupling
V+ feed the Power Amplifier block in the AFE031. module connections
Pins for the 5 V supply. They come from the power rail
tied to the 2.1mm jack in the BBB. Thus, these pins can
be used in two ways:
▪ to get the 5 V from an external supply connected to
5V the BBB through the 2.1mm jack
GND ▪ to supply the BBB with 5 V coming from an external
supply connected to these pins (5V and GND)
Note that these pins are not used by the AC Coupling
module. They have been included in the board just for
comfortable access to the 5 V.
AC_L
They form the connection point with the AC line.
AC_N
To end the chapter, it is worth having a quick look at the JP1 jumper because it offers different configurations
that can be used to simplify the interconnection between modules. By looking at the circuit as it is presented
in Figure 25 we would have these possibilities:
• Jumper on middle and right pins (JP1.2 & JP1.3): this is the standard configuration when using
the module attached to the PlcCape board. It enables the AC coupling transformer and protective
components. The TXRX signal (on the pin 2 of the H1 header) is coupled/decoupled to the signal
present in the AC pins (AC_L and AC_N). There is an example of this configuration in Figure 73.
RX chain analysis - PlcCape + Push-Pull + PlcCape - Testing environment.
• Jumper on middle and left pins (JP1.2 & JP1.1): this allows testing the TXRX line over a simple
resistor placed in the X4 connector.
• Jumper establishing a short-circuit among the three pins (JP1.1 & JP1.2 & JP1.3): this
configuration is suitable for connecting the coupling board to other external modules. It enables the
AC coupling block but also the X4 connector in the top side, allowing a comfortable connection of
an external TXRX through it (instead of using the pin 2 in the H1 header in the bottom side, which
has a more difficult access). An example of this configuration can be found in Figure 84. AC
coupling module - Testing environment.
Design of a low-cost device for data transmission over power lines 41/181
3.3.7 PlcCape-v2
3.3.7.1 Overview
The PlcCape-v1 board was focused on testing.
The PlcCape-v2 is aimed at becoming a first final candidate. For that matter it is required to:
• integrate all the mandatory components in the board (including the coupling part) and remove the
unnecessary blocks from PlcCape-v1
• add a customizable generic purpose output (to optionally connect relays, buzzers, etc.)
• include some probing points (just the essentials) for easy testing and checking
The above objectives turn into these concrete modifications (with regard to PlcCape-v1):
AC coupling The circuitry related to the AC coupling module will be integrated in the
module cape instead of requiring an auxiliary board.
Two low power LEDs will be used to notify about TX and RX status.
LEDs One medium power LED will be used to indicate the proper operation of the
Power Amplifier voltage (if provided). For the 5 V supply, we will rely on
the existing LEDs in the BBB.
The meaning of DIN and DOUT in the SPI bus will be toggled in order to
follow the standard default convention.
Corrections
The size of the ground area surrounding the AFE031 QFN package must be
expanded as much as possible for better thermal dissipation [19]
3.3.7.2 Schematics
The schematics of PlcCape-v2 are divided in these functional areas:
Description of the connection interface between the BBB and the PlcCape.
Expansion headers
The differences with PlcCape-v1 will be highlighted.
Core AFE031 and surrounding logic providing the core functionality of the cape.
AC coupling Block that couples the low-level logic with the high-voltage in the AC line.
Zero-crossing block Detection of the zero-crossing instants of the 230VAC 50Hz wave.
Header to have easy access to the power supplies and the generic purpose
Auxiliary header
output.
Power supply
Connections and capacitors in the power supply networks.
network
EXPANSION HEADERS
These are the pins used from the P9 header in the BBB:
Figure 26. PlcCape-v2 SCH P9 connector
Design of a low-cost device for data transmission over power lines 43/181
The following figure shows in red the main differences with PlcCape-v1:
Figure 27. PlcCape-v1 vs. PlcCape-v2 in the interfacing with the BBB
• DIN and DOUT are reversed to be coherent with the standard SPI criteria.
• INT signal has been moved from SPI1_CS0 to GPIO1_17 to let SPI1 free for other possible future
uses or for an additional stacked cape.
• A new block of pins (GEN_OUT, TX_OUT and RX_OUT) has been reserved for the generic-purpose
output and for LED control
CORE
The core logic surrounding the AFE031 is almost identical to the one in PlcCape-v1:
Figure 28. PlcCape-v2 SCH AFE031 core circuitry
44/181 Design of a low-cost device for data transmission over power lines
AC COUPLING
This block is in charge of coupling the low-voltage signal generated by the AFE031 (TXRX) to the high AC
voltage present in the mains:
Figure 29. PlcCape-v2 SCH AC coupling block
ZERO CROSSING
This block generates, in ZC_IN, a low-voltage square version (3.3 V PP) of the AC sinusoid (230VAC). It will
reach the AFE031 and be used to detect when the AC voltage crosses zero. In future applications we might
use it as a synchronization mechanism.
Figure 30. PlcCape-v2 SCH Zero Crossing block
Due to time constraints I have not tested this block. In fact, I have not even soldered it. It is something to be
evaluated in a future iteration.
In PlcCape-v2 I have added a couple of LEDs to notify about TX and RX activity. Low power LEDs have
been used because they will be directly driven by BBB output pins, which have limited current sourcing
capabilities.
Design of a low-cost device for data transmission over power lines 45/181
I have also added a transistor-based open-collector multipurpose output to connect optional devices like a
relay, buzzer, horn, or similar. I have included a low power LED to notify about the current status of the
output.
Figure 31. PlcCape-v2 SCH LED monitoring block
AUXILIARY HEADER
The auxiliary header provides easy access to the low power supplies used by the cape (3.3 V and 5 V). There
is also a pin reserved for the generic purpose output.
Figure 32. PlcCape-v2 SCH Auxiliary connector
For the +5V power supply, it applies the same considerations as in PlcCape-v1 (see the section Auxiliary
Header in 3.3.6.2 Schematics): +5V is connected to the 2.1mm jack rail (external power supply); if the BBB
is powered via USB, this line will not have any voltage.
The +3V3, however, is always working because it comes from an LDO regulator in the BBB, as indicated in
the section 8.6 Cape Power of the Reference Manual[3].
The power supply network is the same as in PlcCape-v1 except for an extra LED that has been added to
indicate whether the 15 V voltage is present.
Figure 33. PlcCape-v2 SCH Power supplies
46/181 Design of a low-cost device for data transmission over power lines
And this is the resulting board with the AFE031 already soldered:
Figure 36. PlcCape-v2 board - Top Figure 37. PlcCape-v2 board - Bottom
In the bottom layer we can clearly see the large ground area surrounding the AFE031 and the solder paste
dispensed to the vias, for better thermal dissipation.
5 I have manually edited the footprint for the transformer. I have used the JMO suffix to indicate it.
6 Prices consulted on 24-Apr-2017 at http://www.mouser.es
48/181 Design of a low-cost device for data transmission over power lines
• in green, the easily accessible probing points (through female poles or screw connectors)
• in yellow, the SMD-based ones (requiring the probe to be manually held during the measurement)
• in red, the screw connector for the 230VAC (special care must be taken if measuring there!)
Design of a low-cost device for data transmission over power lines 49/181
Figure 40. PlcCape-v2 TX_F_OUT bridge I did not have time to prepare a new board.
Instead, I patched it in order to make the
TX_F_OUT easily available. In particular, I put
a bridge (black mini-wire) bringing the
TX_F_OUT to the non-functional PA_OUT trace.
I removed L3 to open the path with the AFE031
PA_OUT pin and thus, avoid any undesirable
loop.
In fact, if we need extra current we can easily connect an external amplifier, which can also be an interesting
alternative (or complement) to the internal PA on some scenarios. For example, an external current amplifier
could be designed to source higher currents. Moreover, the thermal dissipation design could be simpler
compared to the thermal constraints of the miniaturized AFE031. We will see an example of a very basic
external amplifier in the 3.4.4 Push-Pull amplifier chapter.
• It will imply a bigger board due to the room required for the dedicated Power Amplifier stage.
In any case, the Power Amplifier is not required for the specific scenarios covered in this project, where the
transmitter (the REPORTER device) will be an Arduino-based system with a dedicated amplifier module.
The PlcCape and its AFE will work in the receiver side (the SUPERVISOR unit).
• For safety, change the type or size of the AC connectors to make them incompatible with the low-
voltage ones, in order to avoid dangerous mistakes. In fact, in the current board, they already have a
different size, but the difference is so small that they can be wrongly plugged by applying little force.
• Improve miniaturization and integration to give room for other components (as an EEPROM, more
testing points, some button, etc.): use SMD resistor arrays instead of multiple isolated SMD resistors
(specially useful on pull-ups); use a two-layer board with intermediate ground planes for shorter
routing paths (and hence, closer components), etc.
• Use double side headers (in P8 and P9) to allow stacking other BBB capes on top of the PlcCape.
50/181 Design of a low-cost device for data transmission over power lines
For simplicity in the development I have opted to be based on an existing system. I have chosen the Arduino
platform because:
• It is inexpensive.
• It is multipurpose and reusable (the same board can be used for specific purposes through shields).
• Through its PWM subsystem, it is able to generate simple OOK modulated data (On-Off Keying 7)
with the carrier frequency required for this project (110 kHz)
Contrary to the SUPERVISOR unit, the REPORTING device only needs to send data. And for the OOK
modulation we do not need a DAC. We can use a square wave signal and apply some basic filtering to reduce
the level of the harmonics. This will bring the resulting carrier closer to a sinusoidal shape.
In the programming side, I have developed a simple sketch to periodically send a Hi word wrapped in an
OOK modulation at 110 kHz:
SendModulatedMsg.ino
/**
* PURPOSE:
* Send a message periodically using a square carrier of a specified frequency (around 100kHz)
* The modulated signal is forwarded to pin13
*
* TARGET MODEL:
* Arduino Leonardo
* It relies on FastPWM (High Speed TIMER4)
*
* NOTES:
* FastPWM-part based on code from:
* http://r6500.blogspot.com.es/2014/12/fast-pwm-on-arduino-leonardo.html
*
* LICENSE:
* Copyright (C) 2017 Jose Maria Ortega
* Distributed under the GNU GPLv3. For full terms see the file LICENSE
*/
// NOTE: For some apparently strange reason Arduino IDE 1.6.4 doesn't allow me to use
// 'clock_base_divider_enum' in the function prototype. Patch: use 'byte' instead
unsigned char configure_pwm13(byte clock_base_divider, unsigned char timer_divider_pow,
long required_freq)
{
TCCR4A = 0;
TCCR4B = timer_divider_pow+1;
TCCR4C = 0;
TCCR4D = 0;
// When the Arduino IDE uploads new firmware it seems to modify the 4-low-bits PLLFRQ0..3,
// corresponding to PDIV0..3. That value doubles the PLL frequency compared to the initial value
// when re-powering the board (PDIV = 0x4). The effect is that the PWM frequency after firmware
// uploading doubles the PWM frequency after re-powering (note however that using the Reset button
// keeps PDIV). To avoid this, we should force 'PLLFRQ = 0x4' instead of just masking the
// PostScaler with 'PLLFRQ &= 0xCF'
PLLFRQ = 0x4;
switch(clock_base_divider)
{
case clock_base_divider_one:
PLLFRQ |= 0x10;
break;
52/181 Design of a low-cost device for data transmission over power lines
case clock_base_divider_one_half:
PLLFRQ |= 0x20;
freq_clock = freq_clock/3*2;
break;
case clock_base_divider_two:
PLLFRQ |= 0x30;
freq_clock /= 2;
break;
}
// Sets the value to be used on PWM13 to configure a 50% dutty cycle wave with the new
// configuration
// NOTE: For an exact 50% dutty cycle OCR4C must be odd
pwm13_dutty_half = (OCR4C-1)/2;
}
void setup()
{
// For 110kHz freq a suitable configuration may be:
// 'clock_base_divider_one_half' and 'timer_divider_pow' = 1 ->
// Base freq (with PLLFRQ=0x4) = 48M/1.5/2^1 = 16M
// Min Freq[Threshold counter=256] = 16M/256 = 62.5 kHz
// Freq[255] = 16M/255 = 62.75 kHz
// Freq[139] = 115.10 kHz
// Freq[140] = 114.29 kHz
// Freq[141] = 113.48 kHz
// Freq[128] = 125 kHz
// Freq[1] = 16 MHz
// So, we have an acceptable granulatiry around 110kHz and can achieve
// interesting lower frequencies for testing (here 62.5 kHz)
configure_pwm13(clock_base_divider_one_half, 1, 110000);
}
}
}
void loop()
{
unsigned char message[] = "Hi";
send_message(message, sizeof(message)-1);
delay(DELAY_BETWEEN_MESSAGES_MS);
}
This is the result when probing the pin 13 with the oscilloscope:
In the capture at left, we can clearly identify the bits of each character (have in mind that there is always one
additional start bit):
• H = 0x48 = 0b01001000
• i = 0x69 = 0b01101001
Each bit has a width of 1 ms. We can also observe a gap of 5 ms between characters, which is defined in the
sketch by DELAY_BETWEEN_SYMBOLS_MS.
In the capture at right (zoomed to 10us/div), we confirm that the frequency of the carrier is 110 kHz.
54/181 Design of a low-cost device for data transmission over power lines
A possible simple PCB routing for this shield is proposed in the below figure.
Figure 43. Arduino shield - Routing
This is the sketch to get the temperature and display it on the LCD every 500ms:
TestTemperatureSensorLcd.ino
/**
* PURPOSE:
* Get the temperature from a OneWire-based sensor (e.g. DS18B20) and display it in the LCD
*
* TARGET SYSTEM:
* Arduino Leonardo + Custom "Temperature & LCD shield"
*
* NOTES:
* For the LCD part I’ve been based on the public domain code at:
* https://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay
*
* For the OneWire part there is plenty of information in Internet like this one:
* https://create.arduino.cc/projecthub/everth-villamil-ruiz/temperature-sensor-ds18b20-3decfc
*
* LICENSE:
* Copyright (C) 2017 Jose Maria Ortega
* Distributed under the GNU GPLv3. For full terms see the file LICENSE
*/
#include <LiquidCrystal.h>
#include <OneWire.h>
56/181 Design of a low-cost device for data transmission over power lines
#include <DallasTemperature.h>
void setup()
{
sensors.begin();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("15/2/2017 +--.--");
lcd.setCursor(0,1);
lcd.print("Jose M. Ortega");
lcd.display();
}
void loop()
{
// Send the command to get temperatures
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
lcd.setCursor(11,0);
lcd.print(tempC);
delay(DELAY_BETWEEN_MEASURES_MS);
}
With the Arduino IDE I have uploaded the new firmware to the Arduino Leonardo and verified that it works
as expected:
Figure 46. Arduino shield - Test
For this test I have used a USB Power Bank as the power source. We will use this battery-powered
configuration on some tests in the section 4.8 Data communication through the 230VAC line.
Design of a low-cost device for data transmission over power lines 57/181
To do so, I have just added, to the sketch in the previous section (3.4.2), the fragment of the code that enables
the transmission of modulated data through the pin 13 (in 3.4.1).
This is the final sketch that periodically reports the temperature, wrapped in an OOK modulation:
Lcd_Ds18b20_ModulatedData.ino
/**
* PURPOSE:
* Get the temperature from a OneWire-based sensor (e.g. DS18B20), display it in a LCD
* and send the temperature data through the pin 13 in an OOK modulation
*
* TARGET SYSTEM:
* Arduino Leonardo + Custom "Temperature & LCD shield"
*
* NOTES:
* For the LCD part I’ve been based on the public domain code at:
* https://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay
*
* For the OneWire part there is plenty of information in Internet like this one:
* https://create.arduino.cc/projecthub/everth-villamil-ruiz/temperature-sensor-ds18b20-3decfc
*
* Code tested with Arduino IDE 1.6.4
*
* LICENSE:
* Copyright (C) 2017 Jose Maria Ortega
* Distributed under the GNU GPLv3. For full terms see the file LICENSE
*/
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
break;
case clock_base_divider_one_half:
PLLFRQ |= 0x20;
freq_clock = freq_clock/3*2;
break;
case clock_base_divider_two:
PLLFRQ |= 0x30;
freq_clock /= 2;
break;
}
long counter_counts;
if (required_freq > 0)
{
counter_counts = freq_clock/(1 << timer_divider_pow)/required_freq;
if (counter_counts < 1)
counter_counts = 1;
else if (counter_counts > 255)
counter_counts = 255;
}
else
{
counter_counts = 255;
}
OCR4C = (unsigned char)counter_counts;
OCR4A = 0;
DDRC |= 1 << 7;
TCCR4A = 0x82;
pwm13_dutty_half = (OCR4C-1)/2;
}
void setup()
{
configure_pwm13(clock_base_divider_one_half, 1, 110000);
sensors.begin();
lcd.begin(16, 2);
lcd.print("20/2/2017 +--.--");
lcd.setCursor(0,1);
lcd.print("Jose M. Ortega");
lcd.display();
}
void loop()
{
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
lcd.setCursor(11,0);
lcd.print(tempC);
// NOTE:
// To convert a float to a char array we could use, in theory, this code:
// int chars = snprintf(frame, sizeof(frame), "T=%.2f", tempC);
// However it shows 'T=?'. That's because only the light version of printf is included, without
// float management. If we want to use it we should add these flags to the compiler line:
// '-Wl,-u,vfprintf -lprintf_flt'
// ALTERNATIVE: Use the function 'dtostrf'
// More info:
// https://totaki.com/poesiabinaria/2011/12/utilizar-float-con-sprintf-y-derivados-en-arduino/
// http://www.atmel.com/webdoc/AVRLibcReferenceManual/ch20s10s02.html
Design of a low-cost device for data transmission over power lines 59/181
// http://playground.arduino.cc/Main/FloatToString
char frame[16];
int chars = snprintf(frame, sizeof(frame), "%d:", frame_counter++);
// Convert float to string with 2-digits precision
dtostrf(tempC, 0, 2, frame+chars);
chars = strlen(frame);
frame[chars++] = '\n';
send_message(frame, chars);
delay(DELAY_BETWEEN_MESSAGES_MS);
}
Now, the OOK wrapped temperature is available through the pin 13 (the blue wire in the below figure):
Figure 47. The temperature REPORTER device
With the oscilloscope we can check the OOK encoding of the message (<counter>: <temperature>):
We cannot connect the pin 13 directly to the mains (through the AC coupler module) because the Arduino
Leonardo can only source 40 mA in its outputs, which is not enough to deal with the typical impedance on
the AC line.
The goal of this section is not to build a high featured amplifier, but a basic, simple and low-cost amplifier
stage with the minimum components required to carry out the communication over the 230VAC line.
For that, I have relied on a Push-Pull amplifier topology[22][23] which ideally works as a voltage follower.
The proposed circuit is a very basic stage, good enough for the tests but not reliable enough for a robust
communication. I have preferred the use of discrete components over integrated circuits (like the Power
Amplifier in the AFE031, or the LM386 in the audio scope) because individual components give more
customization possibilities to a particular scenario. Furthermore, its usage can reveal (as we will see) some
important effects and considerations involved in the transmission that might otherwise pass unnoticed.
The proposed Push-Pull amplifier belongs to the Class B category. It does not produce voltage output when
the input is idle (therefore, does not waste power in the transistors when idle). For our REPORTING device
this characteristic is essential because data packets are only sent sporadically.
In the following sections I am going to detail the modifications done from a basic Push-Pull topology to the
final version of the circuit to cover the needs of this project. I will include some analysis with a SPICE-based
tool. This analysis may be useful to improve the stage in future iterations while keeping circuit simplicity
and cost.
• It must follow the principles of a voltage follower. Some attenuation is tolerated, though.
• Some distortion is accepted whenever the signal can be properly demodulated at the receiver side.
• It must be based on 5 V to reuse the power supply that serves other electronics (as the Arduino
board). This is required to reduce the overall size and cost of the proposal.
To analyze the different versions of the circuits proposed I have used the LTspice tool (see 6 Annex I. Tools).
For a more realistic simulation I have downloaded the models of the BJT transistors that I have used in the
tests, a NPN TIP122 and its dual PNP TIP127 (see 7 Annex II. LTspice - How to add third party models). I
have chosen those transistors just because they are able to manage high currents, because are popular and
because I had them available. In future versions we should fine-tune the choice of the transistors depending
on the exact requirements for a given scenario.
• the current at the collector of the transistors, to detect possible wrong behaviors
• the power delivered by the power supply to feed the load and the internal amplifier operation
Design of a low-cost device for data transmission over power lines 61/181
In conclusion, the polarizing resistors should be “proportional” to the expected load impedance: for higher
impedance values, polarizing resistors can be higher.
I have configured a SPICE analysis to measure different variables. In the following pages I am going to
enclose the graphs related to those variables for different configurations:
Dark-
Vo V(vo) The output voltage, which should ideally follow the input
red
Iq1 The current ingoing into the Qa1 and Qa2 collectors. The target is
Ix(QaN:C) Blue to check that both transistors properly balance the delivered
Iq2 powered (each working on the corresponding half cycle)
V(vs1)*I(Vs1) + Power delivered (notice the negative sign in the graphs) by the
Ps Green
V(vs2)*I(Vs2) power supplies
Note: In the graphs, these variables appear in inverted order (from bottom-to top).
62/181 Design of a low-cost device for data transmission over power lines
These are the results we get for our first basic circuit:
Figure 49. Push-Pull amplifier - Basic circuit - SPICE analysis
V(vo)*I(Ro)
90µW
45µW
0µW
V(vs1)*I(Vs1)+V(vs2)*I(Vs2)
-9.730mW
-9.765mW
-9.800mW
-Ix(Qa2:C)
160µA
60µA
-40µA
Ix(Qa1:C)
160µA
60µA
-40µA
V(vo)
1.0V
0.0V
-1.0V
V(vi)
1.0V
0.0V
-1.0V
0µs 10µs 20µs 30µs 40µs 50µs 60µs 70µs 80µs 90µs 100µs 110µs
From this first analysis we can conclude that, for a load of 10 kΩ:
• Both transistors (Qa1 and Qa2) properly balance the sunk and sourced current per half cycle.
• In the power scope, Po and Ps have a sinusoidal shape that doubles the frequency of the input signal.
For the power graphs, besides looking at the shape of the waveform and get P MAX and PMIN, it is also useful to
get the Power Average (PAVG), which is defined as the mean of the product of instantaneous voltage and
current. We can obtain it from two different ways:
• On the one hand, we can get PAVG by directly averaging the Po or Ps graphs. For a periodic and
symmetrical waveform (as the sinusoidal wave), the average is just the middle point of the wave.
• On the other hand, for a purely resistive load, we can conveniently use the root-mean-square 8 on
voltage or current to calculate it: PAVG = IRMS2·R = VRMS2/R. If we are dealing with sinusoidal
waveforms, we can quickly calculate the RMS value from the amplitude: IRMS = IP/√2, VRMS = VP/√2.
Looking at the above graphs we see that our Vo has an amplitude close to 1 V, which would mean a
VO_RMS = 1/√2 = 0.71 V. Considering the impedance of the load (10 kΩ), this would result in a
PO_AVG = 0.712/10k = 50 μW (it would be slightly lower if considering the small voltage drop in Vo).
If we look at the V(vo)*I(Ro) graph (the Po in light red), the middle value is close to 45 μW.
Looking at the power delivered by the power supply (the Ps in light green), we see that the middle value is
9.765 mW. This power includes the 45 μW consumed by the load but also the energy wasted by the
polarizing resistors and some leaking on the transistors.
8 A more extensive explanation about RMS can be found in https://en.wikipedia.org/wiki/Root_mean_square
Design of a low-cost device for data transmission over power lines 63/181
We can now check with lower impedance values at Ro to see how the amplifier behaves. I have miniaturized
the graphs to simplify the reading, focusing on the axes values and the rough shapes of the involved waves:
Ro = 5 kΩ Ro = 1 kΩ
V(vo)*I(Ro) V(vo)*I(Ro)
150µW 330µW
0µW 0µW
V(vs1)*I(Vs1)+V(vs2)*I(Vs2) V(vs1)*I(Vs1)+V(vs2)*I(Vs2)
-9.73mW -9.5mW
-9.88mW -10.8mW
-Ix(Qa2:C) -Ix(Qa2:C)
180µA 540µA
-60µA -120µA
Ix(Qa1:C) Ix(Qa1:C)
200µA 540µA
-60µA -120µA
V(vo) V(vo)
1.0V 600mV
-1.0V -600mV
V(vi) V(vi)
1.0V 1.0V
-1.0V -1.0V
0µs 20µs 40µs 60µs 80µs 100µs 0µs 20µs 40µs 60µs 80µs 100µs
Ro = 100 Ω Ro = 10 Ω
V(vo)*I(Ro) V(vo)*I(Ro)
2.2mW 16mW
0.0mW 0mW
V(vs1)*I(Vs1)+V(vs2)*I(Vs2) V(vs1)*I(Vs1)+V(vs2)*I(Vs2)
-9mW 0mW
-21mW -110mW
-Ix(Qa2:C) -Ix(Qa2:C)
5.0mA 40mA
-0.5mA -4mA
Ix(Qa1:C) Ix(Qa1:C)
5.0mA 40mA
-0.5mA -4mA
V(vo) V(vo)
540mV 400mV
-540mV -400mV
V(vi) V(vi)
1.0V 1.0V
-1.0V -1.0V
0µs 20µs 40µs 60µs 80µs 100µs 0µs 20µs 40µs 60µs 80µs 100µs
• For a high impedance (>= 5 kΩ), Vo is close to Vi, as expected. However, for lower impedance
values, Vo decreases with Ro. In other words, our amplifier as an attenuation that depends on the
load. This makes the basic Push-Pull stage to work as a voltage follower only if within a reasonable
impedance range. A very interesting improvement to overcome this issue would be to add a feedback
loop with an operational amplifier, as mentioned in the bibliography[22].
• For low impedance values (<= 100 Ω), Vo suffers noticeable distortion when crossing 0 V. It is due
to a time gap where both, PNP and NPN, are OFF.
• Concerning the delivered power (Ps), we see that in idle mode (when Vi = 0 V) the amplifier always
consumes around 9.8 mW, mainly due to the current in the polarizing resistor network. Effectively,
assuming a voltage drop of 0.3 V in the diodes, we would have a power consumption there of about
(5-2·0.3)2/2k = 9.7 mW.
64/181 Design of a low-cost device for data transmission over power lines
• Concerning the relation between Ps and Po, we can see that the power supplies need to deliver much
more power than the consumed by the load. So, our amplifier is quite inefficient:
◦ For a high Ro (in the kΩ range), Po is < 1 mW. The power consumed by the polarizing network
(close to 10 mW) is much more significant.
◦ For a low Ro, as 10 Ω, we have instantaneous peaks at Ps of about 110 mW for Po peaks of
16 mW. The difference between both is dissipated by the transistors in the form of heat. In
particular, the collector current (Iq1 or Iq2) reaches peaks of 40 mA for a Vo of 400 mV. That
means a peak of instantaneous power in the transistor of 40mA * (2.5 - 400mV) = 84 mW. Thus,
the power dissipated at the transistor is due to the effort it must do to drop 2.5 V to 0.4 V.
We can repeat the same measures by doubling the input, from the previous 2 V PP to 4 VPP:
-2.0V -2.0V
0µs 20µs 40µs 60µs 80µs 100µs 0µs 20µs 40µs 60µs 80µs 100µs
In these graphs we can observe that the ratio of power supplied versus consumed by the load is much better
now because the lower voltage drop required at the transistors. For example, for Ro = 100 Ω:
Finally, and just for reference, find following a test with a very low impedance (1Ω) for Vi = 2 V PP and 4 VPP:
-1.0V -2.0V
0µs 20µs 40µs 60µs 80µs 100µs 0µs 20µs 40µs 60µs 80µs 100µs
Design of a low-cost device for data transmission over power lines 65/181
Ra1
Vs 1k Now Vi represents an AC signal having a DC
5V vqa1b Qa1 component, which will be removed by the Cd
tip122
capacitor.
Da1 .inc TIP122.LIB
.tran 110u
Repeating the same analysis carried out in the previous section give us this:
Figure 51. Push-Pull amplifier - Single power supply - SPICE analysis
V(vo)*I(Ro)
300µW
150µW
0µW
V(vs)*I(Vs)
0mW
-10mW
-20mW
-Ix(Qa2:C)
280µA
60µA
-160µA
Ix(Qa1:C)
280µA
80µA
-120µA
V(vo)
2.0V
0.0V
-2.0V
V(vi)
6.0V
3.0V
0.0V
0µs 10µs 20µs 30µs 40µs 50µs 60µs 70µs 80µs 90µs 100µs 110µs
66/181 Design of a low-cost device for data transmission over power lines
Ro = 1 kΩ Ro = 100 Ω
V(vo)*I(Ro) V(vo)*I(Ro)
1.8mW 16mW
0.0mW 0mW
V(vs)*I(Vs) V(vs)*I(Vs)
-6mW -5mW
-20mW -65mW
-Ix(Qa2:C) -Ix(Qa2:C)
1.3mA 13mA
-0.2mA -1mA
Ix(Qa1:C) Ix(Qa1:C)
1.3mA 13mA
-0.2mA -1mA
V(vo) V(vo)
1.5V 1.4V
-1.5V -1.4V
V(vi) V(vi)
4.8V 4.8V
0.4V 0.4V
0µs 20µs 40µs 60µs 80µs 100µs 0µs 20µs 40µs 60µs 80µs 100µs
Ro = 10 Ω Ro = 1 Ω
V(vo)*I(Ro) V(vo)*I(Ro)
130mW 800mW
0mW 0mW
V(vs)*I(Vs) V(vs)*I(Vs)
0mW 0.0W
-550mW -4.4W
-Ix(Qa2:C) -Ix(Qa2:C)
120mA 900mA
-10mA -90mA
Ix(Qa1:C) Ix(Qa1:C)
110mA 880mA
-10mA -80mA
V(vo) V(vo)
1.2V 1.0V
-1.2V -1.0V
V(vi) V(vi)
4.8V 4.8V
0.4V 0.4V
0µs 20µs 40µs 60µs 80µs 100µs 0µs 20µs 40µs 60µs 80µs 100µs
We see that results are similar to the double-voltage-supply case. The main difference is in the delivered
power (Ps): peaks are higher but have half the frequency compared to the single-supply case. That is due to
the effect of capacitors in storing energy. The average value is similar.
If we focus on the case Ro = 100 Ω, we see that in both cases the Vo has the same level (close to 1.4 V PP) and
the current crossing the collector of the transistors is also the same (13mA peak). All the graphs are very
similar except for the power supplied by Vs:
• In single-voltage-supply with capacitors, it is a different shape, with a periodicity of 111 kHz and
reaching peaks up to 65 mW.
Design of a low-cost device for data transmission over power lines 67/181
VOLTAGE DIVIDER
The simplest option to attenuate a signal is through a resistive voltage divider (I have also included a Cr
capacitor to remove the DC component in a first stage, much faster than Cd does):
Figure 52. Push-Pull amplifier - Voltage divider
vs
Ri
vi vri Ra1
Vi Vs 1k
50 Cr 5V vqa1b Qa1
0.1µ tip122
Da1 .inc TIP122.LIB
vrr1
1N4148 Ca
vcd vo
Rr1 vqo
150 Da2 10µ
1N4148
Cd
vrr2 vqa2b Qa2
1µ tip127
Rr2 Cf .inc TIP127.LIB
Ra2 Ro
330 1p 1k 10k
.tran 110u
One important drawback of the resistive divider is the load-effect: Rr1 and Rr2 must be much lower than the
input impedance of the next stage to do not be affected by it. A better approach here might be adding an
intermediate stage with a high input impedance (like a voltage follower with an operational amplifier). But
for this project, where the main objective is to evaluate the feasibility of the proposed system, some load-
effect can be tolerated.
The input impedance of our Push-Pull amplifier is low, so we need to use low values for Rr1 and Rr2. The
lowest limit for these resistors comes from the maximum current the I/O pins of the Arduino Leonardo can
source (40 mA). The decision rule here is more the protection against load-effects than power consumption.
In fact, power consumption at I/O pins is not a key factor here because, for this project, the output is enabled
only at sporadic transmissions of short data Figure 53. ATmega32U4 - I/O Pin Output Voltage vs.
packets. Source Current (Vcc = 5V)
If we assume a Ro connected to the output pin of the Arduino, the output voltage would be:
Ro Vcc⋅Ro Vcc Vo
Vo=Vcc → Ri+ Ro= → Ri=Ro( −1)→Ro=Ri
Ri+ Ro Vo Vo Vcc−Vo
On the other hand, we can express Ro as a function of Io:
We can see that the output impedance of the I/O pin (Ri here) depends on the current delivered (besides the
temperature). For our analysis I am going to use the typical 50 Ω value.
In the physical implementation of this circuit I will place a potentiometer in Rr2. Rr1 will limit the maximum
output current. With a Rr1 = 150 Ω and assuming the worst case in the potentiometer (Rr2 = 0), we have a
IMAX = 5V/(150+50) = 25mA, which is below the maximum current the Arduino I/O pin can deliver (40 mA).
For Vi we use now a 5 V square waveform (the Arduino output): Vi vi 0 PULSE(0 5 10u 0 0 4.5u 9u 10).
0.6V
-1.6V
V(vo)*I(Ro)
440µW
220µW
0µW
V(vs)*I(Vs)
2mW
-9mW
-20mW
-Ix(Qa2:C)
800µA
50µA
-700µA
Ix(Qa1:C)
1.4mA
0.3mA
-0.8mA
V(vo)
2.4V
0.4V
-1.6V
V(vi)
5.4V
2.4V
-0.6V
0µs 10µs 20µs 30µs 40µs 50µs 60µs 70µs 80µs 90µs 100µs 110µs
Design of a low-cost device for data transmission over power lines 69/181
At the top, I have added the graph corresponding to the voltage after the resistive divider, in order to check
that the output (vo) continues to follow the input (vrr2).
Looking at V(vrr2) we can see that with a Rr2 = 330 Ω, we turn the 0 to 5 V from the Arduino I/O pin into
approximately -1.4 V to 1.4 V (after a transient). In these conditions the output (Vo) goes from -1 V to 1 V,
which fits with our target of injecting a 2 VPP signal to the AC line.
LOW-PASS FILTER
To end this chapter, I am going to discuss the inclusion of the Cf capacitor into the circuit.
The Arduino board generates square waves. In order to reduce the harmonic content and avoid injecting other
frequencies to the power line (which could interfere other existing systems), a low-pass filter is
recommended. The most basic form of a low-pass filter is the Cf capacitor.
Through experimentation I have found that a proper and easily available capacitance to filter signals greater
than 100kHz could be Cf = 6.8 nF. To confirm it, I have done a simulation of Vi vs. Vo with more cycles and
calculated the FFT:
Cf = 1 pF Cf = 6.8 nF
V(vo)*I(Ro) V(vo)*I(Ro)
440µW 330µW
220µW 165µW
0µW 0µW
V(vs)*I(Vs) V(vs)*I(Vs)
2mW
-2mW
-6mW
-9mW -10mW
-14mW
-20mW -18mW
V(vo) V(vo)
2.4V 1.8V
1.6V
0.8V
0.2V
0.0V
-0.8V
-1.6V -1.5V
V(vi) V(vi)
5.4V 5.0V
4.2V 4.0V
3.0V 3.0V
1.8V 2.0V
0.6V 1.0V
-0.6V 0.0V
0µs 20µs 40µs 60µs 80µs 100µs 120µs 140µs 160µs 180µs 200µs 0µs 20µs 40µs 60µs 80µs 100µs 120µs 140µs 160µs 180µs 200µs
720mV 630mV
640mV 560mV
560mV 490mV
480mV 420mV
400mV 350mV
320mV 280mV
240mV 210mV
160mV 140mV
80mV 70mV
0mV 0mV
0KHz 50KHz 100KHz 150KHz 200KHz 250KHz 300KHz 350KHz 400KHz 450KHz 500KHz 0KHz 50KHz 100KHz 150KHz 200KHz 250KHz 300KHz 350KHz 400KHz 450KHz 500KHz
The top of the scale of the FFT graph at left is 800 mV, while it is 700 mV at right. So, a first side effect of
the capacitor is that it slightly attenuates the main signal. I have scaled the graphs this way to be able to
visually compare the ratio of the harmonics, at 222 kHz, 333 kHz, 444 kHz, etc. We can see that the ratio
between the peaks of the harmonics and the main signal is lesser with the Cf = 6.8 pF. We can also appreciate
the softening effect of the filter in the Vo graph at the top-right figure.
For a narrower and more selective filtering, we should consider designing it with a greater order (with extra
capacitors and inductors).
70/181 Design of a low-cost device for data transmission over power lines
vdm
.inc TIP122.LIB
Da1
vrr1
1N4148 Ca Dm1
vcd vo QTLP690C
Rr1 vqo
vqmc
150 Da2 10µ
1N4148
Cd Rm2
vqmb Qm1
vrr2 vqa2b Qa2 BC547C
1µ tip127 10k
Cf .inc TIP127.LIB
Rr2 Ra2 Ro
330 6.8nF 1k 10k
.tran 210u
• It indicates that the Vo voltage is high enough, which also means that the load impedance is not too
low. More in detail, we have already seen that our Push-Pull amplifier is highly dependent on the
load: for low impedance values, Vo decreases significantly. If Vo is below the threshold to turn on
the base-emitter junction of the Qm1, the LED will not flash. This way, the LED can be used as a
way to roughly check the load impedance.
The consumption of a refrigerator or a TV is usually below 100 W. The consumption of a microwave could
be around the 1000 W.
Note however that, as we will see in the chapter 4.8 Data communication through the 230VAC line, in the
real tests, sometimes we have a much lower instantaneous impedance (at least, for the 110 kHz frequency),
resulting in significant voltage drops at the Push-Pull amplifier output.
Design of a low-cost device for data transmission over power lines 71/181
In the above graphs we can see that the Rr2 potentiometer is a valid way to adjusts the Vo output. Note
however, that it has a modest effect for values higher than 150 Ω and a rapid effect below that (e.g. at 50 Ω
there is no significant output).
72/181 Design of a low-cost device for data transmission over power lines
Just for reference, find following a last simulation for Rr2 = 1 kΩ at a very low impedance, Ro = 10 Ω:
Figure 56. Push-Pull amplifier - Final proposal - SPICE analysis
V(vo)*I(Ro)
130mW
65mW
0mW
V(vs)*I(Vs)
0mW
-300mW
-600mW
V(vo)
1.2V
0.0V
-1.2V
V(vrr2)
3.2V
0.8V
-1.6V
V(vi)
5.0V
2.3V
-0.5V
0µs 40µs 80µs 120µs 160µs 200µs
An interesting conclusion of these tests is that we do not need to dedicate efforts to thermal dissipation (extra
heat sinks are not required). If, for example, we look at the scenario Rr2 = 1 kΩ and Ro = 50 Ω (i.e., low
impedance in the AC line), we see that the power delivered by the power supply and mostly consumed by the
load and the transistors, is easily manageable (< 100 mW).
For the Push-Pull amplifier I have used a breadboard. This way, we can also easily change components and
experiment with.
Figure 57. Push-Pull amplifier - Implementation on a breadboard
For Rr2 I have used 1 kΩ potentiometer to be
able to easily adjust the level of the output
voltage (vo).
The new software has been identified with the version 0.2. Both versions are available in GitHub:
3.5.2 Changes
Find following a summary of the changes introduced on v0.2:
NEW APPLICATIONS
plc-cape-oscilloscope Application in C++ that displays, in real time, the ADC captured data.
NEW PLUGINS
encoder-wav Reads a WAV file and populates the output buffer with proper samples.
NEW FEATURES
The plugin engine has been improved for better modularization. Now
plugins can declare the custom settings they accept so that the plc-cape-
Plugin-based settings
lab application is able to dynamically display them on the configuration
menus.
74/181 Design of a low-cost device for data transmission over power lines
Some encoder and decoder plugins have been reviewed for a more robust
Plugins
execution.
Substantial code refactoring has been carried out for better usability and simpler
Refactoring
maintenance.
Table 13. Changes in the software framework
Note that the introduction of a C++ project into the framework (the plc-cape-oscilloscope) has required some
changes in the public headers for the proper coexistence of both type of projects (plain-C and C++):
#ifndef MY_PUBLIC_HEADER_H
#define MY_PUBLIC_HEADER_H
#ifdef __cplusplus
extern "C" {
#endif
// ... HEADER DECLARATIONS ...
#ifdef __cplusplus
}
#endif
#endif /* MY_PUBLIC_HEADER_H */
Switch from It seems (to be confirmed) that the ARM processor of the BBB has native
float types to support to double types. Using float just adds some extra instructions which are
double required to adapt them to double before reaching the Floating Point Unit.
In the current custom driver, the ADC is always configured with a capturing rate
of 200 ksps. Due to the Nyquist theorem and the undersampling effect (aliasing),
ADC
a signal at 105 kHz and another one at 95 kHz are indistinguishable from the
configurable
ADC perspective. In order to properly process the CENELEC-B band (from 95
sampling rate
kHz to 125 kHz) we should be able to configure the ADC sampling rate. For
example, at 180 ksps the “symmetry axis” will move from 100 kHz to 90 kHz.
Current ADC driver is based on interrupts and ISRs to move back and forth the
ADC FIFO by
ADC data from FIFO to RAM. A DMA approach will be more stable and will
DMA
reduce CPU load.
Table 14. Future improvements in the software framework
Design of a low-cost device for data transmission over power lines 75/181
3.5.4.1 FFTW3
The plc-cape-oscilloscope and plc-cape-freq-response applications use the GNU Fast Fourier Transform
package fftw3[24] to get the representation of the captured signal in the frequency domain.
The binary of the library (libfftw3) comes installed in the off-the-shelf Debian image but this is not the case
for the corresponding developer package (libfftw3-dev). So we need to do it explicitly:
3.5.4.2 GTK+/Cairo
The plc-cape-oscilloscope tool represents the ADC captured data in real time through a GUI (Graphical User
Interface). There are different frameworks available for that purpose, as GTK or Qt. I have chosen the GTK
due to its popularity and because it is lighter and faster than Qt.
As in the FFTW3 case, the developer versions of the libraries (libgtk-3-dev) are not included by default:
Just a note about portability across different platforms: the GTK version in the BBB is typically lower than
in a desktop-PC. For example, I have GTK 3.4 in my BBB and 3.10 in my Ubuntu. As a result, sometimes
we can face some different behaviors depending on the target platform. In such cases (if no alternative is
found) I have added conditional compilation clauses based on the __arm__ or the GDK_VERSION_3_10
definitions:
GtkWidget *Application::create_toolbar_box(void)
{
// In my BBB I need to create the toolbar with GTK_ORIENTATION_VERTICAL to be properly shown
// TODO: Analyze why this patch is required
#ifdef __arm__
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#endif
...
3.5.4.3 Libxml2
In the 0.2 version of the framework, the plc-cape-lab application loads the profiles from an XML file. The
plc-cape-oscilloscope tool also loads the initial settings from an XML file. For that purpose I have relied on
the libxml2 library[27]. To install it, use apt-get install libxml2-dev, like in previous sections.
This library is distributed under a MIT License9. Note that this type of license is more permissive than the
GPL, and therefore MIT-based libraries can be used in GPL projects without conflict 10:
Many of the most common free software licenses, especially the permissive licenses, such as the original MIT/X
license, BSD licenses (in the three-clause and two-clause forms, though not the original four-clause form), MPL 2.0,
and LGPL, are GPL-compatible. That is, their code can be combined with a program under the GPL without conflict
and the new combination would have the GPL applied to the whole (not the other license).
In plc-cape v0.2 this procedure continues to be the way to generate the native binaries for the embedded
platform. However, the new version offers a new interesting feature, the Emulator, which allows the
execution of the whole framework in a desktop-PC (usually based on x86 or amd64 architectures). To build
the native binaries for the desktop-PC, we have two ways:
• We can rely on a new Eclipse-based environment which seamlessly coexists with the direct-
compilation environment.
• The Eclipse IDE offers a comfortable and more efficient method to build the executables from a
powerful desktop-PC. In fact, with the proper configuration, it can also be used to build executables
for the BBB (cross-compilation).
• In the debugging phase, a GUI is much more comfortable than direct interaction with GDB.
• Eclipse provides very interesting features for faster development compared to simple editors. For
example: auto-completion, on-the-fly preprocessing for early error detection, code-style auto-
formatting, refactoring functionality, automatic dependency generation, etc.
For the sake of simple maintenance, these guidelines have been followed:
• In order to keep the main plc-cape tree structure as clean as possible, the Eclipse IDE files have
been placed in a separate tree. This preserves the independence of the plc-cape tree over third-
party tools (like the Eclipse IDE itself). Moreover, in this configuration, the intermediate files
created during the building process are also placed in the separate tree.
• Eclipse allows for different building strategies: manual make, auto-make, etc. For simple
maintenance and best efficiency, the auto-make option has been chosen. This means that we have
two variations for each project: the Eclipse-based and the make-based. This involves some
synchronization effort. For example, when adding a new library reference to a project, it must be
done at both, the Eclipse project and the direct makefile.
The main benefit of Eclipse-based makefiles versus manually-managed is that Eclipse tracks with
exactitude all the dependencies such that only the strictly affected files are used in the rebuilding
process. On the contrary, in manually-managed-makefiles I have specified rough dependencies to
folders instead of files for a simpler maintenance, resulting, sometimes, in unnecessary rebuilds (this
is not a true problem but just an inefficiency, so we can live with. The maintenance simplicity of this
method is worth the extra compilation time).
• To minimize the synchronization effort, the Eclipse projects have been created using the linked
folders feature. With it, the Eclipse projects are automatically synchronized when new files are
added or modified, even when these actions are carried out outside the IDE.
• In some occasions I have also used a file shared between both types of projects. For example, I have
added a file makefile.targets when some resource files (like *.ui, *.cfg, etc.) need to be copied to the
output folder. In both cases (Eclipse compilation vs direct make), the building process automatically
executes the corresponding actions declared there.
• For simpler maintenance, the binaries that result from the compilation process are placed in separate
folders depending on the target (BBB vs desktop-PC).
• For resource location, relative paths based on global environment variables have been used instead
of absolute paths. This simplifies future project reorganizations.
To put in place the out-of-tree compilation strategy[1] in Eclipse, I have first configured my Ubuntu operating
system:
1. I have defined DEV_SRC_DIR and DEV_BIN_DIR as global OS environment variables (with the
export command). They point to the folders where the source code and the binaries reside.
To make these variables permanently available I have added the export commands to the user’s
profile in ~/.profile:
$ cat ~/.profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
[...]
# Global support to DEV environment variables
export DEV_SRC_DIR=/media/x
export DEV_BIN_DIR=/media/y
Design of a low-cost device for data transmission over power lines 79/181
2. I have then restarted the user’s session (to make the changes effective) and checked that my new DEV
variables are in the global environment:
Now, we can create an out-of-tree project from Eclipse following these steps:
Figure 59. Eclipse IDE - Linked Folders
As already commented, the main advantage of using Linked Folders is that when we update the source
folder with new files (from Eclipse or from elsewhere), Eclipse automatically synchronizes the folder.
This allows working in both, the desktop-based PC environment or the embedded environment, in a very
comfortable way.
80/181 Design of a low-cost device for data transmission over power lines
3.5.6 Emulator
The version 0.1 of the plc-cape framework is tied to the BeagleBone Black. We could compile the source
code in a desktop-PC (with a simple make) and get functional binaries (except for the customized drivers on
SPI and ADC). However, the compiled applications will complain at starting because they expect the
customized drivers to be running (and the associated peripherals to be present).
The version 0.2 introduces an emulation mode that allows the applications to be executed in a desktop-PC. It
is based on the ALSA engine[28] (apt-get install libasound2-dev) and is implemented this way:
• To simulate the DAC operation at TX, the ALSA playing engine is used. As a result, the emulator
produces audible sounds (if the signals are generated in the audible band, 20 Hz to 20 kHz).
• To simulate the ADC operation at RX, the ALSA recording engine is used. A microphone can be
used to capture samples and test some real effects which are also present in the communication
through the power line, like distortions, attenuation, noise…
• To simulate the TX-RX loop in the AFE031 Calibration modes (see 9 Annex IV. AFE031
Calibration modes), an internal pipe is used. This involves memory operations only:
The emulation is implemented in a library used by any plc-cape-based application. This way, all the
developed applications can be executed in the desktop-PC with some degree of useful simulation. For
example:
• plc-cape-lab can be used to generate tones, reproduce WAVs, generate and interpret Morse code, etc.
To simplify the execution of the emulator, an auto-detection mechanism has been implemented which checks
for the presence of a true BBB: if it is not found, the emulation mode is automatically entered.
Note that in x86 Emulation we are compiling the source code against different versions of the third-party
libraries. We are also using a different version of the gcc compiler. Therefore, the final x86-based application
may exhibit slight differences with the ARM-based one. As an example, the plc-cape-oscilloscope tool has a
different GUI look depending on the target (see 3.5.7.1 plc-cape-oscilloscope for some screenshots).
Using the emulator has interesting benefits over the direct development in the BBB:
• In emulation, the debugging phase is more comfortable and responsive because the binaries are
executed locally instead of requiring a remote connection with the target platform.
• By having different testing targets (BBB versus Emulation), we can discover more bugs.
• The emulator avoids the need to have a physical board. This can be very helpful in early
development stages, when the hardware may be yet unavailable.
3.5.7 Applications
A couple of new executables (plc-cape-oscilloscope and plc-cape-freq-response) have been added to help in
the full characterization of the system.
3.5.7.1 plc-cape-oscilloscope
Target plc-cape-oscilloscope
Purpose Build a tool that works as a cheap oscilloscope on the BBB to easily and quickly
check the data captured by the ADC
Details It simplifies the task of analyzing the received data without requiring an external
oscilloscope. Moreover, this tools exposes what the ADC of the BBB really gets,
which can be different from the corresponding analog signal.
For example: when measuring a 110 kHz sinusoid with external equipment, we
measure a real frequency of 110 kHz but when measuring it with the 'plc-cape-
oscilloscope' tool we get a signal of 90 kHz, which is the aliased version due to the
max sampling rate of the ADC (= 200 ksps).
Source code ./applications/plc-cape-oscilloscope
This is a typical screenshot of the application running in emulation mode (in Ubuntu 14.04.5):
Figure 60. plc-cape-oscilloscope - Screenshot
• It is based on the GTK+ engine for a rich GUI (Graphical User Interface).
• Compared to the measurements with a real oscilloscope, this application shows the digital samples
after the ADC capturing process, which is very convenient to analyze some effects like the
undersampling (aliasing) or the quantification.
82/181 Design of a low-cost device for data transmission over power lines
• It offers shortcuts to quickly configure the AFE031 PGAs (Programmable Gain Amplifiers) in the
reception chain (RX_PGA1 and RX_PGA2). This is useful to condition the received signal to
suitable levels for the ADC capturing process. A shortcut is also provided to allow switching
between CENELEC-A and CENELEC-B/C/D in the RX filter.
• The application allows to fully customize the captured graphs to simplify post-analysis. Additionally,
the graphs can be stored in PNG (pixel-based) or SVG (vectorial-based) depending on the needs.
• The samples captured can be exported to a format compatible with other third-party tools, as Octave.
• It is more comfortable than using an external oscilloscope because neither probes nor additional
connections are required.
• It allows defining different configuration profiles through an editable XML file which helps to
quickly setup the measurement environment for a given scenario.
This is a typical SVG capture of a 2 kHz ramp generated by the plc-cape-lab tool in calibration mode:
Figure 61. plc-cape-oscilloscope - Example of a SVG capture
By having a look at the above graph, we can see that in the top-right corner we have a series of indications.
For example we can get the whole area dimensions from the Viewer field:
The first unit indicates the total width of the area that is currently displayed in the graph (in this case 2
milliseconds).
The second unit indicates the Y-axis dimensions in the form of the central value followed by half the total
range. In the above example, the middle of the whole displayed area will correspond to 1500, the bottom
will be 1500-500 = 1000, and the top will be 1500+500 = 2000.
The Y-axis values correspond to the ADC captured data (like in the Octave graphs from the plc-cape-lab
tool). The main advantage of plc-cape-oscilloscope over plc-cape-lab is the real-time visualization, a very
interesting feature for a faster and more comfortable analysis at the receiver side.
In contrast to the Octave graphs, the FFT generated by this tool only plots half the digital frequency range,
from 0 to 0.5, avoiding redundant information. In our above example we can see a 10 divisions grid. With a
200 ksps sampling rate, each division corresponds to 100 kHz/10 = 10 kHz.
Design of a low-cost device for data transmission over power lines 83/181
Note: To appreciate the difference between “Export to SVG” and “Export to PNG”, zoom in these graphs.
The plc-cape-oscilloscope is a graphical tool. The real-time captured data will be displayed in a graphical
display if we have one attached to the BBB. The BBB has an integrated HDMI connector which is ready for
use in the off-the-shelf Debian image. We can also use an VGA display but in such a case we need an HDMI-
to-VGA converter (in fact, I have used this configuration in some test).
However, there is a more practical way to see the real-time data in the screen: through a remote SSH
connection. On a Linux-based distribution, a remote graphical connection can be set by means of ssh -X:
# ssh -X [email protected]
Debian GNU/Linux 7
BeagleBoard.org Debian Image 2015-03-01
[...]
# source init_env_samba_usb.sh
# cd $DEV_SRC_DIR/applications/plc-cape-oscilloscope
# ./run.sh 2 2
84/181 Design of a low-cost device for data transmission over power lines
I have successfully tested it in my desktop-PC with Ubuntu 14.04.5 (Linux Kernel 3.13.0) and in my mini-
laptop with Ubuntu 10.10 (Linux Kernel 2.6.35).
The output of plc-cape-oscilloscope is routed from the BBB to the desktop-PC where it is displayed. The
code runs on the BBB but the results are displayed on the PC. This is a very interesting option because we
can remotely manage our oscilloscope in a very comfortable way. The responsiveness of this solution is good
because the CPU load is divided between the BBB and the desktop-PC:
• the BBB is in charge of the ADC capturing data and issuing the graphical commands
• the Desktop-PC is in charge of the final graphical rendering, a heavy task that is assisted by the
powerful graphic card included in any modern PC
In the above graph we can see a sinusoid. I have generated it by opening another terminal session with the
BBB and executing plc-cape-lab configured to transmit a sine wave of 2 kHz in calibration mode:
Figure 63. plc-cape-lab - Screenshot of a remote SSH session from Ubuntu
Note: the above test takes a lot of resources in the BBB (concurrent transmission + reception + graphical
processing + floating point operations), leading the app to freeze quite often (to be fixed in the next version).
Design of a low-cost device for data transmission over power lines 85/181
3.5.7.2 plc-cape-freq-response
Target plc-cape-freq-response
Purpose Analyze the frequency response of a DAC to ADC path
Details This application generates sine waves sweeping over a predefined range of
frequencies and analyzing the captured signal to get the attenuation occurred per
frequency. Then, it stores in a file the data representing the frequency response of
the DAC to ADC loop
Note: this version only analyzes the effects on magnitude (not phase)
Source code ./applications/plc-cape-freq-response
• freq_response.csv: the transfer function for different frequencies (in voltage gain terms)
To analyze the content of these files I have created an Octave script (tools/octave/plc_freq_response.m) that
plots three graphs:
# ./plc-cape-freq-response --help
Usage: plc-cape-freq-response [OPTIONS]
Tool to get the frequency response H(f) of a given TX-RX path via the PlcCape board
For the arguments requiring an index from a list of options you can get more
information specifiying the parameter followed by just a colon
To execute the application, first load the PlcCape custom drivers (for ADC and DAC):
# $DEV_SRC_DIR/env/bbb/setup/load_drivers.sh 1 1
86/181 Design of a low-cost device for data transmission over power lines
Then, go to the location of the executable and run it with your custom parameters. For example, to get the
frequency response between 50 Hz and 200 kHz with 11 intermediate points in TX-RX calibration mode do:
# cd $DEV_BIN_DIR/applications/plc-cape-freq-response
# ./plc-cape-freq-response -A:50 -B:200050 -C:11 -D:20050 -F:0 -O:600 -R:400 -U:3 -T:2
SETUP
-----
Test: f_ini = 50 Hz, f_end = 200050 Hz, iterations = 11
DAC values (in DAC units)
Offset = 600.000000, Range = 400.000000, AC Mean = 127.323952
EXPECTED ADC values [in ADC units]
DC mean = 1912.000000, Range = 1400.000000, AC mean = 445.633820
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 50 Hz...Samples captured. DC mean = 1919.14, AC mean = 69.88
Running freq = 20050 Hz...Samples captured. DC mean = 1912.12, AC mean = 440.26
Running freq = 40050 Hz...Samples captured. DC mean = 1913.95, AC mean = 438.30
Running freq = 60050 Hz...Samples captured. DC mean = 1913.44, AC mean = 433.67
Running freq = 80050 Hz...Samples captured. DC mean = 1916.52, AC mean = 415.20
Running freq = 100050 Hz...Samples captured. DC mean = 1916.62, AC mean = 376.39
Running freq = 120050 Hz...Samples captured. DC mean = 1914.36, AC mean = 320.09
Running freq = 140050 Hz...Samples captured. DC mean = 1919.14, AC mean = 252.47
Running freq = 160050 Hz...Samples captured. DC mean = 1929.33, AC mean = 172.61
Running freq = 180050 Hz...Samples captured. DC mean = 1941.60, AC mean = 124.04
Running freq = 200050 Hz...Samples captured. DC mean = 1932.72, AC mean = 92.16
>> plc_freq_response_plot_all("10k-200k-cenelec-b")
DC mean = 1911.07, AC mean = 440.87, AC Range = 1409.00, FFT max at 20100.00 Hz
H max = 0.99, H min = 0.16
The Octave script returns a brief analysis of the samples captured at the reference frequency (given in the
-D:freq parameter of the command line):
1
N∑
DC mean x [n] Average value of all the captured samples
N
H max max(H [n]) Maximum and minimum values for the H[n] sequence
H min min(H [n]) (representing the H(f) frequency response)
We can save the plotted graphs to PNG files by using the plc_freq_response_save_plots script:
>> plc_freq_response_save_plots
Storing adc.pdf...
Storing freq_response.png...
Storing freq_response_log.png...
These are the results obtained for a test with an isolated PlcCape-v1:
H[n] in freq_respose.png (left) and freq_response_log.png (right) highlighting the CENELEC-B band
And this is the graph for the samples captured at 20050 Hz in the adc.pdf (and a zoom using a stem plot to
see the individual samples):
ADC data from adc.pdf. At right a zoom to 100 samples with plot and stem
Execution examples of this tool can be seen in the section 4.4 PlcCape RX chain or in 9 Annex IV. AFE031
Calibration modes.
88/181 Design of a low-cost device for data transmission over power lines
3.5.7.3 plc-cape-lab
Target plc-cape-lab
Purpose Laboratory tool to explore the main features offered by the PlcCape board
Details It is the main application for "laboratory work". It offers access to the different
configurable options of the AFE031.
Features:
• Multi wave generation
• Real-time and deferred DAC transmission
• Real-time and deferred ADC reception
• Capturing to file in Octave-compatible format for post-analysis
• Configure main AFE031 parameters: CENELEC band, gains, calibration
modes, etc
• Time measurements
Source code ./applications/plc-cape-lab
plc-cape-lab v0.2 introduces two important new features: XML profiles and plugin-specific settings.
XML PROFILES
In plc-cape-lab v0.1 the configuration profiles where hard-coded. When we required some setting to be
modified for a specific test, we had to do that in the source code and then recompile it.
In the new version, the profiles are defined in an editable XML file (profiles.xml) that is loaded when the
application is started. This considerably simplifies the management of the configuration settings associated
to the different testing scenarios: TX-only, RX-only, TX-RX loop, filtering parameters, etc:
profiles.xml
<plc-cape-lab.profile_definitions>
<profiles>
[...]
<profile id="loop_ramp_2k" inherit="loopback" title="LOOP Ramp 2kHz">
<app-settings>
<setting id="samples_to_file">1000</setting>
</app-settings>
<encoder-settings plugin="encoder-wave">
<setting id="stream_type">ramp</setting>
<setting id="freq">2000</setting>
<setting id="offset">800</setting>
<setting id="range">400</setting>
</encoder-settings>
<decoder-settings plugin="decoder-raw"/>
</profile>
<profile id="tx_2kHz" inherit="tx_pga" title="TX 2kHz">
<encoder-settings plugin="encoder-wave">
<setting id="stream_type">freq_sinus</setting>
<setting id="freq">2000</setting>
<setting id="offset">800</setting>
<setting id="range">400</setting>
</encoder-settings>
</profile>
[...]
</profiles>
[...]
</plc-cape-lab.profile_definitions>
Design of a low-cost device for data transmission over power lines 89/181
Profiles can be selected from the user interface or through the command line:
# ./plc-cape-lab -P:tx_2kHz
The UI menu with the profiles is populated according to the tree structure defined in the profiles.xml itself.
Take a look at the existing profiles.xml for an example of how to do so.
PLUGIN-SPECIFIC SETTINGS
In v0.1 the settings available for plugin usage were globally defined in the plc-cape-lab application, a
strategy that goes against the encapsulation/modularity principle (there is an inter-dependency between the
plugin and plc-cape-lab).
In v0.2 each plugin informs the plc-cape-lab application about the settings it supports so that the UI can
dynamically show them.
/**
* @brief Asks for the settings accepted by the plugin
* @param handle Handle to the encoder-plugin
* @param accepted_settings_count The number of accepted settings
* @return
* A persistent pointer with a list of setting definitions.
* The pointer must not be released
*/
const struct plc_setting_definition *(*get_accepted_settings)(encoder_api_h handle,
uint32_t *accepted_settings_count);
Find following an example of the implementation of this function in the encoder-ook plugin:
The main menu in v0.2 is slightly different from the one in v0.111:
Figure 64. plc-cape-lab - Screenshot
Basically:
• The Profiles [P] sub-menu is now dynamically generated from the profiles.xml file.
• The Plugins [L] sub-menu is new. It allows the selection of a specific encoder or decoder plugin
among the available in the predefined directory.
• The Settings Encoder [E] and Settings Decoder [D] are new sub-menus for the
configuration of the plugin-specific settings.
3.5.8 Plugins
Three new plugins have been developed:
• encoder-morse and decoder-morse, to check the interoperability with existing standardized systems
Some improvements have also been introduced in the existing plugins as:
• The demodulation algorithms have been improved for better reliability. In v0.1 the demodulation
was carried out with the abs() function, ideal for performance (very fast) but only acceptable for a
single carrier and low noise scenario. In v0.2 some steps have been taken in coherent demodulation
(which requires much more computational effort)
• In encoder-wave (the plugin in charge of generating different wave patterns) I have added the
possibility to generate a square wave
11 For information about the operation with the plc-cape-lab application consult PlcCapeSoftwareFramework.pdf[1]
Design of a low-cost device for data transmission over power lines 91/181
3.5.8.1 encoder-wav
Target encoder-wav.so
Purpose Reads a 16-bits WAV file and generates the corresponding samples in plc-cape
compatible format
Details Configurable settings
• filename
Source code ./plugins/encoder/encoder-wav
This plugin allows playing a WAV file through the AFE031 DAC. I have used it to verify the real-time
behavior of the custom SPI-to-DAC driver (some real-time pitfalls are difficult to be discovered with an
oscilloscope). The idea is to reproduce some suitable WAV and qualitatively check that the emitted audio is
clean. For example, real-time problems can be manifested as audio glitches.
To produce audible output we can use earphones, a speaker or a passive buzzer. I have used a small passive
buzzer from the 37-in-1-sensors-kit[11]:
Figure 65. encoder-wav - Test with a passive buzzer connected to PlcCape-v2
• Firstly, with the encoder-wave plugin (the multi-waveform generator) I have generated a 1 kHz tone
and confirmed the audible sound. I have also modified the frequency and the TX_PGA settings to
verify that the passive buzzer works as expected
• Secondly, with the new encoder-wav plugin I have selected a WAV file with a clean sound and
reproduced it repeatedly. The resulting audio is clear, indicating that the plugin and the customized
SPI driver are working as expected
Note that, due to the PlcCape-v2 patch (see 3.3.7.7 TX_F_OUT bridge), we are using TX_F_OUT (a
3.3V-based signal with low current sourcing capabilities) instead of PA_OUT (the 15V-based signal for
higher current sourcing). Even in these conditions the current sourced is enough to produce audible sound.
The first version of this plugin is very basic and only recognizes some specific WAV formats. In fact, the
target here was to check only that the system worked fine, not to build a WAV player.
In any case, this is an example of how the PlcCape framework can be used for other purposes than just PLC.
92/181 Design of a low-cost device for data transmission over power lines
3.5.8.2 encoder-morse
Target encoder-morse.so
Purpose Encodes data in Morse-code
Details Configurable settings
• sampling_rate_sps, offset, range, freq, bit_width_us, message
Source code ./plugins/encoder/encoder-morse
Morse code can be considered a specific implementation of an OOK modulation. It is not very efficient but it
is an interesting option that can be used for interoperability: any existing system that implements the well
known Morse code would be able to understand the data sent by this plugin:
As an example of the signal generated by this plugin, I have done a test using these settings:
• Message: SOS
In the left figure we can clearly identify the symbols corresponding to the SOS message in Morse:
• S -> ...
• O -> ---
Design of a low-cost device for data transmission over power lines 93/181
3.5.8.3 decoder-morse
Target decoder-morse.so
Purpose Decodes Morse data
Details Configurable settings
• sampling_rate_sps, freq, data_hi_threshold, data_offset, bit_width_us,
samples_to_file
Source code ./plugins/decoder/decoder-morse
A Morse decoder allows understanding other systems transmitting in that encoding (interoperability).
I have used it to validate the behavior of the Emulator in the desktop-PC. The idea was to use an external
tool to generate standard Morse tones and check that the Emulator was able to capture them from a
microphone and properly decode the message.
On the Internet we can find many tools that return the Morse encoding corresponding to a given message.
For example, we get “...---...” for “SOS”. Additionally, on some tools there is also a play button that
allows reproducing the Morse code through the speakers of the PC. The Pitch (frequency of the beeps) and
the encoding rate (width of the beeps) can also be configured.
To check the proper behavior of the decoder-morse plugin, I have performed the following test with the
desktop-PC:
• At the transmitter side, I have opened a window with the Internet Browser and the tool generating
the Morse beeps of a message12.
• At the receiver side, I have executed the plc-cape-lab application running in emulation mode (3.5.6
Emulator) and configured to decode the data received from the microphone in real-time.
In this test we can hear the beeps and see, in real-time, how the message is properly interpreted, confirming
the correct implementation of the decoder and the Emulator.
Logically, if I make enough noise during the test, the decoded message becomes corrupted.
To test the proper execution of the framework we will just generate a pure tone in Emulation mode (see
3.5.6 Emulator). The advantage of this mode is that it relies on standard libraries (ALSA) instead of using the
custom driver developed for the BBB (in the SPI and ADC areas). The current plc-cape framework checks
for the presence of a BBB and if not, it automatically switches to Emulation mode.
Figure 66. RPI interoperability - Testing environment
First, I have prepared the RPI by writing to a micro SD a Raspbian Lite image downloaded from the official
website13. Then I have started the Raspberry with the new image and updated it with the most recent changes
(apt-get update and apt-get upgrade). After that process, I have executed some identification
commands:
$ uname -a
Linux mjpi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 8.0 (jessie)
Release: 8.0
Codename: jessie
$ dpkg --print-architecture
armhf
• The RPI is based on the armv7l architecture, as the BBB. The armhf also indicates that it has
hardware-floating support, which is important here due to the intensive use of the floating point
calculations performed by the plc-cape software framework.
• The Raspbian Lite is based on Debian Jessie 8.0 (Linux Kernel 4.4.38). In my BBB I have Debian
Wheezy 7.8 (Linux Kernel 3.8.13), which is the original version that came pre-installed. So, this test
is also useful to validate the plc-cape behavior across different versions of Debian distributions.
For the test, I wanted to use the same BBB plc-cape binaries, with no rebuilding process involved. To do so,
I shared my BBB binaries through a SAMBA resource in the desktop-PC (as described in
PlcCapeSoftwareFramework.pdf[1]). Then, I connected to the RPI through a SSH session and followed this
procedure:
[...]
The plc-cape-lab application has started without complaint. I have then configured it to generate a sine wave
at 2 kHz (audible sound) with a sampling rate of 48 ksps (which is a typical value to play audio with high-
quality). This is the screenshot of the plc-cape-lab showing the connection with the ALSA driver:
Figure 67. RPI interoperability - Screenshot of plc-cape-lab when playing a tone
By starting the wave generation with ON, we ear the pure tone through the earphones, confirming that most
of the developed software can be easily reused on other Debian-based platforms.
This test suggest another possible use for the plc-cape framework: we could connect our Push-Pull amplifier
(or similar) to the audio output of the RPI and have a kind of fully customizable function generator (limited
to the bandwidth of the audio DAC, probably close to 48 ksps).
As a curiosity, I have repeated the above test using an HDMI connection with the TV. In this case, the audio
is played through the speakers of the TV because the ALSA engine routes it this way.
96/181 Design of a low-cost device for data transmission over power lines
Firstly, you will find some tests intended to deeply check the behavior of the individual devices involved in
this project. Then, the communication of modulated data between modules will be evaluated:
Test Summary
4.5 Arduino and Push-Pull The behavior of the assembly composed of the Arduino Leonardo
amplifier board and the Push-Pull amplifier is analyzed.
4.7 Analysis of the 230VAC The resulting signal after the 230VAC decoupling stage is captured
mains and analyzed to get an idea of the transmission channel conditions.
At the beginning of each test there will be an initial summary of the objectives pursued and a photo of the
testing environment. When a result leads to an interesting conclusion, it will be highlighted.
• The captured graphs have been minimized because qualitative results are more important than
accurate quantitative measures.
• Each capture has a title indicating the most relevant settings involved in the test. For a series of
graphs, the settings that change from one capture to the next are highlighted in bold.
• At the right of each capture I have added some comments related to the results obtained.
For the meaning of the signals in the TX or RX chains, see 2.2.2 AFE031 blocks and pins. For the PlcCape
probing points, see Figure 21. PlcCape-v1 probing points and Figure 39. PlcCape-v2 probing points.
4.2 Considerations
4.2.1 230VAC measurements
I want to highlight here the special care that must be taken when working with hazardous high voltage, as the
230VAC in the mains (~650 VPP). A mistake in a connection involving 230VAC usually results in dramatic
consequences: huge electronic damage, fire, injuries...
CAUTION!
230VAC high-voltage is dangerous. It may constitute a safety hazard if not operated
properly. It can even imply death. Be very careful if working with. Always double-check
any step you do and, in case of doubt, avoid it.
In fact, due to my modest experience in 230VAC electronics, I realized a few times how easy it is to make a
severe mistake there:
• If you use a USB oscilloscope to capture signals, remember that it is usually grounded to the GND of
the USB connection. If you probe some 230VAC-based signal (usually using x10 scope probes and
behind large resistors to cut down the voltage), you might make a very dangerous loop that can crash
any equipment connected to the USB, including your oscilloscope or the motherboard of your PC
4.2.2 RX filtering
The PlcCape board has a first filtering stage at reception to attenuate frequencies out of the CENELEC band.
As we can see in the Figure 12. PlcCape-v1 SCH AFE031 core circuitry, it consists in a forth-order passive
RLC network (resistors, inductors and capacitors).
At the beginning of the project I soldered, by mistake, the RLC components corresponding to the
CENELEC-A band, whereas this project is CENELEC-B oriented. As a result, the 110 kHz signal used in
the tests experiences extra attenuation (because out of the CENELEC-A band). I realized this mistake in an
advanced phase of the project. In order to avoid confusion, I opted to keep the configuration that I had been
using since the beginning of the project.
In any case, if we are able to receive a 110 kHz carrier with a penalizing CENELEC-A filter, we will also be
(and more easily) with a more suitable CENELEC-B filter.
98/181 Design of a low-cost device for data transmission over power lines
To validate the TX chain, different waves have been generated from the 10-bits DAC of the AFE031 (via the
SPI bus) using the plc-cape-lab application. As a reminder of its usage[1], the Offset setting indicates the
center of the wave while the Range setting indicates the peak-to-peak value. Both come specified in DAC
units. This way, an Offset = 512 and a Range = 1020 means a wave covering a range 512±1020/2, or in
similar terms, a wave from a DAC value equal to 2 to a DAC value equal to 1022. Note that I have usually
used 1020 instead of 1024 to give some margin in case of any possible rounding mistake on the wave
generation software.
With plc-cape-lab we can also configure the gains of the PGAs at TX and RX, and the CENELEC filter.
The most relevant signals involved in the TX chain come directly from the AFE031 chip and are:
TX_F_OUT TX_PGA_OUT once filtered by the AFE integrated Low Pass Filter (LPF).
Signal reaching the input of the Power Amplifier (PA). It is the TX_F_OUT
PA_IN
after a decoupling capacitor which allows for proper required biasing.
Amplified output with a high current sourcing capability. Thus, this output can
PA_OUT
be injected into low impedance AC lines.
Table 16. Signals involved in the PlcCape TX Chain
For the TX test, we are going to generate a simple sinusoid and look with the oscilloscope at the different
points in the chain. I am going to use the PlcCape-v1 board because the better accessibility of the probing
points (compared to PlcCape-v2).
Design of a low-cost device for data transmission over power lines 99/181
For the TX_PGA_OUT the oscilloscope probe must be manually held on the TX_PGA_OUT probing point.
Find following a summary of the signals analyzed and their arrangement in the graphs in following pages:
For the tests in this chapter, I have used a SPI clock of 6 Mbps (bps = bits per second) which means an
effective DAC sampling rate of 522 ksps (sps = samples per second).
Note: To convert from SPI baud rate (bps) to sampling rate (sps) use the following formula 14:
1
freq_DAC [samples per second]=
10.5
+165∗10−9
SPI rate in bits per second
14 To get more information about how this formula has been found consult the PlcCapeSoftwareFramework.pdf[1]
100/181 Design of a low-cost device for data transmission over power lines
Sinus 110 kHz. Offset = 512. Range = 1020. TX_PGA = 0.25 V/V. Filter = CENELEC-B
In the graph at the left, we can clearly see the
effect of the internal low-pass filter (LPF):
▪ TX_PGA_OUT (at top) exposes the typical
sample&hold shape of DACs
▪ TX_F_OUT (at bottom) exposes the
smoothed shape after the low-pass filter
Other conclusions on TX_F_OUT:
▪ A Range of 1020 means a ΔV of ~925 mVPP
▪ TX_F_OUT is centered around 1.7 V
Sinus 110 kHz. Offset = 512. Range = 510. TX_PGA = 0.25 V/V. Filter = CENELEC-B
Sinus 110 kHz. Offset = 256. Range = 510. TX_PGA = 0.25 V/V. Filter = CENELEC-B
Sinus 110 kHz. Offset = 256. Range = 510. TX_PGA = 0.5 V/V. Filter = CENELEC-B
Sinus 110 kHz. Offset = 256. Range = 510. TX_PGA = 1 V/V. Filter = CENELEC-B
Sinus 110 kHz. Offset = 256. Range = 510. TX_PGA = 1 V/V. Filter = CENELEC-A
Sinus 50 kHz. Offset = 256. Range = 510. TX_PGA = 1 V/V. Filter = CENELEC-A
Sinus 50 kHz. Offset = 512. Range = 1020. TX_PGA = 1 V/V. Filter = CENELEC-A
In this last test I have configured the Offset and
Range to practically cover the whole DAC range.
We can appreciate a saturation effect on
TX_F_OUT. That is because we are reaching the
maximum level of TX_F_OUT, close to 3.3V.
Therefore, special care should be taken when
choosing the offset, range and PGA gain to
avoid saturation issues.
Note: here the voltage scale for CH1 and CH2
have been doubled (1V/div) in relation to
previous captures.
102/181 Design of a low-cost device for data transmission over power lines
The sampling rate at the DAC is essential to have a good signal generation. The Nyquist theorem states that
it must, at least, double the maximum analog frequency covered. In the following tests I have used a low
frequency sine wave (~20 kHz) to not be affected by the TX_LPF filtering and, this way, be able to isolate
the sampling-rate effects. In the below graphs:
• The bottom plot is the Fast Fourier Transform calculated by the oscilloscope software.
• All the captures have a scale of 500 mV/div and 50 us/div. For the FFT the scale is 50 kHz/div.
• In the title it is specified the SPI baud rate and the corresponding DAC freq (see formula in 4.3.1).
SPI CLK = 750 kbps = 70597 sps → Nyquist freq = 35299 Hz = 35 kHz
Here we can see that when generating a wave close to the Nyquist frequency (and therefore, using few
samples per cycle), the generated wave has a considerable amount of harmonic content due to the
square shape of the sample&hold process at the DAC.
SPI CLK = 1.5 Mbps = 139567 sps→ Nyquist freq = 70 kHz
If we double the sampling frequency, the sample&hold time is reduced (we have more DAC samples per
cycle). This raises the frequency of the harmonics, which then fall out of the TX_LPF pass band.
SPI CLK = 3 Mbps = 272851 sps → Nyquist freq = 136 kHz
If we repeat the test for higher frequencies we can conclude that a minimum baud rate of 6 Mbps (522
ksps) is recommended in order to generate a suitable 110 kHz signal.
Design of a low-cost device for data transmission over power lines 103/181
The PA_IN is the input at the Power Amplifier of the AFE031. It corresponds to the TX_F_OUT signal after
a decoupling capacitor (see 3.3.6.2 Schematics).
Testing conditions:
The capture shows that PA_IN is equal to TX_F_OUT but with the DC removed (see the 0V reference marks
at the left margin).
To analyze the behavior of PA_OUT (the output of the Power Amplifier), we will use this configuration:
We can see that with a Range of 400 DAC units we get an output of 2.5 VPP centered on 7.5 V, which is half
the power supply of the PA. By doubling the level of the DAC Range, the PA_OUT doubles too, to 5 VPP.
As per the previously obtained formula (ΔVTX_F_OUT = Range·TX_PGA/275), a Range = 400 means a
ΔVTX_F_OUT = 0.36 VPP, and therefore a PA gain of 2.5/0.36 = 6.9 → ΔVPA_OUT (approx) = 6.9·ΔVTX_F_OUT. This
result is close to the nominal gain given in the AFE031 datasheet, 6.5 V/V.
Note that the Offset setting used to configure the DC component of the TX_F_OUT (800 in the left figure,
and 500 in the right one) does not affect PA_OUT, which is internally biased to half the power supply.
Therefore, PA_OUT will always be centered on 7.5 V when using a 15V power supply.
104/181 Design of a low-cost device for data transmission over power lines
• The TX_F_OUT of PlcCape-v1 is connected to the input of the Push-Pull amplifier (blue wire). In
this test the voltage divider block (potentiometer) is skipped: with PlcCape it is not necessary
because we can configure the signal levels by software.
• The output of the Push-Pull amplifier (PUSH_PULL_OUT) is probed with the oscilloscope (green
wire). In the test it is connected to a load of 2.7 kΩ.
• The PlcCape-v1 is powered up with an external power supply of 5V 1A. The power supply rail is
shared with the Push-Pull amplifier (red and black wires).
• The base waveform is configured with: sinus 110 kHz, Offset = 256, Range= 510, TX_PGA_1V/V,
sampling rate = 522 ksps (6 Mbps). This generates a sinusoidal wave in TX_F_OUT from 0 to 1.9 V.
• When relevant, I have reported the status of the red LED in the Push-Pull amplifier module, which is
used as a rough indicator of the voltage level at the PUSH_PULL_OUT.
CH2
Output of the Push-Pull amplifier stage (ideally a voltage
PUSH_PULL_OUT Red
follower).
Top
CH1
TX_F_OUT Blue Output of the PlcCape-v1 DAC after the internal filter.
Bottom
Note the arrangement of the involved signals: the INPUT of the Push-Pull stage (TX_F_OUT) comes at
bottom whereas the OUTPUT comes at top. For a more intuitive view they should be in reverse order.
Design of a low-cost device for data transmission over power lines 105/181
Sinus 110 kHz. Offset = 256. Range = 510. TX_PGA = 1V/V. Ro = 2.7 kΩ
We can see that PUSH_PULL_OUT (at top, in
red) properly follows TX_F_OUT (at bottom, in
blue). There is a small difference due to the
minimum drop voltage required at the transistors
of the Push-Pull stage:
▪ TX_F_OUT = 1.9 VPP
▪ PUSH_PULL_OUT = 1.72 VPP
In this test, the red LED in the Push-Pull module
(used to monitor the output level) lights
tenuously.
Sinus 110 kHz. Offset = 512. Range = 510. TX_PGA = 1V/V. Ro = 2.7 kΩ
Sinus 150 kHz. Offset = 512. Range = 510. TX_PGA = 1V/V. Ro = 2.7 kΩ
Sinus 50 kHz. Offset = 512. Range = 765. TX_PGA = 1V/V. Ro = 2.7 kΩ. Y-axis = 1 V/div
Sinus 1 kHz. Offset = 400. Range = 765. TX_PGA = 1V/V. Ro = 8 Ω (a speaker). 100 mV/div
Sinus 1 kHz. Offset = 400. Range = 765. TX_PGA = 1V/V. Ro = 15 Ω (pure resistor). 100 mV/div
To end this chapter, we are going to check the system with an OOK-based signal, which is the modulation
scheme we will use later on the communication between devices.
In particular, the goal of this test is to confirm that the Push-Pull amplifier removes the DC offset of the input
signal efficiently (with minimum transient time):
Sinus 50 kHz. Offset = 400. Range = 765. TX_PGA = 1V/V. OOK ‘Hi’. Ro = 1 kΩ. 1 ms/div
Sinus 50 kHz. Offset = 400. Range = 765. TX_PGA = 1V/V. OOK ‘Hi’. Ro = 1kΩ. 10 us/div
With this last test we have confirmed that the Push-Pull amplifier removes the DC offset of the input
signal with no transient if the voltage level of the idle state matches the middle level of the OOK
carrier.
Design of a low-cost device for data transmission over power lines 109/181
To validate the RX chain of the PlcCape board, I have studied two different configurations:
• Auto-loop: the same PlcCape board generates and captures the involved signals. There, we will get
the frequency response H(f) of the loop. In a second iteration I have included the Push-Pull amplifier
into the loop and analyzed its impact. The tests has been carried out with the plc-cape-freq-response
tool
• PlcCape-v2 to PlcCape-v1: the PlcCape-v2 board generates different waves that are captured by the
PlcCape-v1. The tests are carried out by using the plc-cape-lab application. In theory we could rely
on the Auto-loop mode for them, but the plc-cape-lab application hangs quite often when
simultaneously running in both modes (TX and RX) due to the extra CPU overload involved.
To characterize a system, a practical way is by obtaining its transfer function in the frequency domain. For
that purpose I developed a simple tool, plc-cape-freq-response, and an auxiliary Octave script (see chapter
3.5.7.2 plc-cape-freq-response for more details).
By the way, a very interesting functionality offered by the AFE031 is the possibility to internally connect
some of its composing blocks to make different TX to RX paths. These paths are called Calibration modes
because they can be used to tune the system parameters within a known predefined configuration. We can
also use them to check the proper behavior of the AFE031 internal blocks (TX_PGA, TX_LPF, RX_LPF,
RX_PGA2). For a detailed analysis refer to 9 Annex IV. AFE031 Calibration modes.
As calibration modes make internal bridges in the AFE031, we cannot check the behavior of the external
forth-order filter. Thus, a better approach is to do a direct bridge from TX_F_OUT to TXRX as follows:
Figure 70. RX chain analysis - TX_F_OUT to TXRX bridge
110/181 Design of a low-cost device for data transmission over power lines
In the above auto-loop configuration, we must disconnect the output of the Power Amplifier from the TXRX
line in order to avoid any unexpected feedback. I have done it in PlcCape-v1 by removing the C12 capacitor.
With this testing environment, we will get the transfer function from the DAC to the ADC when TX_F_OUT
and TXRX are interconnected. We well use this auto-loop configuration to establish a normalized reference
for H(f) = 1.0 in the plc-cape-freq-response application.
• FILTER = CENELEC-B
In the tests, we will use 50 kHz as the reference frequency. That means that the test iteration closest to 50
kHz will be stored in a file for further analysis.
To get the transfer function, we just need to execute the plc-cape-freq-response and the corresponding
Octave script, following the steps described in the section 3.5.7.2 plc-cape-freq-response:
# ./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:50050 -F:0 -O:511 -R:1022 -U:1 -V:2 -W:0 -T:0
SETUP
-----
Test: f_ini = 50 Hz, f_end = 200050 Hz, iterations = 41
DAC values (in DAC units)
Offset = 511.000000, Range = 1022.000000, AC Mean = 325.312714
EXPECTED ADC values [in ADC units]
DC mean = 1912.000000, Range = 807.380005, AC mean = 256.997040
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 50 Hz...Samples captured. DC mean = 1911.08, AC mean = 0.84
Running freq = 5050 Hz...Samples captured. DC mean = 1911.28, AC mean = 10.44
Running freq = 10050 Hz...Samples captured. DC mean = 1911.35, AC mean = 40.18
Running freq = 15050 Hz...Samples captured. DC mean = 1911.49, AC mean = 92.44
Running freq = 20050 Hz...Samples captured. DC mean = 1911.28, AC mean = 155.91
Running freq = 25050 Hz...Samples captured. DC mean = 1911.44, AC mean = 207.64
Running freq = 30050 Hz...Samples captured. DC mean = 1911.48, AC mean = 235.92
Running freq = 35050 Hz...Samples captured. DC mean = 1910.59, AC mean = 250.05
Running freq = 40050 Hz...Samples captured. DC mean = 1911.48, AC mean = 255.29
Running freq = 45050 Hz...Samples captured. DC mean = 1911.48, AC mean = 256.72
Running freq = 50050 Hz...Samples captured. DC mean = 1912.45, AC mean = 256.31
Running freq = 55050 Hz...Samples captured. DC mean = 1912.28, AC mean = 254.24
[...]
Running freq = 195050 Hz...Samples captured. DC mean = 1913.04, AC mean = 6.67
Running freq = 200050 Hz...Samples captured. DC mean = 1912.80, AC mean = 5.94
In the Octave graphs, we can highlight the 3 dB cutoff level, which corresponds to a factor 1/sqrt(2) in
voltage terms:
The Octave script plots the H(f) graphs and returns a brief analysis of the samples captured at the reference
frequency (50 kHz). See the chapter 3.5.7.2 plc-cape-freq-response for information about.
In the left plot we have the frequency response in linear axes; in the right plot we have it in logarithmic axes
(like in Bode diagrams).
As already mentioned, I have manually tuned the plc-cape-freq-response application to give H(f) = 1.0 for 50
kHz with the testing conditions specified above.
By getting the frequencies at which the H(f) reaches the 3 dB cutoff level, we can conclude that the RX
chain of our PlcCape boards has a pass-band between 22 kHz and 91 kHz. This result is according to the
expectations due to the components used in PlcCape-v1 for the fourth-order band-pass filter, targeted to
CENELEC A (as discussed in 4.2.2 RX filtering).
We can compare this result with the obtained in the AFE calibration mode for the TX-RX internal loop (see
section 9.3 TX_PGA + RX_LPF + RX_PGA2 loop):
By comparing both H(f), we can conclude that the inclusion of the forth-order band-pass filter into the loop:
• adds a high-pass cutoff frequency at 22kHz (not present in the H(f) of the Calibration mode)
It is interesting to probe the TXRX with the oscilloscope and compare it with the ADC captured data.
TXRX. Direct bridge. 50 kHz. Offset = 511. Range = 1022. TX_PGA = 0.5 V/V
These are the samples captured by the ADC (a zoom to 60 samples at right):
ADC data. Direct bridge. 50 kHz. Offset = 511. Range = 1022. TX_PGA = 0.5 V/V
We can see that with the configuration used (RX_PGA1 = 1 V/V and RX_PGA2 = 1 V/V) the data captured
by the ADC for a TXRX of 1.67 VPP spans from 1500 to 2300 approximately (which coincides with the AC
Range = 809 calculated by the Octave script above).
From all these data, we can deduce the attenuation of the forth-order filter:
1 4096
ADC Range=TXRX⋅FilterGain⋅RX_PGA1⋅RX_PGA2⋅ ⋅
2 1.8
The ½ factor at the end of the formula is due to the voltage resistor divider to accommodate the 3.3 V levels
of the AFE031 to the 1.8 V of the ADC in the BBB (see R14 and R15 in the Figure 12. PlcCape-v1 SCH
AFE031 core circuitry). The 4096/1.8 term corresponds to the 12-bits of the ADC for the full 1.8 V range:
Here we are going to replace our direct bridge between TX_F_OUT and TXRX by the Push-Pull amplifier in
order to check if it introduces some distortion in the band of interest. We will test two configurations:
Figure 71. RX chain analysis - Figure 72. RX chain analysis -
PlcCape to Push-Pull without voltage divider PlcCape to Push-Pull with voltage divider
We are going to first check the case with the voltage divider disabled (above picture at left):
# ./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:50050 -F:0 -O:511 -R:1022 -U:1 -V:2 -W:0 -T:0
[...]
DAC values (in DAC units)
Offset = 511.000000, Range = 1022.000000, AC Mean = 325.312714
EXPECTED ADC values [in ADC units]
DC mean = 1912.000000, Range = 807.380005, AC mean = 256.997040
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 50 Hz...Samples captured. DC mean = 1911.12, AC mean = 0.81
Running freq = 5050 Hz...Samples captured. DC mean = 1911.36, AC mean = 8.15
Running freq = 10050 Hz...Samples captured. DC mean = 1911.33, AC mean = 28.61
Running freq = 15050 Hz...Samples captured. DC mean = 1911.04, AC mean = 57.94
Running freq = 20050 Hz...Samples captured. DC mean = 1911.12, AC mean = 89.33
Running freq = 25050 Hz...Samples captured. DC mean = 1910.49, AC mean = 113.86
Running freq = 30050 Hz...Samples captured. DC mean = 1910.19, AC mean = 130.54
Running freq = 35050 Hz...Samples captured. DC mean = 1909.94, AC mean = 140.52
Running freq = 40050 Hz...Samples captured. DC mean = 1910.38, AC mean = 145.57
Running freq = 45050 Hz...Samples captured. DC mean = 1911.08, AC mean = 147.57
Running freq = 50050 Hz...Samples captured. DC mean = 1911.12, AC mean = 148.11
Running freq = 55050 Hz...Samples captured. DC mean = 1911.98, AC mean = 146.80
[...]
Running freq = 195050 Hz...Samples captured. DC mean = 1912.74, AC mean = 6.23
Running freq = 200050 Hz...Samples captured. DC mean = 1912.64, AC mean = 5.22
In Octave:
For the cutoff level I have used 0.58/sqrt(2) because a first execution of the Octave script gave 0.58 as
the maximum value of the H(f) response.
• The low-pass cutoff frequency has not decreased. In fact, it has even increased a bit, from 91 kHz to
100 kHz. This means that our Push-Pull amplifier is suited for signals within the CENELEC
band.
• The maximum gain has dropped from 1.0 to 0.58. In logarithmic units this means that the Push-Pull
amplifier introduces an attenuation of 4.7 dB when skipping the voltage divider.
If we look at the signal at the reference frequency (50 kHz) with the oscilloscope and Octave, we have this:
TX_F_OUT (left) and ADC data (right). Push-Pull amplifier between TX_F_OUT and TXRX
Now TX_F_OUT = 968 mVPP, which corresponds to the previous 1.67 mV PP * 0.58 (= 0.969 mVPP).
The ADC captured signal spans from about 1700 to 2150. Octave returns an AC Range = 481. If we look at
the mean values, the Octave script gives an AC mean = 148.39, which is 0.58 times the mean in the direct
bridge case (AC mean was 256.51).
Design of a low-cost device for data transmission over power lines 115/181
Now we are going to analyze the effect of the voltage divider stage. We first set the potentiometer to the
maximum value = 890 Ω (measured with a multimeter):
# ./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:50050 -F:0 -O:511 -R:1022 -U:1 -V:2 -W:0 -T:0
[...]
DAC values (in DAC units)
Offset = 511.000000, Range = 1022.000000, AC Mean = 325.312714
[...]
Running freq = 50 Hz...Samples captured. DC mean = 1911.08, AC mean = 0.85
[...]
Running freq = 200050 Hz...Samples captured. DC mean = 1911.29, AC mean = 2.54
[...]
FFT max at index 2504 (freq 50080.00 Hz), abs(H)/N = 59.07
In Octave:
H(f). Push-Pull amplifier between TX_F_OUT and TXRX with voltage divider (Rr2 = 890 Ω)
TX_F_OUT (left) and ADC data (right). Push-Pull amplifier with voltage divider (Rr2 = 890 Ω)
• H max = 0.34 which means that the Push-Pull amplifier with the voltage divider enabled
introduces a minimum attenuation of 9.4 dB (for Rr2 = 890 Ω).
• The entry capacitor in the voltage divider has a significant impact on the low-pass cutoff
frequency of the TX-to-RX loop, which falls from 100 kHz to about 80 kHz.
116/181 Design of a low-cost device for data transmission over power lines
# ./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:50050 -F:0 -O:511 -R:1022 -U:1 -V:2 -W:0 -T:0
[...]
DAC values (in DAC units)
Offset = 511.000000, Range = 1022.000000, AC Mean = 325.312714
[...]
Running freq = 50 Hz...Samples captured. DC mean = 1911.61, AC mean = 0.78
[...]
Running freq = 200050 Hz...Samples captured. DC mean = 1911.69, AC mean = 2.51
[...]
FFT max at index 2503 (freq 50060.00 Hz), abs(H)/N = 27.80
In Octave:
H(f). Push-Pull amplifier between TX_F_OUT and TXRX with voltage divider (Rr2 = 150 Ω)
TX_F_OUT (left) and ADC data (right). Push-Pull amplifier with voltage divider (Rr2 = 150 Ω)
In this configuration H max = 0.2. This means that with Rr2 = 150 Ω in the voltage divider, the Push-Pull
amplifier introduces an attenuation of 14 dB.
Design of a low-cost device for data transmission over power lines 117/181
In this chapter we will deeply analyze the received signal in different points while it traverses the RX path.
For that, we will use the PlcCape-v2 as the transmitter and the PlcCape-v1 as the receiver. I have also
included the Push-Pull amplifier15 as a replacement for the Power Amplifier of the PlcCape-v2 (see 3.3.7.7
TX_F_OUT bridge):
Figure 73. RX chain analysis -
PlcCape + Push-Pull + PlcCape - Testing environment
• PlcCape-v2 is used to generate known signals over the TX_F_OUT (blue wire).
• The Push-Pull amplifier is powered by the 5V from the PlcCape-v1 (red wire) which directly come
from the 5V 1A power supply. We cannot use the 5V from the auxiliary header of the PlcCape-v2
because it has no voltage when powered by USB (as explained in the section 3.3.7.2 Schematics).
• The grounds of the three modules are bridged to guarantee the same GND reference.
• Default signal used: Sinus 50 kHz. Offset = 400. Range = 765. TX_PGA = 1 V/V.
15 Examples of direct transmission from BBB to BBB without an intermediate stage can be consulted in
PfcSoftwareFramework.pdf[1]
118/181 Design of a low-cost device for data transmission over power lines
We interact with PlcCape-v2 via USB and configure it for transmission with the plc-cape-lab app:
Figure 74. RX chain analysis - plc-cape-lab at transmission
On a basic initial test, we can see at the bottom of the Figure 75 that AC Mean = 50.1, which indicates that
PlcCape-v1 is receiving a signal with a significant voltage level.
For reference, we also measure TX_F_OUT with PlcCape-v2 isolated (leaving the blue wire floating):
Figure 76. RX chain analysis - TX_F_OUT on an isolated PlcCape-v2
We get a TX_F_OUT of 2.4 VPP for a Range = 765. Note that the signal is slightly saturated at top. It seems
to be due to the wearing of the AFE031 in the PlcCape-v2 because it did not happen with the PlcCape-v1
using the same settings (as seen in 4.3.4 PlcCape-v1 and Push-Pull amplifier stage, which resulted in a
proper sinusoid of 2.8 VPP).
Design of a low-cost device for data transmission over power lines 119/181
In the following pages I have included the oscilloscope captures at different points in the RX chain for
different configurations. For the probing points of the involved signals see Figure 21. PlcCape-v1 probing
points. By default, I will use the TX_F_OUT signal at 50 kHz already seen above.
120/181 Design of a low-cost device for data transmission over power lines
For the final tests on the RX chain, I am going to focus on the digital samples captured by the ADC of the
BeagleBone Board. For that matter, I am going to rely on the plc-cape-lab functionality that allows storing in
a file an interval of the ADC captured samples. Then, we will use Octave and a custom script16 to plot that
data. In particular, I will execute this command:
16 For additional information about the Octave script see PfcCapeSoftwareFramework.pdf[1] or look at the source code
Design of a low-cost device for data transmission over power lines 123/181
ADC data (with Octave). RX_PGA1 = 1 V/V. RX_PGA2 = 4 V/V. 50 kHz. CENELEC-B
I have repeated the previous test and captured
2000 samples from ADCIN (1.23 VPP, saturated).
If we look at the Y-axis of the ADC capture plot,
we see that the top ADC value is about 2800
which coincides with the expected value:
▪ ADCIN max = 1.8 V (see the BBB datasheet)
▪ ADC max value (12-bits) = 212 = 4096
▪ ADC[1.23V] = 1.23*4096/1.8 = 2799
In the FFT plot at bottom, we see a peak at the
sample index 500. In digital frequency terms this
means 500/2000 = 0.25. And considering the
sampling rate of 200 ksps, this translates to a
frequency of 0.25*200k = 50 kHz.
ADC data. RX_PGA1 = 1 V/V. RX_PGA2 = 4 V/V. 50 kHz. CENELEC-B. Zoom to 50 samples
To analyze the case of a typical non-saturated waveform I have reduced the gain of RX_PGA2 to 1V/V:
ADC data (with Octave). RX_PGA1 = 1 V/V. RX_PGA2 = 1 V/V. 50 kHz. CENELEC-B
ADC data. RX_PGA1 = 1V/V. RX_PGA2 = 1V/V. 50 kHz. CENELEC-B. Zoom to 50 samples
By zooming we can see the details of the captured
sinusoid.
Note that the peak-to-peak values vary depending
on the interval chosen: we will have maximum
values when the capture triggering coincides with
the peak value of the analog signal.
This test ends this chapter. We can conclude that we have validated the proper operation of the RX chain.
124/181 Design of a low-cost device for data transmission over power lines
Testing environment:
• The Arduino Leonardo board will generate a 110 kHz square wave through the pin 13
(ARDUINO_TX, blue wire), which is connected to the input of the Push-Pull amplifier BEFORE the
voltage divider to allow simple adjustments of the voltage level.
• To power the Push-Pull module we will use the 5V provided by the Arduino (which come from the
USB).
• An Arduino sketch is developed to send a Hi word in OOK once per second, with a 110 kHz carrier
(see 3.4.1 Simple transmitter with Arduino).
• Load Ro = 1 kΩ.
CH1
It is the Arduino OOK signal from the pin 13
ARDUINO_TX_DIV Blue
(ARDUINO_TX) but AFTER the voltage divider block
Top
CH2
PUSH_PULL_OUT Red Output of the Push-Pull amplifier stage
Bottom
Design of a low-cost device for data transmission over power lines 125/181
We are going to analyze the output of the Push-Pull stage when operating the potentiometer of the voltage
divider. For the different potentiometer positions tested, the resistance has been measured with a multimeter.
In particular, for the 1 kΩ potentiometer that I used, I got a real measure around 860 Ω at the top of the scale
(due to tolerance, imperfections, wearing, etc).
Find following a first couple of graphs displaying the signal at the Arduino pin 13 (ARDUINO_TX, at top, in
blue) and a typical Push-Pull output (PUSH_PULL_OUT, at bottom, in red):
• The Arduino generates a proper square wave of 110 kHz from 0 to 4.6 V.
Next, we check the effect of the potentiometer on the Arduino signal after the voltage divider
(ARDUINO_TX_DIV) and on the Push-Pull output (PUSH_PULL_OUT).
We are now going to examine the effects of the basic low pass filter in the Push-Pull amplifier (Cf capacitor
in the Figure 52. Push-Pull amplifier - Voltage divider).
For that purpose, I have adjusted the potentiometer to 860 Ω (for maximum output) and modified the
Arduino sketch to generate different carrier frequencies.
To conclude this series of tests focused on the Push-Pull amplifier, we are going to analyze the effects of the
load impedance.
For that purpose, I have adjusted the potentiometer to 860 Ω and checked with different loads.
As a final test, I have used an 8 Ω speaker as a very low load impedance to test a scenario where the
deliverable current from the power supply becomes an important factor.
Figure 78. Arduino to Push-Pull amplifier -
Testing environment with a low impedance
The mini speaker has the following
attributes17:
• Impedance: 8 Ω
• Speaker diameter: 36 mm
I have also modified the sketch to generate an audible carrier frequency of 1.5 kHz and longer OOK pulses:
...
#define DELAY_BETWEEN_MESSAGES_MS 100
#define DELAY_BETWEEN_SYMBOLS_MS 100
#define SYMBOLS_LENGTH_MS 100
...
void setup()
{
// Code used to generate a 110kHz carrier
// configure_pwm13(clock_base_divider_one_half, 1, 110000);
• From an external power source, either through the 2.1 mm jack or the Vin pin. In fact, both
(connector and pin) share the same power rail. As a consequence, Vin can be used as Power Input or
Power Output depending on the needs.
• From a USB connection, limited to 500 mA. In this case, if we need to power other circuits from
the Arduino, we can use the pin identified as 5V, which comes from the USB power.
In the test, we properly get audible sound. By operating the potentiometer we adjust the volume. The
changes in loudness are mainly noticeable for Rr2 values < 200 Ω. For greater values it hardly changes.
Concerning the LED, it shuts down since Rr2 < 200 Ω (approx).
Find following the output we get (PUSH_PULL_OUT) for different scenarios: with the USB port (5V
500mA) versus an external power supply (5V 1A):
In the Log area we can see the received words (many Hi) with no transmission errors. So plc-cape-lab
properly decodes a message sent in OOK.
Design of a low-cost device for data transmission over power lines 133/181
With the oscilloscope we can check the output at PlcCape-v1 (TX_F_OUT) and the output at the Push-Pull
amplifier (PUSH_PULL_OUT):
In the capture at left, we can clearly identify the H symbol in the OOK encoding.
In the capture at right, we can see the smooth transient at the beginning of the carrier.
With plc-cape-lab we can store the ADC samples received and plot them with Octave:
TX_F_OUT (top) and PUSH_PULL_OUT (bottom). ‘HI’ word in Morse. 1 V/div. 2 ms/div
For the next experience, we replace the BBB by the Arduino board configured to transmit the Hi word in a
110 kHz OOK encoding through the pin 13. It is the configuration implemented in the section 3.4.1 Simple
transmitter with Arduino.
Figure 82. Arduino to PlcCape communication -
Testing environment
Testing environment:
▪ RX_PGA2 = 1 V/V
136/181 Design of a low-cost device for data transmission over power lines
With plc-cape-lab we observe that we properly receive the ‘Hi’ word (one ‘Hi’ per second):
Figure 83. Arduino to PlcCape communication - plc-cape-lab at reception
For each transmitted Hi, the LED in the Push-Pull amplifier flashes weakly.
With the oscilloscope we probe the input signal at the Push-Pull amplifier after the voltage divider
(PUSH_PULL_IN_DIV), and also the output of the module (PUSH_PULL_OUT):
In the PUSH_PULL_OUT we can observe the effect of the low pass filter in the Push-Pull amplifier,
which converts the square wave generated by the Arduino to a smoothed version.
In contrast to the tests done with PlcCape-v1 being the transmitter, here we see a short initial and final
transient at each symbol due to the time required for the capacitors to remove the DC component:
• In the PlcCape-v1 case, the idle level matched the middle of the wave so that no additional biasing
was required for DC removal
• In the Arduino case, the idle level corresponds the low level of the wave (0 V). For effective DC
removal, a biasing is required per symbol
Design of a low-cost device for data transmission over power lines 137/181
ADC data. RX_PGA1 = 0.25 V/V. RX_PGA2 = 1 V/V. Zoom to 100 samples
FFT of TXRX
4.7.2 AC to PlcCape
Objective: Analyze the impact of the connected appliances into the 230VAC line
ADC data. RX_PGA1 = 0.25 V/V. 10000 samples ADC data. RX_PGA1 = 1 V/V. 2000 samples
Like in the oscilloscope case, we can appreciate here the noise bursts at 100 Hz.
In the FFTs we can clearly identify the frequency of the carrier, now around 58 kHz (remember that our ADC
is configured with a sampling rate of 200 ksps which directly translates to a 200 kHz width for the Digital
Frequency axis).
For the test in the previous chapter, I run the USB oscilloscope from a different PC. As the frequency of the
noise has changed now (from 65 kHz to 58 kHz), this could mean that the power supply of the PC could be
the responsible of that noise.
Design of a low-cost device for data transmission over power lines 141/181
To confirm if the periodic noise comes from the PC or not, I run the BBB + PlcCape-v2 from an isolated
laptop powered by the internal battery:
Figure 86. AC to PlcCape - Testing environment with a laptop
With this environment and running the plc-cape-oscilloscope application through a ssh -X session (with
RX_PGA1 = 1 V/V and RX_PGA2 = 1 V/V), we can see how the level of the periodic noise decreases when
switching OFF the desktop-PC (which is running on a contiguous room):
ADC data in 230VAC mains with desktop-PC ON ADC data in 230VAC mains with desktop-PC OFF
Therefore, we can conclude that the switched-mode power supply of the desktop-PC introduces a
considerable amount of noise into the AC mains.
142/181 Design of a low-cost device for data transmission over power lines
ADC data. PC ON. Bedroom. RX_PGA1 = 0.25 V/V. RX_PGA2 = 4 V/V. Y-Range ±50
ADC data. PC ON. Bedroom. RX_PGA1 = 0.25 V/V. RX_PGA2 = 4 V/V. Y-Range ±200
ADC data. PC ON. Bedroom. RX_PGA1 = 0.25 V/V. RX_PGA2 = 4 V/V. Zoom to desktop-PC noise
ADC data. PC ON. Bedroom. RX_PGA1 = 0.25 V/V. RX_PGA2 = 4 V/V. Zoom to high-level pulse
If we zoom to the “high-level” pulse (viewer ±200)
and do the FFT, we can see that in this case the
frequency representation of the noise is different: it
is present at lower frequencies and spans over a
wider bandwidth.
This noise will probably come from a different
connected appliance.
The important fact here is that our 230VAC is very
noisy. In these conditions, if we use simple
decoding methods based on just the presence of a
carrier, we will have frequent errors when these hi-
level pulses occur. For a robust implementation we
should use more complex strategies, as coherent
demodulation using the predefined carrier
frequency.
Design of a low-cost device for data transmission over power lines 143/181
ADC data. PC ON. Kitchen. RX_PGA1 = 0.25 V/V. RX_PGA2 = 4 V/V. Y-Range ±50
I have repeated the previous test but now plugging
the PlcCape-v2 to an outlet in the kitchen, which
involves a longer distance to the desktop-PC room.
By comparing this graph with the dual one in the
previous page (Y-Range ±50), we can see here how
the PC noise is highly attenuated (because the
distance).
However, we can still appreciate the other low-
frequency noise.
ADC data. PC ON. Kitchen. RX_PGA1 = 0.25 V/V. RX_PGA2 = 4 V/V. Y-Range ±500
ADC data. PC ON. Kitchen. RX_PGA1 = 0.25 V/V. RX_PGA2 = 4 V/V. Zoom to low-level pulse
ADC data. PC ON. Kitchen. RX_PGA1 = 0.25 V/V. RX_PGA2 = 4 V/V. Zoom to high-level pulse
On the other hand, a zoom to the high-level pulse
reveals that the low-frequency noise has, in the
kitchen, a higher voltage level than in the bedroom.
This would indicate that the source of the low-
frequency noise is close to the kitchen.
The important fact here is that, even in the same
domestic line, we can have different noise
scenarios depending on the location of the
transmitter and the receiver.
144/181 Design of a low-cost device for data transmission over power lines
Now that we have analyzed how the transmitter and the receiver work, and done a basic analysis on the
230VAC line, the next step is to effectively communicate some data between the low-cost device (Arduino-
based) and the central unit (BBB-based).
At the transmitter side (the REPORTING device) I have used the following assembly, composed of the
Arduino Leonardo + the Push-Pull amplifier + the AC Coupling module:
Figure 87. 230VAC communication - The REPORTING device at transmission
In the AC Coupling module, in JP1 I have placed a customized jumper which shortcuts the three pins of the
connector. This simplifies the link with the PUSH_PULL_OUT through the X4 connector in the top side of
the board (see 3.3.6.7 AC coupling auxiliary module)
At the receiver side (the SUPERVISOR unit), I have used the assembly composed of the BBB + the
PlcCape-v2. It will be connected to the mains, as we have already seen in the previous chapter:
Figure 88. 230VAC communication -
The SUPERVISOR unit at reception
First, we check that the system works in the simplest way, through a direct isolated connection with a couple
of wires from the transmitter to the receiver, with no 230VAC involved yet.
In all the tests the Arduino board generates an OOK signal sending Hi at every second, using a 110 kHz
carrier (as seen in 3.4.1 Simple transmitter with Arduino).
Design of a low-cost device for data transmission over power lines 145/181
AC pins. Isolated direct connection. 1 ms/div AC pins. Isolated direct connection. 20 us/div
We can identify the OOK signal corresponding to the transmission of the H symbol.
This is the only measurement I have done with the oscilloscope in this chapter. Remaining graphs correspond
to the captured data by the ADC of the BBB, recorded either by the plc-cape-oscilloscope tool or the plc-
cape-lab application + Octave.
In all the test the AFE031 is configured to work in the CENELEC-B band.
So, I have repeated the previous test (direct wire with no 230VAC present) and captured the data with the
plc-cape-lab application.
ADC data. Isolated direct connection (230VAC OFF). RX_PGA1 = 1 V/V. RX_PGA2 = 1 V/V
In this basic scenario with RX_PGAs configured
for unitary gain, the ADC captured samples span
from 1150 to 1450.
In the FFT plot we can see that the ADC
interprets the 110 kHz carrier as 90 kHz because
the undersampling effect (as already seen in
4.6.1.1 OOK encoding).
If we take a look at the Push-Pull monitoring
LED, we can observe an important fact. In the
interconnected system, the LED flashes tenuously
per word transmitted. However, if we disconnect
the PlcCape-v2, then it flashes energetically.
This is due to the input impedance of the PlcCape
board: at 110 kHz it would be around 150 Ω
which cuts down the output voltage of the Push-
Pull amplifier in a significant way (as seen in
4.5.3 Load impedance).
The next step is to inject the 230VAC into the direct connection. We can safely do that because both, the
transmitter and the receiver, have a coupling transformer.
146/181 Design of a low-cost device for data transmission over power lines
So, if we supply 230VAC to the direct connection and repeat the capture with plc-cape-lab, we get this:
Therefore, this experiment confirms that the main behavior of the system is correct.
Now we need to cover more realistic scenarios, testing the communication between separated plugs, and
looking at the effects of the longer transmission lines and the noise. For that matter, I am going to use the
plc-cape-oscilloscope tool at the receiver side.
Find following a couple of photos of the testing environment at both sides of the communication channel:
Figure 89. 230VAC communication - Figure 90. 230VAC communication -
Transmitter configuration Receiver configuration
In this series of tests, the refrigerator and the water heater were always ON. Therefore, they are possible
sources of noise.
Design of a low-cost device for data transmission over power lines 147/181
By default, unless otherwise specified, the PGA gains are configured to RX_PGA1 = 0.25 V/V and
RX_PGA2 = 4 V/V.
For all the tests in this chapter, I have set the base location of the transmitter assembly in the study room,
where the desktop-PC is located.
For the first series of tests (in the study room), I have placed the receiver and the transmitter in the same
outlet, through a hub. The desktop-PC is ON.
ADC data. BBB isolated (AC pins unconnected). RX_PGA1 = 0.25 V/V
ADC data. BBB connected to mains (AC pins to 230VAC). No TX. RX_PGA1 = 0.25 V/V
ADC data. BBB connected to mains. TX ON, in the same outlet hub. RX_PGA1 = 0.25 V/V
ADC data. BBB connected to mains. TX ON, in the same hub. RX_PGA1 = 0.25 V/V. Zoom to 500 us
ADC data. BBB connected to mains. TX ON, in the same hub. RX_PGA1 = 0.25 V/V. FFT
In this section I have changed the location of the PlcCape receiver for a more practical test: the
communication between the outlets of two different rooms. In particular, I have put the receiver in an outlet
of the bedroom, which is contiguous to the study room.
ADC data. Desktop-PC ON. RX_PGA1 = 0.25 V/V. Viewer [10 ms; ±200]
ADC data. Desktop-PC ON. RX_PGA1 = 0.25 V/V. Viewer [500 us; ±50]
ADC data. Desktop-PC ON. RX_PGA1 = 0.25 V/V. Viewer [20 ms; ±50]
ADC data. Desktop-PC OFF. RX_PGA1 = 0.25 V/V. Viewer [20 ms; ±100]
If we switch OFF the PC, we observe two effects:
▪ The impulsive noise at 100 Hz is considerably
lower.
▪ The signal received doubles (notice the Viewer
±100). That is because the impedance in the AC
line increases when the PC disconnects, and due
to the load-effect of our Push-Pull amplifier this
means a boost in the output voltage.
ADC data. Desktop-PC OFF. RX_PGA1 = 0.25 V/V. Viewer [2 ms; ±100]
ADC data. Desktop-PC OFF. RX_PGA1 = 1 V/V. Viewer [20 ms; ±400]
ADC data. Desktop-PC OFF. Power supply from battery. RX_PGA1 = 1 V/V. Viewer [20 ms; ±300]
ADC data. Desktop-PC OFF. TX OFF. RX_PGA1 = 1 V/V. Viewer [20 ms; ±300]
ADC data. 230VAC switch OFF. TX OFF. RX_PGA1 = 1 V/V. Viewer [20 ms; ±300]
ADC data. 230VAC OFF. TX ON from battery. RX_PGA1 = 1 V/V. Viewer [20 ms; ±300]
ADC data. 230VAC OFF. TX ON from battery. RX_PGA1 = 1 V/V. Viewer [2 ms; ±300]
ADC data. 230VAC OFF. TX ON from battery. RX_PGA1 = 1 V/V. Viewer [20 ms; ±300]
ADC data. 230VAC OFF. TX ON from battery. RX_PGA1 = 1 V/V. Viewer [2 ms; ±300]
ADC data. 230VAC OFF. TX ON from battery. RX_PGA1 = 1 V/V. Viewer [1 ms; ±300]
ADC data. 230VAC OFF. TX ON from battery. RX_PGA1 = 1 V/V. Viewer [1 ms; ±300]
ADC data. 230VAC OFF. TX ON from battery. RX_PGA1 = 1 V/V. Viewer [20 ms; ±300]
ADC data. 230VAC OFF. TX ON from battery. RX_PGA1 = 1 V/V. Viewer [1 ms; ±100]
To check if we are able to recover the original message (periodic Hi words) I have stopped the plc-cape-
oscilloscope application and started the plc-cape-lab. I have configured it with RX_PGA1 = 1 V/V,
RX_PGA2 = 4 V/V and manually adjusted the threshold for the carrier detection.
In these conditions I have successfully recovered the original message without errors, as shown in the
following capture of the laptop screen:
Figure 91. 230VAC communication - plc-cape-lab capture from the laptop
Design of a low-cost device for data transmission over power lines 153/181
ADC data. 230VAC ON. TX OFF. RX_PGA1 = 1 V/V. Viewer [20 ms; ±200]
Here, I have disconnected the Arduino transmitter
and turned ON again the 230VAC main switch.
The high levels of sporadic noise reappears.
If we compare the level of that noise with the level
of the received signal in the previous test, we will
see that it will completely mask the OOK carrier
(note the scale of the viewer here set to ±200).
In fact, in these conditions I have not been able to
recover the original signal using the plc-cape-lab
application and the carrier-detection-by-level
method.
ADC data. 230VAC ON. TX OFF. RX_PGA1 = 1 V/V. FFT
ADC data. 230VAC ON. TX OFF. RX_PGA1 = 1 V/V. Viewer [20 ms; ±200]
ADC data. 230VAC ON. TX OFF. RX_PGA1 = 1 V/V. Viewer [20 ms; ±200]
The most important conclusions we can take from the experiences done in this section are:
• The connected appliances introduce a significant level of noise on frequencies in the kHz range
• The instantaneous impedance in the transmission line is not regular. The power supplies of the
connected appliances have consumption peaks that involve sudden impedance drops which
translate to huge voltage notches in our transmitted data
154/181 Design of a low-cost device for data transmission over power lines
This chapter is going to summarize, in a final practical scenario, most of the experiences covered in previous
chapters.
On the TX side we arrange the temperature sensing and REPORTING device (Arduino Leonardo +
Temperature sensing Shield + Push-Pull amplifier). We do first a test without the AC coupling module:
Figure 92. Final system - Push-Pull output probing
With the oscilloscope we probe the output of the Push-Pull amplifier which will be emitting a periodic OOK
message with the temperature. Note that there is a Ro = 1 kΩ just to simulate a medium impedance load:
In the current configuration the Push-Pull amplifier reduces the input voltage from 5 V PP to 2.3 VPP and
softens the original square wave towards a sinusoidal waveform.
The message transmitted by the Arduino is a counter followed by a colon and the temperature, all in ASCII
chars (as described in 3.4.3 Sensing and transmitting device with Arduino).
Design of a low-cost device for data transmission over power lines 155/181
On the TX side, I have added the AC coupling module. Notice the JP1 triple-jumper in order to comfortably
connect the PUSH_PULL_OUT using the X4 connector (see 3.3.6.7 AC coupling auxiliary module).
On the RX side, I have arranged the testing environment that I have already used in previous chapters, based
on an isolated laptop running on batteries. The SUPERVISOR unit (BBB + PlcCape-v2) is controlled
through a SSH session via USB.
I have connected the temperature REPORTER device (TX) in the room where the desktop-PC is located
(study-room) and the SUPERVISOR unit (RX) in the outlet of a contiguous room in order to test the
communication in low-attenuation conditions.
• Normal conditions: The ARDUINO_TX input signal traverses the whole Push-Pull amplifier
(Figure 93).
• Voltage boost: The ARDUINO_TX input signal is injected into the Push-Pull amplifier skipping the
voltage divider and thus resulting in a higher voltage output.
• 230VAC OFF: I have switched off the main 230VAC breaker so that the communication is carried
out through an unpowered line.
• the ADC samples captured by the plc-cape-oscilloscope tool running on the laptop
• the data interpreted by the plc-cape-lab application configured for OOK symbol decoding (with a
width of 1 ms) using the simplest method, the carrier-detection-by-level. For each test I have
manually adjusted the RX threshold to detect the OOK carrier and ignore the background noise
156/181 Design of a low-cost device for data transmission over power lines
In normal conditions these are the ADC samples captured by the plc-cape-oscilloscope tool:
Figure 95. Final system - ADC data captured from the 230VAC
In the above graph (captured with RX_PGA1 = 1 V/V and RX_PGA2 = 4 V/V) we can guess some main
challenges we are going to face at decoding the OOK message, due to the following issues:
• There are high level noise bursts due to the power supplies of the appliances connected (e.g. see the
interval from 10 ms to 12 ms in the above figure).
• We are receiving a low level signal due to the line attenuation. The ADC data spans over 600
peak-to-peak ADC units, even with the x4 gain in RX_PGA2.
Despite these conditions, I have been able to receive some data with the plc-cape-lab application, which I
have configured with RX_PGA1 = 2 V/V and RX_PGA2 = 4 V/V:
Figure 96. Final system - Demodulated data from 230VAC
In the Log panel we can identify the format of the reported counter and temperature (e.g. 1252: 20.06 ºC) but
we also see many errors in the form of dots (‘.’), which in plc-cape-lab are used to indicate an OOK
detection out of the ASCII range (32 to 128). Such errors will probably be due to a wrong interpretation of
the background noise in the carrier-detection-by-level method. A more complex coherent-frequency-based-
detection would avoid them.
Conclusion: we are able to communicate data between two 230VAC close outlets, but with errors.
Design of a low-cost device for data transmission over power lines 157/181
In this test I have injected more voltage into the 230VAC line just by skipping the voltage divider of the
Push-Pull amplifier (which introduces some extra attenuation). In plc-cape-oscilloscope I have used the same
PGA gains as in the previous test (RX_PGA1 = 1 V/V and RX_PGA2 = 4 V/V):
Figure 97. Final system - ADC data captured from the 230VAC
(voltage divider at TX skipped)
We can see the improvement on the voltage level: now the OOK carrier spans over 1200 ADC units,
compared to the 600 ADC units of the previous case (notice the double value of grid divisions).
In this case the main problem is not the noise but another challenging issue:
• There are sporadic significant voltage drops in the OOK signal due to instantaneous changes in
the line impedance. In the above graph we can identify two occurrences of this issue, in the first and
third OOK pulses, which are partially good, partially attenuated.
Find following a screen capture of the plc-cape-lab application configured with RX_PGA1 = 1 V/V (AFE
rx1:2) and RX_PGA2 = 4 V/V (AFE rx2:1):
Figure 98. Final system - Demodulated data from the 230VAC (voltage divider at TX skipped)
Now, with a higher threshold for the carrier detection, we have fewer errors (fewer dots).
Note that the initial temperature is 23.56 ºC and the final one is 20.56 ºC. That is because I forced a rise by
putting a finger in the sensor, to check that the device was properly sending the real current temperature.
158/181 Design of a low-cost device for data transmission over power lines
As a final test, I have turned OFF the 230VAC by switching OFF the main breaker of the electrical network
at home. This way, we eliminate the noise and the impedance drops due to the power supplies of the
connected appliances. For this test we need the REPORTER device to be self-powered. I have used the
PowerBank already employed in Figure 46. Arduino shield - Test.
In these conditions, we perfectly receive the transmitted data, even using low PGA gains. For instance, in the
figure below the PGAs were configured with RX_PGA1 = 0.25 V/V and RX_PGA2 = 1 V/V:
Figure 99. Final system - ADC data captured from unpowered mains
Here we are neither facing voltage drops nor background noise. The captured signal spans only for 80 ADC
units due to the low PGA gains (0.25 V/V in total). Note that in previous tests we used a total gain of 4 V/V,
16 times higher.
This is the capture of plc-cape-lab configured with RX_PGA1 = 0.25 V/V and RX_PGA2 = 1 V/V:
Figure 100. Final system - Demodulated data from the mains when unpowered
The message transmitted by the Arduino assembly is perfectly received, with no errors.
The tests carried out in this chapter demonstrate that the whole system is working and viable but it
requires important improvements, mainly in the Push-Pull module (to avoid the dependency with the
instantaneous line impedance) and in the detection software (which should implement a more robust
decoding strategy).
Design of a low-cost device for data transmission over power lines 159/181
5 Conclusions
5.1 Feasibility
This project can be considered an introductory step to PLC technology.
I have been able to transmit data between two 230VAC outlets in different rooms using affordable electronics
(4.9 Final system integration).
For that purpose, I have proposed this system and deeply analyzed each component:
Figure 101. System proposal
However, the communication performed has not been reliable enough to consider it a suitable system.
In the positive side, the reliability problems have been clearly identified and alternatives have been proposed.
• On the one hand, we have achieved a reliable communication at home between two distant outlets
after having switched off the 230VAC (through the main circuit breaker). With this test we have
confirmed that our system is suitable for data transmission over medium distances and is able to deal
with the attenuation in the line.
• On the other hand, with the 230VAC present, we have also achieved an acceptable communication
between two outlets close enough. Therefore, the system is able to properly couple and decouple the
data to and from the electrical network.
In the analysis phase, many tests have been carried out and results deeply analyzed. They constitute a helpful
guide for the design of a more robust future system (4 Analysis & results).
In this project I have also developed software tools to simplify the analysis phase (3.5.7 Applications). I have
also provided some plugins (3.5.8 Plugins) to demonstrate the ability of the framework to use different
encoding algorithms in the communication (4.6 Data communication over an unpowered line).
Concerning reusability, I have included some examples and guidelines of how to use the developed tools for
other applications than just PLC (5.2 Reusability).
The usage of Linux (and Debian) as the backbone of the software framework has been proven to be a key
point of this project. The extensive functionality provided this operating system will be indispensable when
designing a complete solution where the BBB will act as an Internet-ready central server able to send and
receive data from several low-cost devices attached to the electrical network.
Summarizing, the proposed system is feasible and versatile but needs to be improved in reliability and
robustness. The weaknesses have been identified and point the way to follow in future versions.
160/181 Design of a low-cost device for data transmission over power lines
5.2 Reusability
The experiments done in this project prove that the system proposed may be used for other purposes beyond
the communication over power lines.
• The assembly composed of a BeagleBone Black and a PlcCape can be used to play sound (as seen
in 3.5.8.1 encoder-wav or in 4.5.3 Load impedance).
• Similarly, we can use the current software as a microphone recorder taking advantage of the ADC
of the BBB, which is able to capture signals up to 100 kHz, far below the typical high-fidelity audio
range.
• The load-dependency-effect of the Push-Pull amplifier (an important pitfall in this project) can be
profitable. It might be used as a rough instantaneous impedance meter of all the appliances
connected to the mains. We can inject a carrier of a predefined level and analyze with the FFT the
attenuation experienced, which is proportional to the impedance.
• The whole system can be used to measure the attenuation between two points in the electrical
network (or any other transmission line) for a given frequency. The idea is to inject a predefined
waveform on one point and measure the level received at a different location.
• The mini-oscilloscope application that shows in real time the captures from the ADC of the BBB
(3.5.7.1 plc-cape-oscilloscope) is a tool that can be used even with no PlcCape attached (therefore,
usable out of the PLC scope). It can be used to monitor real time data at frequencies up to
100 kHz (sensors, microphones, etc.).
• The frequency-response analyzer (3.5.7.2 plc-cape-freq-response) can be used to get the behavior in
frequency of any system, not only for PLC related ones. As an improvement, we should provide an
access point in the PlcCape board to allow direct access to the ADC of the BBB and avoid passing
through the CENELEC filters.
• The main application (3.5.7.3 plc-cape-lab) can be comfortably used as a function generator of any
waveform thanks to the high-speed DAC and the plugin-based approach.
I have also demonstrated the reusability of most of the software framework in other Linux-based
platforms (except for the custom SPI/DAC and ADC drivers, specifically targeted to the PlcCape and the
BBB):
• In the section 3.5.9 Multiplatform test with the Raspberry Pi, I have executed the software
framework in a Raspberry Pi (with Debian Jessie) to play sound
• In the section 3.5.6 Emulator, I have explained how the software framework has been adapted to
allow execution in a desktop-PC (with Ubuntu 14.04.5) and be able to do most of the available
operations through a speaker and a microphone, emulating the DAC and the ADC of the
BBB+PlcCape assembly
Design of a low-cost device for data transmission over power lines 161/181
Concerning software, considerable development work is still pending to have a stable and profitable
package. That is way I have identified it with the version 0.2 (the zero in the major number means beta
phase).
In the following sections I have summarized a list of proposed improvements in the different areas covered
by this project.
• Due to a mistake, the RLC values proposed in this project for the forth-order RX filter are targeted to
the CENELEC-A band, whereas the whole project is targeted to the CENELEC-B band (see 4.2.2
RX filtering). This results in extra attenuation for the 110 kHz carrier used in the tests. For the next
version use CENELEC-B values for the RX filter.
• Add more access points, connectors and jumpers for more versatility. For example:
◦ Add comfortable access points to TX_F_OUT and TX_PGA_OUT, which exhibit different
characteristics (as seen in 4.3.1 TX_PGA_OUT vs. TX_F_OUT).
◦ Give the possibility to reach the ADC of the BBB bypassing the CENELEC-based RX chain in
order to cover other applications than just PLC (e.g. use the plc-cape-oscilloscope tool to
monitor real-time data from a sensor).
• Make the PlcCape more modular in order we can easily solder only the involved components for a
given application. For example, for a basic receiver in a low-noise environment, we could even omit
the AFE031 (which would only add a LPF and a couple of PGAs here) and fully rely on the ADC of
the BBB, reducing this way the cost of the board.
• Improve the thermal dissipation in the AFE031 and its monitoring in order to avoid damage even
in the worst conditions.
• Add an EEPROM for identification of the PlcCape (model and version) when connected to the
BBB.
• In the software side we should improve the decoding algorithms. In this project I have relied on
what I have called the carrier-detection-by-level mechanism: the DC offset is first removed from the
samples captured, then calculated the absolute values and applied an averaging formula to finally
compare with a threshold to determine if the OOK carrier is present or not. This method is simple
and computationally efficient but it only works if we have a single carrier and the level of signal is
higher than the background noise. In practical terms it means that this system only works if the
outlets are close enough.
162/181 Design of a low-cost device for data transmission over power lines
A much better approach for a more reliable communication would consist in applying a coherent
demodulation using the predefined frequency of the carrier. I was working on it but I have been
short of time. It is an imperative action to be done in the next version.
• For extra robustness and reliability we should also put in place communication protocols with
error detection (like parity, Checksum, CRC) or even with error correction (ECC).
• In the current implementation the ADC capturing rate is hard-coded to the maximum allowed value,
200 ksps. Due to the Nyquist theorem and the undersampling effect, this poses a problem when
recovering signals close to the 100 kHz (as it is the case in the CENELEC-B band). A lower ADC
capturing rate (e.g. 150 ksps) could overcome it (more details in 3.5.3 Future improvements).
Therefore, consider a configurable ADC capturing rate for a future version.
Push-Pull amplifier
• The Push-Pull amplifier used in this project is very basic and lead to considerable trouble due to its
dependency with the load impedance. It would work fine on a scenario with small changes in the
impedance but it is not the case in the 230VAC mains (as seen in 4.8 Data communication through
the 230VAC line and 4.9 Final system integration). A future iteration should improve the circuitry
to avoid any dependency with the line impedance.
• The voltage divider stage in the Push-Pull amplifier is a basic method to roughly adjust the output
level (it is affected by the input impedance of the next stage). We should use a better alternative for
a more appropriate voltage tuning, for example using an operational amplifier configuration.
• The filtering stage is composed of just a capacitor. This is enough to soften the square wave coming
from the Arduino board but a more selective filter should be considered for a more pure
sinusoidal output.
• In the current implementation with Arduino, there is a short transient at the beginning and ending of
each OOK pulse (seen in 4.5 Arduino and Push-Pull amplifier). We should put in place means to
eliminate or reduce the OOK transients.
Arduino + Shield
• Integrate the Push-Pull and the AC coupling module into the Arduino shield to reduce cost and
connection complexity.
• To reduce cost we can even replace the Arduino + Shield concept by a whole custom board. We
can reuse the processor of the Arduino Leonardo (ATmega32u4) to benefit from the Arduino
framework (IDE and libraries). We can start from the free schematics available in the Arduino
website[9] by removing all the unnecessary components (headers, LEDs, reset button, etc.).
Design of a low-cost device for data transmission over power lines 163/181
6 Annex I. Tools
Find enclosed a list of the tools used in this project:
ELECTRONIC DEVELOPMENT
EAGLE 7.5.0 I have used it to design the PlcCape boards. The limitations of the freeware
license fulfill the needs of this project: board dimensions, just one schematic
sheet and educational purposes. It is available for Windows, Mac and Linux.
http://www.autodesk.com/products/eagle/free-download
http://www.cadsoft.de/freeware.htm
UltraLibrarian I have used the free version to download the footprint of the AFE031 in Eagle-
6.4.202 compatible format.
http://www.accelerated-designs.com/ultra-librarian
LTspice 4.23l It has been a very helpful GUI to analyze electronic circuits with SPICE.
http://www.linear.com/designtools/software/#LTspice
SOFTWARE DEVELOPMENT
Eclipse 4.5 Mars Multipurpose open source IDE to develop, build and debug applications.
http://www.eclipse.org
Arduino IDE Open source IDE for the Arduino framework to write code, build it and upload
1.6.4 the resulting binary to the board.
https://www.arduino.cc/en/Main/Software
DEVICES
Hantek 6022BE It is a cheap entry-level USB oscilloscope. It has a 48 Msps ADC covering a
oscilloscope bandwidth up to 20 MHz. It can measure voltage levels up to 35 VPP.
http://www.hantek.com/en
OTHER TOOLS
LibreOffice Open source office suite used for the edition of this document.
5.1.3.2 https://libreoffice.org
Table 17. Tools used in this project
164/181 Design of a low-cost device for data transmission over power lines
Finally, I want to mention a tool that I have developed to automatize and simplify the conditioning of the
images included in this documentation. I have called it ImageConditioner:
I have used it to adapt some screenshots to Figure 102. ImageConditioner tool - Main screenshot
3. We also need to remap some colors that are not paper-friendly. For instance, the original background is
black. In paper, a white background is preferable for better readability and for environmental friendliness
(because less ink consumption)
4. Finally, it is probable that some details in the capture need to be removed for a cleaner documentation
This an example of a conditioning from a Hantek capture (at left) to the resulting image (at right):
At development level the tool is simple and not very efficient in computational terms. But in any case, it does
the automated job quickly enough.
The tool is programmed in C# .NET. I have released it under GPLv3 and uploaded the sources to GitHub:
https://github.com/jose77105/ImageConditioner
Design of a low-cost device for data transmission over power lines 165/181
It offers a powerful and helpful GUI that simplifies the edition and the analysis phase.
It also allows the integration of third-party library models. There is a guide for at
http://www.linear.com/solutions/1083.
As a summary, find here the steps that I have followed to incorporate the TIPxxx.LIB BJT models:
3. Change the Value field by the exact name of our transistor (look at the .SUBCKT or .MODEL
clauses in the LIB file).
Note: if our LIB is a .SUBCKT, we also need to change the Prefix field by specifying an X (which
corresponds to generic sub-circuits). In our case, the TIP122 comes defined as a .SUBCKT. It is a
Darlington macro-model using several components.
It is also important to mention that, when using a .SUBCKT, we must check that the netlist order in
the .SUBCKT clause matches the logical pins of the symbol used. In LTspice we can check it
opening the symbol definition by clicking on the Open symbol button.
For instance, for NPN and PNP transistors (Prefix = QN and QP) the order is 1-Collector, 2-Base and
3-Emitter. By looking at the .SUBCKT of the TIP122 (and TIP127) we can confirm that it matches
the netlist order of the corresponding transistor symbols.
Tip: If we do not find a suitable symbol for a specific SUBCKT, we can create our own with LTspice
just by opening the LIB file, going to the .SUBCKT line, right-clicking there, and selecting Create
Symbol. The symbol (tip122.asy) will be stored in the LTSpiceIV/lib/sym/AutoGenerated directory
and available within the [AutoGenerated] section when adding a circuit component.
4. Add a .inc SPICE Directive indicating the location of the library18. For example:
“.inc http://www.onsemi.com/pub_link/Collateral/TIP122.LIB”
5. Run a simulation. The LIB will be automatically downloaded and copied into the local directory.
6. We can then replace the URL-location with the local relative path (just by specifying the name):
“.inc TIP122.LIB”
Notes:
• We can use the directive “.lib” instead of “.inc” if we want to download just the referenced model
instead the whole library file. In our case, as there is only one model in the library, it will produce
identical results.
• Alternatively, we can manually download the LIB file and copy it to our local directory.
Testing conditions:
• SPI involved lines (SCLK, DOUT, CSN) are captured with the oscilloscope.
Note: the standard criteria states that the DOUT line corresponds to the data sent from the BBB to the cape.
In PlcCape-v2 this standard is met but PlcCape-v1 implements just the opposite. Therefore, to measure the
SPI data sent from the BBB to the PlcCape-v1 put the probe at DIN.
By measuring the clock period, we confirm that the baud rate is properly configured by the software.
We can appreciate a small gap every 10 clock cycles. That is due to the 10-bits size of the DAC samples.
SCLK (top) and DOUT (bottom). 46875 bps. DAC sample = 0x200 2 V/div. 50 us/div
In this test, a static DAC sample with value 0x200 is being continuously sent (in binary 0b1000000000).
We see that the first bit (after the gap in SCLK) is ON during 1 clock cycle and then OFF, confirming that the
DOUT line is properly managed.
This test is also helpful to figure out the bit order: most significant bit first (as required by the AFE031).
Design of a low-cost device for data transmission over power lines 167/181
The next graphs expose some more examples for different data values:
As explained in the first stage of this project [1], the transmission of DAC samples to the AFE031 involves a
particular management of the Chip Select: it is used to indicate the end of every sample (10-bits). This
implied a customization of the standard driver which resulted in the following management:
SCLK and CSN (Chip Select Negated). 375000 bps 2 V/div. 10 us/div
This test confirms that the customized driver properly emits a CSN pulse every 10-bits in order to notify the
AFE031 that a full DAC sample has been sent.
DOUT (0x2AA) and CSN. 3 Mbps 2 V/div. 1 us/div
Here we can see that the CSN pulse has a significant width at high baud rates.
CSN detail. 375000 bps 1 V/div. 500 ns/div
At medium baud rates (375 kbps) the CSN pulse takes 160 ns, which is much lower than the DAC sampling
period (= 10.5/375 kbps = 28000 ns). Therefore, the CSN pulse width is negligible.
CSN detail. 3 Mbps 1 V/div. 500 ns/div
At high baud rates (3 Mbps) the width of the CSN pulse is also 160 ns, but in this case it cannot be ignored
when compared to the theoretical DAC sampling period (= 10.5/3 Mbps = 3500 ns).
Design of a low-cost device for data transmission over power lines 169/181
If we evaluate the CSN pulse width for different baud rates, we get these graphs:
Note: At 12 Mbps the SCLK is not displayed as a square wave because we are close to the bandwidth
limitation of the USB oscilloscope used.
• The CSN pulse is independent of the baud rate and takes around 160ns.
• The CSN pulse adds an extra delay in the clock line that must be considered when calculating the
effective DAC frequency. It can be ignored only when using low baud rates.
The formula that considers the CSN pulse width in the conversion from the SPI baud rate (bits per second) to
the effective DAC sampling rate (samples per second) is given in the chapter 4.3.1 TX_PGA_OUT vs.
TX_F_OUT.
170/181 Design of a low-cost device for data transmission over power lines
In this chapter, all the available calibration configurations are tested to have a clear idea of how they work.
The following pages enclose the DAC-to-ADC frequency response graphs obtained with the plc-cape-freq-
response tool (see chapter 3.5.7.2):
H(f) = K*ADC(f)/DAC(f)
K is an arbitrary constant to normalize the H(f) response to 1.0 for a predefined configuration, since the
direct relation from the DAC (10-bits) to the ADC (12-bits) is not very interesting. In particular, for each
calibration configuration I have adjusted K in order H(f) returns 1.0 for 10 kHz (just a reasonable reference)
with the AFE031 filters configured for CENELEC-B.
◦ TX_PGA = 0.25 V/V. The minimum gain of the TX_PGA has been chosen to avoid saturation
effects.
◦ RX_PGA1 = 0.25 V/V. This value is ignored, since RX_PGA1 does not participate in any
calibration mode.
• Signal: sinusoid with a DAC Offset = 600 and Range = 800. This range has been selected because it
is in the linear region of all the calibration modes. Other values can produce saturation in the
transmitted signal.
• Iterations: 41 equidistant frequencies between 50 Hz and 200 kHz. I have chosen 10 kHz has the
reference frequency to be captured because it is within the pass-band of the CENELEC filters and far
from the Nyquist frequency (to have many samples per cycle).
./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:10050 -F:0 -O:600 -R:800 -U:0 -V:0 -W:0
Note that the plc-cape-freq-response application takes in consideration the PGA gains (-U:n -V:n -W:n)
as well as the Range (-R:n) when calculating H(f) so that they can be freely modified to adjust the level of
the DAC-to-ADC signal without affecting the 1.0 normalized reference.
Design of a low-cost device for data transmission over power lines 171/181
This mode only adds the Programmable Gain Amplifier block to the DAC-to-ADC loop.
# ./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:10050 -F:0 -O:600 -R:800 -U:0 -V:0 -W:0 -T:3
SETUP
-----
Test: f_ini = 50 Hz, f_end = 200050 Hz, iterations = 41
DAC values (in DAC units)
Offset = 600.000000, Range = 800.000000, AC Mean = 254.647903
EXPECTED ADC values [in ADC units]
DC mean = 930.000000, Range = 1240.000000, AC mean = 394.704224
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 50 Hz...Samples captured. DC mean = 640.41, AC mean = 423.04
Running freq = 5050 Hz...Samples captured. DC mean = 636.47, AC mean = 418.24
[...]
Running freq = 195050 Hz...Samples captured. DC mean = 632.63, AC mean = 177.71
Running freq = 200050 Hz...Samples captured. DC mean = 634.98, AC mean = 179.96
In Octave:
>> plc_freq_response_plot_all("10k-200k")
DC mean = 638.48, AC mean = 394.58, AC Range = 1245.00, FFT max at 10100.00 Hz
H max = 1.07, H min = 0.45
19 The calibration configuration diagrams are copied from AFE031 datasheet. Replace the C2000 MCU proposed in the
AFE031 by the BBB used in this project
172/181 Design of a low-cost device for data transmission over power lines
In the graph we can see that this mode exhibits a considerable attenuation for even low frequencies. This
does not fit very well with the expected behavior, which should be H(f) = 1.0 for a wide range of
frequencies. So, it might be a sign of a wrong behavior of the AFE031 due to wearing or damage, or due to
an indirect feedback from somewhere. It is something to be analyzed in a future review.
This configuration adds the TX Low-Pass Filter (CENELEC-configurable) to the transmission path.
# ./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:10050 -F:0 -O:600 -R:800 -U:0 -V:0 -W:0 -T:1
SETUP
-----
Test: f_ini = 50 Hz, f_end = 200050 Hz, iterations = 41
DAC values (in DAC units)
Offset = 600.000000, Range = 800.000000, AC Mean = 254.647903
EXPECTED ADC values [in ADC units]
DC mean = 480.000000, Range = 640.000000, AC mean = 203.718323
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 50 Hz...Samples captured. DC mean = 1500.99, AC mean = 196.81
Running freq = 5050 Hz...Samples captured. DC mean = 1539.00, AC mean = 201.32
Running freq = 10050 Hz...Samples captured. DC mean = 1538.93, AC mean = 200.83
Running freq = 15050 Hz...Samples captured. DC mean = 1539.20, AC mean = 200.64
[...]
Running freq = 195050 Hz...Samples captured. DC mean = 1538.94, AC mean = 12.58
Running freq = 200050 Hz...Samples captured. DC mean = 1538.24, AC mean = 10.32
In Octave:
>> plc_freq_response_plot_all("10k-200k")
DC mean = 1538.32, AC mean = 201.28, AC Range = 641.00, FFT max at 10100.00 Hz
H max = 0.99, H min = 0.05
174/181 Design of a low-cost device for data transmission over power lines
Here the graphs are the expected ones. We can clearly identify a cutoff frequency (gain = 1/√2 = 0.7) around
125kHz.
The FFT representation is a useful way to detect distortion effects. For example, in case of saturation we will
see several harmonics with a noticeable level.
We can force this situation by configuring the TX_PGA to 1V/V. To do so, use the flag -U:3 in the command
line:
# ./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:10050 -F:0 -O:600 -R:800 -U:3 -V:0 -W:0 -T:1
SETUP
-----
Test: f_ini = 50 Hz, f_end = 200050 Hz, iterations = 41
DAC values (in DAC units)
Offset = 600.000000, Range = 800.000000, AC Mean = 254.647903
EXPECTED ADC values [in ADC units]
DC mean = 1920.000000, Range = 2560.000000, AC mean = 814.873291
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 50 Hz...Samples captured. DC mean = 1502.71, AC mean = 625.16
Running freq = 5050 Hz...Samples captured. DC mean = 1621.14, AC mean = 629.39
Running freq = 10050 Hz...Samples captured. DC mean = 1622.87, AC mean = 631.41
Running freq = 15050 Hz...Samples captured. DC mean = 1626.76, AC mean = 636.61
[...]
Design of a low-cost device for data transmission over power lines 175/181
In Octave:
>> plc_freq_response_plot_all("10k-200k")
DC mean = 1621.10, AC mean = 632.08, AC Range = 1773.00, FFT max at 10100.00 Hz
H max = 0.81, H min = 0.14
Here we can see a first sign of trouble: the maximum value of H(f), H max, has decreased from 1.0 to 0.8.
That means that we are getting 20% less voltage level (in average) than expected.
The H(f) response is similar in shape to the non-saturated case, except for the H(f) gain level.
We can see the saturated wave at right, and the presence of harmonics in the FFT at bottom.
The ADC captured range spans now from 600 to 2400 which is far below the maximum ADC range (from 0
to 4905). That means that saturation occurs on transmission, not on reception.
176/181 Design of a low-cost device for data transmission over power lines
In the following test we have switched the TX_LPF filter from CENELEC-B to CENELEC-A, and reverted
back TX_PGA to the default gain (0.25 V/V):
./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:10050 -F:1 -O:600 -R:800 -U:0 -V:0 -W:0 -T:1
SETUP
-----
Test: f_ini = 50 Hz, f_end = 200050 Hz, iterations = 41
DAC values (in DAC units)
Offset = 600.000000, Range = 800.000000, AC Mean = 254.647903
EXPECTED ADC values [in ADC units]
DC mean = 480.000000, Range = 640.000000, AC mean = 203.718323
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 50 Hz...Samples captured. DC mean = 1497.99, AC mean = 195.67
Running freq = 5050 Hz...Samples captured. DC mean = 1537.65, AC mean = 200.98
Running freq = 10050 Hz...Samples captured. DC mean = 1537.48, AC mean = 200.64
Running freq = 15050 Hz...Samples captured. DC mean = 1537.45, AC mean = 200.44
[...]
Running freq = 195050 Hz...Samples captured. DC mean = 1536.31, AC mean = 1.20
Running freq = 200050 Hz...Samples captured. DC mean = 1536.03, AC mean = 0.99
In Octave:
>> plc_freq_response_plot_all("10k-200k")
DC mean = 1538.03, AC mean = 201.07, AC Range = 637.00, FFT max at 10100.00 Hz
H max = 0.99, H min = 0.00
Note: Although the diagram in the AFE031 datasheet includes into the loop the first RX PGA (RX_PGA1), it
seems that it is not. In a dedicated test I got the exact same ADC values for RX_PGA1 = 0.25 V/V as for
RX_PGA1 = 2.00 V/V.
This calibration mode is enabled with the -T:2 flag:
# ./plc-cape-freq-response -A:50 -B:200050 -C:41 -D:10050 -F:0 -O:600 -R:800 -U:0 -V:0 -W:0 -T:2
SETUP
-----
Test: f_ini = 50 Hz, f_end = 200050 Hz, iterations = 41
DAC values (in DAC units)
Offset = 600.000000, Range = 800.000000, AC Mean = 254.647903
EXPECTED ADC values [in ADC units]
DC mean = 1912.000000, Range = 700.000000, AC mean = 222.816910
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 50 Hz...Samples captured. DC mean = 1915.47, AC mean = 35.09
Running freq = 5050 Hz...Samples captured. DC mean = 1912.56, AC mean = 223.42
Running freq = 10050 Hz...Samples captured. DC mean = 1912.22, AC mean = 223.88
Running freq = 15050 Hz...Samples captured. DC mean = 1912.03, AC mean = 223.84
[...]
Running freq = 195050 Hz...Samples captured. DC mean = 1913.38, AC mean = 42.94
Running freq = 200050 Hz...Samples captured. DC mean = 1914.20, AC mean = 38.03
In Octave:
>> plc_freq_response_plot_all("10k-200k")
DC mean = 1911.10, AC mean = 224.35, AC Range = 719.00, FFT max at 10100.00 Hz
H max = 1.01, H min = 0.16
178/181 Design of a low-cost device for data transmission over power lines
Notice here an important difference compared to the previous calibration modes: now the iteration at 50 Hz
is not in the pass-band (gain < 0.2).
If we repeat the test for the CENELEC-A (-F:1) we get:
H(f). TX_PGA + RX_LPF + RX_PGA2 loop. CENELEC-A
Finally, we can analyze the low frequency range (10 Hz to 1 kHz) in a more accurate way by executing the
tool as follows:
# ./plc-cape-freq-response -A:10 -B:1010 -C:41 -D:1010 -F:1 -O:600 -R:800 -U:0 -V:0 -W:0 -T:2
SETUP
-----
Test: f_ini = 10 Hz, f_end = 1010 Hz, iterations = 41
DAC values (in DAC units)
Offset = 600.000000, Range = 800.000000, AC Mean = 254.647903
EXPECTED ADC values [in ADC units]
DC mean = 1912.000000, Range = 700.000000, AC mean = 222.816910
Sampling rate = 522 ksps
TRANSFER FUNCTION
-----------------
Running freq = 10 Hz...Samples captured. DC mean = 1919.55, AC mean = 3.12
Running freq = 35 Hz...Samples captured. DC mean = 1916.11, AC mean = 24.45
Running freq = 60 Hz...Samples captured. DC mean = 1912.51, AC mean = 42.16
Running freq = 85 Hz...Samples captured. DC mean = 1917.21, AC mean = 59.75
Running freq = 110 Hz...Samples captured. DC mean = 1915.82, AC mean = 74.13
[...]
Running freq = 985 Hz...Samples captured. DC mean = 1913.38, AC mean = 212.72
Running freq = 1010 Hz...Samples captured. DC mean = 1910.60, AC mean = 213.21
In Octave:
>> plc_freq_response_plot_all("10-1k")
DC mean = 1909.71, AC mean = 214.21, AC Range = 679.00, FFT max at 1000.00 Hz
H max = 0.96, H min = 0.01
We see here the response of a high-pass filter with a cutoff frequency around 300 Hz.
180/181 Design of a low-cost device for data transmission over power lines
10 Bibliography
All the bibliographic references (unless otherwise noted) are provided as online URL links which have been
accessed and validated on April 2017.
10.3 Arduino
[7] Arduino - Home
https://www.arduino.cc
[8] Arduino - ArduinoBoardLeonardo
https://www.arduino.cc/en/Main/arduinoBoardLeonardo
[9] Arduino_Leonardo-REV3b.sch, 2012, 1 page
https://www.arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf
[10] Atmel, ATmega16U4/ATmega32U4 8-bit Microcontroller with 16/32K bytes of ISP Flash and USB
Controller, Datasheet, 438 pages
http://www.atmel.com/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf
[11] Arduino | 37 in 1 Sensors Kit Explained
http://www.instructables.com/id/Arduino-37-in-1-Sensors-Kit-Explained
10.4 Raspberry Pi
[12] Raspberry Pi - Teach, Learn, and Make with Raspberry Pi
https://www.raspberrypi.org
10.5 PLC
[13] Power-line communication
https://en.wikipedia.org/wiki/Power-line_communication
[14] DC Power Line Communication (PLC) Reference Design
http://www.ti.com/tool/24VDCPLCEVM?keyMatch=PLC&tisearch=Search-EN-Everything
[15] Welcome to CENELEC - European Committee for Electrotechnical Standardization
https://www.cenelec.eu/
Design of a low-cost device for data transmission over power lines 181/181
10.6 AFE31
[16] AFE031 | Precision Amplifier | Operational Amplifier (Op Amp) | Description & parametrics
http://www.ti.com/product/afe031
[17] "Texas Instruments, Incorporated”, Powerline Communications Analog Front-End (Rev. D), Data Sheet,
2010-2012, 58 pages
http://www.ti.com/lit/ds/symlink/afe031.pdf
http://www.ti.com/lit/gpn/afe031
[18] "Texas Instruments, Incorporated”, AFE Design for a Narrowband Power-Line Communications
Modem Using the AFE031 (Rev. A), Application Reports, 2011, 36 pages
http://www.ti.com/lit/an/sboa130a/sboa130a.pdf
[19] "Texas Instruments, Incorporated”, QFN Layout Guidelines, Application Reports, 2006, 7 pages
http://www.ti.com/lit/an/sloa122/sloa122.pdf
[20] System on Module for Industrial Power Line Communication (CENELEC Frequency Band)
http://www.ti.com/tool/tidm-somplc-industrial-cenelec
[21] Power Line Communications Kit for CENELEC Frequency Band
http://www.ti.com/tool/tmdsplckitv4-cen
10.7 Push-Pull
[22] Push-Pull Output Stage
http://www.ecircuitcenter.com/Circuits/pushpull/pushpull.htm
[23] MOSFET Push Pull Amplifier
http://reviseomatic.org/help/s-push-pull/Push%20Pull%20MOSFET%20Amp.php