Hello,
New here, so forgive me if this is in the wrong spot.
I am using a Teensy2.0 Atmega32U4, very similar to the other devices used on Arduino boards. I've installed the necessary libraries for the Teensy and have had no real problems getting my device working.
I am working on a project to read in a value from a temperature controller using Modbus, this portion is working without a problem. I am taking a value read from the temperature controller (0-10,000) and will do one of two things, I will output a frequency which will be fed into a frequency to voltage converter, or I will output a voltage and bypass my converter.
I am unsure of which method to choose as I have run into problems trying both. The first using a frequency output utilizing the Tone function. This appears to work great at first but upon further investigation I run into several problems.
First problem with Tone is the duration value does not seem to work unless the Tone function is followed by a delay of equal value, for my application I need a continuous output, so I leave the duration value blank, but the function will not work without being followed by a delay of some value.
My second problem is that I can not determine the resolution of the frequency output available through the Tone. The Tone function takes in frequency as a uint_16 so I was assuming 65K. Below around 1Khz, I am easily able to resolve and output in 1Hz increments, however, above 1Khz I start to resolve only 2 or 3Hz, above 5K its closer to 10 to 20Hz. For example, my program is trying to output a value of 7061Hz, however I only achieve 7042Hz, this is the output from around 7000 to 7050Hz. Is there something I am missing in being able to resolve 1Hz from 0 to 10Khz?
My second option of using a PWM to output a voltage was even less successful as the standard analogwrite function will only take 0-255, I would again need at least a resolution to handle 0-10000. The Atmega32u4 has PWM outputs that can be setup for 16-bit, its just the case of figuring out how to do it.
If anyone has any information on how to get by either of these problems I would greatly appreciate it, or at the very least if anyone could point me in the direction where I may be able to find out how to modify the functions if need be that would be great.
Thanks