• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC delay timing; Is my math correct?

Status
Not open for further replies.

Krumlink

New Member
Ive been working on some PIC delay timing for a Servo, but It does not budge. I am just wondering if the math I am doing is creating proper 1.5msc pulses?



8mhz/4=2MIPS

1/2M = 1.25*10^-7 (1 second divided by 2 MIPS = seconds per cycle)
1.5/1000 = 0.0015 (1.5msc desired divided by 1000msc = 0.0015)
0.0015/(1.25*10^-7)=3000 cycles

Then to get the 1.5msc pulses I divide by 2, so 1500 clock cycles per wavelength.

Using a similar method, I have tried to create 38khz IR signals but the IR receiver hooked up to receive the signals does not indicate a pulse. Is my math right?


/////////////////////////////////////////////////////////////////
38khz timing
/////////////////////////////////////////////////////////////////
1/2MIPS = 5*10^-7
1/38khz = 2.631578947368^-5

38khzanswer/2MIPSanswer = 52.6316 cycles

divide by 2 = 26.3158 cycles per wavelength
 

Pommie

Well-Known Member
Most Helpful Member
One millisecond at 2MHz is 2000 cycles so 1.5mS is 3000 cycles. This is the pulse length not the frequency and so there is no need to divide by two.

Mike.
 

Krumlink

New Member
One millisecond at 2MHz is 2000 cycles so 1.5mS is 3000 cycles. This is the pulse length not the frequency and so there is no need to divide by two.

Mike.
You have to delay so many cycles ON and delay so many cycles OFF. Do you delay 3000cycles on and 3000 off?
 

Pommie

Well-Known Member
Most Helpful Member
You delay 3000 (1.5mS) on and 40,000-3000 (20mS - 1.5mS) off. The 40,000 isn't critical and you can get away with 1-2mS on and 20mS off.

Mike.
 

MrAl

Well-Known Member
Most Helpful Member
Hi there,

I believe your math is correct in that your carrier has to have 26 clocks 'on'
and 26 clocks 'off', or if you want you can get closer by dithering with two
states that are 26 in duration and one state that is 27 in duration, although
i find that those IR receivers are the most insensitive when it comes to
carrier frequency (26 and 26 will work just fine).

Your burst duration and the position of the bursts depend on what protocol
you are working with. There are quite a few of them and many of them
have different burst durations for different locations in the data stream.
It is worth looking at a few unless you already know what protocol you
have to work with.
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top