Using Arduino for animating features on a scale boat - RC Groups
Thread Tools
Jul 20, 2017, 10:05 AM
Webmaster, MMCNE
RCBoater's Avatar
Question

Using Arduino for animating features on a scale boat


I'm a newcomer to Arduino-- I've been going through the tutorials, and really enjoying it.

My end goal is to create a solution where I can use an Arduino to execute a series of commands. I have an Arduino Uno, and the Adafruit V2.3 motor shield, which can control up to 4 DC motors and a servo.

I'm thinking I will create an Arduino program to do the following, as an example:
- Run motor #1 forward for 3 seconds (open hangar door)
-Run motor #2 forward for 4 seconds (push helicopter model out of the hangar)
- run motor #1 reverse for 3 seconds (close hangar door)
- wait 30 seconds
- reverse the above (put the helo back in the hangar)

Creating a sketch to do this is fairly straighforward, I think.

My question:
I'm unsure how to implement the start/stop feature for the program via RC. Ideally, I would use a switch channel (retracts) on the RC unit to start/stop the program. It seems to me there are two ways to do this:
1. use the switched channel to power up the Arduino, upon which it executes the stored program. (This sounds rather crude to me.)
2. Have the Arduino powered up full time, looking for an input from the RC unit. When it gets the "gear up" signal, it runs the main part of the program. (I am assuming this is the better way to go?)

I have googled the topic, but haven't found my answer-- I'm sure this has been done before, and I'm just phrasing the question incorrectly. I suspect I'm missing one or more keywords that would help me sort this out.

Any advice or pointers? (I'm trying not to be one of those "please do the research and design my project for me" guys....!)

Once I get this sorted out, I can see all sorts of opportunities for animating features on scale boats......

-Bill
Sign up now
to remove ads between posts
Jul 20, 2017, 02:18 PM
No "R" !!!!!!!
Fitz Walker's Avatar
Yes, definitely use option 2.
It is not hard to do at all.
Use the pulseIn() function to look for the servo pulse from the receiver of a specific duration (or duration range):
https://www.arduino.cc/en/Reference/PulseIn
Jul 20, 2017, 06:00 PM
Submarines, etc.
tsenecal's Avatar
GAHHHH no.. DO NOT USE PULSEIN!!!!!!!!

please, use the info here... there are several of us that have tread down this road before, and we will be happy to post any and all answers to questions, including code snippets to help you get going.... but PLEASE, PLEASE, PLEASE do not start with the wrong path by using the pulseIn function...

PulseIn is basically the worst possible answer for this problem... it is simple to use, but has major limitations that will cause more problems than fix further down the road.


a perfect example of a sketch that reads two r/c inputs and converts those to four on/off switches. including all the sketch iterations:

http://www.modelboatmayhem.co.uk/for...c,57119.0.html

check out that thread... and if you still have questions, you can ask here, or even better, check out the following site, set up by several of the people that are here and at the modelboat mayhem site:

http://rcarduino.freeforums.net/
Jul 21, 2017, 02:09 PM
No "R" !!!!!!!
Fitz Walker's Avatar
Quote:
Originally Posted by tsenecal
GAHHHH no.. DO NOT USE PULSEIN!!!!!!!!
Oh, it won't be the end of the world if he uses pulsein to do one thing (on/off switch, essentially).
You are correct that there are much more versatile ways like in your link, but he said he was a beginner and working with timers and interrupts could be very confusing for a newbie.

But hopefully Bill has a good idea of his options.
Jul 21, 2017, 03:48 PM
Submarines, etc.
tsenecal's Avatar
it is much wiser to bite the bullet early and learn about interrupts from the start, rather than learn about them the first time the project fails in a real-world scenario, forcing the beginner coder to rewrite the project to make it work in a world where glitches occur constantly.
Jul 23, 2017, 12:04 AM
Webmaster, MMCNE
RCBoater's Avatar
Thanks for the help, guys!

I've got my DC motor testbed sketch working-- using the sample program that came with the Adafruit library, modified to do two motors sequentially.

Next step will be to sort out the RC integration part. I'll take a look at those references.

I also need to figure out the best way to control this from a programming point of view.
The simplest way is to have a program that does this:
1. Open door (motor 1 forward)
2. push helo out of hangar (motor 2 forward)
3. close door (motor 1 reverse)
4. sleep (maybe 30-60 seconds?)
5. open door (motor 1 forward)
6. pull helo in (motor 2 reverse)
7. close door. (motor1 reverse)

In theory this will work, but it is not fault tolerant. If the program is interupted before it finishes, the next time it starts it would begin at step 1, and may overdrive the hangar door lift or push the helo overboard, or try to force it through a partially closed door!

One thing I will look at will be to modify the sketch to use a servo instead of a DC motor (The Adafruit board supports it) - that may make it much easier to reset to point zero at the start of the program. Plus I can look at limit switches, sensors, etc.

This is fun stuff-- sort of a combination between programming and Rube Goldberg engineering!
Last edited by RCBoater; Jul 23, 2017 at 12:09 AM.
Jul 25, 2017, 07:29 AM
Registered User
Bill, As you have noted there can be problems using a standard motor to do much more than spin unlimited. You'd likely be happier if you used servos for it. You can slow their speed several ways if you don't like their speed, they will probably operate too fast, a simple loop in the sketch can control that, more complicated and you can accelerate and deccelerate the servos as well. I'm not a big servo fan because I buy cheap servos and they don't track well, plus the jittering, so I've used stepper motors that you can control location fairly well.

You seem intrigued by the mechanics of it, so you might at least experiment with a stepper motor. I don't know much but have gotten by. I use the unipolar type with six wires, probably my first mistake, lots of wires everywhere, bipolar has only 4 wires (mine operates gun turrets on destroyer model). The unipolar also uses 4 digital outputs unless you use a separate driver, so uno won't operate too many of them (I use a Mega, it has many more extra pins). If they are small (under 1/2 amp) you can use cheap darlington array to drive them. Once you have it figured out you can animate your door and heli to perform ballet. (which can be done with servos too, just not as well).

Post some pictures Cap
Jul 25, 2017, 07:36 AM
Registered User
Bill, As you have noted there can be problems using a standard motor to do much more than spin unlimited. You'd likely be happier if you used servos for it. You can slow their speed several ways if you don't like their speed, they will probably operate too fast, a simple loop in the sketch can control that, more complicated and you can accelerate and deccelerate the servos as well. I'm not a big servo fan because I buy cheap servos and they don't track well, plus the jittering, so I've used stepper motors that you can control location fairly well.

You seem intrigued by the mechanics of it, so you might at least experiment with a stepper motor. I don't know much but have gotten by. I use the unipolar type with six wires, probably my first mistake, lots of wires everywhere, bipolar has only 4 wires (mine operates gun turrets on destroyer model). The unipolar also uses 4 digital outputs unless you use a separate driver, so uno won't operate too many of them (I use a Mega, it has many more extra pins). If they are small (under 1/2 amp) you can use cheap darlington array to drive them. Once you have it figured out you can animate your door and heli to perform ballet. (which can be done with servos too, just not as well).

Post some pictures Cap
Jul 31, 2017, 09:20 PM
Webmaster, MMCNE
RCBoater's Avatar
Thanks to you guys, I have done some better focused Google-ing. I understand now that there is an important difference between using the PulseIn function and a proper Interrupt driven solution.

One thing I'm not completely clear on-- it seems to me that a lot of of the examples I found of Arduino integration involved people looking to use the Arduino to drive a bunch of servos. They wanted to have the Arduinio to take the servo signals from the RC receiver, and interpret them and then tell the servos what to do. Using hardware interupts seems like a "must have" in this situation. But that's not where I'm going, at least not yet.

I am looking to automate a variety of functions as described before. I've just ordered a pair of stepper motors-- I think they may give me the precise positional control that a basic on/off DC motor control can't provide. So I'm wondering-- is the PulseIn enough to allow a sketch to break out of the "check the pin status" loop and run the part of the sketch that executes the motors? I'm not concerned about lag or delay, like I would if I was trying to drive servos. And I won't have collisions with the 50Hz pulse cycle that the RC system is using....

I found this definition online, I think it is a pretty succinct description of the PulseIn function:
"PulseIn is a function available with the Arduino that implements an approach know as 'polling'. It essentially sits around waiting for something to happen, until something happens the rest of your code is blocked. "

I think in the end, I'll try it both ways-- should be a good learning experience.
Last edited by RCBoater; Aug 01, 2017 at 01:36 PM.
Aug 01, 2017, 02:00 PM
Big Boats Rule!
boater_dave's Avatar
This is just an observation from a lurking model guy, who also works with some industrial automation. But I too would like to get rolling on a micro computer to operate some model ship animation. A destroyer, too. So these comments are more schematic in nature and not specific code related.

There is an advantage to a servo (quality discussion later) because it includes a built in feedback loop. Provide a location signal and the servo will move until the position is obtained. A motor/gearbox is just a one way action, unless there is some kind of position information coming back in. Take, for example, simple end stop limit switches. If you supply power to a gearhead motor and the motor leads pass through a normally closed switch that will open when end of travel condition is met, it can't over run. But the system will not 'know' where the unit is between the stops. A stepper is a step above (no pun intended) a simple dc motor, but you still can't be guaranteed of position unless you re-home on every cycle, and you still could have signal issues. The signal says move 1500 steps but there is no feedback that the device actually has moved 1500 steps. What you might see in application is position drift.

My experience is working with robot assisted machines. Controllers send position info to servo motors, but also gather feedback info from electromagnetic inputs. Comparing desired position with actual position can also be used to activate fault alarms. For example, signal to move 1500 steps resulted in actual movement of 500 steps. System shuts down because of obstruction.

The threads on using an Arduino, or any of the micro sets is fascinating. My project is a 1:48 scale Fletcher destroyer and I would like to animate the turrets. Also, a sequence to rig out the motor launch would be neat. I have been bouncing between steppers and servos for the reasons listed.

Dave
Aug 01, 2017, 03:57 PM
Submarines, etc.
tsenecal's Avatar
RCBoater,

its all about the frame of mind... do you want an error to lock up the ardiuno, or do you want the arduino to be able to recognise an error, and decide what is the proper action to do to either bail out or fix that error... any function like pulsein or delay will effectively lock up the arduino until the time allotted is over. if an error (like the receiver loses connection during the pulsein) occurs, you have effectively turned the arduino into a brick. if you use the interrupt routine, then the arduino can tell that a failsafe situation has begun, and you can then write code to handle your animation scenario best for that failsafe/error situation.

boater dave's discussion of servos vs stepper motors is spot on. i have built hall sensors and magnets onto the shaft of stepper motors to guarantee that they move the distance you asked for. the use of a motor vs a stepper motor vs a servo really depends on what it is you are trying to do. even something like a winch or a crane might be better done with a drum style sail servo.
Aug 02, 2017, 08:47 PM
Registered User
Yes, servos are best probably for animation per boaterdave's description, with the (approx) location known at all times, hard to beat. Again, best off not getting cheap servos, even average. Stepper motors are a pain, although I haven't had too much problem with them skipping steps. They probably do drift over time, but with turrets you can just turn them manually to reset their location if they are off a bit.

The pot in the servo is one of the key parts, a good one will track well. I'd likely remove the pot from the servo and buy a precision pot with more than 360 deg revolution and connect it to the turrets shaft (if I were to change what I have), or simply buy the perfect servo (which likely exists), one that can do more than a full revolution and tracks well. You can pick up precision pots with multiple revolutions, or at least more than 270 deg to replace it with. I picked up a few surplus pieces that have ball bearings in them set up like planetary gears so about 6 revolutions of the pot shaft from one end to the other. Keeping it simple can't be beat though, so the right servo with the turret stuck on its shaft with no other crap would be ideal.

Geared motors with end switches works fine, I used one on my chicken coop door, has not failed yet, winter or summer. Best to run the end switches (and motors) through opto-isolated relays, they work well, if you connect switches directly to processor they need to be debounced etc.

boaterdave, there's an older thread on RCG by Nico Ottevaere not sure if you've seen, he also has 1/48 scale fletcher and rigged the turrets with servos, probably worth a search, he used to have a website too, not sure he's much active on it anymore. http://users.skynet.be/nico.ottevaere/

Not sure about the pulsein vs other interrupts, I've set my model to run from laptop using an xbee so that I can directly control all the animation on it (in my basement, not sure what the range is), so it doesn't use interupts to operate. I rigged up tachometers for the two propulsion motors that I had working at one time, that used interupts, but something happened and I haven't been able to get it to work since, very frustrating.

Post some photos. Cap
Aug 02, 2017, 10:25 PM
Submarines, etc.
tsenecal's Avatar
here is a perfect example why i use interrrupts:

utb lights (0 min 41 sec)


the "flashing" blue beacon is an ultrabright LED directly powered via an arduino pro micro, the other three sets of lights are multiplexed from a total of 2 3 position switches, so i have 2 r/c inputs, driving 4 outputs... all will turn on or off without any delay, and the fading/brightening of the beacon is not interrupted by the switching of other outputs. It has been updated since the video was made, so that a mp3 of a siren plays while the beacon is active... i will post a video of that as soon as i can get one taken.
Aug 04, 2017, 11:14 AM
Big Boats Rule!
boater_dave's Avatar
Yes, I have seen the destroyer gun director video. Functionality is great, but you can see the problems of getting all the stuff inside a model boat. At eight feet long you think you have unlimited room, but things get out of hand fast. I would like to keep it simple, and with the power of todays controllers and gadgets it should be possible. My plan is to separate the animation into several groups. Drive the boat from a traditional rc setup. I have an old Vantech dual motor mixer and a pair of huge Pittmann instrument motors. This way anyone can drive the boat without looking at a control box that has 45 buttons on it. Controlling the guns is up in the air. Use another radio with custom mods? or maybe a tablet type interface? Not sure of the range or complexity. Would be nice to include some fpv on the gun director. The other simple animations will probably get done with a simple relay box to begin a servo sequence. This winter is when I would like to get construction started.

Dave
Aug 05, 2017, 10:25 AM
Registered User
Did you make the prop? Nice one. It is amazing what a mess the wires become, photos below shows compartment with contoller for my DD, it's 10 ft long, so that compartment is more than a cubic foot, one of the 12v batteries goes in there too. Most of the wires are for the turrets, six per turret and director for rotation, that is 36 wires, plus 3 for elevation servos for each turret and director, that's another 18, so 54 wires, quite a wiring effort. I've used hansen hobbies to get all the connector pieces, terminals, crimper, it's pretty much required to make your own for stuff like this. http://www.hansenhobbies.com/product...rvoconnectors/

The main controller is an arduino Mega on a raised platform in the middle with an xbee and antenna. The starboard side has the turret stepper motor controllers, a bunch of darrlington arrays, the port side has a couple banks of the opto isolated relays for lights, motors etc. The farthest right relay on the port side is not opto isolated, I ran out of relays so had to add one to reverse the anchor winch motor, it has to be replaced, when it's used, even with flyback diode, pull up/down resistors etc it still causes problems when activated.

So to control the turrets the director is operated and all the turrets are slaves. When the director is pointed toward forward the two forward turrets operate and the other three are disabled until the director is pointed more than 45 deg from the centerline, then the other 3 turrets operate as well, same thing when pointed aft. Obviously it's not the simple version, but my interest was in making it operate as I wanted, not neccessarily to keep it simple with a preprogrammed animation, which makes much more sense if you want to actually run the boat around and show some turret action.

Another problem I have with servos is when the leads are too long. I have a giant scale servo to run the rudders, and they are probably 6 or 7 ft from the controller. I can't get it to operate smoothly, servo noise trap etc does not help much. Obviuosly it's a solvable problem but so far not much luck, I may just add an arduino mini in the aftmost compartment and run it from that.


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion FPV Audio Channel Telemetry for DJI Naza (and everything else) using AFSK and Arduino neoklisv FPV Talk 0 Mar 10, 2017 08:19 AM
Question Odd feature on a full scale Lancaster Mad_Mike Scale Fuel Planes 5 Oct 23, 2016 10:26 PM
Discussion Note on ESC Inputs (Using Arduino) lordvon Power Systems 2 May 22, 2016 11:51 PM
Discussion need help control two motor boat use arduino Jame David Homebrew Hacks for Model Boats 1 Jan 12, 2014 03:16 PM
Discussion I own a RC boat older than me, will be using it for an arduino project, need help! huseyinozsut Micro and Sub-Micro Boats 3 Nov 25, 2012 05:52 PM