There was a time, probably just 5 years ago, when regular mobile phone providing connectivity at an affordable price while allowing a person to be mobile was considered good enough. The smartphones were considered an object for the rich (due to their prices) and one used to wonder why I need such expensive phones when I can easily afford a cheaper one that serves “the purpose”.
The US President-elect’s stand on climate change, amongst other things, has been a hot topic of discussion since the election day. As the world fears losing a leader in the fight against climate change when Donald Trump takes charge of the oval office later this month, all eyes are set on China and India to fill this void.
Sensors come in all shapes and sizes and just like anything else in the world, one size does not fit all. It would also be unwise to say that more expensive means more suitable. Before choosing a sensor, one needs to define the purpose that one is expecting it to serve.
Power factor is nothing but a representation of reactive power required by the load (froth on the beer). The need for utility to supply reactive power can be eliminated if it is made available at site. Correction capacitors are installed to meet this requirement.
Have you ever looked at your electricity bill and wondered why you are being charged for more than your consumption? This problem is often faced by industrial consumers, who are billed on kVAh supplied instead of kWh consumed. Let us first try to understand what these terms mean and what role does power factor play in your electricity consumption.
Climate change is no more a thing of the future, it is no more about making the planet inhabitable for the future generations. It is happening right here, right this moment. Many of us discard the “theory” of climate change pointing towards the extra snowy winters in their towns. A simple explanation to that is that as temperatures rise, more water vapour is held in the atmosphere which leads to more intense rain and snow storms. Duration of cold weather decreases but the intensity can very well increase.
This post is about making an OpenWRT image with the usb dongle support.
We, as a part of our kit that collects and sends data of energy meters over then net required to use routers in the solution along with the raspberry.
We settled on TP-LINK MR3020 with usb dongle support. Now, there is always an issue with usb dongles which cause them to lose connectivity and they go into a hung state which can be resolved by just plugging out an plugging in the dongle back. But in a system that has to be deployed, has to work without manual intervention, that can’t be a solution. So we needed more control over the router, and hence OpenWRT.
OpenWRT has a pretty decent documentation wiki of its own, but it is a little scattered, and this post is intended to describe making of an image with the 3g dongle usage in mind. The steps listed here should work with pretty much any router just by replacing a few words in the command which I will highlight as and when required.
(This is the link to the OpenWRT documentation on how to make a custom image. — http://wiki.openwrt.org/doc/howto/obtain.firmware.generate )
Firstly, check the architecture of your router and download the appropriate image builder from here (go to the folder of your router’s architecture and download the ImageBuilder archive. For TLMR3020, I went to ar71xx)—http://downloads.openwrt.org/barrier_breaker/14.07/
Extract the archive. Go to the extracted folder (for me it was OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64). Configure the package repositories in the repositories.conf file. My repositories file looked like (copied from the OpenWRT wiki)
src/gz barrier_breaker_base http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/base src/gz barrier_breaker_luci http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/luci src/gz barrier_breaker_management http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/management src/gz barrier_breaker_oldpackages http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/oldpackages src/gz barrier_breaker_packages http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/packages src/gz barrier_breaker_routing http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/routing src/gz barrier_breaker_telephony http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony ## This is the local package repository, do not remove! src imagebuilder file:packages
The command to build the image is
make image PROFILE=XXX PACKAGES="pkg1 pkg2 pkg3 -pkg4 -pkg5 -pkg6" FILES=files/
Check the name of profile for your router, most likely it would be the router’s name. For me it was TLMR3020. You can check the list of available profiles by running <make info> command in the extracted folder. The list of profiles available for ar71xx are — http://pastebin.com/WbudpBDJ.
Following are the packages required for the usb dongle to work and for luci (the web interface. You can exclude it if just ssh access is fine for you)
comgt kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan usb-modeswitch kmod-usb-storage block-mount kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859–1 luci-proto-3g luci
This is the important part for the image to work out of the box. For wireless and usb dongle to work as soon as you install the image (this is important for those who are update the firmware over remote access, as was the case for me), some files need to be included in the image. The way to include the files is extremely simple. You just make a directory in which you include the files exactly in the same structure as you want them in the router and pass the path of that directory. I included the following files in my directory –
ABORT BUSY ABORT ‘NO CARRIER’ ABORT ERROR REPORT CONNECT TIMEOUT 10 “” “AT&F” OK “ATE1" OK ‘AT+CGDCONT=1,”IP”,”$USE_APN”’ SAY “Calling UMTS/GPRS” TIMEOUT 30 OK “ATD*99#” CONNECT ‘ ‘
The second last line might need to be changed according to your ISP.
config defaults option syn_flood 1 option input ACCEPT option output ACCEPT option forward REJECT # Uncomment this line to disable ipv6 rules # option disable_ipv6 1
config zone option name lan list network ‘lan’ option input ACCEPT option output ACCEPT option forward ACCEPT
config zone option name wan list network ‘wan’ list network ‘wan6' option input REJECT option output ACCEPT option forward REJECT option masq 1 option mtu_fix 1
config forwarding option src lan option dest wan
# We need to accept udp packets on port 68, # see https://dev.openwrt.org/ticket/4108 config rule option name Allow-DHCP-Renew option src wan option proto udp option dest_port 68 option target ACCEPT option family ipv4
# Allow IPv4 ping config rule option name Allow-Ping option src wan option proto icmp option icmp_type echo-request option family ipv4 option target ACCEPT
# Allow DHCPv6 replies # see https://dev.openwrt.org/ticket/10381 config rule option name Allow-DHCPv6 option src wan option proto udp option src_ip fe80::/10 option src_port 547 option dest_ip fe80::/10 option dest_port 546 option family ipv6 option target ACCEPT
# Allow essential incoming IPv6 ICMP traffic config rule option name Allow-ICMPv6-Input option src wan option proto icmp list icmp_type echo-request list icmp_type echo-reply list icmp_type destination-unreachable list icmp_type packet-too-big list icmp_type time-exceeded list icmp_type bad-header list icmp_type unknown-header-type list icmp_type router-solicitation list icmp_type neighbour-solicitation list icmp_type router-advertisement list icmp_type neighbour-advertisement option limit 1000/sec option family ipv6 option target ACCEPT
# Allow essential forwarded IPv6 ICMP traffic config rule option name Allow-ICMPv6-Forward option src wan option dest * option proto icmp list icmp_type echo-request list icmp_type echo-reply list icmp_type destination-unreachable list icmp_type packet-too-big list icmp_type time-exceeded list icmp_type bad-header list icmp_type unknown-header-type option limit 1000/sec option family ipv6 option target ACCEPT
# include a file with users custom iptables rules config include option path /etc/firewall.user
config interface ‘loopback’ option ifname ‘lo’ option proto ‘static’ option ipaddr ‘127.0.0.1' option netmask ‘255.0.0.0'
config globals ‘globals’ option ula_prefix ‘fd66:0dee:5f2c::/48'
config interface ‘lan’ option force_link ‘1' option type ‘bridge’ option proto ‘static’ option ipaddr ‘192.168.1.1' option netmask ‘255.255.255.0' option ip6assign ‘60' option _orig_ifname ‘eth0 wlan0' option _orig_bridge ‘true’ option ifname ‘eth0'
config interface ‘wan’ option _orig_ifname ‘radio0.network1' option _orig_bridge ‘false’ option proto ‘3g’ option device ‘/dev/ttyUSB0' option service ‘gprs_only’ option apn ‘internet’
config wifi-device ‘radio0' option type ‘mac80211' option channel ‘11' option hwmode ‘11g’ option path ‘platform/ar933x_wmac’ option htmode ‘HT20' option txpower ‘30' option country ‘US’
config wifi-iface option device ‘radio0' option mode ‘ap’ option ssid ‘OpenWRT-Wifi’ option encryption ‘none’ option wmm ‘0' option network ‘lan’
Last three files are just copied from the router once all the options had been configured.
The next 3 files are two fix the dongle reset problem.
What we figured out was that every now and then the dongle got reset and lost its connection which can be solved by plugging out and plugging back the dongle. To emulate this a script is there by name of donglereset which checks if the internet is not working it switches the usb power off and on again after a couple of seconds. This is done by switching off the GPIO pin on the router.This pin might be different for different routers. The current script works for TLMR3020 with pin 8 for usb. The other two files are for initiating the cron and one crontab which runs the cron every 15 minutes.
wget -s http://google.com if [[ $? -eq 0 ]]; then echo “Online” else echo “Offline” ifdown wan # turn off USB power echo 0 > /sys/devices/virtual/gpio/gpio8/value # let things settle sleep 2 # turn on USB power echo 1 > /sys/devices/virtual/gpio/gpio8/value # restart the interface ifup wan fi
*/15 * * * * ash /root/donglereset
# start crond /usr/sbin/crond -c /etc/crontabs
All these files are to be included in a directory files within the extracted folder and with the same directory structure as mentioned.
Now, run the make image command. For me, it was
sudo make image PROFILE=TLMR3020 PACKAGES=”comgt kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan usb-modeswitch kmod-usb-storage block-mount kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859–1 luci-proto-3g luci” FILES=files/
You now will have the image in bin folder of the extracted folder in the directory name of your architecture. Mine’s name was openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin. You can now use upload this image via the firmeware upgrade option in the router.
Power factor improvement has always been a crucial area of concern for all industrial plants and big office spaces incurring large electricity cost. According to government norms, these type of consumers are to be supplied through HT line and billed on KVAh instead of Kwh. Where Kwh means total active energy delivered and KVAh is vector sum of both active and reactive energy. Supply at HT line of 11kv or 33kv has increased the effects of low power factor on the billing amount of the users. Although capacitor banks are already installed at every facility for power factor correction, confusion still remains about the ideal point of sensing and correction to minimize the overall losses.
To get the ideal point of compensation, we need to analyze the ways in which low power factor affects the total electricity cost.
Type of losses due to low Power Factor-
For all the users which are being supplied at HT, low power factor affects the billing by two ways. One component is the difference of KVAh and Kwh, which accounts for direct per unit billing and the other is of the copper losses in the transmission and distribution losses due to the extra current.
Considering the example data to quantify this type of losses. For a 1000KVA connection (contract demand), if the user is consuming a constant load of 800kw at 0.9 power factor on day1 and at 0.95 on day2.
For day1- Energy consumed= (800/0.9)*24= 21333KVAh
For day2- Energy consumed= (800/0.95)*24= 20210KVAh
This shows an additional 1123 units in one day for which the consumer will be charged for a power factor of 0.9 as compared with 0.95.
Copper losses –
Considering the same situation as for direct losses, current flowing in the conductors will be higher on day1; when the power factor is low. So there will be additional heating losses in the conductors for both transmission and distribution side. As the current on HT lines are low as compare to LT, this type of losses are very less on HT conductors. But on LT line, as the voltage is 430V, current flowing will be-
For day1- ((800/0.9)*1000)/430= 1192 amperes
For day2- ((800/0.95)*1000)/430=1130 amperes
Copper losses are directly proportional to square of current and resistance of the conductors. As cables used for distribution are generally 4 core copper armored cables and they are of different sizes according to load distribution and have different resistances.
For a rough estimation, consider the conductor resistance as 0.19 ohm/km (based on data in Table.1) and length of conductor as 200meter for distribution. Copper losses will be-
For day1- ((1192)^2*(0.19/5))/1000= 54kw; for 24 hours- 54*24=1296kwh
For day2- ((1130)^2*(0.19/5))/1000=48kw; for 24 hour- 48*24=1152kwh
This indicates the additional loss of 144 units in one day.
Check the chart below as reference for cable resistance.
Ideal Point of correction-
The decision about the point of capacitor connection and APFC relay sensing is to be decided while keeping in mind the utility’s billing design and copper losses in the power cables. Along with cables, reactive current flowing in transformer decreases its efficiency and results in poor voltage regulation. 
Different approaches to the problem are presented below, along with their benefits and shortcomings.
CASE1: Capacitor Bank and APFC connected at Point B-
Refer to figure.1 and consider line-1 and line-2 connected under this condition, the power factor on the distribution is low (without compensation) but it is corrected at the HT panel, there will be no penalty from the utility but the copper losses in the distribution will be high. In this situation, there will be reactive current flowing in the transformer as well, reducing its efficiency and operational life. As the sensing of APFC is at point-B, control on the power factor of point B will be better.
CASE2: Capacitor Bank and APFC connected at Point A-
Consider Line-3 and Line-4 as connecting lines in fig.1, in this case the relay and capacitor arrangement will increase the power factor at point A. Consider PF to be 0.99 at point A. But in this condition relay has no data about the power factor at point A, it is the point at which utility will bill the consumer. It will fall below set point due the inductive nature of transformer and the power cables. Thus this arrangement will reduce the copper losses at distribution but relay will have poor control over the power factor at which utility is billing.
CASE3: Capacitor Bank at point A and APFC relay at Point B-
Consider line-2 and line-3 connected, as the APFC is connected at point B and Capacitor at point A, relay will always sense the power factor at HT meter. Under this situation, power factor of the distribution side is high and capacitor switching is governed by the power factor at HT meter. Thus, this arrangement gives the high PF at distribution side and also better control over the PF at HT meter and is considered as the ideal situation of working.
Refer to the table below for further clarity of all three cases with sample data.
Sizing of Capacitor Banks-
For attaining proper control over the power factor through APFC, capacitor banks are to be sized properly otherwise frequent switching of power contactors will damage the capacitor and power feeder as well.
For illustration, consider a distribution circuit where 250KVAr of reactive power is required and the capacitor banks are of 50KVAr each. If this arrangement will put on AUTO mode of APFC control, relay will switch ON 5 Capacitor Banks and power factor will be close to unity but it will not be able to respond to small changes in KVAr demand. If the KVAr demand is shifted from 250 to 225, relay will not be able to maintain a unity PF. To maintain a power factor close to unity, rating of different capacitor banks is dependent upon the analysis on reactive power requirement. Based on demand analysis, this compensation requirement should be divided into the fixed and variable parts. For a production plant, minimum load and thus minimum KVAr load can be calculated. And the remaining KVAr is to be compensated based on variable requirement. Consider the similar situation of 250KVAr requirement; calculation for minimum reactive power requirement can be done based on stored data for months. Let’s assume that the minimum requirement comes out to be 150KVAr; that means single capacitor bank of 150 rating is to be used. Along with this, rest of the demand is to be compensated in steps. Thus, ideal compensation should have one 150KVAr, 3*25KVAr capacitors and 3*10 capacitors. As one APFC relay can control the switching of up to 12 capacitor banks, all the arrangement can be controlled by one relay. (Other than this, APFC relay are available for 3, 5, 7 and 8 capacitor control too.  ) In this distribution scheme, relay will sense the change in reactive compensation and switch ON/OFF the capacitor bank which gives the best result.
By the analysis of the data collected by Zenatix’s software, we help clients to figure out the ideal number of Capacitor Banks and their sizes at different points of distribution network. Other than the size of capacitor bank, optimum number of APFC relay required and number of capacitor banks to be controlled by it can be determined by the same data.
Figure and Table Detail-
Fig.1-Power distribution scheme of a consumer with HT incomer along with capacitor banks
Table.1-Resistance of 4 core armored copper cables with their specific current rating
Table-2-Pros and cons of different power factor improvement schemes
1 Schedule of Tariff for – H.T. Industrial And Steel Furnace Power Supply by DHBVN.
Description of Nameplate-
The nameplate installed on a DG reads it KVA rating, KW,maximum current and power factor among other parameters. Our focus here is onlyon power factor and its effect on output KW. Most of DG manufacturers mention0.8 as rated power factor of DG. But itdoesn’t mean that DG must be operated at 0.8 power factor at all the time, ratherit is the minimum limit on power factor of the load which can be served by it without affecting its performance in the long run.  Also, as a DG cannot absorb reactive energy the power factor must stay in lagging region. So the power factor has to be kept between 0.8 and 1.0.
Consider the alternator capability curve below for referring to safe operational limits on DG.
The green part is the region ideal for the DG to operate; it is the window of 0.8 to 1.0 power factor. The yellow region represents the working conditions where DG will run on low efficiency but with no damaging effects. And the red area represents the load operation which will have damaging effects on the DG.
Even within the power factor window of 0.8 to 1.0, the efficiency of the diesel generator varies which is analyzed next.
Understanding the impact of power factor on DG-
All diesel generators have a rated KVA and a nameplate power factor. For a diesel generator of 500KVA and 0.8 power factor, the active power capacity is limited by 400KW. Also, the reactive power that can be supplied by it is 300KVAr. Now, to compare the efficiency at 0.8 and 1 power factor, consider exact same active load on the output sides of two diesel generators.
Consider two DGs of 500KVA, with DG1 supplying an active load of 400KW on 0.8 power factor and DG2 supplying 400KW on 1.0 power factor. The output will be 500KVA on DG1 and 400KVA on DG2. With constant single phase voltage of 240 volts at the terminal, the current flowing in the two DGs will be-
I1= 500000/ 240= 2083 amperes (also the maximum current limit)
I2= 400000/240= 1666 amperes
I1-I2= 417 amperes
As copper losses inside the alternator part of the DG are directly proportional to the square of the current flowing, the efficiency reduces at lower power factor.
As the losses of the alternator increases by decreasing the power factor, the engine part of the DG will have to produce more active power and so it will consume more diesel. 
Refer to the image below for the effect of power factor on DG’s efficiency, which is published by a leading manufacturer of diesel generator in India.
Also for power factor of 0.8 to 1.0, it is important to understand the role of automatic voltage control relay (AVR). AVR is responsible for maintaining the output voltage of the DG, for lower power factors, by producing higher excitation current to keep the voltage within acceptable limits. To compensate for extra current losses, generator will have to produce more KW at 0.8 pf than at 1.0 pf. But as it goes to leading pf region, current has to be induced in the magnetic coil for compensation. However this induced current has a limit and thus DG cannot supply a load of power factor more than 0.97 leading.  After this limit, AVR gets cut off and DG will be tripped on over-voltage.
As diesel generators do not handle the leading power factor loads very well, it is to be made sure that the load applied to them does not cross 1.0 power factor.
Considering the effects of current losses and risk involved with going into leading power factor region, it is advised to maintain the power factor from 0.95 to 0.97. 
Effects of Single phase non-linear loads-
The true power factor of an electrical distribution system is a multiple of two contributing factors, displacement power factor and distortion power factor. Displacement power factor is angular displacement between current and voltage waveforms; caused by inductive or capacitive loads. Distortion power factor arises due to harmonics present in the system and this cannot be compensated by adding shunt capacitors.
In an office space most of the loads consists of computers or laptops which are single phase non-linear loads. In such conditions, level of distortion in current is very high. Typical values of displacement and distortion power factor for a computer are 0.99 and 0.6. When connected to the grid, the effect is minimized due its rigidity but if a DG is supplying to such a load, adding shunt capacitors will make DG to absorb reactive energy. Which will make it trip, giving the impression of over load operation.
Adding capacitors as filters under such situation will reduce the distortion of the current waveform and will improve the power factor. Following table can be referred for relationship between current harmonics distortion and power factor which can be attained using shunt capacitors.
At Zenatix, we collect both power factor and KVA delivered by the DG on continuous basis. Also with the help of advanced metering devices, current harmonics can be measured and used to draw the right compensation measure. By the analysis provided by Zenatix, a client can keep a check on DG’s operational parameters and draw power at maximum efficiency without affecting its performance in the long term. As a unit of power produced by DG costs 15-20 rupees with a typical efficiency of 30-35%, improving the efficiency of alternator will result in significant reduction in diesel consumption per unit produced.
Below is the plot of data collected from two of Zenatix’s customers.
By the plot, it can be inferred that power factor of client-2 can be improved for obtaining better performance from diesel generator. According to Fig.2, an improvement of power factor from 0.87 to 0.96 will result in improvement of efficiency by 0.5% at 60% loading.
1. Alternator adaptability curve for DG under leading and lagging load.
2. Effect of power factor on the efficiency of diesel generator.
3. Power factor plot of 2 DG’s at Zenatix’s Customer side.
2 Power topic #6001 | Technical information from Cummins Power Generation
4 Power topic #6004 | Technical information from Cummins Power Generation
6 Harmonics and how they relate to power factor- by W.Mack Grady, The university of Texas at Austin, Austin, Texas 78712 AND Robert J.Gilleskie, San Diego Gas & Electric , San Diego, California, 92123