Arduino Uno IR Battle System

This forum relates to the Open Source Tank Control Board (TCB). Please read the sticky and visit the main site to find out all about the board and how to install it.
User avatar
LukeZ
Lance Corporal
Posts: 178
Joined: Sat Apr 17, 2010 8:03 pm
Contact:

Re: Arduino Uno IR Battle System

Post by LukeZ »

Wobbly, a great deal of work has been done and you are free to use it. Check out the OP_IRLib library on our GitHub. The library can send and decode pretty much every RC tank protocol known to man, all of which we have already decoded.

The library is somewhat tailored to the TCB (essentially an Arduino Mega2560) but if all you need is hit and receive and read a pin, it could certainly be adapted to the Arduino Uno or even the smaller Arduino Nanos and Minis.

For an example of how we actually call the firing routine look at the Cannon_SendIR function in the OP_Tank library.

I don't know how experienced you are with Arduinos but this may be all you need to get going. Otherwise feel free to ask and I will try to help!
NO SUPPORT THROUGH PM - read why
User avatar
LukeZ
Lance Corporal
Posts: 178
Joined: Sat Apr 17, 2010 8:03 pm
Contact:

Re: Arduino Uno IR Battle System

Post by LukeZ »

FYI, we also did testing with various emitters and found the Vishay TSAL6100 to be comparable to the standard IR emitter in performance (slightly better), and much cheaper.

You are absolutely right about the LED current. The Arduino will not be able to drive it near far enough. Tamiya feeds theirs full battery voltage (~7v) through a very low resistor (~1 ohm). The current is considerable, far beyond what the LED is rated for, but since it is only on a short amount of time they get away with it - for a while. Eventually their LEDs will burn out. Other boards manufacturers use anything from 3 to 70 ohms. On the TCB we settled for 3.3 ohms (1 watt) which allows a range equivalent to the Tamiya but with greater longevity on the LEDs.

However you will need a transistor of course because the Arduino pin will not be able to source the current this will draw.
NO SUPPORT THROUGH PM - read why
User avatar
LukeZ
Lance Corporal
Posts: 178
Joined: Sat Apr 17, 2010 8:03 pm
Contact:

Re: Arduino Uno IR Battle System

Post by LukeZ »

Wibbly, looking through the TCB code I see it is rather cluttered because of course it is doing a lot more than just IR. I extracted a subset that might be useful to you and tried to clean it up a bit, and posted it as a new project on our GitHub page: TankIR.

This code is designed to be run on any Arduino with the 328 processor, which includes the Duemillanove, Uno, Nano, etc...

You don't have to know anything about GitHub, just click the green download button in the top right and download the files. Put the TankIR folder in your Arduino sketch folder and open the sketch. There will be several files (or tabs) within the sketch. One of them is called "A_Setup.h" - that is where you can adjust various settings such as which protocol is used, recoil servo times, etc...

There are some notes on the GitHub page you can read, as well as a simplified PDF schematic in the download files. Basically you can set the device to fire any tank protocol either manually with the push of a button or externally from a positive voltage trigger (such as the RX-18). The device can also control a recoil servo and flash unit. It has the ability to also send out repair signals which could be useful as a tank "repair station." Of course it can also accept hits and light up a standard Tamiya apple to indicate such.

Hopefully this is useful to you and other Arduino tankers. I haven't done extensive testing so let me know if you find any bugs!
NO SUPPORT THROUGH PM - read why
User avatar
LukeZ
Lance Corporal
Posts: 178
Joined: Sat Apr 17, 2010 8:03 pm
Contact:

Re: Arduino Uno IR Battle System

Post by LukeZ »

Note - I don't have an RX-18 to test, but if the voltage signal it gives out is over 5 volts, then some extra protection on the Arduino input will be required.
NO SUPPORT THROUGH PM - read why
User avatar
wibblywobbly
Major
Posts: 6398
Joined: Fri Oct 17, 2008 9:30 am
Location: South Wales Valley
Contact:

Re: Arduino Uno IR Battle System

Post by wibblywobbly »

Hi Luke.

Thanks for the IR link, I'll take a look at that when I get the IR boards delivered. These are an emitter board and a sensor board, and come as mini pcb's that have fuses and transistors on them, which should allow a Uno to cope with the current draw.

I wrote a script to monitor the IR pins on an RX18. With a multimeter on them it gave a reading of 0v, or flashed up to almost 4v (though cheap multimeters don't have a function to freeze the max reading - it was probably 5v in the real world).

By monitoring the IR pins via the Uno analogue inputs, and using a bit of voltage converter code I was getting >0.5 and <2.5v at rest. When I fired the gun, it bounced up to 5v, and then took forever to drop back down to the at rest voltage.

I kept adjusting the code so that it was only printing voltages above a threshold, and reached a point where if the gun isn't being fired then the voltage is definitely below 3.25v. The max when the circuit is live is 5v.

ATMEL ATMEGA328 (UNO and Duemilanove) Current Specifications:

Absolute Maximum Ratings - the point where damage will start to happen
DC Current per I/O Pin ........... 40.0 mA
DC Current VCC and GND Pins...... 200.0 mA
1 VCC pin: Means these Arduinos can Source a total of 200mA
2 GND pins: Means these Arduinos can Sink a total of 400mA

So, if the IR boards do what I am hoping and are designed to protect the Arduino circuits, I can trigger a Tamiya compatible beam by detecting an input >3.5v , and then activating the emitter with 5v. I have no idea why Tamiya use huge current, I don't think Clark, IBU or Elmod do, and they all have a range of over 30m.

I use the Maplins emitters as I have a store a very short drive away. ;)
Tiger 1 Late
Panther G
King Tiger
M36 B1
User avatar
LukeZ
Lance Corporal
Posts: 178
Joined: Sat Apr 17, 2010 8:03 pm
Contact:

Re: Arduino Uno IR Battle System

Post by LukeZ »

That's good news on the RX-18 signal, sounds like it won't be a problem to read it directly with an Arduino.

It could be the RX-18 signal rests around 3 volts because they might just leave it floating, and your meter is showing you the average of something somewhere between 0 and 5 as it wanders around. In my schematic you will see a 10k resistor to ground on the voltage input - this insures that if there is no signal present, the pin will be held to ground, eliminating a floating input if there is one. If not the 10k resistor still won't hurt anything.

I don't know about Elmod as I have not had one in person, but the Clark, IBU, RCTA and even the old RX-18 boards all certainly overdrove their IR emitter outputs from my examination of those boards.
NO SUPPORT THROUGH PM - read why
User avatar
LukeZ
Lance Corporal
Posts: 178
Joined: Sat Apr 17, 2010 8:03 pm
Contact:

Re: Arduino Uno IR Battle System

Post by LukeZ »

wibblywobbly wrote:My tank build project is coming to a close so I picked up the Arduino Uno that I bought as a project to create an IR system. I looked at the GIThub and found that you guys have kindly done all of the hard work. Many thanks for that.

The schematic provided details the circuit for connecting seperate components, however I purchased separate boards for the IR led and sensor, as these theoretically have the transistors and resistors that will protect the main board. I may need to change the emitter, but that is an easy task. I have added additional pins strips to the board.

Could I ask you a small favour?

The boards have pinouts labelled GND, VCC and SIG. Could you clarify where these should be connected on the Uno? I would rather ask than create magic smoke. 8O

One small detail, I tried using the provided Sketch using 1.8, but as I have found with the Arduino's that I use on my 3D printers, the code that 1.8 will recognise is different to 1.6, hence any attempt to upload the Sketch using 1.8 produces numerous errors.

Using 1.6 removes the errors, with the exception of the servo recoil code, it still rejects the code.
Wibbly, as shown on the schematic, you will connect the SIG line of the IR emitter to D3 (digital 3), and the SIG line of the IR receiver to D2. GND on both should obviously be connected to Ground. VCC on the IR emitter should be connected to VIN on the Arduino, and VCC on the IR receiver should be connected to 5 volts.

I have no problem compiling the code in any version of the editor. It doesn't sound correct to me that you are getting errors in 1.8 but not 1.6, in fact your description makes clear you are getting errors in both. Something is amiss with your setup. What board do you have selected in the Tools->Board menu?
NO SUPPORT THROUGH PM - read why
User avatar
wibblywobbly
Major
Posts: 6398
Joined: Fri Oct 17, 2008 9:30 am
Location: South Wales Valley
Contact:

Re: Arduino Uno IR Battle System

Post by wibblywobbly »

The whole Arduino thing is new territory for me, apart from editing Marlin software on the printers.

Just checked, I have 1.8.0, and the Uno is selected. Click on Verify and it generates the following:
Uno 1_8_0.png
Uno 1_8_0.png (42.34 KiB) Viewed 9129 times
If I use 1.0.6 I get the following:
Uno 1_0_6.png
Uno 1_0_6.png (32.55 KiB) Viewed 9129 times
Tiger 1 Late
Panther G
King Tiger
M36 B1
User avatar
LukeZ
Lance Corporal
Posts: 178
Joined: Sat Apr 17, 2010 8:03 pm
Contact:

Re: Arduino Uno IR Battle System

Post by LukeZ »

I wonder if you are perhaps using an Apple computer?

I wouldn't think it should matter but something clearly is different about your environment than mine since it compiles fine over here.
NO SUPPORT THROUGH PM - read why
User avatar
wibblywobbly
Major
Posts: 6398
Joined: Fri Oct 17, 2008 9:30 am
Location: South Wales Valley
Contact:

Re: Arduino Uno IR Battle System

Post by wibblywobbly »

Not an Apple, I use Linux. It's all very strange. B|
Tiger 1 Late
Panther G
King Tiger
M36 B1
Post Reply

Return to “Open Panzer Tank Control Board”