Skip navigation

Arduino Projects

5 Posts authored by: peterjcs23

At last a chance to catch up with my Energy Monitor Arduino Project.

 

Here is the circuit I will build to work with my Arduino Uno via the SPI interface:

 

It is a design that was informed by discussions from this question:

 

How to Use Current and Voltage Sensors on Domestic supplies - Worldwide?

 

In the USA they use a split transformer to feed power to houses so that appliance will run on 110V or 220V. Using 220V keeps the current down for cookers and heaters.

 

The next step will be to make a prototype and set up the SPI port of the Arduino.

 

Previous Blogs:

 

1. AardEnergy – Kick Off - a new project

2. AardEnergy – Set Up Uno and Due

3. AardEnergy – Current and Voltage Transformers

4. AardEnergy – Metering Chips

4. AardEnergy – Metering Chips

In this Blog

So far I have chosen sensors without much consideration of how the Arduino will handle the data. The plan is to use a meter chip with the Uno and to directly convert the sensor voltages (after suitable scaling) with the Due.  In this blog I will evaluate a number of meter chips for use with the Uno…ADE7753, ADE7763, MCP3905, MCP3909.

See previous Blogs…

http://www.element14.com/community/groups/arduino/blog/2015/11/23/1-aardenergy-kick-off--a-new-project

 

http://www.element14.com/community/groups/arduino/blog/2015/11/26/2-aardenergy-set-up-uno-and-due

 

http://www.element14.com/community/groups/arduino/blog/2015/12/10/3-aardenergy-current-and-voltage-transformers

Metering Chips

ADE7753

This chip is made by Analog Devices as part of their Energy Metering IC family. They say:

Analog Devices’ ADE energy measurement ICs address the challenges of next-generation smart meter architectures and are ideal for measuring active energy (kWh), apparent energy (kVA), reactive energy (kVAR), rms, and power quality with the highest accuracy in single phase and polyphase revenue meters, industrial instruments, and energy monitoring applications. ADI’s ADE energy measurement ICs combine analog-to-digital converters with fixed-function digital signal processors to perform critical measurements, while providing unparalleled functionality and ease of use.

This is a summary of its capabilities:

Part

ADE7753

Function

Single Phase Meter

Measurements Available

Apparent Power, Irms, Total Active Power, Total Reactive Power, Vrms

Current Sense Type

Current Transformer, Rogowski Coil, Shunt    

MPU Interface

Energy Pulses, SPI …see below

Current Channel Input Range

±0.5V maximum.

Voltage Channel Input Range

±0.5V maximum

Active Energy Accuracy

0.1%    

Special Features

Low Power, Waveform Sampling        

VSupply min

4.75V  

VSupply max

5.25V  

Supply current

5 mA

Price 1off Farnell

£2.63

SPI Description:

 

ADE7763

 

Part

ADE7763

Function

Single Phase Meter

Measurements Available

Apparent Power, Irms, Total Active Power, Vrms

Current Sense Type

Current Transformer, Rogowski Coil, Shunt    

MPU Interface

Energy Pulses, SPI …see below

Active Energy Accuracy

0.1%    

Current Channel Input Range

±0.5V maximum.

Voltage Channel Input Range

±0.5V maximum

Special Features

Low Power, Waveform Sampling        

VSupply min

4.75V  

VSupply max

5.25V  

Supply current

5 mA

Price 1off Farnell

£1.69

SPI description:

 

 

MCP3905

 

Part

MCP3905

Function

Single Phase Meter

Measurements Available

Real Power

Current Sense Type

Current Transformer, Shunt  

MPU Interface

Power Pulses

Active Energy Accuracy

0.1%    

Current Channel Input Range

±0.47V maximum.

Voltage Channel Input Range

±0.66V maximum

Special Features

 

VSupply min

4.5V    

VSupply max

5.5V    

Supply current

2.7 mA

Farnell Price

£1.14

 

 

MCP3909

 

Part

MCP3909

Function

Single Phase Meter

Measurements Available

Real Power on pulse output, waveforms on SPI

Current Sense Type

Current Transformer, Shunt  

MPU Interface

Power Pulses, SPI

Active Energy Accuracy

0.1%    

Current Channel Input Range

±0.47V maximum.

Voltage Channel Input Range

±0.66V maximum

Special Features

 

VSupply min

4.5V    

VSupply max

5.5V    

Supply current

2.7 mA

Farnell Price

£1.47

SPI:

 

Making a Choice of Meter Chip

 

The list of chips above was based on 3 requirements:

  • Single phase monitor
  • SPI interface, power and energy data
  • Low cost

The MCP3905 does not have an SPI interface, so is ruled out. The pulse output of this chip could be counted on an Arduino input but that was not my target application.

The MCP3909 has an SPI interface but that data is the raw waveform, so the chip is acting as an external ADC which again is not what I wanted to do in my application. I want to use the internal Arduino ADC on the Due and for the Uno I want a meter chip that does all the calculations and presents power and energy data at the SPI port.

The ADE7753 has all the required features, the power and energy calculation are done on the chip and the results are presented as data to the SPI port. The same is true of the ADE7763 which is less expensive but has less features as it does not calculate the Reactive Power. I’m going to use the ADE7753 as I’m not concerned about the small extra cost £2.63 against £1.69 and the Reactive Power may be of interest. Both of these chips have to ability to interface with Current Transformers or Rogowski coils to measure current. I’m interesting in Rogowski coils so this is a feature I will use at some point.

Product page:

http://www.analog.com/en/products/analog-to-digital-converters/integrated-special-purpose-converters/single-phase-metering-ic/ade7753.html

 

 

Sensor Interface

 

Current Transformer CT

 

What are the essential parameters we know about?

  • The input to the ADE7753 is a differential programmable gain amplifier with a range of ±500mV relative to analogue ground.
  • Input impedance 390k
  • The output of the current transformer is ±1000mV.
  • The power rail available from the Arduino Uno is 5V.
  • The signal can be 50Hz or 60Hz with a measurement Bandwidth of 14kHz Anti-aliasing cut-off frequency needs to be 10kHz.

The description of the interface to the ADE7753 in the evaluation circuit is based in a meter with direct connection to the mains wiring and as such is unsuitable for this application. We are using isolated sources for the signals to make them safe to handle on an Arduino board. However there has to be an anti-aliasing filter on the input and the normal operating range has to be limited to ±500mV relative to analogue ground. Our CT has an output of 1000mV so we need a ½ attenuation as well as the filter. From the datasheet a simple RC filter with a corner frequency of 10kHz is recommended to remove any high frequency noise. The input impedance of the ADE7753 amplifiers is 390k so we can use a voltage divider of say 1k resistors and a suitable capacitor to give 10kHz low-pass bandwidth. The equivalent resistance of the divider will be 1k in parallel with 1k or 500R. The capacitor can be calculated from frequency=1/(2πRC) and we will use 33n as the closest available value. So that we do not degrade the 0.5% accuracy of the chip too much we will use 0.1% resistors, and a 5% capacitor will be good enough.

 

Voltage Transformer VTx

 

What are the essential parameters we know about?

  • The input to the ADE7753 is a differential programmable gain amplifier with a range of ±500mV relative to analogue ground.
  • Input impedance 390k
  • The output of the voltage transformer is  ±17.2V
  • The power rail available from the Arduino Uno is 5V.
  • The signal can be 50Hz or 60Hz with a measurement Bandwidth of 14kHz. Anti-aliasing cut-off frequency needs to be 10kHz.

Our VTx has an output of 17.2V so we need an attenuation to 0.5V as well as the anti-aliasing filter with a corner frequency of 10kHz. The input impedance of the ADE7753 amplifiers is 390k so we can use a voltage divider of around 1k resistors and a suitable capacitor to give 10kHz low-pass bandwidth. If we choose resistors to ultimately give the same capacitor value as for the current measurement channel, we will only have to buy one type of capacitor. This is a good design aim as capacitors are available in fewer types and values compared to resistors. If we choose 510R as the lower value then the voltage divider is made with 17.4k and 510R resistors, which is an attenuation factor of 0.0284757, so 17.2V will be represented by 489.8mV which is within the measurement range of the ADE7753. The equivalent resistance of the divider is 17.4k in parallel with 510R or 495.5R and the capacitor can be calculated from frequency=1/(2πRC) and we will use 33n as the closest available value.

SPI Interface (Hardware)

 

This is the Arduino SPI reference page:

https://www.arduino.cc/en/Reference/SPI

…and the Atmel data sheet:

http://www.atmel.com/Images/doc8161.pdf

 

The Arduino Uno will be set up as the SPI master and the ADE7753 as the slave/peripheral. The logic signals can be directly connected, both operate on 5V logic:

SS Arduino is slave select, connect to ADE7753 nCS.

MISO Arduino is the data input from the Slave, connect to DOUT of the ADE7753.

MOSI Arduino is the Master Data Output to the slave, connect to DIN of the ADE7753.

SCK Arduino is the master clock output, connect to SCLK on the ADE7753, 10MHz spec.

The ADE7753 use mode2 transfers of data with the MSB leading.

 

Next Steps

Next we will design the circuit to be built onto the Uno prototype based on the details worked out in this Blog.

We will need to purchase the following parts:

Farnell Order Code 2313624 Manufacturer Part No  ADE7753ARSZADE7753ARSZ Meter Chip

Farnell Order Code 1670224 Manufacturer Part No  ERA6AEB511VERA6AEB511V 510R 125 mW 0.1 100 V

Farnell Order Code 2094720 Manufacturer Part No  ERA6ARB1742VERA6ARB1742V 17.4k 125 mW 0.1 100 V

Farnell Order Code: 2320843 Manufacturer Part No MC0805B333J500CT  0.033µ, ±5%, X7R, 50 V

Farnell Order Code 1426164 Manufacturer Part No  RE931-03RE931-03 ADAPTOR SMD SSOP-20


03 AardEnergy – Current and Voltage Transformers

 

In this Blog

I have a Current Transformer and a Voltage Transformer to evaluate. In this blog there will be a description of the sensors and some analysis of the signals as well as some measurements to assess performance.

 

See previous Blogs…

http://www.element14.com/community/groups/arduino/blog/2015/11/23/1-aardenergy-kick-off--a-new-project

http://www.element14.com/community/groups/arduino/blog/2015/11/26/2-aardenergy-set-up-uno-and-due

Current Transformer

The current transformer (CT) was bought from Amazon; the SCT 013-030 is a 30A device that costs £8.75.

http://www.amazon.co.uk/gp/product/B005CTWE8A?psc=1&redirect=true&ref_=oh_aui_detailpage_o01_s00

This part is made by YHDC and details can be found on their website:

http://www.yhdc.com/en/product/320/

The part supplied is fitted with an internal resistor that converts the output of the current transformer (CT) to a voltage with the scaling of ±30A input to ±1V output.

Check that the part supplied has the resistor before use. You can do this with by measuring the output resistance with a meter, it should read about 37R. It is clearly marked 30A/1V. You should note that a CT without a resistor will generate very high voltage – see the article linked below in the section on Transformers.

 

This CT has insulation rated for 1000VAC and we will only be using it clipped onto wire that is also insulated. It must be applied to a single live or neutral wire and our project will be limited to use with the meter connection on the supply to our house, like this:

Note that if you place the CT over an appliance cable that has live and neutral running through it, the magnetic fields cancel and the CT will read zero.

The electrical supply to my house is 15kW so in theory I could draw 65Arms through the meter and my 30A sensor would not be able to detect anything above 30A. Also we need to be mindful that the peak current of my sensor is 30A so the maximum rms current will be 21.2Arms. 65Arms requires 92A peak measurement. For my house this should be okay as we do not use electrical power for cooking or heating water. We have oil filled radiators but these are used on rare occasions. The peak consumption will come from the washing machine and the tumble drier. I am expecting my 30A sensor to be able to deal with these loads. However if you expect your loads to be higher you need to purchase a suitably rated sensor. For example if you want the full current capability of 65Arms the peak current will be 92A so you should buy a 100A sensor. There is a 100A/1V sensor in the YHDC product range and you should buy that.

It is a difficult choice to design a measurement system either for the maximum possible or the maximum you normally need. If I use a 100A sensor but normally I am measuring around 1Arms with occasional 20Arms maximum then I am using the sensor at the bottom of its range and suffer the inaccuracy that entails. However if my supply is normally around 1A but with 60Arms occasional consumption I have to use a 100A peak sensor and put up with inaccuracy at 1Arms.

Note that the jack plug is compatible with this cable mounted socket from Farnell 1280665

http://uk.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=15001&langId=44&urlRequestType=Base&partNumber=1280665&storeId=10151

Voltage Transformer

The voltage transformer (VTx) was bought from Farnell 2112026:

http://uk.farnell.com/ideal-power/77db-06-09/adaptor-uk-9v-0-67a/dp/2112026?ost=2112026&selectedCategoryId=&categoryName=All+Categories&categoryNameResp=All+Categories

Follow the link to find the datasheet.

 

The transformer will operate at no load and the datasheet specifies the output as 11.6Vac ±3% with a nominal input of 240Vac. The output is specified as rms so the peak output will be nominally ±16.4V. However we should note that the electrical system in the UK has a nominal rating of 230Vac and a maximum of 10% which means 252Vac and ±358V peak. So the maximum output of the VTx will be ±17.2V

To measure the mains voltage, the VTx will be plugged into the ring main. To get the most accurate reading, choose a wall socket close to the meter to minimise voltage drops around the ring.

 

Note that the jack plug is compatible with this socket from Farnell 3648102

http://uk.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=15001&langId=44&urlRequestType=Base&partNumber=3648102&storeId=10151

Some Test Results

The following tests we done under workshop conditions rather than home conditions. The CT and the VTx were compared with a precision current and voltage amplifier using a National Instruments NI USB 6008 DAQ logger with Signal Express. The load and the VTx were plugged into an extension cable and the CT was installed into the case that housed the instrumentation amplifiers.

Current Transformer Results

Direct measurement 7.83A

CT Measurement 257.29mV

Scaling 7.83/257.29 = 0.0304A/mV

Voltage Transformer Results

Direct measurement 236.38

Tx Measurement 11.346

Scaling 236.38/11.346 = 20.8V/V

Current Transformer Basics

This is a useful explanation about current transformers:

http://www.electronics-tutorials.ws/transformer/current-transformer.html

Next Steps

So far I have chosen sensors without much consideration of how the Arduino will handle the data. The plan is to use a meter chip with the Uno and to directly convert the sensor voltages (after suitable scaling) with the Due.  In the next blog I will evaluate a number of meter chips for use with the Uno…ADE7753, ADE7763, CS5463, MCP3905, MCP3909.

In this Blog

Download the Arduino software and power up the Uno and Due. Look at debug, does it exist from the Arduino GUI?

See previous Blog…

http://www.element14.com/community/groups/arduino/blog/2015/11/23/1-aardenergy-kick-off--a-new-project

IDE Download

IDE Down load from Uno board page, version 1.6.6 (I had already installed 1.6.5, so an upgrade). 1.6.5 uninstalled first, 1.6.6 now in place.

However, under Tools>Board…Due is not listed.

Get Started with Uno

Use the IDE, Help>Getting Started.

  • Plug USB into socket on Uno
  • Power LED is on (and port  LED is blinking)
  • In Windows Device manager select Ports and find Arduino Uno (COM3) (note Windows 8.1)
  • Right click and update driver from C:\Program Files (x86)\Arduino\drivers
  • Open Blink in IDE File > Examples >01.Basics > Blink
  • Select board as Uno
  • Select Serial Port (COM3 as determined above)
  • Upload, TX, RX LEDs flash happily.
  • And LED on pin 13 is flashing, so all good.

That went well but the Due was not listed so let’s try that from the link above.

Get Started with Due

Due board needs a micro B USB cable. Order this one:

http://www.amazon.co.uk/dp/B00FAAGNLU/ref=pe_385721_37986871_TE_item

The cable has arrived and fits the board programmer port (and it fits the Native USB port). The Due powers up, Green LED is on and the yellow LED blinks.

There are some special factors to keep in mind with the Due, read the guide:

https://www.arduino.cc/en/Guide/ArduinoDue

Follow the guidance on the drivers:

(Note that is says “tested on Windows XP and, but we are using 8.1)

From Device Manager>Ports, Arduino Due Programming Port is COM4. Right Click and Update Driver Software. Browse to C:\Program Files (x86)\Arduino\drivers. Hit Next and drivers are up to date.

Also load the core software to support the Due:

From Tools>Board>Boards Manager

Install the SAM board ARM Cortex-M3

The Due can now be selected from the list of boards.

Test the set up by loading the Blink programme:

  • Open Blink in IDE File > Examples >01.Basics > Blink
  • Select board as Due
  • Select Serial Port (COM4 as determined above)
  • Upload, TX, RX LEDs flash happily.
  • And yellow LED is flashing, so all good.

Software Debug

I am curious about how to debug the software, is there a Debug Mode or JTAG port? There is nothing on the GUI as far as I can tell at the moment. A Search for Arduino Uno Debug threw up a discussion on element14:

http://www.element14.com/community/thread/17697/l/debugging-atmega328?displayFullThread=true

Looks like print on the serial port is the Arduino “debug” unless you add some other utility. In essence a Uno Sketch needs to be simple to get away with no debug tool. This also might help:

http://www.element14.com/community/groups/arduino/blog/2012/09/30/the-first-practical-arduino-debugger

On the Due there is a Debug connector marked up but is not described in the top level Arduino document. A search throws up comments about the port as JTAG but used with third party tools:

http://forum.arduino.cc/index.php?topic=134907.0

So as a challenge I’ll attempt to use Arduino GUI and see how far I get with a fairly ambitious project to do real time calculations using Due board!

Other Blogs:

1. AardEnergy – Kick Off - a new project

3. AardEnergy – Current and Voltage Transformers

 

Next Steps

After a bit more shopping I have a Current Transformer and a Voltage Transformer to evaluate. In the next blog there will be some analysis of the signals from these sensors as well as some measurements to assess performance. That should lead on to a design for the Uno and the Due interface. The plan is to use a metering chip with the Uno and to a use direct analog input to the Due.

 

These are the sensors:

AardEng Parts_002 small.jpg

And, here is the ARDUINO MEGA, REV 3 Farnell 2285197 prototype board, which appears to be compatible with the Due.

AardEng Parts_006 small.jpg

1. AardEnergy.

 

A Simple Plan

  • Measure current and voltage on single phase electrical supplies
  • Calculate electrical parameters like RMS, Real Power, Apparent Power, Power Factor, Frequency, THD, kWhr
  • Use Arduino Uno with an electrical metering chip for parameters
  • Use Arduino Due using software calculation of parameters

Kick Off

I’m new to Arduino but have used microcontrollers like PSoC4 and ARM Cortex-M3. Although my career has been more about hardware design I have written software, but would not claim to be a full time software professional.

I want to keep the voltages low on the boards to make them safe to handle, so no 240Vac mains exposure!

The current transducer needs to be an isolated type that can be clipped around an electrical feed wire. So it could be a Hall based sensor like LEM or a current transformer CT. I also want the set up to be cheap and available for other people to try out, the attraction of Arduino is the number of people learning about electronics and software. A bit of a survey turned up some CTs on Amazon which makes them readily available to all.

So the design decision at the moment is to use a CT for current measurement.

Voltage measurement also requires isolation. I’ve just spent 6 months designing an isolated amplifier for industrial applications, but it is too expensive for a low cost Arduino project and too complex. It is possible to buy plug in transformers with an AC output and I intend to use one of these as the source of a low voltage signal and isolated from the mains. It could also double up as a power supply to the finished project with some useful power up/down features for metering.

With all this in mind I bought some bits, starting with the Arduino. It was all a bit of a guess as I had no idea about the compatibility of Uno and Due parts or even whether they are the right parts for the job; so all a bit of a voyage of discovery.

Uno

The Uno uses an ATmega328P chip which is an 8 bit microcontroller. I am not expecting it to log waveform data in real time and do complex calculations. It does have an SPI port which will make it compatible with metering chips that do the calculations in real time and transmit the results to the Uno board. It has some EEPROM which is useful for kWhr retention when the power goes off.

Due

The Due uses an Atmel SAM3X8E ARM Cortex-M3 chip which is a 32bit microcontroller. I am expecting to be able to log current and voltage waveforms in real time and do some calculations without any need for a metering chip. EEPROM storage may need to be external, not yet sure if the internal memory is accessible for data.

Accessories

I’m expecting to build any additional circuits onto a prototype board, not one of the plug in type panels you see in Arduino kits.

A display will be a useful thing, rather than relying on a PC display of results.

Shopping List

With all these things in mind I sent off a shopping list to Farnell and received some parts.

  • Arduino Uno 2075382. Neat little board, clear silkscreen, ready to go. No product data came with it, just a guarantee and a sticky label telling me to visit Arduino.org.
  • Arduino Due 2250861. Another neat board, bigger than the Uno, clear silkscreen and ready to go. No product data just the same sticky label.
  • Prototype Shield 2075345. A prototype board compatible with the Uno but not the Due. Did not know whether to expect the Uno and Due to have a common footprint. Have yet to identify the prototype board for the Due.
  • TFT LCD display 2360852. Okay, well this board is not directly compatible with either the Uno or Due

So a bit of a “lesson learned”. Arduino boards are not compatible across types and not all that clear at time of purchase.

Shopping List 2

The prototype shield for the Due appears to be the PROTO BOARD, ARDUINO MEGA, REV 3 Farnell 2285197.

And the LCD display is compatible with the Arduino Esplora Boards. But there is a tutorial to help you connect to other types of board. https://www.arduino.cc/en/Guide/TFTtoBoards . Could be mounted on a prototype shield for each type of CPU.

To provide a low voltage AC measurement, a plug-in transformer should work, Farnell 2112026.

At Farnell the lowest cost current transformer that clipped onto the cable was 1797760, a 50A device at £37.61. From Amazon the SCT 013-030 is a 30A device that costs £8.75.

Do I need to buy a book? For now I’ll rely on the Arduino website…

Parts ready for set up

 

Arduino Boards

 

Next Steps

…down load the Arduino software and power up the Uno and Due.

https://www.arduino.cc/en/Main/ArduinoBoardUno

http://www.atmel.com/Images/doc8161.pdf

https://www.arduino.cc/en/Main/ArduinoBoardDue

http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf

  Big question, how do I debug the software? Is there a JTAG interface for debugging with breakpoints? Am I too optimistic?

Next Blog:-


2. AardEnergy – Set Up Uno and Due

3. AardEnergy – Current and Voltage Transformers

4. AardEnergy – Metering Chips

 

Peter Cox-Smith, 23 Nov 2015