I was wondering if I may ask for a little input from the geniuses here. I am in the process of building a Pulse Generator, I started a tread for it but thought this question was better asked on a seperate thread. Pulse Generator Tread: http://www.tinyclr.com/forum/topic?id=7069
I am doing some home work and trying to find the best way to invert a Pins output. For Example: I may have pin(X) running 1Khx at 62% Duty Cycle, I then want to make pin(y) the inverted wave to pin(x) still at 1Khx and 62% Duty Cycle but opersite.
I have looked at “OutputCompare” but this looks to be to slow at high frequency. Is there a better way to do this and make it efficent and Accurate? I can see there may be a way to do it in an ISR but not yet quite sure how to go about this.
I am just looking at C# Coding at this stage and dont think I will need to use RLP as the speed of any changed will not be so important. I will be using Serial (USB) Comms to report changes back to a Windows Form, The Windows Form will also be making changes to the Frequency and Duty Cycle. So I expect that I wont need RLP at this stage.
Use a logic inverter chip and only use one Fez Pin? That way you guarantee it’s in sync !
Srry for the late reply. I thought about that but my problem is, I am new to FEZ and went to learn as much as I can while I am doing this project. Even if I come accross limitations, which I no doubt will. I see FEZ is a bunch more practical and more userfriendly than Arduino, with a huge amount of extra features.
I may have found a way to invert the pins I need using CAP and MAT, by throwing an interupt on the MAT we should be able to detect the Rising and Falling Edges and then do a smallcalculation to adjust for the Duty Cycle Differencees we strike.
I just love getting the grey matter working ;0)
Thanks for the pointer though, I will come back to this if my idea fails.
I can’t tell or misread- but if you’re trying to output a signal and its opposite, this may work:I haven’t tried this but you could maybe use two pins and RLP, then output a byte that changes both simultaneously to the output register? You may even be able to just do this directly with the Register class.
See p172 in the LPC manual in Table 132. the IOPIN register and thereabouts.
if however you’re looking to take in a signal and then output its opposite, you’re going to miss transitions if you try to go through the FEZ. As someone else said, the inverter would be your choice there.
Thanks for your reply! Yes I was thinking this also. I mentioned above that I thought this was possible. I may have to do some C++ RLP after all to make this all work.
I hope to get a bit more time today and get some progress happning.
I would try just with the Register class first and see how it goes. Let us know how you do!
It would be cool if GHI/MS/someone would make a builtin class that lets you write a whole IO bank (8 pins) at once, perhaps with a mask you can set to only affect certain pins.
There is parallel port class and also you can implement using register access class or RLP.
Hey thanks for the tip. You’re always around! I shall call you my Big Brother?
No need, they said Gus is just a bot with complex script!
Ok GusBot! I’d like to get my hands on your programming. Might come in handy. I might never have to work again.
I have an answer to this question after a while experimenting…
On my project here: http://www.tinyclr.com/forum/topic?id=7069&page=4#msg74861 (Pulse Generator on a FEZ Panda 2 - 1Hz to 30Mhz?)
I have found that if you use Double Edge Controlled PWM Outputs by setting bits in the PWM1PCR Register:
// Set Double Edge Mode PWM...
Register PWM1PCR = new Register(LPC23xx.PWM1PCR);
PWM1PCR.SetBits(1 << 2);
PWM1PCR.SetBits(1 << 4);
PWM1PCR.SetBits(1 << 6);
Then you can set the MR1-6 accordingly.
See Page 565 Table 480. Set and reset inputs for PWM Flip-Flops from the LPC23XX User manual Rev. 02 — 11 February 2009
This will enable you to set MR3 to 50% then add Pulse width to MR4 of the same value as MR1 and this will Invert the MR4 from the MR1 outputs Real Time
Hope this helps,
All the Best
P.S. Up to 6 Outputs are availiable but only 3 Inverted are possible.