Ir ao conteúdo
  • Cadastre-se

Número de pontos de uma curva com pic18f


paivadaniel

Posts recomendados

Pessoal, estou trabalhando no pic18f452, e tendo um movimento periódico e de período conhecido, que traduz a aceleração no eixo x de um acelerômetro, tenho a curva desse movimento, esse sinal vem do a/d, e gostaria de saber quantos pontos estão presentes em cada período, quantas conversões foram feitas. Dessa forma, como eu conheço o período, se eu souber o tempo de aquisição de cada amostra, eu tenho quantas amostras foram feitas.

Lendo o livro do Noboru sobre pic, eu vi a expressão Tad = 1/(Fosc/16).

Eu estou compilando no ccs, e o clock interno é de 20.000 MHz, pelo menos é o que encontrei no pic18f425.h

#use delay(clock=20000000)

Gostaria de saber se a expressão que encontrei no livro do noboru é válida para o meu caso, pois ele trabalha com o pic18f4550, e como o meu pode ser de 8 ou 10 bits,

acredito que ao invés de Tad = 1/(Fosc/16), seja Fosc = 1/(Fosc/8), mas não tenho certeza.

Aguardo uma ajuda.

Daniel

Link para o comentário
Compartilhar em outros sites

Veja se ajuda algo que encontrei em um forum tempo atrás. Tá em inglês:



>You seem to not understand what I am asking. I have no idea what TAD
>is.

TAD is the time it takes for one complete cycle of the clock that runs the A/D
process. The A/D process takes 11.5 of these TAD clocks to complete. So if TAD
is 2 usec, then the A/D process will complete in 23 usec. after you trigger a
conversion.

> I have no idea what Fosc is.

Fosc is the frequency of the instruction cycle clock, which is the CPU clock
divided by 4. The Fosc clock is used to step through the instructions. It is
used in many places in the chip besides the A/D section, such as the input to a
timer and the UART.

> Therefore I have no way to wrap my
>head around what they do and how they are calculated.

I just said what they do. As for calculating them, the TAD time is calculated
by taking the Fosc period (which is the reciprocal of the Fosc frequency) and
dividing by whatever ratio you select in your choice of ADCON configuration bits
that to set.


>> It means changing the tap on the prescaler that derives the A/D clock from the
>> CPU clock.
>
>Again this means nothing to me. So we change the "tap" and come up
>with a different time. That tells me nothing about how to calcualate
>either number.

A "tap" refers to a point in a series of divide-by-2 circuits. By picking a
different tap you select a frequency that is equal to the input frequency
divided by 2, 4, 8, 16, etc. By the way, I don't know if you have mentioned it
before, but which particular PIC are you looking at? It would help me to relate
to what you are seeing.


>> The minimum setting is specified in terms of TIME not in terms of the divide
>> ratio. But you must specify it in terms of the divide ratio.
>
>Scott, divide ratio of what?

The divide ratio is what you specify when program the ADCON registers. The
datasheet says which divide ratio goes with which bit settings.

> What is being divided?

The Fosc clock frequency.

>Examples and
>numbers would help.

OK. If the external crystal oscillator is 10MHz (no PLL), then the Fosc
frequency is 2.5 MHz. If you select a divide-by-16 in the ADCON configuration,
then the TAD frequency is 2.5 MHz / 16 = 156250 Hz. Therefore the TAD period is
6.4 usec., which is a valid TAD period since is is greater than 1.6 usec.

>> The chip does not know what frequency XTAL you are using, so they offer different >divide ratioes and leave
it up to you to pick an appropriate divide ratio to make the A/D clock:
>
>I FULLY understand the concept. I think your missing that point. I
>DONT understand what numbers to use, what they mean and where they come
>from. Again examples would help

The choice of what numbers to use is up to you. You have to decide what your
design requirements are. For example, most people want their A/D operations to
complete as fast as possible, so they program the ADCON registers to generate a
TAD time as short as possible, as long as it is not less than 1.6 usec. However
the choice of crystal also impacts current drain. If your device is battery
powered, then you want to use as low a crystal frequency as you can, consistent
with getting the job of your application done. Also, you might want to consider
how the choice of CPU frequency might impact the available UART frequencies.

>> I have found the Microchip datasheets to be among the clearest in the industry
>> for giving things in as close to laymans terms as is possible without
>> sacrificing accuracy. Just keep reading them. Nothing else is needed other
>> than a general understanding of principles of digital electronics.
>
>I think that is the problem here. I READ THEM and have questions and
>you are answering the questions with almost direct quotes from the
>Datasheet. No matter how well YOU think the datasheet is written, I am
>struggling to put a few of the concepts into perpective. YOU
>understand your anwers but I do not. If I did understand, then the
>datasheet would have been all I needed in the first place.

I think I understand where you are coming from. I just went through a difficult
learning period on trying to crack the "secret" of programming Nokia Symbian
cell phones. I read all the Nokia documentation and asked lots of questions in
the Nokia forum. For the longest time it seemed like they were all in a secret
society and I was confused because I had never been taught the secret handshake.
But I finally found some documentation that got me over that initial hurdle.


Robert Scott
Ypsilanti, Michigan
On 21 Sep 2006 07:18:57 -0700, "beananimal" <[email protected]> wrote:

Falou

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!