Notifications
Clear all

Ship model with custom made transmitter and Raspberry Pi control

38 Posts
4 Users
0 Likes
3,494 Views
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

Coco777

From what you have written so far I can see it is going to be quite a complex and interesting project! How much of this ship is going to be under manual control? I assume the idea is to control the ship as if you were the captain on a real ship? It seems similar to those here with their model train sets? Are you going to use gps to keep the ship's position automatically?

What is not clear to me yet is what radio transmitter and receiver you are going to use?

The RPi is probably a good choice.  Best to have too much computing power than not enough and keeping to one system means a lower learning curve would be required to get something up an running.

 


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1037
 

@coco777

Wow, that's quite an undertaking!  I guess I stand corrected as I did not understand the immense size of this project.

Good Luck! 

SteveG


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@coco777

Just an after thought.  Instead of that physical control box is it possible to use your touch screen instead of all those physical joysticks? A simple tablet sized touch screen controller would be easy to carry out into the field just as many projects do when they use their smart phones to remote control hardware.

 


   
ReplyQuote
(@coco777)
Member
Joined: 4 years ago
Posts: 23
Topic starter  

Thanks for thinking along guys!

This ship will be mostly on manual control. The position keeping mode can be used when working with the cranes. The real ship uses this when the divers are in the water, their very lives depend on the ships ability to keep position when their down in the water working their magic. 

I intent to rely mostly on 2 accelerometers, maybe accomponied by 1 GPS. I thought that GPS is only accurate to 1,6m, which is almost as much as the length of this beast. I don't even dream of scaling down the real ships accuracy in this (16cm or 1/2") but keeping it at this level would mean loosing position half the width of the boat. That would certainly make me smile and maybe even hang out the flag when achieved! Getting somewhere in the middle would also satisfy me greatly.

Apart from the automatic position keeping only the interior lights will be controlled random, but only when I turn on the interior lights using the corresponding touch button on the screen.

 

Using mostly the touchscreen has crossed my mind too, however, now I have a nicely clean screen with only some very understandable texts to show what I can do. Removing the joysticks would mean that I'd need to add at least 1 more tap, since I will multiplex the use of those 12 joysticks, so currently I'm at the point where I will generate 36x2 = 72 commands. I'm not actually using that many, I also use the multiplexing so all actually used commands will be in logical directions, for example pushing towards the screen will always be either going up (moving a cranes boom or hoisting) or going forward and likewise moving to the right will result in the subject turning to the right. And then I also have some bad experience using a laptop with a 2,4GHz transceiver with an Arduino Nano as translater in between. The moment you push 2 buttons within say half a second of eachother the connection froze unrecoverable... The idea certainly has it's potential, though I think this feels more convenient to me. 

I'll try and find the set-up I thought of for the joysticks and post it here in the near future, that will also help show the size of this project. I think I will be working on this for quite some years to come, and happily so.

 

For the wireless communication I intent to use 2,4GHz long range transceivers (I got 4 laying around here) and the short ranged versions when I get to building the lifeboats. WiFi might be an alternative though I'm a little worried about the range. Though I'd probably need WiFi for the video signal anyways. 

 

Greetings Josse

Still working on getting my transmitter to work and trying to get my boats engine's controlled with RPi.


   
ReplyQuote
(@coco777)
Member
Joined: 4 years ago
Posts: 23
Topic starter  

Hi all,

 

I tried to get the PWM module to work, but I didn't succeed on this. See below for the code I used. Code now runs (at first I even had trouble opening the file, the Pi said it couldn't find it) but there is no respons from the servos.

adafruit products raspi pca9685 i2c bb

This is the wiring diagram.

# Simple demo of of the PCA9685 PWM servo/LED controller library.
2 # This will move channel 0 from min to max position repeatedly.
3 # Author: Tony DiCola
4 # License: Public Domain
5 from __future__ import division
6 import time
7
8 # Import the PCA9685 module.
9 import Adafruit_PCA9685
10
11
12 # Uncomment to enable debug output.
13 #import logging
14 #logging.basicConfig(level=logging.DEBUG)
15
16 # Initialise the PCA9685 using the default address (0x40).
17 pwm = Adafruit_PCA9685.PCA9685()
18
19 # Alternatively specify a different address and/or bus:
20 #pwm = Adafruit_PCA9685.PCA9685(address=0x41, busnum=2)
21
22 # Configure min and max servo pulse lengths
23 servo_min = 150 # Min pulse length out of 4096
24 servo_max = 600 # Max pulse length out of 4096
25
26 # Helper function to make setting a servo pulse width simpler.
27 def set_servo_pulse(channel, pulse):
28 pulse_length = 1000000 # 1,000,000 us per second
29 pulse_length //= 60 # 60 Hz
30 print('{0}us per period'.format(pulse_length))
31 pulse_length //= 4096 # 12 bits of resolution
32 print('{0}us per bit'.format(pulse_length))
33 pulse *= 1000
34 pulse //= pulse_length
35 pwm.set_pwm(channel, 0, pulse)
36
37 # Set frequency to 60hz, good for servos.
38 pwm.set_pwm_freq(60)
39
40 print('Moving servo on channel 0, press Ctrl-C to quit...')
41 while True:
42 # Move servo on channel O between extremes.
43 pwm.set_pwm(0, 0, servo_min)
44 time.sleep(10)
45 pwm.set_pwm(0, 0, servo_max)
46 time.sleep(10)

This is the code I used.

Can you guys see a reason why it wouldn't work?

 

Thanks in advance.

 

Greetings Josse

Still working on getting my transmitter to work and trying to get my boats engine's controlled with RPi.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

It might help if you gave the source of your circuit and code.
If you followed the instructions I don't see why it wouldn't work unless there is something you missed in the actual wiring. As we can't inspect your actual physical implementation we can't check for wiring errors or power issues. We cant test to see what the output signals or voltages are. An image of your actual circuit might help.

Also if you can figure out how to copy paste Python code into a post without the line numbers and loss of indentation. Although it is easy in this example to see where the indentation should be you probably know it is how Python blocks code. I noticed that the Editor I use that came with the Python download (IDLE) doesn't have a save as HTML which is what I use to copy source code from the Arduino IDE.

https://forum.dronebotworkshop.com/question-suggestion/sticky-post-for-editing/#post-4939

 

 

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

   
ReplyQuote
(@coco777)
Member
Joined: 4 years ago
Posts: 23
Topic starter  
Posted by: @robotbuilder

@coco777

This seems to be the relevant code?

https://github.com/adafruit/Adafruit_Python_PCA9685/blob/master/examples/simpletest.py

The main (only?) difference is the last line, time.sleep(10) instead of time.sleep(1)

Hello Robotbuilder,

 

That indeed is the case. After testing with sleep time 1 (I think ms?) I decided this might be too short for reaction so a gave it some longer time, also without any result. 

Still working on getting my transmitter to work and trying to get my boats engine's controlled with RPi.


   
ReplyQuote
(@coco777)
Member
Joined: 4 years ago
Posts: 23
Topic starter  
Posted by: @robotbuilder

It might help if you gave the source of your circuit and code.
If you followed the instructions I don't see why it wouldn't work unless there is something you missed in the actual wiring. As we can't inspect your actual physical implementation we can't check for wiring errors or power issues. We cant test to see what the output signals or voltages are. An image of your actual circuit might help.

Also if you can figure out how to copy paste Python code into a post without the line numbers and loss of indentation. Although it is easy in this example to see where the indentation should be you probably know it is how Python blocks code. I noticed that the Editor I use that came with the Python download (IDLE) doesn't have a save as HTML which is what I use to copy source code from the Arduino IDE.

https://forum.dronebotworkshop.com/question-suggestion/sticky-post-for-editing/#post-4939  

Hello Robotbuilder,

 

I use Moba Xterm on my PC to remotely control my Pi, I can try if copying to HTML will work there.

20200603 071350[1]

 This is the wiring on the PWM itself. Since I had a good night sleep since testing and making the photo's (you guys seem to awake when I sleep) I removed 1 of the batteries to avoid leaking power. Turning the battery when in use will the servo that should be controlled turn a tiny bit.

20200603 071402[1]

Unfortunately I don't have that much jumper wires suitable for connecting to the Pi and the cobbler cable I ordered has an yet undetermined lay out. It says with a G how it should be connected, but I found that the 3,3V and GND on the opposite sides of the GPIO pins on the same row are attached to the outmost wires. That means it must change between front row first and rear row first somewhere along the way.

20200603 071408[1]

Hopefully these 3 photo's will make enough sense.

While typing about the removed battery the thought sprung to mind that the batteries might be empty or at least too empty to be able to power the servo's. This because I would expect all servo's to move when turning the battery in it's place. Maybe I'll try again today with a fresh recharged set of batteries

 

Thanks for the help!

 

Greetings Josse

Still working on getting my transmitter to work and trying to get my boats engine's controlled with RPi.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@coco777

If the battery is working ok perhaps check the wiring.

In the last image the +power red wire into the PCA9656 looks loose?  No dry joints?  The soldering to the PCA9656 looks a bit suspect as well?

When you strip the plastic off the end of a wire you can hold the braids between your fingers and twist them. Then add solder to the wire ends and to the tabs on the board. Then hold the soldered ends of the wire to the soldered tab and apply the soldering iron to add heat and it should all melt together nicely. (Unless of course you first have to thread the wire end through a hole in the board).

I use Moba Xterm on my PC to remotely control my Pi, I can try if copying to HTML will work there.

I just use the RPi as a stand alone computer. I use a wireless keyboard, mouse and monitor. I don't know how to control it from a PC.

(you guys seem to awake when I sleep)

I live in Australia eastern time. Sometimes I am awake in the early mornings.

The main problem I would have in helping you is I can't duplicate the circuit. My supplier of electronic stuff Jaycar doesn't stock the PCA9685 module. They do stock the MCP3008 chip.

There is a mess of wires in your images and I can't really trace them all visually.

It is now 4:22pm my time 🙂

 


   
ReplyQuote
(@coco777)
Member
Joined: 4 years ago
Posts: 23
Topic starter  

@robotbuilder,

Maybe this photo will help:

20200603 175243[1]

 I tried again today with new batteries, thinking the power might be the isue, but unfortunately this didn't solve the problem. I did notice however that the servo's don't get any power at all. Tomorrow I will contact the store as well. Maybe the power only comes on when the servo gets an order, but that would be unpratical for servo use in my users opinion.

 

I did uncomment the debug in the code, this let me now it came with very many different codes. The numbers were similar in format to the I2C adress, though the numbers were lower (0x07, where the default adress is 0x40). I don't know what this means though, I couldn't make up enough of the long sentences.

 

Thanks for any help.

 

Greetings Josse

Still working on getting my transmitter to work and trying to get my boats engine's controlled with RPi.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

There are so many points at which you may have gone wrong but which I can't check out,  particularly as I lack the experience in setting up the Raspberry Pi to use its I2C and do not have a PCA9685 to test it with.

One thing I have noticed in this forum is there is very little electronics expert help available perhaps because of a lack of experienced or knowledgeable members or perhaps they are too busy doing their own thing and only have time for those doing something similar. Apparently no one here has driven servo motors via a PCA9685 using a Raspberry Pi.  I would have helped more as a learning experience for myself but I don't have the same hardware to play with.

 


   
ReplyQuote
(@coco777)
Member
Joined: 4 years ago
Posts: 23
Topic starter  

Hi Robotbuilder,

 

Thanks a lot for the help anyways. At least I got a step further. 

The store is willing to help figure out what is wrong and how to solve it, hopefully that will get things going.

 

In the mean time I can try to modify the code for the MCP3008's so I can try to make the interpreter code. First step on this way is to read and translate all 8 inputs of the first MCP3008, then try to read out the second MCP3008 as well. At first I'll leave the input from the interface out of it, I can always add that later on. I can even go as far as trying to add code that will actually send the command through the 2,4GHz transceiver. Though it would be difficult without a receiver to verify the transmissions are working properly.

 

Greetings Josse

Still working on getting my transmitter to work and trying to get my boats engine's controlled with RPi.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@coco777

Found an Australian source for the PCA9685 but I will have to buy it online and it will probably take a week to arrive. I will order a MCP3008 as well to play with. Will look around for a pair of cheap transceivers. How do you intend to attach the transceivers to the RPi? I will probably try and link two Arduinos first as from a programmers point of view they are much simpler than using the RPi. The RPi comes into its own when you need higher level processing like AI.

pots --> RPi ---> tx   }}}}}  rx ---> RPi ---> servos

 


   
ReplyQuote
(@coco777)
Member
Joined: 4 years ago
Posts: 23
Topic starter  

@robotbuilder,

 

That is so kind of you, helping me out that way! Thanks a lot.

 

I bought 2,4GHz transceivers from China, I think the Pi can also control it though I'd need to search Google to find out how. Perhaps WiFi could be an alternative as a USB WiFi antenna can easily be attached to the Pi. Only downside to this is the limited range even though I'll mostly be in open terrain, aside from maybe using the camera sight from the wheelhouse to steer behind a bridge. 

My current transceivers (NRF something I thought) have a range of 1km, or say 0,7miles, that is clearly sufficient for my purpose.

 

I think I still have the Arduino code somewhere to translate at least on the transmitter side, so I could see what works best and the easiest. Would be quite a bit overkill for an Arduino Mega, but since that is what I have laying around (3 of them) I could perfectly use them.

 

Greetings Josse

Still working on getting my transmitter to work and trying to get my boats engine's controlled with RPi.


   
ReplyQuote
Page 2 / 3