Sending 8 clock outputs at different variable speeds ?

Status
Not open for further replies.

lucian_dusk

Active member
Hi all,
Long time reader, first time caller. Been using teensy for about a year now (thanks Paul, incredible device), mostly for fairly simple tasks.
I'm diving into a new project now- it involves sending 8 (<10kHz) clock outputs, each with variable speed control from a front panel.
I'm coming up with a few ideas for code, and before i start working, i'd like to know if anyone has any suggestions for approach.

Leading idea right now has to do with setting a variable for each rate, and comparing them with millis() - set high output every (variable) in relation to millis.

I've been naiive in the past regarding time and microcontrollers, so i have a suspicion that this won't work due to something i'm unaware of.

Would appreciate any ideas !
Best,
L.
 
You can get 3 very easily using analogWriteFrequency() and analogWrite(). But there's only 3 separate timers for PWM. Details here.

Comparing timing in a loop is probably reasonable. You might use 5 elapsedMicros variable to simplify the coding.

You could use the tone() function, which internally uses an IntervalTimer. There are 4 of those timers, so if you find the tone code, you could make 3 more copies, with new names for everything. But that would only get you to 7.
 
Paul - fantastic advice, this rules and simplifies a lot of things.
Is there additional hardware that could be hooked up for the teensy to support more timers for PWM?
 
Another Teensy?!

Silly as that sounds, a Teensy-LC is under $12, and has 3 PWM timers and 2 IntervalTimer. It's really easy to get Serail1 connected between 1 boards. For a one-off project, that might be the simplest path.

Of course, there's lots of digital and analog circuity to generate waveforms. You can use a CPLD or FPGA to implement your own timers! Analog voltage to frequency circuits exist, so perhaps you could use the DAC or remaining PWM with low-pass filters to get analog signals to control them.

I'm sure plenty of people will chime in with other ideas. Maybe even 555 timers could be used somehow?
 
much success with multiple outputs running with elapsedMillis !
nonetheless now i'm curious about timer peripherals, sounds like there could be some interesting applications there...
 
Status
Not open for further replies.
Back
Top