Pages: [1]   Go Down
Author Topic: Producing phase-shifted but identical frequencies  (Read 361 times)
0 Members and 1 Guest are viewing this topic.
Athens, GA, USA
Offline Offline
Newbie
*
Karma: 2
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12936
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Pages: [1]   Go Up
Jump to: