Thanks for your reply. PIC_USER is correct in post #16, both GPIO.0 and GPIO.1 are at the same level in time periods 2 and 4, but they are both low. I want them to be high. Can someone tell me what is wrong with my code?
BTW, I changed to TRISIO=0, didn't make a difference.
Hi Russ,
I think with your original pins (GPIO.0 and GPIO.1), and your second (inverse) code:
LOW GPIO.0 'INITIAL CONDITIONS
LOW GPIO.1
START:
HIGH GPIO.1
PAUSEUS 4168 ' HIGH TIME
LOW GPIO.1
PAUSEUS 4167 'DEAD TIME, BOTH LOW
HIGH GPIO.0 'SETS PIN 7 HIGH
PAUSEus 4168 'FOR 4.168 MILLISECONDS
LOW GPIO.0
PAUSEUS 4167 'DEAD TIME
GOTO START '60 HZ FREQUENCY
END
...and your diodes reversed and the resistor tied to ground (as skimask said).
Your two LEDs will not be on at the same time... (try it)
I still would like to know between which points are you measuring the wave (voltage) from?
-Adam-
Ohm it's not just a good idea... it's the LAW !
Hi Pic_User. Yes, I know that, but why cannot I connect the LEDs to + and pulse to ground? I changed the program, trying to zero in on the probem. Now GPIO.1 pulses to ground like I want but GPIO.0 pulses positive in phase with GPIO.1. I would not expect GPIO.0 to change at all.
high GPIO.0 'INITIAL CONDITIONS
high GPIO.1
START:
low GPIO.1
high GPIO.0
PAUSEUS 4168 ' ON TIME
high GPIO.1
PAUSEUS 4167 'DEAD TIME, BOTH high
high GPIO.1
PAUSEus 4168 'FOR 4.168 MILLISECONDS
high GPIO.1
PAUSEUS 4167 'DEAD TIME
GOTO START '60 HZ FREQUENCY
END
I will post the final circuit so you can see what I am trying to do. I want to replace the 555, flip flops and gate with the PIC.
Last edited by Russ Kincaid; - 7th May 2007 at 17:10.
Hi Russ,
Looking at the circuit you want to replace:
It looks like you want to avoid both being on at the same time, at all costs (as you said).
It may be better to declare variable for the HIGH TIME and the anti-overlap time so you can change them in one place in the program, while playing with the duty cycle.
Could be missing something but it looks like you want the positive part of the cycle to take 8.336 milliseconds and same time for the negative part.
Sixty Hertz = 1/60 = 0.0167 (16.67 milliseconds).
This gives us 16.67 milliseconds for a complete (whole) cycle.
How much on or off time can be played with but the recurring 60Hz, is fixed.
So the total on and off time for GPIO.0 and GPIO.1 should equal 16.67 milliseconds, and never be on at the same time.
I used your same code and beat it up pretty bad:
LOW GPIO.0 'INITIAL CONDITIONS
LOW GPIO.1
START:
HIGH GPIO.1
PAUSEUS 8236 ' HIGH TIME - GPIO.1 only
LOW GPIO.1 both pins low
PAUSEUS 100 ' anti-overlap time
HIGH TIME and over-lap time should add to 8.336 milliseconds
HIGH GPIO.0 ' GPIO.1 has been low during anti-overlap time
PAUSEUS 8236 ' HIGH TIME - GPIO.0 only
LOW GPIO.0 both pins low
PAUSEUS 100 ' anti-overlap
HIGH TIME and over-lap time should add to 8.336 milliseconds
GOTO START '60 HZ FREQUENCY
END
Play with HIGH TIME and anti-overlap to get the desired duty-cycle (average vs. RMS vs. 0.7 ) but they should total to 8.336 milliseconds each half cycle. Then 16.67 milliseconds for the whole cycle.
You should run the diodes (LEDs) between the PIC pins and the resistor to common (ground).
Oh yeah, I should warn you that I dont know what I am doing!:>
-Adam-
Ohm it's not just a good idea... it's the LAW !
Thanks, but I have already built the board, I don't want to cut traces if I don't have to. My original program produced the inverted waveform, I want to be able to produce the waveform per the sketch. As another experiment, I modified the program, adding another HIGH GPIO.0, but now both outputs go low at the same time for 8 mS.
high GPIO.0 'INITIAL CONDITIONS
high GPIO.1
START:
low GPIO.1
high GPIO.0 'GPIO.0 GOES LOW
PAUSEUS 4168 ' ON TIME
high GPIO.1 ' GPIO.1 GOES LOW
HIGH GPIO.0 'GPIO.0 STAYS LOW
PAUSEUS 4167 'DEAD TIME,
high GPIO.1 ' BOTH GO HIGH
PAUSEus 4168 'FOR 4.168 MILLISECONDS
high GPIO.1 BOTH STAY HIGH
PAUSEUS 4167 'DEAD TIME
GOTO START '60 HZ FREQUENCY
END
GPIO.0 and GPIO.1 are synchronous but I don't know that they follow the program!
I think you might be confusing yourself a bit...not sure, but that's what it looks like to me...
high GPIO.0 'GPIO.0 GOES LOW ---- GPIO.0 looks like it goes low because the LED goes out. No... it's got 5v on both sides of the LED...no current flow...
I think, in the end, you're going to end up cutting traces and doing some rewiring.
Bookmarks