CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Power Meter ADC problems
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Feb 26, 2013 5:30 am     Reply with quote

Three things:-

a) At this stage, are you using the turbine as your power source or mains?
b) Your formula is the way to go to calculate power.
c) Zero drift from you current sensor is not an issue.

I'll come back to you with a more complete analysis when I have a little time to spare.

Mike
Can



Joined: 26 Feb 2012
Posts: 23

View user's profile Send private message Visit poster's website

PostPosted: Tue Feb 26, 2013 8:04 am     Reply with quote

Quote:
Your putting the cart before the horse.
Rushing to get something to show gets you nowhere.
You're not answering the questions that others and I are asking.
We're trying to help you by making you think about what's going on.
We've all been there before, so can see what's happening.
We're not going to give you the answers, because that won't help you become good at the job.

1) Isolate yourself from the killer volts.
2) Bias your volts measurement to half Vref.
3) Get each section to work correctly, BEFORE moving on to the next.
4) Tell me the frequency of the voltage output from your generator.
5) Tell me how much current your expecting at maximum output.
6) Suitably isolated you can hook a PC up to the UART and have a dialogue with the PIC.
7) What makes you think measuring peak volts and current allows you to measure power?
8) I'd be worried that you're still getting interaction between ADC channels.
9) Once isolated, it's easier to look at your ADC inputs with a 'scope.

Mike


Hi Mike, I want to tell you that I've been working on this thing for a long time and I am trying to overcome the problems I encounter myself first. When I take a long time thinking and trying ways to solve the problems but cannot figure out a solution, I turn for help. I am doing my very best at answering any questions anybody ask. I am sorry if I overlooked some. It is not intentional. As for the "giving answers" part, I am pretty sure you would see that I am not looking for any easy answers. I am introducing solutions myself, trying them, failing, introducing some other solutions.. This being said, I hope I was able to make clear that I am no "someone give me the solution" guy.
As for your listing:
1- I knew the importance of isolation but as all of you stick it into my eye, I know that I have to find a way to isolate.
2- Ok, I will try and bias the voltage to 2.5V and see what happens
3- Individually they work ok, for example if I read the voltage only, I have no problem and I see my 220V. However, trying to run the channels at the same time, I have problems.
4&5 Turbine specifications say that it is 0-300Hz, 0-21.5A and 0-46Vac (I've written that it was 64Vac earlier but seems like I was mistaken. It is 46V)
6- Now that you mention it, I am going to extract the data written to the eeprom via uart. I am thinking that if i don't do something about the isolation, the best thing that can happen is that I would fry the computer.
7- I was thinking that if my load is purely resistive, then I would get P=Vrms * Irms. From the measured peak values, I was planning to go to the RMS values. But as I don't know the phase relationship between I and V, that does not seem to be plausible.
8- I think there is an interaction as well, but I can not figure out the solution for it.
9- Ok, I have to isolate, that's for sure. But something is puzzling me. Let's assume I used 2 identical transformers connected to each other. One steps down the 220V to a lower voltage, the other steps it back from that lower voltage to 220V again. Am I being mistaken to think that the output of the step up transformer is isolated? I really don't get how it can be secure as there is still 220Vac?

Ttelmah:
I know even up to this point you want to behead me. I figured out that I can not be beheaded twice (as long as you don't attach the head back, revive me and behead me again) so I am coming up with a confession. The resistors I am using are 1/4W carbon film resistors. According to my calculations, 220V should not exceed the power rating or the resistors. I might be mistaken, of course. But when I unplug the 220V and check up on the resistors, they are not hot.
I've considered the optocoupler as well but could not figure out how to use it to measure the AC. As to my understanding, the optocoupler will output on/off. But again, maybe I am wrong about it. I will reconsider the datasheet and try to find a solution to it. Thank you for your advise on the ground. I will definitely keep that in mind when prototyping the board.
The ACS714 breakout board I am using is this one : But I haven't used any external filters.

Mike (for the latter message)
For now I am using the mains as the signal to be measured. The reason I am doing that is that the mains is the closest thing that I can simulate the turbine with. When the circuit and the code is complete, I will be changing the voltage divider resistors to be compatible with the turbine output. So in the end, the turbine output is going to be the source.
About the formula, I couldn't figure out if you were being sarcastic about the way I planned to measure the power (P=I*V, ok I accept that it was naive to think on using that) or you were giving me a go on the summation formula.

I am sorry if I missed anything.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Feb 26, 2013 8:37 am     Reply with quote

Only as an example to others.... Smile

Standard 1/4 carbon film resistors, normally have a maximum voltage rating of something like 250v. Now remember what the peak voltage is on 220V ac, and cringe....

Isolate, before (if you are _lucky_), you 'live to regret it'.

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Feb 26, 2013 12:09 pm     Reply with quote

OK. So we understand each other.

When we meet someone new on the forum we don't know who the chancers are.
I don't like answering questions directly.
I'd rather answer your question with a different one.
That way you may be persuaded to work out the answer to the original for yourself.
This is a public forum, your tutor can monitor our conversation as well as the next person.

As I see it you still have a problem with interaction between ADC channels.
In which case you can tackle the problem by disconnecting from the dangerous sources.
I.e. use low voltage benign ones instead.
That was my thinking behind the suggestion to apply DC to one channel and AC to the other.
For this scenario you can use battries, DC power supplies and signal generators.
That way you (and your nearest & dearest) won't have to worry about your imminent demise.
You can monitor what's going on with a 'scope, and stream loads of data to a PC.
Without good raw data, you can't progress.

I was not being sarcastic about Vrms*Irms.
The hint was that you needed to do some research.
I intended to be helpful.

You go to class and they tell you Power = Irms * Vrms
A few weeks later, another guy says:-
We should have said Power = Irms * Vrms * cos(theta)
(Or something similar)
Then they let you out into the real world.......
The voltage isn't sinusoidal and the current isn't even the same shape as the volts.

What you've forgotten (or didn't notice) was, at the beginning of the class, they gave you the integral formula for calculating power.
The emphasis was on getting the nice neat equaton you recorded in your notes, and expected to duplicate in exams.

Sorry but the neat equations are special cases only.
Welcome to the real world.

Mike
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Feb 26, 2013 3:46 pm     Reply with quote

Read the data sheet.
Look at the section entitled 'A/D Acquisition Requirements'.
The second paragraph of this explains what is wrong with your code.
Study the examples of the forum here and from CCS. Notice what they all do when changing channels.

Best Wishes
Can



Joined: 26 Feb 2012
Posts: 23

View user's profile Send private message Visit poster's website

PostPosted: Tue Feb 26, 2013 5:26 pm     Reply with quote

Ok, 80 us cost me a really long time. So, now I can read the voltage and the current independently. Now I will be trying to isolate the source from the rest of the circuit and then I will try to arrange the power calculation parts.

When I finalize the code with the power measurement and everything, I will put it here.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Calculating RMS & power
PostPosted: Wed Feb 27, 2013 2:55 am     Reply with quote

Assuming that you've got your ADCs biassed somewhere near centre.

To calculate one ADC RMS you:-

1) Create variables sum_of_samples, sum_of_squares, mean, mean_square, rms, n.
2) Reset n, sum_of_samples and sum_of_squares to zero

3) For as near as possible an integer No of complete cycles, i.e. n samples:-

4) Add each new sample to sum_of_samples.
5) Square each sample and add to sum_of_squares.
6) Repeat for n samples.

Then calculate :-

7) mean = sum_of_samples / n.
8) mean_square = (sum_of_squares - n * mean ^ 2) / n
9) rms = square_root of mean_square.
10) Convert to engineering unit.

You can do the above for Irms, Vrms as shown, then a similar process for power.
Do all the maths as integer maths except for the final ones and conversion.

I can see the wide frequency range from the turbine will create some problems.
But that shouldn't stop you getting it to all work at mains frequency first.

Best of luck.


Mike
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Feb 27, 2013 5:16 am     Reply with quote

Can wrote:
The resistors I am using are 1/4W carbon film resistors. According to my calculations, 220V should not exceed the power rating or the resistors. I might be mistaken, of course. But when I unplug the 220V and check up on the resistors, they are not hot.


WOW someone is going about the right way of getting themselves killed.

A couple of things to consider, resistors have both a maximum voltage rating and a maximum dv/dt - when these are exceeded the resistor can breakdown or arc internally. Carbon is about the worst choice. Higher wattage resistors (actually physically larger resistors) have both higher maximum ratings for voltage than dv/dt. This explains why in these type of circuits you often see resistors in series rather than a single resistor.

Where is the protection in the event one of these resistors fails or you have a poor solder joint on the smaller resistor? You should back to back zener protection as a minimum.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group