Go Down

Topic: Ship model controlled using Arduino (Read 2753 times) previous topic - next topic

tweety777

Feb 22, 2012, 09:09 pm Last Edit: Feb 23, 2012, 03:38 pm by tweety777 Reason: 1
Hello guys,

I'm new to this forum and to Arduino.
A few years ago I did intern ship at a shipyard, and as I enjoyed my intern ship I decided to build a model of the ship I was working on.
I always liked to make everything working that works on the real thing, and as the ship I'm referring to above has quite some working stuff fitted I'm able to go such far that normal radio control systems get to their limits, and then only through using decoders for which I would need to remember 16 functions per switch.
As that would make it hard to use all functions to their full extent I decided that a different system was needed to do the job, especially seeing the fact that I like to go further with every new model.
A friend of mine told me about Arduino, so I decided to try it out.
At first it appeared to be easy, but as soon as I tried to get further then simply Hello World I got stuck with a not properly working set-up.
Mostly I don't even get the codes to pass the test, let alone make more then just 1 LED go on and off.
Therefore I decided to join this forum, hoping you guys could tell me how to start.
The load of information is simply way too big to start finding out where to start myself.

The problem starts with my lack of knowledge of any kind of programming.
I simply don't know how I can start programming, how the codes work.
Therefore I can't find a way to get any further then the basic codes that Arduino provides in the software.
My first question therefore is: is there a list of what code does what?
Then: how can I get started with some proper programming, starting with turning on and off some LED's separately?

Right now I only have 1 Arduino Uno starter kit.
I would prefer to use Wifi for communications between transmitter (laptop or tablet) and Arduino aboard the model.
In order to keep the wiring as short as possible I intent to build several "board computers" as I like to call them, each having there own set of functions to control, or having a larger job to do, like handling all communications, controlling the propulsions to keep the model at her position under the name Dynamic positioning.

For those of you interested in the model I'll add a link to the build log here:http://www.shipmodels.info/mws_forum/viewtopic.php?f=13&t=45744

Thanks in advance.

Greetings Josse

Pauly

Welcome to the forums. 
Have you looked at the Learning page http://arduino.cc/en/Tutorial/HomePage
or the reference page http://arduino.cc/en/Reference/HomePage yet?   The Reference page has lots of code examples on it.

I would start simple first  and do 1 thing at a time.  First make 1 led blink, then make 2 leds blink, then try adding a switch to turn them on and off.

Good luck!

tweety777

Hello Pauly,

Thanks for the help.
I thought I tried to find what I was looking for, but didn't find it then.
I'm reading it now, and it seems to be helping already.

I just found out that I forgot to ask a question: would Wifi work for a range of up to 100m, and would it not be all too hard to set up a WiFi connection for controlling the Arduino?
Or is the range of Wifi in open field (read water) too limited to be of any use?
My current normal transmitter has a range of about 100m, and I haven't reached the limit of its range yet.
Next question: would Wifi take more electric power then other wireless communications (such as blue tooth)?
I want to be able to sail at least 6 hours with only the batteries of my laptop and the lead acid batteries of the model (the last one can be backed up by an additional battery).
The battery of my laptop gives enough power to be on internet for some 4 hours, but that is not in power saving mode, so that endurance can probably be extended a bit.
Would a tablet get a better performance for this matter?

Greetings Josse

tweety777

Just a moment ago I managed to write my first properly working program!!!
I started with the Blink program, and expanded that to make 2 LED's blink, though the second LED blinks shorter, and starts with off rather then on.
Now that I've done this I can make the next step.

Can there be several void loops in 1 program?

What would be the next logical step?
Could that be trying to control a servo?
That is a function that I will be using quite a lot.

In the main mast of the ship are about 20 lights that are used to "tell" other vessels what condition the vessel is in (like "diver in the water", "limited manoeuvrability", etc.).
I want to make the software on the transmitter such that I will just need to select the condition of the ship, and that the Arduino will know which of the 20 lights will need to be turned on (most conditions require several lights).
Would I need to adjust the command code in the transmitter (transmitter knows which lights should be turned on, and Arduino gets the order to turn several lights on), or would it be better to tell the Arduino which lights should be turned on when a single code comes in (that single code would trigger several pins on the Arduino)?

Greetings Josse

wildbill

Quote
would Wifi work for a range of up to 100m

Maybe, given that you'll have unobstructed line of sight to the model, but it's likely at the edge of its range. I would not risk it. XBee is an alternative, but make sure you get one of the models that has a one mile (or more) range - the lesser ones have much the same range as the wifi shield.

tweety777

Hello Wildbill,

An unobstructed line of sight is highly likely, as I'm having her sail on the water, which is usually unobstructed.
Can Xbee be attached to a laptop or tablet?
That is what I want to use as transmitter.
100m of range is more then enough, a mile is overkill, when the model is at that range she'll be barely visible by then.
The model isn't quite small (1,76m long), but most waters I sail in aren't even 100m long, so even if I want to get beyond that range I won't be able to do so due to lack of range.
I can't imagine that a model or fellow model builder would limit the range noticeably, not when I bear in mind that there would most likely be a slightly longer way around that small obstruction.
Would it help to have an antenna placed high in the model?
There is a tower that gets as much as 55cm above the water, so would that make at least a slight difference in range when opposed to placing the antenna near the waterline?

Greetings Josse

CrossRoads

You could set up your code to have to do certain code sequence defined.
For example, your main loop would just look for a character to come in, then perform the code for that character.
Code: [Select]

void loop(){
if (Serial.available()>0){  // character is in the queue
commandCode = Serial.read();  // go get it
}
switch(commandCode){  // now do the code
case 'a':
// do the code for 'a'
commandCode = 0;  // clear the command if you only want it to run 1 time
// or leave it equal to 'a' if you want this section of code to run again without another character being received
break;
case 'b':
// do the code for 'b'
commandCode = 0;  // clear the command if you only want it to run 1 time
// or leave it equal to 'b' if you want this section of code to run again without another character being received

break;
:
:
case 'z':
// do the code for 'z'
commandCode = 0;  // clear the command if you only want it to run 1 time
// or leave it equal to 'z' if you want this section of code to run again without another character being received

break;
case 0:
// do nothing
break;
} // end switch
} // void loop
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

wildbill

I've had trouble with the range of a wifi shield on a previous project where the separation was markedly less than 100m, although in that case the signal had to pass through several walls. However, since it sounds like you're sailing the model in enclosed waters, perhaps it doesn't matter - at worst you'll have to walk closer.

Could you post a picture of it?

tweety777

Thanks for the help Crossroads.

@ Wildbill,

In my first post I included a link to the build log of the model, as this forum is only about electronics it doesn't seem to be appropriate to include pictures of models.
The build log contains close to a thousand pictures at the moment, so I'd say that shows the project pretty well.

When the model happens to get out of range walking indeed will solve the problem.
Most of the time walking is perfectly well possible, so that won't be a reason to use a different form of communication.
If one can show me an easier way to communicate with the boat using a different form of communication I'd like to hear it.
I do have experience with building websites, therefore it appeared to be relatively easy to make proper "software" for controlling the Arduino's aboard the vessel (the amount of functions, especially servo-driven functions, is simply to high for just 1 Arduino).
My first thought is to go with 4 Arduino Mega's, 2 Arduino Nano's (for handling the communications) and 4 port expanders with each 8 pins.

Greetings Josse

wildbill

Quote
My first thought is to go with 4 Arduino Mega's, 2 Arduino Nano's (for handling the communications) and 4 port expanders with each 8 pins


That's a lot of arduinos! Clearly you need a Mega - 20 pins are gone just handling the lights in the mast unless you add additional hardware, but how many other things do you need to control? Having looked at pictures of your build I suspect that a single Mega to handle it and two certainly could.

tweety777

These are the functions:
-throttle
-rudder
-bow thruster
-prepare to sail (turns on cooling water pump, navigation lights and some more functions)
-Mooring (turns off prepare to sail)
-both anchors dropping and retrieving and cleaning (6 functions in total)
-interior lighting (randomly, will need a Mega to control just this)
-deck lights (2 groups, each take 1 function)
- 3 different cranes (first 1 5 functions, one of 4 functions and the last one takes 3 functions)
-4 lifeboats (each 2 functions, throttle and rudder)
-1 hyperbaric lifeboat, also taking 2 functions
-possibly 1 RHIB, also taking 2 functions
-2 ROV's, each taking 10 functions (throttle, rudder, depth, arm to the left, arm to the right, up and down, videocamera, searchlight and lowering the hoist cable, or heaving it).
-1 helicopter
-firemonitors (taking 6 functions in total for independent control)
-fire fighting equipment on the helideck
-lights on the helideck
-20 lights in the mast
-2 searchlights on the bridge wings (each taking 3 functions to make sure I can keep them away from pointing in some-one's eyes as they're pretty bright).
-Another searchlight on the bow, also taking 3 functions for the same reason
-3 Panama steering lights, each taking 1 function
-Dynamic Positioning, which can control each thruster unit independently

I thought that was pretty much it, totalling the number of functions to about 120, so yeah, I'll need several Arduino's.
Then there will be more then just a few inputs:
-positions of all the smaller craft (at least lifeboats, hyperbaric lifeboat, RHIB and helicopter, the ROV's camera will do the job of navigating, and when I'm using does I'll have the ship either at anchor or in DP-mode.
-throttle and heading of all thruster units
-light-meter for telling the interior lights to go on more often, and to turn on more lights
-2 gyroscopes to tell the DP if the ship is moving, the second 1 will be back-up for added accuracy.
-1 camera inside the main crane, 1 in each ROV, maybe also 1 on the bridge.
-position of the crane, as there are some objects that are within it's reach, and I don't want it to hit any of those objects, even if it would be by accident.

This is pretty ambitious, but I know it can be done, so I will at least try, but actually I'm pretty much determined to make it happen, even if it means I'll be working on this model for quite some years.
Actually, before I started building this model I had another ship in mind to build a model of, but my intern ship made me change my mind.
The model I had in mind then is still to be the successor to this model.
I have a bit of a tradition that every next model should be build better, and should also have more, or at least more complex, functionality.
As soon as I figured out how to do this I will be able to improve the system for use in the next model.
After that it's again a matter of small adjustments to make the next model working.

Greetings Josse

wildbill

Wow, that is a lot to control. I withdraw my earlier remark  ;)

Going to be quite a coding effort.

tweety777

Hi Wildbill,

It indeed will be quite some job to make all the codes :smiley-red:
Fortunately I'll be able to build it up step by step, that gives the opportunity to use parts of the system even when it isn't completely finished.
I guys using comments will be quite useful here, one might easily get lost in such a huge amount of codes :smiley-mr-green:

Greetings Josse

CrossRoads

I would guess a  lot of those functions will need more thatn 5V/23-30mA to make them happen.
I'm doing (have done) a circuit card for another user with 12 TPIC6B595 shift registers to provide 96 outputs.
I think you would need something similar to provide higher curent/voltage control than straight-up Arduino's could provide.
That would allow you to reduce the # of arduino's and cut down on arduino-arduino comm's, with maybe just a mega and its 4 comm ports for comms, and a bank of drivers/shift register to complement the 50+ IO lines the Mega has.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

tweety777

Hi Crossroads,

Thanks for the advice.

One of the reasons I want to use at least 4 Arduino's is that I can then place each Arduino as close to it's functions as possible.
Would that also be possible with the 12 TPIC6B595 shift registers?
Otherwise I would need quite some connectors to get the functions in the superstructure attached to they're controller.

Greetings Josse

Go Up