Teensy 3.1 & Audio board as a soundcard for a RC Tank?

Status
Not open for further replies.

Zoomzky

Member
Hi,

Im developing a IR Battle System for Heng Long RC Tanks
http://www.rcgroups.com/forums/showthread.php?t=2145303

In my quest i need a soundcard on board. Right now im using a Sound shield that fits a Arduino Uno.
Too big and cant play multiple sounds.

Bought a Teensy 3.1 and a audioboard cos i liked the size and as i understand it supports what i want to accomplish.

Have i got it right it can give me the following?

Play multiple sounds simultaneously? (Enginesound at the same time as a effect like ...cannonsound)

Be controlled by I2C? (The main controller in tank is a Arduino Uno or Arduino Nano using I2C for communcation)

Regards,
/Z
 
It'd be easier (imho) if Teensy 3.1 was the master on your I2C bus but you should be able to do it using Teensy 3.1 and the Audio Library
 
It'd be easier (imho) if Teensy 3.1 was the master on your I2C bus but you should be able to do it using Teensy 3.1 and the Audio Library

I have to use Arduino as I2C master cos it gets IR-coded hits from a Nano I2C slave.
But there is no problem using I2c with Teensy and audioboard??

/Z
 
Teensy 3.1 communicates (as master) with Audio Adapter over I2C to initially configure the adapter and then for any manipulation of things like volume and such like for the duration of use.

Teensy 3.1 could do all the audio and take care of anything that "arduino as master" is doing for you, I'm betting this would mean the least amount of work on your part funnily enough.


It is far from impossible to do exactly what you want a couple of different ways; Have Teensy 3.1 configure the Audio Adapter as master and then drop that and have Teensy 3.1 re-join that I2C bus as a slave; Leave Teensy 3.1 as master of the I2C bus between it and the Audio Adapter and use a software I2C slave set up on it; Enable the other I2C bus on the Teensy 3.1 and set it up as slave; Transfer all required code to initialise and change volume settings to the Arduino which is master of the I2C bus.
 
Teensy 3.1 communicates (as master) with Audio Adapter over I2C to initially configure the adapter and then for any manipulation of things like volume and such like for the dion of use.

Teensy 3.1 could do all the audio and take care of anything that "arduino as master" is doing for you, I'm betting this would mean the least amount of work on your part funnily enough.


It is far from impossible to do exactly what you want a couple of different ways; Have Teensy 3.1 configure the Audio Adapter as master and then drop that and have Teensy 3.1 re-join that I2C bus as a slave; Leave Teensy 3.1 as master of the I2C bus between it and the Audio Adapter and use a software I2C slave set up on it; Enable the other I2C bus on the Teensy 3.1 and set it up as slave; Transfer all required code to initialise and change volume settings to the Arduino which is master of the I2C bus.

Ty or your answer...though im a lil confused. The config im using now. A Arduino Uno is handling movement of tank and all of the major functions of the tank as turret movement, elevation etc. A Arduino Nano has 4 IR-receivers connected and keep check of if its hit or not. The Arduino Uno(I2C-master) polls the Nano(I2C-slave) in main loop checking if tank is hit or not with a I2C-request. Nano responds with hitinfo(Uno requests 3 bytes answer). Uno responds with a "hitaction". When a tank is hit i want to play a hitsound through teensy +audio board. Preferably with a I2C-onreceive. Nano will also be the IR-cannon and i will use a firecannon-command with a onreceive-command. Do you mean that keeping the teensy I2C-master will makes things easier??

I want to use the teensy to play the engine sounds in one channel. Channel two will be used for hitsounds and firing gunsounds.
As easy as possible using I2C-communcation.

I must add im no I2C-expert!!

/Z
 
Last edited:
I've some degree of confidence that one well implemented Teensy 3.1 with well crafted code running on it could replace all other micro controller units in your project and do mono sound (including simultaneous sounds) without even implementing the Audio Adapter. Maybe a lesser MCU (like Uno or Nano), or some sipo/piso devices (s for serial, p for parallel) might be called for.

Regardless of all that, to do it 'your way' I think you would be better off to consider Serial communication between Uno & Teensy 3.1 because it can be more than fast enough and doesn't complicate the I2C issue at all. SPI could be an option tho Serial has to be easier to implement.

would you consider posting (or PMing me) as fulll a circuit diagram of your tank setup as possible?
 
First, yes, you can use Teensy 3.1 with the audio library to play multiple sounds and with the Wire library to receive instructions from the Arduino Uno.

If you don't need stereo, and if all your sound effects can fit within the ~220K of extra flash memory on Teensy 3.1 (eg, about 20 seconds total), the 12 bit DAC can give you sound output without needing the audio shield.

Teensy 3.1 is dramatically faster than Arduino Uno & Nano. Even with multiple audio streams running, it can probably also do the work those other 2 boards are doing. I2C communication is relatively slow, so unless that Uno & Nano are running something really inefficient (eg, the blocking Stepper library instead of the non-blocking AccelStepper library), I'd guess the whole thing will likely run better with just a single Teensy 3.1. The I2C communication between 3 boards is probably the slowest part of the whole system.

But if you really want to keep the 3 board approach, yes, Teensy 3.1 can easily do the sound playing part. Especially if this is just a fun project where you're only building a couple units, the cost of using 3 processors with 3 simple program might be more attractive than the extra work figuring out how to make write 1 complex program?
 
I've some degree of confidence that one well implemented Teensy 3.1 with well crafted code running on it could replace all other micro controller units in your project and do mono sound (including simultaneous sounds) without even implementing the Audio Adapter. Maybe a lesser MCU (like Uno or Nano), or some sipo/piso devices (s for serial, p for parallel) might be called for.

Regardless of all that, to do it 'your way' I think you would be better off to consider Serial communication between Uno & Teensy 3.1 because it can be more than fast enough and doesn't complicate the I2C issue at all. SPI could be an option tho Serial has to be easier to implement.

would you consider posting (or PMing me) as fulll a circuit diagram of your tank setup as possible?

Thanks again Robsoles or your answers. I think i will stick to 'my way' for this build even though i understand its a bit overkill using a teensy just serving as soundcard.
I choose I2C cos SPI is already used or 2.4Ghz communication. Liked the simplicity of I2C. Im no Arduino expert but since i started this project i have learned that many nice Arduino libraries works excellent alone but when multiple libraries used, often timing and clock issues. I have now accomplished a working setup thar doesnt interfer with each tankfunctions. Will try to make a circuit diagram and pm you if you like.

Im a lil tempted to use a Teensy as controller for next tank conversion..

/Z
 
First, yes, you can use Teensy 3.1 with the audio library to play multiple sounds and with the Wire library to receive instructions from the Arduino Uno.

If you don't need stereo, and if all your sound effects can fit within the ~220K of extra flash memory on Teensy 3.1 (eg, about 20 seconds total), the 12 bit DAC can give you sound output without needing the audio shield.

Teensy 3.1 is dramatically faster than Arduino Uno & Nano. Even with multiple audio streams running, it can probably also do the work those other 2 boards are doing. I2C communication is relatively slow, so unless that Uno & Nano are running something really inefficient (eg, the blocking Stepper library instead of the non-blocking AccelStepper library), I'd guess the whole thing will likely run better with just a single Teensy 3.1. The I2C communication between 3 boards is probably the slowest part of the whole system.

But if you really want to keep the 3 board approach, yes, Teensy 3.1 can easily do the sound playing part. Especially if this is just a fun project where you're only building a couple units, the cost of using 3 processors with 3 simple program might be more attractive than the extra work figuring out how to make write 1 complex program?

Thanks for your answer!! Will stick to 'my way' a lil bit more(see last answer to robsoles)
/Z
 
Circuit diagram may be worthwhile after all but my main reason for asking to see it was to check the feasibility of redesign around a single Teensy 3.1; you want to stick by a multiple controller approach and it is your project so don't do it if you can't think of other benefits from doing it for yourself alone at this point.

Is 20 or so seconds of audio enough? 4 or so seconds of engine sound to loop and some others?
 
Is 20 or so seconds of audio enough? 4 or so seconds of engine sound to loop and some others?

It could be enough. Right now i only have a startupsound and a idlesound. Havent decided yet if i should use a couple of sounds for different revs of engine.
Smarter to have one running engine sound and change speed/freq? Other sound effects will be cannon, hitsound, turretmovement also short in length.

Current setup allows me to play music (tank stereo)... but thats not really a must have. :)Testdrive #?

/Z
 
Status
Not open for further replies.
Back
Top