You can cross-feed your HPWM to one of the Hardware Comparators and have it invert the signal.
You can cross-feed your HPWM to one of the Hardware Comparators and have it invert the signal.
Sounds simple,
I presume I only need one comparator so I would make CMCON = %100101
I would then connect RA1 (VIN-) to ground and feed RA2(VIN+) from RB3 (PWM signal)
I would connect my Tx to RA2 and pick another unsused pin (RB5)
I figure I would get the inverted signal from RA2 by reading CMCON.7
But how to I pass the value of CMCON.7 to RB5?
Or am I going the wrong way?
This is what works feeding just one pin of the Tx
Code:Main: ;reset timer hpwm 1, 127,40000 ; Send burst, Ch1, D.Cycle50%, Freq 40Khz pauseus 150 ; length of burst. CCP1CON = 0 ; Turn off PWM pause 100 ; Wait to prevent picking up ; noise generated by Tx ; detect timer overflow ; do the maths ; display results GOTO Main
Mike
Ok so I think I have my answer (mostly).
I realized I must use this operating mode to access the output directly from an I/O pin:
Therefore I have used CMCON = %110
Connected RB3 (PWM signal) to RA0
and I can see the inverted signal on RA3
Now I still have an issue, the rising edge of RB3 happens at the same time as the falling edge of RA3 but the rising edge of RA3 happens 4uS after the falling edge of RB3.
Is there something I can do to fix this?
Thanks
Mike
Found it...!
I added a 100K resistor between RA2 and +5, not sure if 100K is the perfect value but it works.
Thanks for the guidance.
Mike
Now I am starting to feel psycho responding to myself that many times but after putting my glasses on, it is a 180 ohms I have there and the delay is now 80nS, tried 1k and got 120nS, also tried direct but no go.
So 80nS is acceptable and way better than 4uS.
If anyone can figure out a way to make it 0 delay that would make things just perfect.
Mike
You won't make it zero. There's hardware between the input and output, and it takes time for the little electrons to wiggle their way through very tiny wiring. You could always strap RA2 directly to +5, but it won't get much better than that. The performance limits are somewhere in the back of the Datasheet.
I tried to connect RA2 direct to +5 but that gives me a straight 5 V at RA3
But its good now, I have improved the range, driving one side of the Tx was 10 feet and now having the inverted output I get 28 feet.
I will probably improve more when I get to the mechanical aspect.
Thanks for your help.
Mike
Last edited by lilimike; - 22nd April 2010 at 20:27.
Bookmarks