*

Offline LukeZ

  • 302
    • View Profile
  • Kansas, USA
Standalone Tank IR
« on: January 18, 2017, 06:18:27 PM »
For the fun of it I've taken some code from the TCB having to do with IR, simplified it and packaged it as a self-contained sketch for running on any Arduino Uno/Nano/or other board with ATmega328 processor.

The sketch can be downloaded here: TankIR

What does it do? Basically it lets you send and receive tank IR signals. Sending (ie, "firing the cannon") can be triggered in three ways:
  • Manually with a pushbutton (connect pin D4 to ground)
  • With a positive 5 volt trigger on pin A0 from some other circuit (greater than 5 volt inputs are possible but further input protection will be required)
  • Or the device can automatically fire a repair IR signal in response to being fired at by some other tank (useful as an "automatic tank repair station.")
The sketch can also control a recoil servo which will articulate whenever the cannon is fired (pin D8). Cannon fire will also cause a brief positive signal to appear on pin D6, this could be used to trigger a Taigen High Intensity Flash unit.

Within the sketch is a file called "A_Setup.h" (it will appear as a tab in your Arduino editor). That is where all user settings can be adjusted. Recoil servo end points and retract and return times can all be adjusted, as well as which protocols are sent and which are received.

Leave your Arduino attached to your computer with a USB cable and open the Serial Monitor from within the Arduino IDE to see informational messages printed during operation.

NO SUPPORT THROUGH PM - read why
Open Panzer FAQs

*

Offline LukeZ

  • 302
    • View Profile
  • Kansas, USA
Hardware Notes
« Reply #1 on: January 18, 2017, 06:19:59 PM »
Hardware Notes

Included in the project files is a simple schematic in PDF format, please review it for wiring details. An Arduino Nano is shown but the pins are the same for the Uno.

You can connect a standard Tamiya "apple" directly to your Arduino (Tamiya 53447). The Tamiya apple combines an IR receiver and notification LEDs; the LEDs already have current limiting resistors included inside the apple. If you build your own receiver and use your own hit notification LEDs, you need to include your own current limiting resistor appropriate to the LEDs you choose. Most Arduinos can't source more than 40mA per pin.

For the IR transmitter you can use the Tamiya IR LED that is included with the apple. We have also found the Vishay TSAL6100 (DigiKey 751-1203-ND) to be a comparable replacement.

For maximum distance the IR transmitter should be driven far beyond its typical current rating, but even so it still needs a current limiting resistor. The LED will survive the high current because the IR signal is very brief. In testing we have found a 3.3 ohm, 1 watt resistor to be the best compromise between range and LED longevity.

If you wish to send repair signals it is often desired to prevent the beam from traveling very far. In this case a higher value resistor is used inline with the IR emitter - we have found 1k ohm will give you a range of just a few feet.
NO SUPPORT THROUGH PM - read why
Open Panzer FAQs

*

Offline Rileyelf

  • 6
    • View Profile
  • Brighton, UK
Re: Standalone Tank IR
« Reply #2 on: May 24, 2017, 12:17:27 PM »
Hello, new bloke here!

I designed my own Arduino powered tank battle system a while back, great to see this project!    I did a cut down version like this specific part to run a Panzerturm...  This runs a servo for a random time, fires the cannon then rests for a reload period and starts again.   Adds an interesting feature to the battleground!    I have also designed my own tank sound system which works pretty well.

Here's a video of the Panzerturm during dev....

https://www.youtube.com/watch?v=LaTYOzBSGUo

Drew.

*

Offline LukeZ

  • 302
    • View Profile
  • Kansas, USA
Re: Standalone Tank IR
« Reply #3 on: May 25, 2017, 10:36:52 AM »
I've always known there were others working on Arduino tank projects, it's been nice to meet several of you recently. That's a good idea for your autonomous Panzerturm. A similar functionality could be added to the TankIR sketch, it is already set up to control up to 4 servos, right now only a single one is being used for the recoil. One of the others could be set to turret rotation and then as you did code it to turn and fire randomly. If you or anyone else would like to add these or other features don't hesitate to submit a pull request to the GitHub project.

I'm sure many people would be even more interested in your sound project. If you want to share more details about that feel free to start a thread in the Sound Forum.
NO SUPPORT THROUGH PM - read why
Open Panzer FAQs

*

Offline Wibbly

  • 1
    • View Profile
  • Bristol, UK
Re: Standalone Tank IR
« Reply #4 on: November 16, 2017, 12:50:53 AM »
I built a standalone artillery gun, all of the IR cannon and hit functionality works, the gun is triggered via a microswitch acting as a hidden landmine, so when a tank runs over it, the gun is fired from a short distance away. Tanks can fire at the installation, and the led's flash in the diorama.

So far so good.

The one thing missing is a cannon sound.

To create a test bed I used a separate Uno and downloaded this sketch:
http://www.instructables.com/id/Audio-Player-Using-Arduino-With-Micro-SD-Card/

Quote
*/

#include <SPI.h>       //Enable use of SD library
#include <SD.h>        //Read MicroSD card
#include <TMRpcm.h>    //Play music from MicroSD card


//This value is assumed by the TMRpcm library, so I don't recommend altering it!
const int SD_ChipSelectPin = 4;

//Plug the speaker's red (non-GND) wire into this pin on the Arduino
//TMRpcm assumes this is 9 on Arduino, so I don't recommend altering it!
const int speakerP = 9;

//File name of the WAV audio file loaded on the MicroSD card
//Remember to include the file extension (should be .WAV)
const String audioFileTitle = "music.wav";

//Create TMRpcm object
TMRpcm tmrpcm;

void setup(){

  tmrpcm.speakerPin = speakerP;

  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
    Serial.println("SD fail"); 
    return;   // don't do anything more if not
  }
 
  //Need to convert String variable to char*, per TMRpcm documentation
  char charBuf[audioFileTitle.length()+1];
  audioFileTitle.toCharArray(charBuf, 50);
 
  //Play the test sound
  //This sound file will play each time the Arduino powers up or is reset
  tmrpcm.play(charBuf);
 
  //Report to the user
  Serial.println("Sound file played!");
}

void loop()

tmrpcm.play("test.wav");
//delay(5000);
}

which is part of this project on Instructables.

To get a decent volume I used:

Arduino Uno
PAM8403 amplifier, the version with a volume control.
Voltage regulator set to 5v to power the amplifier (a resistor could be used)
SD card

After a bit of playing around, it all works. I get the cannon sound when I press the Uno reset button.

So, I now have a tank IR system, and a sound system, but running on separate Arduino's.

Does anyone know whether I can import the sound sketch into the Tank IR sketch, and where it should go in order that I get the sound when the cannon is fired? I am also concerned regarding the wiring/circuits, eg is there a conflict between the SD card hook up and the Tank IR?


 

*

Offline LukeZ

  • 302
    • View Profile
  • Kansas, USA
Re: Standalone Tank IR
« Reply #5 on: November 16, 2017, 11:49:42 AM »
Wibbly, I already added support for the Adafruit sound effects board to the project (as discussed here), no coding required, just use the sketch from the GitHub. Read the instructions on that page for how to interface with the Adafruit board, you can see I've also updated the schematic. It supports 4 sounds, cannon fire, cannon hit, destroyed, and repair sound.
NO SUPPORT THROUGH PM - read why
Open Panzer FAQs