Go Down

Topic: Producing phase-shifted but identical frequencies (Read 389 times) previous topic - next topic

poeticoddity

A professor I used to work with extensively asked me to help him with a research project.  I need to toggle 2 pins with a 50% duty cycle at the same frequency but with an adjustable phase difference between them.

I've used Timer1 extensively to get this duty cycle and frequency range (for this project, I need about 0.25Hz to 60Hz) for previous projects, and getting 2 pins to toggle in phase or perfectly out of phase is pretty simple.  I've never had to deal with any other phase shifts, though.  My initial plans of having a timer call new TOP values from an array (cycling through the array and grabbing XOR masks for the appropriate port) each cycle won't be able to handle a 0 phase shift or a full cycle phase shift.

Any thoughts would be appreciated.  If I can get this frequency generation problem solved, the rest of the research equipment is actually pretty straight forward.

Thanks in advance.

Coding Badly


If the Arduino isn't doing much else you could just use blink-without-delay and get good results.

DuaneB

You could try DDS - Direct Digital Synthesis. A lot of the simple synths I have put together recently generate square waves with independent frequency control. Its very simple to modify this for a common frequency but variable phase.

This post I published last night has two oscillators which can be set to squarewave, the code is quite readable so you should quickly figure out how to (big clue here) add a phase offset to the phase accumulator.

http://rcarduino.blogspot.com/2013/02/arduino-notes-frequencies-and-scales.html

Duane B

rcarduino.blogspot.com
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

Go Up