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 support@ccsinfo.com

Square wave to DC convertor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asjad



Joined: 09 Mar 2004
Posts: 52
Location: Greater Manchester - UK

View user's profile Send private message

Square wave to DC convertor
PostPosted: Thu Apr 15, 2004 2:14 am     Reply with quote

Dear All,

Does anyone know how to convert a square wave into a DC signal

I have hgeard you can use a low pass filter OR a diode and a filter.

Ccan anyone help.

I need compnenet values or weblinks please!


Thank you

Asjad
_________________
Best Regards
Ttelmah
Guest







Re: Square wave to DC convertor
PostPosted: Thu Apr 15, 2004 2:29 am     Reply with quote

asjad wrote:
Dear All,

Does anyone know how to convert a square wave into a DC signal

I have hgeard you can use a low pass filter OR a diode and a filter.

Ccan anyone help.

I need compnenet values or weblinks please!


Thank you

Asjad

Component values will depend on the frequency of the source.
What do you actually want to measure/return?. I suspect that in fact it is not a 'square wave', but a 'rectangular wave', and you want to produce a DC voltage proportional to the mark/space ratio?.

Best Wishes
asjad



Joined: 09 Mar 2004
Posts: 52
Location: Greater Manchester - UK

View user's profile Send private message

PostPosted: Thu Apr 15, 2004 2:55 am     Reply with quote

Unfortunatly I do not know the frequency that will be coming out at this
stage.

THe output will be derived from a liquid flow meter.(output=pulses).

I wish that if a liquid is flowing I get a logic 1.
If no liquid flows I get a logic 0.

I will be using a 16f874's external interrupt

will this circuit do:

http://www.callerid.8m.com/mini/peakdet.htm

I am not sure how it works though
-------------------------------------------------------------

FOr your original soloution proposal can you PLEASE
give me a formula to calculate R & C and the configuration!!

Best Regards

Asjad
_________________
Best Regards
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Apr 15, 2004 6:48 am     Reply with quote

Hi asjad,

It will be easy & cheaper to do it using a rettriggerable monoestable multivibrator like the 74HC4538 or similar.
Configure the setup pins as retriggerable monoestable, feed the trigger input with the pulses coming from the flow meter and choosing the Q output you will get a stable HIGH state while the pulses kick the trigger input.

Exclamation Connect to GND all unusued inputs

Regards,

Humberto
Ttelmah
Guest







PostPosted: Thu Apr 15, 2004 7:06 am     Reply with quote

asjad wrote:
Unfortunatly I do not know the frequency that will be coming out at this
stage.

THe output will be derived from a liquid flow meter.(output=pulses).

I wish that if a liquid is flowing I get a logic 1.
If no liquid flows I get a logic 0.

I will be using a 16f874's external interrupt

will this circuit do:

http://www.callerid.8m.com/mini/peakdet.htm

I am not sure how it works though
-------------------------------------------------------------

FOr your original soloution proposal can you PLEASE
give me a formula to calculate R & C and the configuration!!

Best Regards

Asjad

I'd consider using a CMOS 555 timer, set up as a 'missing pulse detector'. The big advantage is this gives quick switching when the pulse train stops, and does not result in the interrupt pin sitting at a potentially 'indeterminate' level (which can lead to the PIC drawing more power than expected...).
Look at:
http://www.uoguelph.ca/~antoon/gadgets/555/555.html
Circuit 10a, is for such a detector. The time constant for the monostable used in it, is approximately T=1.1*R1*C1. The output pin will need a pull up resistor (the 555, has an 'open collector' drive output).
You are going to need to know the frequency of the pulse train, whatever solution you choose. Does the manufacturer have a data sheet, or stick a scope on the signal, and make some rough measurements.

Best Wishes
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Apr 15, 2004 8:39 am     Reply with quote

The peak detector circuit with an op amp, or the missing pulse detector with the 555 are more accurate and more expensive than the diode + RC circuit I mentioned in an earlier post. It all depends on what accuracy you need.
_________________
The search for better is endless. Instead simply find very good and get the job done.
dbotkin



Joined: 08 Sep 2003
Posts: 197
Location: Omaha NE USA

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

PostPosted: Thu Apr 27, 2006 1:06 pm     Reply with quote

I dunno... you could do this with a monostable, but why bother adding parts? Just watch the flow meter output with one of your inputs. Use a short variable to indicate whether it's gone high within the last whatever period of time you want. I can think of several ways to do it, like using an interrupt-on-change, or a CCP input in capture mode, or if the pulses are long enough check it during an existing (or new) timer-driven ISR. Now you have the flexibility to change the time constant of your software "one-shot" to whatever you wish without having to change components.

If a picture is worth a thousand words, a few lines of code can be worth a few dozen solder joints. Make sense?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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