2 Conversion AD

Moderator: Benj

Post Reply
Frank123
Posts: 36
Joined: Fri Jan 15, 2010 5:17 pm
Location: Saint-Nazaire - France
Has thanked: 1 time
Contact:

2 Conversion AD

Post by Frank123 »

Hello

I have a problem with the AD conversion. I work with a 18F4331. I made a little macro that occurs every 200μS. It should generate a square wave of period 2 ms with a duty cycle of 80%.
In addition to 1.8 ms I measure 2 channel with AD converter.
If I put the measure to follow I obtain a term which does not correspond to what I'm waiting.
buh-hs.png
(12.49 KiB) Downloaded 3056 times
chrono-hs.png
(2.05 KiB) Downloaded 3056 times
By cons, if I do my interval measures 200μS it works.
bug-ok.png
(17.05 KiB) Downloaded 3055 times
Can you tell me why or fix this bug.

Frank
Frank
Electronics teacher

Frank123
Posts: 36
Joined: Fri Jan 15, 2010 5:17 pm
Location: Saint-Nazaire - France
Has thanked: 1 time
Contact:

Re: 2 Conversion AD

Post by Frank123 »

What about this bug ?
Frank
Electronics teacher

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 2 Conversion AD

Post by Benj »

Hi Frank,

Sorry I may be being a bit thick here, (its monday morning after all) but is the problem that the delays are not coming out ok? or that the analogue readings are incorrect?

I think its this sentance that is throwing me off.
If I put the measure to follow I obtain a term which does not correspond to what I'm waiting.
If you could please state your problem again then hopefully I will be able to help you solve the problem.

Frank123
Posts: 36
Joined: Fri Jan 15, 2010 5:17 pm
Location: Saint-Nazaire - France
Has thanked: 1 time
Contact:

Re: 2 Conversion AD

Post by Frank123 »

Hi Benj,

English language is not always easy and i use, sometimes, automatique translation :oops:

It's the delay that is not ok. I want a 2 ms period (like second example with just on conversion) but i have 35.52 ms (like first example) if i make two successivex conversions.

The result of ADC it's ok.

Frank
Frank
Electronics teacher

User avatar
Steve
Matrix Staff
Posts: 3423
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 2 Conversion AD

Post by Steve »

Hi Frank,

We have many French users, and if you prefer you can post in French (or any other language) instead of English - or perhaps post in French and include a translation into English as well. We can always use the online translators anyway.

Frank123
Posts: 36
Joined: Fri Jan 15, 2010 5:17 pm
Location: Saint-Nazaire - France
Has thanked: 1 time
Contact:

Re: 2 Conversion AD

Post by Frank123 »

Merci,

Ca c'est une bonne nouvelle.

Frank
Frank
Electronics teacher

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: 2 Conversion AD

Post by Dan81 »

Salut Frank

As tu résolu ton problème ?
il semblerait que la durée des 2 acquisitions soient supérieures aux 200us de ta base de temps. Surprenant !
Envoie moi ton prog si tu veux.

Daniel

User avatar
Steve
Matrix Staff
Posts: 3423
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: 2 Conversion AD

Post by Steve »

The "Lire comme Octet" ("read as byte") ADC macro does take a certain amount of time, so your 200us interrupt is probably not firing properly.

In your "=9" branch, you could put some additional debugging statements (such as i/o transitions) around and between the ADC macro calls to determine how long each is taking.

Post Reply