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

ADC for a AC signal question

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



Joined: 08 Apr 2015
Posts: 77

View user's profile Send private message

ADC for a AC signal question
PostPosted: Wed Apr 08, 2015 10:39 am     Reply with quote

I have a ac signal from 0,1V to 3,1V that i want to process with a dspic. I would then like to do zero crossing (at 1,6V), my question is : are the 3,1V replaced by the value of 1023 (10bit) and the 0,1V by 0?

thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 10:56 am     Reply with quote

Depends on where you set the voltage references....

If you set Vref- to 0.1v, and Vref+ to 3.1v, then the ADC will read from 0.1v to 3.1v. That's what the reference inputs are for....
irmanao



Joined: 08 Apr 2015
Posts: 77

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 11:00 am     Reply with quote

I wasn't aware of that, thank you very much, i am new to programming.
Mike Walne



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

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 11:03 am     Reply with quote

Depends on your ADC, ac signal and what you want to do with the data.

Assuming your ac signal is swinging from 0V1 to 3V1, the ADC lower ref is 0V1 and upper ref is 3V1, then you are probably correct.
Depending on the nature of your ac signal you may not need to use zero crossing.

Mike

EDIT I see Mr T. got in as I typed.
temtronic



Joined: 01 Jul 2010
Posts: 9240
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 11:10 am     Reply with quote

It's NOT an 'ac ' signal if it transitions from +0V1 to +3V1, rather just a DC signal...

perhaps a 'moot' point but PIC ADC subsystems will NOT tolerate a real AC signal !!

jay
irmanao



Joined: 08 Apr 2015
Posts: 77

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 11:22 am     Reply with quote

Yes i know the average is not 0 so it's not a ac signal
thanks

the signal is a sine wave (50 Ηz) and i need to trigger a pulse for two SCR's at the 1.6V point after a delay
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Apr 08, 2015 12:31 pm     Reply with quote

have a look at this PDF selector matrix

http://www.microchip.com/stellent/groups/sitecomm_sg/documents/devicedoc/en570055.pdf

see the column ZCD under the gold heading Intelligent Analog
ZCD= Zero Crossing Detector

the pics designated are OPTIMIZED for just what you want to do only SO MUCH better than you may have envisioned.

check data for parts
16f161x
and
18fxx40/42
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 12:36 pm     Reply with quote

Also, seriously, 'step back'. The poster needs to start by doing some basic C programming before trying to work with AC.

1) Do a basic 'hello world' output.
2) Read an ADC, and then experiment with how the numbers relate to the voltages etc..
3) Learn how to loop, test, one stage at a time.

Trying to jump in the deep end, rather than starting with basics, is a sure way of wasting a lot of time.
temtronic



Joined: 01 Jul 2010
Posts: 9240
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 2:41 pm     Reply with quote

hmm....
the signal is a sine wave (50 Ηz)

NOW you're telling us it really IS an AC waveform, so you CANNOT feed that signal into the PICs ADC. well you can but risk destroying it !
The PICs ADC section is NOT designed for -ve voltages, ONLY +ve ones.

jay
asmallri



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

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

PostPosted: Wed Apr 08, 2015 6:01 pm     Reply with quote

temtronic wrote:
hmm....
the signal is a sine wave (50 Ηz)

NOW you're telling us it really IS an AC waveform, so you CANNOT feed that signal into the PICs ADC. well you can but risk destroying it !
The PICs ADC section is NOT designed for -ve voltages, ONLY +ve ones.

jay


I interpreted this differently as an AC signal superimposed on a DC offset.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
temtronic



Joined: 01 Jul 2010
Posts: 9240
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 6:47 pm     Reply with quote

hmmmmmmmm... perhaps the original poster can show us an example of his input waveform.
A 50Hz sine wave usually tells me it's 'mains voltage' from across the pond.
Having a 'zero cross' at 1.6V when the signal goes from .1 to 3.1 does sound like superimposed AC on a DC level.

now I'm more confused....
a picture would be worth 1000 words ( or bytes !)

Jay
irmanao



Joined: 08 Apr 2015
Posts: 77

View user's profile Send private message

PostPosted: Thu Apr 09, 2015 4:38 am     Reply with quote

It is superimposed on a DC offset
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