Assorted Gubbins on toy tank

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
Progress Report:

2 output shift-registers connected

Speed Selector Working
Hull Points +/- working
Status Lights working (Stunned, Shaken, Immobilised)
Immobile Status over-rides speed selector (Speed = 0 when immobile!)

to do:
3 outputs available for 3 guns. (using 1 analogue input)
1 output available for Engine (Microswitch underneath tank to detect being picked up)
2 spare outputs

AUDIO.
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
One rat's nest! :)
Engine switch is working. Light activates when switch open (i.e. tank is picked up)
Status buttons toggle appropriate Status (Stunned, Shaken, Immobile)

I've colour-coded as much as I can, but don't have unlimited wires in unlimited length and colour combinations.

For the final circuit, the LEDs and switches will be attached to the top-plate of the Tank, and some of the resistors will be, too (partly to save PCB-space!)
The PCB will mainly be the Arduino and Shift Registers, with lots of pads for wires to LEDs.
A removable 9V "square" battery with voltage regulator will sit inside the "troop loading/unloading" doors.

I have not decided whether to use veroboard/perfboard, or get a friend to etch a PCB.

And I still haven't got Audio (which was actually the starting-point for this project! "Hey, wouldn't it be cool if, instead of saying "vroom vrooom" every time I pick the tank up to move it across the battle-field, it had a switch underneath, and a speaker so it made its own noises!")
 

Attachments

  • Labelled breadboard.jpg
    Labelled breadboard.jpg
    204.6 KB · Views: 52

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
One rat's nest! :)
Engine switch is working. Light activates when switch open (i.e. tank is picked up)
Status buttons toggle appropriate Status (Stunned, Shaken, Immobile)

I've colour-coded as much as I can, but don't have unlimited wires in unlimited length and colour combinations.

For the final circuit, the LEDs and switches will be attached to the top-plate of the Tank, and some of the resistors will be, too (partly to save PCB-space!)
The PCB will mainly be the Arduino and Shift Registers, with lots of pads for wires to LEDs.
A removable 9V "square" battery with voltage regulator will sit inside the "troop loading/unloading" doors.

I have not decided whether to use veroboard/perfboard, or get a friend to etch a PCB.

And I still haven't got Audio (which was actually the starting-point for this project! "Hey, wouldn't it be cool if, instead of saying "vroom vrooom" every time I pick the tank up to move it across the battle-field, it had a switch underneath, and a speaker so it made its own noises!")
Here's the difficult or fun part... You can make simple sounds directly with the tank, but it will ignore inputs while the sound is playing unless you work on an 'interrupt' .
The other option is a secondary device dedicated for sound that you can simply trigger like an LED.
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
Short sounds would be fine, even if they stop everything else.
The engine only runs when you pick the tank up, and won't be pressing buttons during that.
Guns fire one at once, short "dakkadakka" or "pew pew".

The Arduino Audio Shields I've seen cost ~£20, which is not going to happen. I did see one for £5, but don't know why it was so cheap ...

I can buy a SD reader for £2, for lots of audio available (would be nice to have lots of selection, not the same sound all the time. I need 2 Guns, 1 Engine, 1 Immobilised Engine. With an SD card, I can have at least 10 of each sound, and randomise which gets called).

I've looked over some tutorials and projects, but nothing has grabbed me yet.
I think that I'd like:
SD card with wav files.
Speaker run from Arduino (maybe small amplifier circuit)
Code that calls and plays a file as needed (doesn't matter if it freezes everything while playing).
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Short sounds would be fine, even if they stop everything else.
The engine only runs when you pick the tank up, and won't be pressing buttons during that.
Guns fire one at once, short "dakkadakka" or "pew pew".

The Arduino Audio Shields I've seen cost ~£20, which is not going to happen. I did see one for £5, but don't know why it was so cheap ...

I can buy a SD reader for £2, for lots of audio available (would be nice to have lots of selection, not the same sound all the time. I need 2 Guns, 1 Engine, 1 Immobilised Engine. With an SD card, I can have at least 10 of each sound, and randomise which gets called).

I've looked over some tutorials and projects, but nothing has grabbed me yet.
I think that I'd like:
SD card with wav files.
Speaker run from Arduino (maybe small amplifier circuit)
Code that calls and plays a file as needed (doesn't matter if it freezes everything while playing).

Well.. you may be able to find a cheap enough product :http://www.banggood.com/1Pc-WT588D-...ronic-xie-ca&gclid=CNro8-q_tMsCFY17fgodVQgDxA

As far as playing it directly with the Arduino, there are projects out there... but I'm very light on exact details.
There is a write-up here regarding audio : http://hackaday.com/2016/02/12/embed-with-elliot-audio-playback-with-direct-digital-synthesis/
As well as an 'Arduino Spin-off' write up here for a 'Trinket'...
https://learn.adafruit.com/trinket-audio-player/overview

If I were making the project, I'd splurge on a pre-made board if I was in a hurry... i don't know how to do audio directly from an Arduino.
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
OK, I'm making progress with the audio. By which I mean I've read far too much, and am now confuzzled! :)

I want to check a couple of things before I buy things, wire them up and watch it all go wrong :)

I will be using a Voltage Regulator (currently using circuit : https://www.sparkfun.com/tutorials/57 ) to drop the PP3 9V down to a usable 5V.
This will be powering the Arduino, and the LEDs (Currently 16, at ~10mA each. Probably only use 14).
I also want to add a speaker. I am thinking of using the attached amplifier circuit (single transistor). I have salvaged a 8 Ohm 0.2W speaker from an old radio.

Is there any problem with just wiring the Amp to the PP3 9V?
Do I need to worry about feedback, flyback, decoupling, or any other words I've heard but don't understand? ;)
(This is what you get for reading too much, only half-understanding, and trying to reconcile with 20+yr old, half-remembered info! Feel free to point and laugh!)
 

Attachments

  • spkr-2.gif
    spkr-2.gif
    4.3 KB · Views: 81

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
I'm not too fussed about sound quality, and can improve the amp if necessary.
14x10mA LEDs should give me a couple of hours at least, which is all I really need.

Is it possible to have a "better" amp? i.e. still increase volume while not draining battery so much? (Maybe with less distortion ;) )
I've looked at a lot of circuits, but few mention (directly) how draining they are.
I have to run on batteries, rather than wall/PC-power, but can look at longer lasting ones.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Is there any problem with just wiring the Amp to the PP3 9V?
Do I need to worry about feedback, flyback, decoupling, or any other words I've heard but don't understand? ;)
(This is what you get for reading too much, only half-understanding, and trying to reconcile with 20+yr old, half-remembered info! Feel free to point and laugh!)
Well.. the picture you showed will only be able to drive 1/2 of a full wave-form... ie, the speaker can be pushed out, but not pulled in electrically. (The speaker will return to it's neutral state by itself)
This creates a lot of distortion, but if you are only making little engine sounds, you can get away with it. What would be ideal would be finding one of those little 'record your own greeting' cards, and mimicking the hardware in that. It uses a small speaker and can reproduce sounds reasonably well. Using the 8Ω directly off the 9V battery will surely kill it in no time xD

Feed-back : When your circuit has an input that is designed to change it's output. This can be something as minor as a microphone and an amplifier, or more complex like the speed sensors in a car. Feed-back could also mean that horrible squealing sound when you put a microphone too close to the speakers. This usually occurs when a feed-back 'loop' is created. The same signal that goes out, goes back in again and it builds on itself.
Flyback : I only typically see this with transformers, although I'm sure there are other sources. This is a type of feed-back often used in the transformer in Television sets. (The old tube type)
De-coupling : Some audio circuits use a capacitor to 'decouple' AC and DC... sounds odd, but it has it's uses. For example, some signals generated from a microcontroller are between 0V and 5V... but how do you send a negative signal to an amplifier? (Pretend the 2.5V is actually 0V... Connect a capacitor in series, and when the microcontroller changes from 2.5V to 1V... then -1.5V passes through the capacitor! ... in this case, it's not required, but it could be if you wanted to build a different type of amplifier)
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
OK, I need a better amp!
I can probably squeeze a second PP3 9V in the tank if needed, but obviously would rather not have to.
LM386 seems a popular component to base a low-power amp around.
Something like this:
http://www.reprise.com/host/circuits/lm386.asp
?

Thanks for definitions. I'm just trying to be careful, after blowing one Arduino! Would rather not blow another, or any other parts!. I'm sure I will, but trying to minimise it ...
 

Alec_t

Jul 7, 2015
3,817
Joined
Jul 7, 2015
Messages
3,817
I'm just trying to be careful, after blowing one Arduino! Would rather not blow another, or any other parts!.
Precautions include not trying to drive heavy-current loads directly with Arduino outputs, and ensuring that any relay coil, motor or similar inductive load has a catching diode across it to suppress back-emf voltage spikes.
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
Ok. Audio Amplifier. LM386.
http://www.reprise.com/host/circuits/lm386.asp

If you don't mind, I'd like to check I've got the components right.

Components:
10k variable resistor. I presume this acts as a volume control. If I want constant volume, can I replace with a 10k resistor, and connect Pin 3 direct to input?
0.05uF Capacitor. I have a little blue "473k" ceramic one. This is 47 *10^3 pF = 47000pF = 47 nF = 0.047uF, yes? Should be OK? (k = 10% tolerance)
250uF capacitor. Can't find any decent priced ones. 220uF be OK?
LM386: LM386N-1/NOPB is right, yes?
10 Ohm Resistor: Brown Black Black. Got plenty of these.
8 Ohm speaker.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Ok. Audio Amplifier. LM386.
http://www.reprise.com/host/circuits/lm386.asp

If you don't mind, I'd like to check I've got the components right.

Components:
10k variable resistor. I presume this acts as a volume control. If I want constant volume, can I replace with a 10k resistor, and connect Pin 3 direct to input?
0.05uF Capacitor. I have a little blue "473k" ceramic one. This is 47 *10^3 pF = 47000pF = 47 nF = 0.047uF, yes? Should be OK? (k = 10% tolerance)
250uF capacitor. Can't find any decent priced ones. 220uF be OK?
LM386: LM386N-1/NOPB is right, yes?
10 Ohm Resistor: Brown Black Black. Got plenty of these.
8 Ohm speaker.
Heck, I'm pretty sure you are fine with all of that except the 10K resistor swap out part ;)
The 10K pot that's in use is acting as a voltage divider. It has less to do with the resistance, and more to do with how it is wired. So using a 5K resistor between the input and pin 3, then a *second* 5K resistor between pin 3 and ground would be the equivalent of having the pot adjusted to 50% .
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
No 5k resistors handy. Got plenty of 3.3k and 6.8k. Will use these one way round or the other :)

Waiting for rest of stuff to arrive now. And busy with real job :(

Will build test circuit, and then add to real breadboard, and report.

I've started drilling holes in the tank to accommodate LEDs and switches. Going to be interesting trying to get all the wires in!
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
No 5k resistors handy. Got plenty of 3.3k and 6.8k. Will use these one way round or the other :)

Waiting for rest of stuff to arrive now. And busy with real job :(

Will build test circuit, and then add to real breadboard, and report.

I've started drilling holes in the tank to accommodate LEDs and switches. Going to be interesting trying to get all the wires in!
Good to hear! I still encourage you to find a smaller speaker xD
That thing is a power hog, you can compensate by using the sounds less.
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
What is "smaller"?
The sounds will not be too often, but yes, don't want to drain battery too much.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
What is "smaller"?
The sounds will not be too often, but yes, don't want to drain battery too much.
Well... I guess I shouldn't loosely just tell you to go smaller. The power used by the speaker is proportional to the power required to drive it... which translates into volume as well. Larger speakers require more power to move.
Considering it's only a sound effect every now and then, I think you'll be fine, but I can't estimate run-times with the speaker on there.
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
Update: Have received my SD Card reader.
Not sure how to wire it up, will investigate.
Still wondering about Audio circuit. Not had a lot of time this week.
 

Crystal Wizard

Feb 10, 2016
100
Joined
Feb 10, 2016
Messages
100
While I'm waiting for Audio, I'm going back to Power Source for a while.

Currently I have a 9v PP3 battery, going through a 7805 Linear Regulator. ( https://www.sparkfun.com/tutorials/57 )
Would I be better off using 4xAA batteries? I hear they have better mAh capacity. ( http://cybergibbons.com/uncategorized/arduino-misconceptions-6-a-9v-battery-is-a-good-power-source/ )
Would I be better with a Switching Regulator? ( http://www.eleccircuit.com/simple-5v-1a-switching-regulator-by-ic-lm2575-50/ )

I am looking at powering the Arduino Nano, 14 LEDs (@ 10mA each. Probabaly only 7 lit at any time - very occasionally all 14) and an intermittently-used speaker.
I would like to get 2-3 hours battery life. More is obviously better, but I can swap batteries after each Fight, and keep some recharging.

Am starting to design circuit boards. Main board just has 2 Shift Registers and a couple of tracks. Amp Board looks simple enough. And then regulator board (If I can do something like this: http://www.instructables.com/id/Portable-5V-Regulator/ )
Some of these may end up on the same board, depending upon size/space/etc.

Advice appreciated.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
While I'm waiting for Audio, I'm going back to Power Source for a while.

Currently I have a 9v PP3 battery, going through a 7805 Linear Regulator. ( https://www.sparkfun.com/tutorials/57 )
Would I be better off using 4xAA batteries? I hear they have better mAh capacity. ( http://cybergibbons.com/uncategorized/arduino-misconceptions-6-a-9v-battery-is-a-good-power-source/ )
Would I be better with a Switching Regulator? ( http://www.eleccircuit.com/simple-5v-1a-switching-regulator-by-ic-lm2575-50/ )

I am looking at powering the Arduino Nano, 14 LEDs (@ 10mA each. Probabaly only 7 lit at any time - very occasionally all 14) and an intermittently-used speaker.
I would like to get 2-3 hours battery life. More is obviously better, but I can swap batteries after each Fight, and keep some recharging.

Am starting to design circuit boards. Main board just has 2 Shift Registers and a couple of tracks. Amp Board looks simple enough. And then regulator board (If I can do something like this: http://www.instructables.com/id/Portable-5V-Regulator/ )
Some of these may end up on the same board, depending upon size/space/etc.

Advice appreciated.
4 AA Cells will certainly give you more capacity. A Switch mode converter will also provide you with more effeciency.
I would choose one or the other... but I'd settle for a linear regulator with 4 AA cells.
Especially if you are using rechargeables... 9V dont hold much unless you buy the Lithium types.
 
Top