Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpPrograms › How to do this

Page Index Toggle Pages: 1
How to do this (Read 3911 times)
01/13/09 at 03:05:20

Nocturnal   Offline
YaBB Newbies

Posts: 5
*
 
I have a question, its hypothetical now, since I did it in C after I confirmed that pulseOut() wasn't up to the task.

How can I create a program that outputs two very specific continuous frequencies (to the hertz, preferably, though +/- a hertz or two should work), with a 50% duty cycle, in the 2000-5000hertz range. At the same time the program needs to be able to read the state of a 8 switches and 4 buttons, all of which combine together to modify the output frequencies.

Now the way I did it, was to use two timers and their overflow interrupt handlers to handle outputting the frequencies, and used the main loop to read the state and vary what the counter were reset to. This method does not seem possible with wiring since all 4 timer overflows are being set.
 
IP Logged
 
Reply #1 - 01/28/09 at 16:47:35

Nocturnal   Offline
YaBB Newbies

Posts: 5
*
 
So I'll just take this as a can't be done, and move along shall I?
 
IP Logged
 
Reply #2 - 01/28/09 at 18:54:16

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
I do not fully understand what you need to do, but you could use the available timers to do it, please check the servo library, it uses one of the available timers to do it. also please check this file http://wiring.uniandes.edu.co/source/trunk/wiring/core/WTimer.c?revision=420&view=markup all timers management is there.
 
IP Logged
 
Reply #3 - 01/30/09 at 03:19:40

Nocturnal   Offline
YaBB Newbies

Posts: 5
*
 
Simply put, I need to create two seperate square waves with a 50% duty cycle, that hit the target frequency within a few hertz.

That you for the code link, I can see how to get it done now. So this is just another case of the documentation sucking, unless I missed a whole section on timers somewhere on the website.
 
IP Logged
 
Page Index Toggle Pages: 1