Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How do I work with the ADC and DAC of the teensy 3.2/3.6

Status
Not open for further replies.

Sashvat

Member
Hi guys, I am a beginner in Arduino and made a small code for a project. The project is as you turn the pot, the frequency given out on the speaker outputs a range of frequencies from 0-9000 Hz. It works on my Arduino Mega, but not on my teensy. I understand that the mega/UNO has a ADC resolution of 0-1023. For the teensy its ADC resolution is 0-65535, and DAC resolution is 0-4095, but am I using it right with my 100K potentiometer? (also would like to know how to choose a pot for these applications)

As I turn the pot, it works, but when I hit the ends, it starts behaving weirdly, I assume its the problem with my pot but didn't want to jump to conclusions. And soon I will be making my own electret microphone amplifier circuit and attaching it to the teensy. I used the teensy because it has a very high ADC and DAC sampling resolution. Let me know if this is fine. Thank you.
 

Attachments

  • Speaker.ino
    766 bytes · Views: 227
Try changing the line
Frequency = (9000.0/4095.0)*potValue; //Formula to convert analog input value into frequency to drive the speaker

to
Frequency = (9000.0/65536.0)*potValue; //Formula to convert analog input value into frequency to drive the speaker

Mike.
 
Try changing the line
Frequency = (9000.0/4095.0)*potValue; //Formula to convert analog input value into frequency to drive the speaker

to
Frequency = (9000.0/65536.0)*potValue; //Formula to convert analog input value into frequency to drive the speaker

Mike.
Thanks, now it works, but the pot when turned to the extremes makes some weird noises and is not increasing or decreasing what should I do for that?
 
Print the frequency and see what it is when it sounds weird.

Mike.
Edit, it probably sounds weird when you approach zero.
 
Also, try changing to,
Frequency = (8950.0/65536.0)*potValue+49; //Formula to convert analog input value into frequency to drive the speaker

Mike.
 
Thanks a lot for your help, it works, I haven't tried this out "Frequency = (8950.0/65536.0)*potValue+49; //Formula to convert analog input value into frequency to drive the speaker"

it works decently, but I have bought some good potentiometers and are coming
 
The change to,
Frequency = (8950.0/65536.0)*potValue+49; //Formula to convert analog input value into frequency to drive the speaker
is so the frequency is between 50 and 9000Hz. Low frequencies can sound very strange and sometimes like clicking.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top