![]() |
Forum Index : Microcontroller and PC projects : DAC Puzzle
Author | Message | ||||
davematt Regular Member ![]() Joined: 27/09/2011 Location: AustraliaPosts: 55 |
Morning all. I am trying to do a wave generator to test a new CRO, but the DACS on my CMM2 have me puzzled. I can brute force the DAC to produce a lovely smooth ramp wave (or whatever), but if I use Play Tone or Play Sound the output is a dreadful 5 step mess. Can find no other way to adjust the DACs. Am I missing something? Am using a newly flashed 5.0505. Cheers, Dave |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Example code showing what you are trying would help. VK7JH MMedit |
||||
davematt Regular Member ![]() Joined: 27/09/2011 Location: AustraliaPosts: 55 |
Straight from the manual, P78, Play Tone, 4000, 4000 should produce a nice smooth sinewave. But for me, I get more like a 4 bit wave, ie a curved staircase. Could someone please verify that Play Tone or Play Sound produces smooth 12 bit waves? TIA, Dave |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Thanks. I agree. The output seems to be set at 25uS intervals, independent to the frequency. ![]() It's a while since I have played with the audio so I am not sure when this problem appeared. Jim VK7JH MMedit |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
This has always been the case. That is how tone generation works. Same as on all MMBasic versions. Can't find the reference but the technique uses a constant frequency interrupt and then picks the appropriate place in a sine table for the next sample. The interrupt frequency on the CMM2 is 44100 Hz. Because other MMBasic versions use an RC filter on a PWM output the sine wave will look smoother but the technique is the same Edited 2020-09-29 17:30 by matherp |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Thanks for the info Peter, I hadn't noticed it before and the audio is OK, just looks rough on the CRO. Jim VK7JH MMedit |
||||
davematt Regular Member ![]() Joined: 27/09/2011 Location: AustraliaPosts: 55 |
Many thanks Jim and Peter. If I use an array to drive the DAC as per the manual, should I be able to see a smoother wave? Can do so with a for-next loop, but haven’t yet got the array process to work ... |
||||
William Leue Guru ![]() Joined: 03/07/2020 Location: United StatesPosts: 405 |
Just put a small capacitor between the output and ground to filter out the high-frequency components of the waveform to smooth it out. You will have to experiment to find the right value. I would start with something like 0.05 microfarad. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |