Hi,
you can generate two square waves with a PIC 1000 Hz out of phase with each other in advance or delay of 90 degrees?
Printable View
Hi,
you can generate two square waves with a PIC 1000 Hz out of phase with each other in advance or delay of 90 degrees?
Yes, you can use, just use timer1 and DT interrupt.
Assuming you will use the internal oscillator @ 8 MHz, timer1 should be set with prescaler at 1 tmr1h =252 and tmr1l = 24. This will give you the right timing.
Use the following array:
Chan VAR byte [4]
A0 VAR byte
Forward VAR bit
chan[0]=0
chan[1]=1
Chan[2]=3
Chan[3]=2
Within the ISR I will call overflow as an example you will write the following code:
Overflow:
If forward = true then
A0 = A0 + 1
If A0>3 then A0 = 0
Else
A0=A0 - 1
If A0>200 then A0 = 3
Endif
PortB = Chan[A0]
@Return
You will use portB.0 and portB.1 as your output. Set flag Forward to true (1) for channel A high prior of channel B, set flag to False (0) to reverse.
Cheers
Al.