I am publishing this as an initial design to let people comment on it. The idea is to take all the best bits of EmonTX v3.4 and any other stuff that we have learnt about since then and use a chip that is faster than the Arduino.
The Particle Photon seems like a good replacement and best of all is web connected already.
Once we get the hardware sorted we can get to work on the software. People have already ported some bits of the required software to the Photon's predecessor (Core). But a pre-built shield isn't available, hence this project.
1. All the Analogue inputs will be used for Voltage and Current detection.
2. All the Digital IOs will be exposed to allow other stuff to be connected e.g. OLED display, temperature sensor, pulse, IR etc.
Note : The diagram symbol used for the LMV321 is wrong. I couldn't find a nice 5 pin op-amp symbol in Fritzing to use! Pin numbers used are correct.
Go on. Have your say.
Re: EmonTX shield using the Particle (formerly Spark) Photon
This looks like an interesting project --- I have a SparkFun Photon Red Board on the way.
It has a P1 Particle module on a board / shield which should make the hardware hookups easier and sells for only $39.95.
Definitely be watching this thread for info as more software is developed for it.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I too would have gone that way, if the emontx shield had kept up with the improvements.
So decided that creating a new one was not a bad plan. So took the opportunity to develop the board that takes all the best bits.
Just waiting for the comments and then I can move to building a sample batch.
Re: EmonTX shield using the Particle (formerly Spark) Photon
Robert and dBC mentioned that a 3 phase monitoring will need 3 ac inputs. I'll see if I can design 3 inputs to configurable either as CT inputs or AC inputs. We have the ADCs so might as well use them, right.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I had the same idea this morning. I would like to help.
I see some nice advantages with the Photon:
- More analog inputs than the Arduino and more processing power.
- No need for RF by using the Wifi (cost reduction)
- Possible standalone solution without raspberry pi. (cost reduction). Directly posting to emoncms.org or own webserver/nas.
It would be nice to have full 3 phase monitoring and maybe 1 phase solar installation.
Re: EmonTX shield using the Particle (formerly Spark) Photon
Does anyone know of a 3 channel op-amp that I can use instead of 3 separate LMV321 in case I need to include 3 phase monitoring on the board?
Otherwise, I've had no further feedback to the initial thoughts.
Re: EmonTX shield using the Particle (formerly Spark) Photon
No! They tend to come as 1-channel, 2-channel or 4-channel. Have you thought about looking at the LMV321 data sheet - the TI version at least. [BIG HINT! BIG, BIG HINT! ! !]
Re: EmonTX shield using the Particle (formerly Spark) Photon
My "vote" on getting this project up and running is to first do it as a considerably simpler single phase monitoring system. If you have boards made up for this --- put me down for a couple.
As for op-amps, I have been searching for some components myself to do some proto- typing. The only LMV321's I can find all have SMD/SMT cases --- not very friendly for this use.
I did order some LM358 op-amps in a Dip 8 Pkg at a very low cost 10 for $2.07 with free shipping. I think Robin has used the LM358 in some of his designs.
http://www.amazon.com/gp/product/B00CL588O2?psc=1&redirect=true&ref_=oh_...
Re: EmonTX shield using the Particle (formerly Spark) Photon
Why can't we use 1 op-amp for all sensors?
The documentation states: "Only one op.amp is needed, the current sensors can share the bias supply and connect to amplifier output (“mid-point”) with little fear of interaction between the inputs (which can be troublesome in some circumstances)."
http://openenergymonitor.org/emon/buildingblocks/acac-buffered-voltage-bias
Re: EmonTX shield using the Particle (formerly Spark) Photon
If we are going to attempt a proper 3 phase monitoring system then we need 3 op amps all on separate channels.
The op amp output can be shared by the CTs.
Re: EmonTX shield using the Particle (formerly Spark) Photon
If you're using the op. amp. as the bias source, you only need one. If you're using it to isolate/amplify, you need 4. I think we need an outline circuit diagram of your 3-phase arrangement.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I'm going to start with just the 1 for single phase and bias source.
But why 4? Even for 3 phase I would have thought you needed only 3.
Also does anyone know which ADC is connected to which Photon pins
Re: EmonTX shield using the Particle (formerly Spark) Photon
"But why 4?"
3 to buffer/amplify each phase and 1 for the common bias.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I am having a slow day today, so forgive me.
So in a single phase setup, how come we have just one doing both the buffer/amplification and the bias?
Re: EmonTX shield using the Particle (formerly Spark) Photon
"Also does anyone know which ADC is connected to which Photon pins"
From the Photon Docs:
A0~A7 12-bit Analog-to-Digital (A/D) inputs (0-4095), and also digital GPIOs.
https://docs.particle.io/datasheets/photon-datasheet/
Re: EmonTX shield using the Particle (formerly Spark) Photon
What I meant is, I know the ARM chip used in the Photon has 3 ADCs, so does anyone know if the ADCs are dedicated to the pins or do they just use some algorithm to divide the load between them?
Re: EmonTX shield using the Particle (formerly Spark) Photon
"I am having a slow day today, so forgive me
So in a single phase setup, how come we have just one doing both the buffer/amplification and the bias"
In the diagram in http://openenergymonitor.org/emon/buildingblocks/acac-buffered-voltage-bias, the op.amp. is purely providing a low impedance (whatever the output impedance of the op.amp. is in voltage follower mode, probably a few ohms) bias supply. It is not doing any amplification at all. When you said you needed one per phase, I thought you wanted to use an op.amp. as a switched gain amplifier (as per the Atmel application note) to improve the sensitivity at low currents, which is a common complaint from those who want to measure just a few watts.
I can't see any advantage in having multiple op.amps and multiple bias supplies.
There might be some value in measuring the bias supply by each ADC (assuming they are multiplexed); that would be justified if the difference in the ADC readings around the midpoint due to non-linearity errors was 'significant'. (I'll leave you to decide what that means - I'd suggest more than 1 count, because the software filter works down to a fraction of 1 count. It depends on what the minimum current you want a reliable reading for is, and the errors you can accept.)
Re: EmonTX shield using the Particle (formerly Spark) Photon
My basic need is to measure current and voltage as accurately as possible. The only reason we started talking about using more than 1 op-amp was to satisfy the use within a 3 phase installation. Lets leave that to one side for the moment.
If we are going to only use this within a single phase installation can we stick with the design as above. Or are there any further suggestions to improve on the design?
Re: EmonTX shield using the Particle (formerly Spark) Photon
so does anyone know if the ADCs are dedicated to the pins
See my comment here: http://openenergymonitor.org/emon/node/10428#comment-34308
That's based on a quick perusal of the datasheet mind, no personal experience, so you might want to confirm that with your own research.
use some algorithm to divide the load between them
That'll be your job, and what I was referring to when I wrote "If you're prepared to put the coding effort in...". There'll be lots of fun design decisions to play with there. If your mid-rail and ADCs are as stable as I think they will be, you might be able to use all sorts of strategies, like have each ADC read the mid-rail once-in-a-while (every second instead of every 10usecs for example) and run with that for its subtractions until the next second. Since each ADC can read the mid-rail for itself, I don't think there are any issue with offset errors between the ADCs.
It looks like you can even configure it for simultaneously triggered conversions. So you might set it up so that one is reading V, and the other two are reading CT1 and CT2, and then say "GO"... that alleviates the typical phase shift introduced by the software starting the conversions, though you'd still need to deal with all the other sources of phase error (external and internal).
I think the first thing you're going to have to do is throw out the Photon programming manual and hit the ST datasheet and use that as your manual for all things ADC related. (OK, maybe the second thing: using the existing synchronous library calls is probably a good way to make sure the hardware is working the way you intended).
Or are there any further suggestions to improve on the design?
I'd probably put anti-aliasing filters on all your inputs. There are plenty of references on the web that will talk you through that... including the datasheet for just about any ADC, or any CPU containing an ADC. You can see a picture of one doing its thing in this thread: http://openenergymonitor.org/emon/node/9956#comment-26546
Re: EmonTX shield using the Particle (formerly Spark) Photon
You might want to keep an eye on this thread too: http://openenergymonitor.org/emon/node/11309#comment-34553
Re: EmonTX shield using the Particle (formerly Spark) Photon
@dBC any suggestions on how to go about the anti-aliasing filter?
Re: EmonTX shield using the Particle (formerly Spark) Photon
Google is your friend in this case. Here are a few I just found:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/928
http://www.ti.com/tool/antialiasingcalc
and an application note from your own vendor:
http://www.st.com/web/en/resource/technical/document/application_note/CD00211314.pdf
You'll need to know your sampling rate which you may not know for sure still you start banging on the ADC registers, so you might need to tweak the filter later, but as the ST note says, it's not super-critical. You want the corner frequency at about half the sampling rate, and above any frequencies of interest in the signal.
The only other tip I'd add is to put the exact same filter on all your inputs, including V. That way any phase shift they introduce will be roughly the same across all your inputs.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I would encourage keeping this as simple as possible and a usable product as soon as possible. The EmonTx, in my experience has more than adequate accuracy / resolution without anti-aliasing filters and the Photon will have considerable higher resolution capability.
By far most of my difficulties have been with the limited radio range of the EmonTx. I have large PV installations on farms at both my location and my sons, where the Utility main feed / connection panels are over 100 feet from the house and other out buildings. Signal drop outs are a problem.
Hopefully, the Photons WiFi range will be an improvement, even if I need to add access points.
In 3 or 4 months, the Particle Electron with Cellular – Connected Capability will be available, which will make the radio range a moot problem. I have them on pre-order.
https://store.particle.io/?product=particle-electron
Re: EmonTX shield using the Particle (formerly Spark) Photon
I agree with sd solar. Lets keep this idea alive and try to make a usable design first. If someone can tell us what components we need to place for the anti-aliasing filter we can implement it. But personally I am not experienced enough to figure it out by myself an be sure it wil work as expected.
If everything works like we want we can just make a V2 version with improvements.
Lets list what features we want:
We have 8 ADC inputs to work with.
-1 input for monitoring the bias source?
-1 input for AC Voltage monitoring (Or 3 for the 3 phase variant)
-6 inputs for CT sensors? (Or 4 for the 3 phase variant)
Do we want other sensor inputs? Do we prepare something for the digital IO pins?
Lets say we make it possible to break out al the pins of the photon. How do we do that? Make it arduino shield compatible? Or is there a better way?
I also started drawing a schematic.
You can view it at https://easyeda.com/Roeland54/Photon_emon_shield-lFDBzUSs2
Re: EmonTX shield using the Particle (formerly Spark) Photon
The schematic looks good. In my case, I don’t have any need / use for the digital IO pins at the location I will be installing the Photon.
I have done a very similar circuit on a prototype board, but using a LM358 op amp In a dual 8 pin pkg for the bias and the outputs from the CT’s and voltage adapter are right on.
The real challenge, for me is going to be getting the code correct and flashed.
Officeboy has published some extensive work on this at:
https://github.com/officeboy/EmonCore
I have tried modifying his for my setup and flashing the Photons firmware, but the result is it now won’t even go on line and connect with the Cloud. I then have to force it into Safe Mode and re-flash a known good firmware before it will connect again.
This type of coding is way above my pay grade.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I got a decently good design but was quoted an insane figure to turn it into a PCB.
If there are people on here who could help with designing a PCB, for a fee of course then we may be able to get this out for people to play and develop on.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I will try to design a pcb. It wil be a smd pcb. I'm going to try to make 1 pcb that can be used for 3 phase or Single phase. If jou want 3 phase jou can put the components for 3 phase on the board. Then you wil have 4 ct's and 3 ac inputs.
For single phase you wil have 6 ct's and 1 ac input.
It wil make the pcb a little bigger but I think it is worth it to have 1 design to meet both requirements.
Anyone having a request about the pcb size/shape?
updated schematic : https://easyeda.com/Roeland54/Photon_emon_shield-lFDBzUSs2
Re: EmonTX shield using the Particle (formerly Spark) Photon
Will be make the pcb gerber files available to all? In that case we can collaborate?
Re: EmonTX shield using the Particle (formerly Spark) Photon
What problem is L1 trying to solve, and how does it solve it?
Re: EmonTX shield using the Particle (formerly Spark) Photon
I will share the design files to all and I will need some collaboration. I am not a pcb expert. The last time I designed a pcb was in school 8 years ago.
I copied L1 from the emontcV3.4 design. It is a ferrite bead to filter out noise from the microcontroller.
I don't know if it is really necessary.
Re: EmonTX shield using the Particle (formerly Spark) Photon
There's more on L1 here: http://openenergymonitor.org/emon/node/11130 and here: http://openenergymonitor.org/emon/node/6196
Re: EmonTX shield using the Particle (formerly Spark) Photon
In particular, in one of those threads I wrote "L1 was included by mistake, carried over from a previous version. If you had checked the pcb layout, you would have found that it's actually shorted out by copper, and hasn't been removed from the assembly process because it costs more to do that than to leave it."
In particular, you need to keep the analogue and digital sides totally separate, except for one common ground point and a filter separating the digital power from the analogue power and reference voltage. It seems that in the emonTx, the largest noise contribution comes in via the analogue reference. It is well worth taking a lot of care with the analogue inputs, as noise limits the performance of the emonTx even though it's only a 10-bit ADC. If you're not a pcb expert specializing in low-level analogue stuff, you need to do a lot of reading - some of the better sources are the application notes for high-end ADCs.
I like the idea of a common pcb, populating it for 1-phase or 3-phase as appropriate.
If you are having any digital inputs or outputs, arrange an adequate number of ground and supply terminals adjacent so that you have a choice of connecting the sensor / output between Gnd or Vcc. Provision for wire-ended pull-up or pull-down resistors could be useful, as would be provision for wire-ended burden resistors on the CTs and voltage divider resistors on the VTs.
Re: EmonTX shield using the Particle (formerly Spark) Photon
Doesn't look like I have anyone ready to turn my design into a PCB.
I had aimed for a completely through hole design for maximum flexibility. And the only part that needed to be replaced was the op amp with the LM358.
What I had done was used the left hand ground for all the analogue inputs. And the right hand ground was reserved for the digital inputs.
To reduce the part count and to avoid someone putting both VT and CT into one input I added a jumper to switch the input between being a VT or a CT. You can still use the 1K and the 2 protection diodes for either.
Re: EmonTX shield using the Particle (formerly Spark) Photon
That ST Micro application note referenced above (from your own vendor no less!) touches on most of the issues you need to consider for good analog results. Much of it is directed at someone designing the entire board, but some of it will apply to your "shield". Because you're using the Photon module you'll be at the mercy of how well they followed those guidelines, and that probably depends on how concerned they were with permitting good low-noise low-level analog measurements.
It might be worth doing some up-front tests on the Photon to see how well it behaves. A really simple test is to inject a stable low-ripple low voltage into one of the analog inputs and then have the f/w read it repeatedly and measure the PtoP noise in A/D units. Ideally it'll be 0 or 1 even while doing other stuff like wifi transmitting the results.
Re: EmonTX shield using the Particle (formerly Spark) Photon
@Roeland54
Just looking at your schematic. I think there is a major error. I assume your stereo jack are the switching type that short pins 2&3 and 4&5 if no plug is inserted? On the V3 shield i understand this is used to detect if a CT is plugged in or not. That works on the V3 boards as each has its own bias reference made up of a resistor divider. Shorting the bias to ground is ok and only a small amount of current is drawn from the voltage rail through the 470k ohm resistor. But in your case, you have the op amp supplying the bias reference. So if ANY one of the CT's isn't plugged in, the output of the op amp is pulled directly to ground. This affects ALL the inputs.
Please correct me if i'm wrong. Just wanting to help....
Re: EmonTX shield using the Particle (formerly Spark) Photon
@Robert Wall: Thank you for the feedback.
- I removed L1 from the schematic.
- I will read up on using ADC's.
- Are the internal pull up/down resistors of the Photon STM micocontroller not good enough?
Still not sure if I should add the digital I/O breakouts.
- Added wire ended resistors for the CT & VT inputs
@MattyZee: Thanks for spotting the major error. Could we solve this by adding a 470K resistor between pin4 of the jack and the ground? Or we could delete the connection to the ground completely. Do we need the detection?
Re: EmonTX shield using the Particle (formerly Spark) Photon
"Do we need the detection?"
The answer to that is, will you get 'noise' output when no CT is connected and will it be troublesome, or do you otherwise need or want to know, i.e. so that you don't send a string of zero values for non-existent inputs?
The idea (on the emonTx) is if the input is a solid zero at power-up, there is no plug in the socket. That's not quite the same as no CT. If you retain the detection facility, you need a lowish value resistor (say 2.2 kΩ at a guess, which will still give a low impedance source but not cost excessive current to be supplied by the op.amp even with nothing plugged in anywhere) between the op-amp output and each socket, not between the socket and ground.
If you don't want detection, by far the best solution is to leave the switched short to ground off completely.
Re: EmonTX shield using the Particle (formerly Spark) Photon
Ok thanks. I will leave the the detection off. I think the sensor configuration changes rarely in most setups and we could make it configurable by a web interface.
Re: EmonTX shield using the Particle (formerly Spark) Photon
First pcb version "ready" at https://easyeda.com/Roeland54/Photon_emon_shield-lFDBzUSs2
Re: EmonTX shield using the Particle (formerly Spark) Photon
I've also got a PCB ready. But I've taken a different route to the design. I'll publish my design next week.
Re: EmonTX shield using the Particle (formerly Spark) Photon
Finally!
Here is my take on using all the best bits and working it into a single Photon OEM board.
Features:
1. 8 CT inputs.
2. 3 VT inputs.
3. Switch 3 inputs between CT or VT via jumper.
4. Switch 1 input between CT or Voltage Bias Ref.
5. Voltage terminals accessible on the wire end terminal block.
6. All the Digital and analogue inputs are accessible.
7. The Digital inputs can be pulled up or down as required.
8. The Rj45 connector is also available to connect OEM sensors as required.
9. The board should be able to take the Electron as well, when it's released later.
10. Deliberately went for a through hole version to allow components to be either changed or not added at all.
Comments? Before I make up a few board for people to have a play with.
This wouldn't have been possible without Robert, Robin and dBC. So thank you guys.
Re: EmonTX shield using the Particle (formerly Spark) Photon
Nice to see your take on it. I have few questions.
Is it possible to upload a higher resolution schematic I can't read some component values & the PCB design with visible traces?
What are the dimensions of the PCB ?
Can you explain how you determined the capacitor value at the input of the ADC's?
Re: EmonTX shield using the Particle (formerly Spark) Photon
That's awesome! Can you use at least 6 CT's and 3 VT's simultaneously? If so I'm in for a few of these.
JD
Re: EmonTX shield using the Particle (formerly Spark) Photon
The Photon only has 8 inputs. So max you can have 3 VTs and 5 CTs. Or any combination inbetween.
All the digital inputs are free for you to what you want.
The good thing is that you can connect an I2C display to D0 and D1 using 2 4K7 pull up resistors. This then becomes a stand alone monitor and display too.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I'm getting an initial batch of boards made up.Those interested just drop me a PM and we'll take it from there. Do people want fully populated boards, just PCBs or PCB kits.
I just changed the design slightly to add a 5V power line as well, incase some sensors are better run via 5V (remember the emonTX v2 where the board runs at 3.3 but the temperature sensor runs at 5V)
Also all Photon pins are also now accessible. And in case you are wondering what those cut-outs on the board are for, they are for some kind of USB plug strain relief. I wasn't too happy with the USB plug just hanging off the photon unsecured.
Re: EmonTX shield using the Particle (formerly Spark) Photon
I am just getting wrapped up enough with life projects to get back into this. What are you using on the software end? Is the Cinezaster/EmonLib still a good working library? What code are you running? And Bruce, how is your PCB working out?
Re: EmonTX shield using the Particle (formerly Spark) Photon
My pcb will have to wait until the new year unfortunately. Am told Tis the season to be jolly not soldering.