Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:16 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : DAC Puzzle

Author Message
davematt
Regular Member

Joined: 27/09/2011
Location: Australia
Posts: 55
Posted: 12:32am 29 Sep 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 6283
Posted: 02:11am 29 Sep 2020
Copy link to clipboard 
Print this post

Example code showing what you are trying would help.
VK7JH
MMedit
 
davematt
Regular Member

Joined: 27/09/2011
Location: Australia
Posts: 55
Posted: 05:20am 29 Sep 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 6283
Posted: 07:20am 29 Sep 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10310
Posted: 07:28am 29 Sep 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 6283
Posted: 07:59am 29 Sep 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 55
Posted: 11:05am 29 Sep 2020
Copy link to clipboard 
Print this post

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 States
Posts: 405
Posted: 03:24pm 02 Oct 2020
Copy link to clipboard 
Print this post

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.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025