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
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 »

Message for Luke.

As mentioned above I have installed the Uno in a tank to test. The board powers up, and I have tested the emitter using a manual switch on 04. This works.

I have connected the RX18 5v+ to the Uno using a voltage divider, two 10k resistors. One resistor feeds to GND on the Uno.

Quick question, how do I loop the circuit back to the 5v- on the RX18 to complete the pulse circuit?
Attachments

[The extension pdf has been deactivated and can no longer be displayed.]

Tiger 1 Late
Panther G
King Tiger
M36 B1
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 »

All IR systems tested, jeez this is good. Just need confirmation on where to hook up one wire.

The system has an editable file, so you can set the tank to heavy, medium or light, change reload times etc. It can also be set up as a repair tank.

The servo recoil is next on my list of things to do.

It all runs off the Heng Long 2.4ghz tx. Anyone who wants an excellent IR tank system for very little money can do this. Once it is all working I will post up a detailed how-to.

phpBB [video]
Tiger 1 Late
Panther G
King Tiger
M36 B1
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 »

Just need to find solutions to two problems:

1. Where to hook up the V- to take the circuit back to the IR(-) pin on the RX18.
2. The recoil servo initialises, but doesn't activate when I fire the gun.

For the recoil wiring I am using:

GND - A Uno gnd pin.
SIG - D8
5v - 5v power pin on Uno.
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 »

wibblywobbly wrote:I have connected the RX18 5v+ to the Uno using a voltage divider, two 10k resistors. One resistor feeds to GND on the Uno.

Quick question, how do I loop the circuit back to the 5v- on the RX18 to complete the pulse circuit?
I'm a little confused by the question. I'm certain the RX-18 doesn't use anywhere a -5v signal. Maybe you mean ground? The Uno and RX-18 should definitely share a ground connection, but if they are powered by the same battery then that is probably already taken care of. Have you tested the circuit as you have it now to see if the RX-18 will successfully trigger the Uno to fire?

If you are talking about the track recoil signal to the RX-18 that is usually provided by the airsoft unit, I believe that is actually a positive signal, but I'm not sure if the RX-18 expects +5v or +VBatt. You should be able to continue to use airsoft in addition to your Uno circuit.

Maybe you can provide a bit more information. There are lots of Heng Long diagrams on the web, maybe you can show me which pins on the RX-18 you are talking about.
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:2. The recoil servo initialises, but doesn't activate when I fire the gun.
Not sure what to say here, you have the pins listed correctly but you might want to re-check your wiring just to be sure. The servo would probably successfully initialize on any pin from D8 to D11 but would only recoil if were correctly attached to D8.

Also make sure the cannon fire really is happening. You can leave your Uno connected to the computer and open the serial monitor, you should see a "Fire Cannon" message appear if all is working correctly (set the baud rate in the serial monitor to 115200).

I don't actually have a Uno to test, but I have confirmed the recoil servo works on a Duemilanove and Pro Mini which are the two types I have on hand right now. There theoretically should be no difference between those and the Uno so I don't think that would be the problem.
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 »

I have used the RX18 IR LED pins, as these generate a 5v pulse to power the original HL IR LED. Sorry for the confusion, I was referring to the (-) pin when I said 5v-.

Image

RX18 (A) IR led B+ >>> UNO A0

To complete the circuit so that the RX18 can generate the pulse, I need to go back through the UNO, and return to

RX18 (B) IR led B- (GND)

I tested the IR emitter using a manual switch via D4/GND. This functioned ok.
Before I can test the IR using A0, I need to know where to connect RX18 (B) IR led B- (GND).


****
The barrel recoil servo will not operate, it will initialise, this confirms the circuit is ok, it doesn't seem to get a signal when the gun is fired. I assume that it is triggered by A0. If the IR circuit is resolved it should work ok.
I am happy to be the User Acceptance Tester. :D It was my job for many years.
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 »

First, try testing the recoil servo using the manual switch from D4 to GND. That will eliminate the RX-18 from the equation for now.
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

I ran a few tests and documented them, details below.
// CANNON FIRE
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------>>
// Pin change interrupt service routine for pins A0 - A5
// We use this to detect a positive voltage on pin_VoltageTrigger (A0) and if we do, fire the cannon.
ISR (PCINT1_vect)
{
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();

// Check if the pin is high, and if it has been more than some minimum length of time since the last interrupt
if (digitalRead(pin_VoltageTrigger) == HIGH && (interrupt_time - last_interrupt_time > 250)) // 250 mS = 1/4 second
{
// Pin went high - fire the cannon
FireCannon();
}
last_interrupt_time = interrupt_time;
}


This is what I have tested:

1. Manual Fire Button

D4
GND

Press button.

Test Result
Onboard LED will flash.

2. Manual Fire Button

D4
GND

Connect LED Emitter Board

SIG > D3
GND > GND
VCC > VIN

Press button.

Test Result

Onboard LED flashes
External LED flashes

3. RX18 IR +/-

Connect multimeter to pins.
Fire tank using transmitter.

Result
5v pulse displayed on multimeter.

4. RX18 IR pins connected to UNO board.

RX18 IR+ > A0 via 10k resistor plus 10k resistor to GND
RX18 IR- > GND
LED Emitter board disconnected

Fire tank using transmitter.

Result
Onboard LED does not flash

5. RX18 IR pins connected to UNO board.

RX18 IR+ > A0 via 10k resistor plus 10k resistor to GND
RX18 IR- > GND

LED Emitter board connected:
SIG > D3
GND > GND
VCC > VIN

Fire tank using transmitter.

Result
Onboard LED does not flash
External IR LED does not flash.

********
The same tests were attempted with a gun servo.

SIG > D8
V+ > Power 5v
GND > GND

Gun fired from transmitter
No response from servo.

*********
Manual Button Test
D4
GND

SIG > D8
V+ > Power 5v
GND > GND

No response from servo.

Servo has operating range of 3-6v.
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 »

There are two issues here and they are not related.

1. Servo
For now do no bother testing the servo with the RX-18, use only the manual button to ground.

First, re-download the firmware from GitHub. I made a few changes that should eliminate some of the warnings the IDE was giving you earlier. I don't think they will make any difference to the servo, but it won't hurt.

Second, attach the servo as you have done (Sig to D8, Positive to Uno 5V, Negative to Uno Ground). Now test by momentarily bringing D4 to Ground. But it is not enough to simply say, "the servo does nothing"! I need to know whether putting D4 to Ground while the servo is attached does anything at all. Does it send the IR successfully, but not the servo? Or does it do neither? In other words, does everything work except the servo, or does connecting the servo cause nothing to work?


2. RX-18 Trigger
First, do NOT attach both RX-18 IR connections to the Uno! Especially do not connect one of them to ground. The RX-18 IR negative is an output, it is not a Ground connection. You could damage your RX-18 by connecting it to ground and firing the cannon as you have done.

We may not get the RX-18 to work with the Uno, but if we do you only need to connect a single wire from the RX-18 to Uno A0 for the trigger. There is no looping back required, that is not how these electronics work. What we need to do is figure out which wire from the RX-18 might give us an adequate signal. You have assumed the positive IR signal from the RX-18 and that is a reasonable guess but it may not be correct. Try the following steps:

1. Disconnect the servo so we know that isn't causing any problems.
2. Test fire the IR emitter (or just keep the Uno connected to your computer and watch the serial monitor) using the manual switch from D4 to Ground, to make sure the board is working correctly. The emitter should fire.
3. Next test fire the emitter by using a jumper to manually and momentarily connect A0 to +5v on the Uno. This lets us test if the firmware is reading A0 correctly. If it fires, proceed.
4. Now connect RX-18 IR positive wire (connector CN2-A on the RX-18) to Uno A0 (through a 10k resistor with another 10k to ground as you had earlier). Leave the RX-18 IR negative wire (CN2-B) disconnected! Now fire the cannon with your Heng Long transmitter. Does the Uno respond? Ie, does the serial monitor indicate anything?
5. If not, try the other way. Connect RX-18 IR negative (connector CN2-B on the RX-18) to Uno A0. Yes, I really said connect IR negative to A0. Leave the RX-18 IR positive wire (CN2-A) disconnected! Again try firing the cannon with the HL transmitter, and see if the Uno responds.
6. If that doesn't work, try connecting the RX-18 strobe output (CN3-G) to the Uno A0. This provides a clean 5v trigger source, the only drawback is that the RX-18 will probably only send the trigger if you have an airsoft attached. Maybe you don't want to use an airsoft but just attach one for this test (I believe the RX-18 needs to get the signal from the limit switch on the back of the airsoft unit before it will send the strobe signal).

I didn't design this with the idea of integrating it with the RX-18, nor have I tested it (unfortunately I do not have an RX-18 right now or I would). There's no guarantee the two are going to be (easily) compatible. But let's see what the above produces.
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 »

Many thanks for all of your time and effort on this project, I do appreciate it. I logged off last night and went to bed, and suddenly had a thought, the Uno that I have has additional ports etc, it is an enhanced build. I am going to check back with the supplier to see if there is a custom firmware for it. It may be that this is the cause of the problems. There is no reason why this should not work, your sketch looks perfect. I need to eradicate that potential source of the problem before I do anything else,
Tiger 1 Late
Panther G
King Tiger
M36 B1
Post Reply

Return to “Open Panzer Tank Control Board”