Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/03/01 11:34
Read: times


 
#12148 - RE: Phase angle, Duty Cycle
What Aad said is true, but you HAVE to meet two conditions:

1) Only the DUTYcycle of the inputsignal may vary, NOT the FREQUENCY.

2) You MUST have a clocksignal for the shiftregister which is absolutely synchron with the input signal, but exact 360 times the input frequency. So this clocksignal must be derived from the circuit that delivers the input signal for your microcontroller. Simplest way is NOT to connect your inputsignal to P0.0, but to an interrupt inputpin. Make the pin negative edge detect, and HIGH preority interrupt. So you can measure the period time. (Time between two input interrupts). Devide this time by 360 and you'll have the nessesary sampleclockfrequency. Use a timer to generate 360 (low preority) interrupts
per inputcycle.

Make a buffer in RAM of 360 continuous bits.
Also make a software counter for clockpulses
Now, after having used one inputcycle to define the sampleclockfrequency, you have to do the following:

when an external interrupt occurs (inputsignal becomes low)
* reset the sampleclockcounter
* Reset the softwareclockpulscounter
* write the momentary value of the inputpin to bufferlocation 0


when an timerinterrupt occurs:
* Increment the softwareclockpulcounter by one
* Write a sample of the signalinputpin to the RAMbufferlocation defined by the softwareclockpulscounter.

If you have reached RAMbufferlocation 359, the next location should be location 0, because 360 degrees and 0 degrees are the same position (start of cycle).

In your MAIN program, you have to set a value between 0 and 359 in a variable, wich stands for the phaseshift. If you compare this value in your timer-interruptroutine with the softwareclockpulscounter and it is equal, you know you have to start writing the value from bufferlocation 0 (zero) to P0.1, the next interrupt bufferlocation 1 to P0.1, etc.
So your inputpin writes your buffer, the outputpin P0.1 reads the buffer, with an adjustable shift between them of 0 to 359 degrees.

Hope this helps you...
Henk

List of 17 messages in thread
TopicAuthorDate
Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      
RE: Phase angle, Duty Cycle            01/01/70 00:00      

Back to Subject List