Previous in Forum: PC Problem   Next in Forum: Hacking a Camera Through the UART Port
Close
Close
Close
18 comments
Rate Comments: Nested
Participant

Join Date: Jun 2012
Posts: 4

Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/20/2012 3:46 PM

Hello.I try to make a practical and precise circuit that detect the peak value of

a sinusoidal signal input with frequency from 1HZ to 1KHZ and apply that into

PIC18F452 to display it on the LCD;[ I used microC PRO for PIC V5.3 compiler,

XTAL;40MHZ].But that circuit does not display correctly;I think my peak detector

circuit does not work properly.

Would you please help me for that?Any practical circuit and project example for

PIC18F452 and peak detector?

Thanks,

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru
Engineering Fields - Electrical Engineering - Been there, done that. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 15600
Good Answers: 981
#1

Re: Practical & precision sinusoidal peak detector for PIC18F452

06/20/2012 4:59 PM

Well this is fairly straight forward. You can also consider this. However, without a schematic to view your configuration or any data there's not much I can do for you. You maybe expecting too much from the circuit design. You may not have actually constructed what you hoped to construct. You may be incorrectly reading the PIC microcontroller. I cannot tell.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Guru
Hobbies - DIY Welding - Don't Know What Made The Old Title Attractive... Popular Science - Weaponology - New Member United States - US - Statue of Liberty - 60 Year Member

Join Date: Apr 2009
Location: Yellowstone Valley, in Big Sky Country
Posts: 7425
Good Answers: 295
#2

Re: Practical & precision sinusoidal peak detector for PIC18F452

06/20/2012 5:43 PM

This sounds a little familiar...

Do you know a fellow named m mirza? Is this the same project?

May be a simple coincidence.

__________________
Semper Ubi Sub Ubi
Register to Reply
Guru

Join Date: Jan 2008
Posts: 1753
Good Answers: 59
#3

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/21/2012 12:15 AM

Any PIC is not a peak detector. When you program one it will sample an input, when it gets around it in the program flow, not when that occurs.

You need an analog peak detector, that holds it value until the next peak, or a defined decay time constant. That is definitely Analog Design.

Other than that, I concur with RedFred.

Register to Reply
Guru

Join Date: Mar 2007
Location: City of Light
Posts: 3943
Good Answers: 183
#4

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/21/2012 9:46 AM

If you want to make it complex then consider that the time derivative changes sigh at the peak i.e. it crosses zero! So you change the peak detection into a zero crossing detection which is very simple with an Op-amp and output limiters.

Register to Reply
Guru
Engineering Fields - Electrical Engineering - Been there, done that. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 15600
Good Answers: 981
#5
In reply to #4

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/21/2012 9:58 AM

That's only true if the waveform can only be a single sinusoid wave with one and only one fundamental frequency. A polytonic waveform, like a bandwidth limited approximation of a square wave, will have multiple instances in time where the derivative crosses zero in each periodic sequence. Only one of these will will occur at the peak amplitude.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Guru

Join Date: Mar 2007
Location: City of Light
Posts: 3943
Good Answers: 183
#6
In reply to #5

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/21/2012 3:58 PM

I agree with you but he mentions a "sinusoidal" signal with different frequencies he did not mention it is a superposition of several signals.

My suggestion was based on the assumption he analyses a clean signal.

I am still aware of the fact that the derivative of a sum can go through zero several times over the lowest frequency period.

It was good to mention for other readers.

Register to Reply
Guru
Engineering Fields - Electrical Engineering - Been there, done that. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 15600
Good Answers: 981
#7
In reply to #6

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/21/2012 4:18 PM

YES! and Thank You.

It was also great to discuss signal analysis without having to resort to Wikipedia links.

Now if we could only get the OP to reply some additional information then we might actually get somewhere.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply Off Topic (Score 5)
Guru

Join Date: Mar 2007
Location: City of Light
Posts: 3943
Good Answers: 183
#9
In reply to #7

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/22/2012 2:19 PM

I agree with you I am a bit taken aback how few are those who base their answer ONLY on own words and explanations. I could say most are excellent users of search engines, I can do it as well but my pleasure is to take from my memory and knowledge as much as possible for the answer. I have the feeling that you do the same.

Register to Reply
Participant

Join Date: Jun 2012
Posts: 4
#8

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/22/2012 1:29 AM

Hello and thanks a lot for your answers.But I meant that I want to measure a

sinousoidal input signal that vary its frequencies from 1HZ to 1KHZ at each specific

time and at each time I want to measure its peak.

Thanks,

Register to Reply
Participant

Join Date: Jun 2012
Posts: 4
#10
In reply to #8

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/22/2012 2:52 PM

Hello.Indeed I want to display a 100KV ac voltage [50HZ] may vary its frequency

on the LCD and I have a 100V as a sample of that 100KV ac voltage.

So,I try to find a way to display that voltage precisely.[using mikroC PRO V5.3

compiler,PIC18F452,XTAL=40MHZ].

Would you help me for that?

Thanks,

Register to Reply
Guru

Join Date: Jan 2008
Posts: 1753
Good Answers: 59
#11
In reply to #10

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/22/2012 8:48 PM

First of all - as you are new here - the ground rules need to be repeated. You get free advice, and you can take it for what it is worth. We do not do homework. You do your heavy lifting. With that out of the way:

1,. You picked a way too complicated PIC for such a simple task. PIC is so cheap, even later expansion dreams are never realized. K.I.S.S.. Figure the smallest, then 4x the memory, and that is the ballpark.

2,. Analog Design is coequal, if quality performance is expected. Generally, analog guys can program, but do not like it. Programmers, on the other hand, frequently believe they can cookbook it, and it does not work. Example: how much smoothing, averaging, spike and noise suppression do you want in analog? What about allowable phase delay? I do not care if you make them happen. But - a power bus being a badly noisy environment - drop them with care, if you want something useable.

3,. What is the precision and impedance of the 100V sample? If, later a current transformer is added, the same? Specification creep is normal in any proiect.

3.1,. How do you transport your sample(s) to a quieter environment? Because a PIC will go bonkers near to a power bus.

4,. Did you design for such eventuality?

5,. Spend 1/4th of your time in specmanship, exploring these and such. Then, mostly you know what you want to realize in some detail.

6,. Then you can spend 1/4th time in laying out, and refining hardware and software block diagrams.

7,. Then you do know, how much Analog help is needed. At the same time, you can start programming with confidence. A seaserpent, flow of consciousness programming is a guaranteed path to failure. I took a few bets, never lost one on that.

8,. An example for decision. Peak detector is good for pure sinus, that does not exist on a generator's bus. Far from it. Decide, if the solid harmonic is important to you? Dou you want to go to a multisampling / integrating route? For timing, an Analog massaged Zero Crossing is the way to go.

9,. How precisely do you can measure 50Hz? It is a trick question with measurement theory. Software doing any? Yeah, right.

10,. If this is a thesis work, or some such, pare it down to the minimum to do. Pay due obeisance to issues left out. The go on with life.

Contemplate on it.

Register to Reply Score 1 for Good Answer
Guru
Engineering Fields - Electrical Engineering - Been there, done that. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 15600
Good Answers: 981
#12
In reply to #11

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/22/2012 10:02 PM

Good Answer.

I'm afraid though that our OP has taken a task far larger than they can handle and just wants code thrown at the problem. I also very much worry about their safety in this attempt. 100KV is not an environment for a novice. 100KV at 50 Hz implies to me power line distribution with enormous amounts of lethal instantaneous power being available. I realize that this might be instead be step-up transformer for some other purpose that needs to be monitored. Power distribution or step-up, I'm certain the concerns of corona discharge have not been considered if the dynamics of a simple analog peak detector circuit have not been considered.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Participant

Join Date: Jun 2012
Posts: 4
#13
In reply to #10

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/23/2012 4:07 AM

Hello.My special thanks to Mr.Leveles & Mr.Redfed for their precise analysis of my project.So, I am still at begining of my project way to realize that.

Thanks,

Register to Reply
Guru
Engineering Fields - Electrical Engineering - Been there, done that. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 15600
Good Answers: 981
#14
In reply to #13

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/23/2012 8:23 AM

You are very welcome. I hope that your 100KV is either a typographic error or that your PIC based instrumentation is actually getting a linearly scaled down signal for you to measure. As I said earlier 100KV is a very dangerous voltage to work on and equipment working at this voltage should not be worked on casually. As the video shows, 100KV will easily arc through air.

One complication that I did not mention earlier about using a peak hold circuit to measure the peak voltage that have baffled many engineers. While many function generators successfully generate very clean sine wave signals, very few real world signal sources are this clean. As such any apparent error voltage level produced by a peak hold measuring circuit may actually be due to a real signal plus noise or interference.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Guru

Join Date: Feb 2012
Posts: 595
#15
In reply to #14

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/23/2012 10:35 AM

when i was a kid . . . (? do i need to tell futher)

so when i was a kid i concidered that if i put the isolated (cleaned ends) wire - the thinnest i got to a ~220AC outlet then it will fail before the mains - the both went - iwas blinded some time by the flash of spark cloud ... (?what) ... when i checked my thumb and pointer fingers - i could admire that isolation had saved my skin just under it but not around - it (the ash) came off with the soap and water mostly

so everything near above ~400 V (0.4kV) tends to set up an air traffic (man is a very good ground - even with no earth around/avail.)

__________________
ci139
Register to Reply
Guru

Join Date: Feb 2012
Posts: 595
#16
In reply to #15

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/23/2012 11:27 AM

"a 100V as a sample of that 100KV ac voltage."

? down transformed
? Gigaohm resistive voltage divider
? u name it

no experience with 100KV K is for Kelvin k is for kilo- (i almost hate non physicist - they put it even on product labels WTH?)

no eperience with 100kV eighter - but sampling of that range is tricky i suppose (all my digital meters fail near 2kV (as location/close by) metering (something low amps -range) )

__________________
ci139
Register to Reply
Guru

Join Date: Feb 2012
Posts: 595
#17
In reply to #16

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/23/2012 6:25 PM

... ok ... suppose the stuff is metered by resistive voltage divider - there is some issue other than EM field influence to apparattus ...
(±-.1MV) -[99900]--[100]-(±.1MV) , <-- the problem likely rises with such
(±-.1MV) -[49950]--[100]--[49950]-(±.1MV) ? donno ...

... other words ground or 0 tracking -- as i said no practise with .1MV

__________________
ci139
Register to Reply
Guru

Join Date: Mar 2007
Location: City of Light
Posts: 3943
Good Answers: 183
#18

Re: Practical & Precision Sinusoidal Peak Detector for PIC18F452

06/24/2012 4:28 PM

It is possible to use a solenoid to induce a curent and work wit it. The field is concentric and the solenoid can be placed with its axis perpendicular to the cable. The obtaind voltage can be a lot less and not as dangerous as the original tension.

Register to Reply
Register to Reply 18 comments

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

bobx (3); ci139 (3); Doorman (1); leveles (2); nick name (4); redfred (5)

Previous in Forum: PC Problem   Next in Forum: Hacking a Camera Through the UART Port

Advertisement