This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Motor spins at startup and pypilot plugin not working properly
#1
Hello everybody,

my name is Andrea and I write you from Italy. I own a small power boat, 5.5 m 10 cv inboard engine, a "gozzo" in Italian. You see it in my avatar pic.
In these days of coronavirus, I started the project to add a navigation system and an autopilot to the boat, which is obviously overdesigned, but the main aim is to have fun in doing that and at least for this I'm succeeding. I'm a mechanical engineer with very limited knowledge in electronics and programming, so my approach is mainly to look for documentation and tips in forum threads and applying it. 


This what I've done up to now:

I've a Raspberry PI 4 and I've installed on it 2020-03-24-OpenPlotter-v2-Headless-NOOBS.

I have bought:

- USB GPS dongle
- IBT-2 motor controller
- Arduino Nano clone
- 9255 IMU
I've installed the pypilot plugin in opencpn


In raspberry configuration I have activated:
- SHH
- VNC
- I2C
- Serial Port
the rest is disabled

In Serial:
- I activated UART (and reboot)
- I find ttyACM0 which I gave alias ttyOP_gps NMEA 0183 and I assigned it to GPSD
- I find ttyAMA0 which I gave alias ttyOP_serial NMEA 0183 and I assigned it to pypilot
- I find ttyS0 which I've not assigned

In Signal K I've established connections to
- Pypilot NMEA 0183 TCP client - localhost 20220
- Pypilot signal K UDP 20220
- GPSD localhost 2947

In opencpn I've established connections:
- Network TCP input localhost 10110 Priority 2
- Network TCP in/out 10.10.10.01 20220 Priority 1
   
I've connected the IMU 9255 to the PI GPIO pins 1(3.3V) 3 (SDA) 5(SCL) 9(GND)
I've connected the Arduino to the PI GPIO Pins 4 (+5V to +5V) 6 (GND to GND) 8(TDX to RDX) 10(RDX to TDX) (I'm not using optical isolation, i know it's risky, I've ordered a RS 232 logic converter but it is not yet arrived and I've not been able to wait for it....)

At this point, I tried to get into motor.ino to understand how to set it up but I've been struggling, then I found a post from McNuggets https://hackaday.io/project/168592-openc...-waypoints that has modified the motor.ino to work with IBT-2 driver, it also provided a clear schematic, so I decided to have a try with it and I followed his schematic, adding resistors and so on to have voltage, current and temperature sensors.

I've ordered a linear actuator with a potentiometer, but is not yet arrived, so to make trials I've connected a basic potentiometer coming from an Arduino kit as a rudder sensor and a water pump as a motor.

The Arduino and the motor controller are powered by the raspberry pi +5v and GND pins and the motor is powered by a 12v battery.

All I've done up to now has been done on a table in my kitchen, not on the boat.

   

At the moment several things look to work:
- GPS is showed in opencpn ( the boat is in my kitchen)
- Magnetic heading is shown both I pypilot app and opencpn (i can see it both in pypilot scope, pypilot web app, opencpn  and il Signal K)
- I see rudder angle changing if I move the potentiometer, this in pypilot scope and in opencpn dashboard)
- I see accelerometers working in IMU calibration (I've performed calibration on the table by rotating the board 360°)
- If I activate the AP in compass mode and I rotate the IMU the motor start to spin
- If I activate the AP in GPS mode and I activate a route I see the green line pointing to the closest waypoint and the red line alligned with the magnetic heading. If I rotate the imu to have the red line away from the green line the motor start to spin if I align the red and green line the motor stops. 
- I see the temperature of the motor controller in the web app of pypilot.

Now I have two strange behaviors:

- when I turn on the Raspberry Pi, with all the stuff connected, the motor starts to spin. It keeps spinning until I open pypilot app, there I find the AP off, I turn on the AP, then the motor slows down and stops because the target heading is the same as the read heading. Then I turn off the AP. From this moment everything starts to work properly. It looks like the motor controller boots with a wrong logic state and starts to spin the motor until I reset it by turning it on and off.

- In Opencpn pypilot plugin I do not see the gains and most part of the calibration options.
   
Can you help me to understand why I have these 2 issues?
On top of this, I'd apreciate it if you can confirm that my settings are generally correct.

In conclusion, I want to say thanks to Sean and all the other peapole that have developed and is maintaing this sw which is incredibly amazing and well done and, among other things, it allows a small boat owner to implement this equipment at a negligeble expense, which for sure I was not going to do by buying commercial much more expensive stuff.
Reply
#2
The modified version of motor.ino had a lot of changes to make it more "readable" but at the cost of reduced features/performance and possibly you found an actual introduced bug. You will need to check the software to make sure it does the right thing at startup and all the timeout logic is working correctly.

As for the gains being broken.. hmm. What if you resize the window? what if you simply run "pypilot_control" or "pypilot_calibration" ? Can you adjust the gains from the other interfaces like the client or web?
Reply
#3
Hello Sean, thanks for your prompt reply. 

I understand it is hard to help me with a version of the software modified with respect to yours. It was just easier for me to try to make it work because was already set for my hardware, but if it keeps going this way I'll try to make the original version to work. Do you have any tips and/or schematic I can refer to in order to make it work with my hardware?

About the pypilot plugin there is no effect if I resize the window. Everything works perfectly if I use "pypilot_control" or "pypilot_calibration" and I can adjust the gains from the other interfaces like the client or web. During these days I've changed several times the configuration before to be able to make it work.... I remember that the gains were visible in opencpn at the beginning, but I sincerely do not have an idea about the moment when they disappeared from the opencpn plugin.

What about the settings? Do they look correct?

Thanks again.
Reply
#4
You reassure me and show me that I am not the only one to encounter this display problem!
I followed your post with your detailed explanations, as well as Sean's response.
For your untimely starting of the movements of your engine (which I do not find on my installation) I give you here my settings which work for me:
My gps is recognized in the 'Serial' tab as 'USB0' for which I assigned the alias 'gps', NMEA0183 data. In the second tab of 'Serial', I connected ttyOP_gps to SignalK by assigning it the transmission speed (4800Bps).
I followed the same procedure for the anemometer found in 'Serial' as USB1: alias 'wind', data NMEA0183, then in connection ttyOP_vent to SignalK in 4800Bps.
Remain AMA0 auqUel I gave the alias 'pilote' and that I send in 38400Bps to Pypilot.
In signalK, I go to the tab 'plugin config' and I activate the menu 'CONVERT SIGNALK to NMEA0183' by checking the values that interest me: (APB, GGA, GLL, HDG, HDM, MTA, MWV, RMC , VWR, VWT, XDR)
Then in Opencpn, I established 2 network connections:
one incoming and listening to localhost: 10110 (powered by signalk)
the other incoming and outgoing assigned to localhost: 20220 to communicate with pypilot.
In summary, my sensors are sent to signalK which redirects them to Opencpn which retransmits them to pypilot.
I am not sure that this is the optimal method, but at home, it works and when Opencpn is open, I have access to all the pypilot modes (compass, apparent wind, real wind and gps).
Try these settings and tell me if the problem is resolved.
Thank you for the link you offer in your post (McNugget). It is well documented and we learn a lot there and despite my hours of research on the web, I had not found it !!! Long live the forums !!
There remains the problem of displaying the adjustment parameters in the pypilot-Opencpn plugin: I have not yet found, but do not despair, because our case should not be isolated.
cordially

Kinefou
Reply
#5
Thanks kinefu for your tips, I tried but no change in behavior. I think it makes sense, at the end the stream of data between Pypilot, opencpn and Signal K was already working.

I've done some steps forward in understanding the behavior of motor spinning at startup.

1) once I've turned on and off AP, so the system starts to work properly, if I reset the Arduino by pressing its button the motor doesn't start to spin, so it looks that is not the Arduino code that goes in the command mode at startup
2) I realized that if I press the center command on pypilot_control when I have the rudder sensor/potentiometer out of the center the motor start to spin and keeps spinning indefinitely. Is that command trying to center the rudder position? If so it makes sense because being my motor is decoupled from the rudder sensor/potentiometer it can spin indefinitely without centering the rudder.
3) I centered the rudder sensor and I reboot the pi--> the motor doesn't spin at startup
4) I off-centered the rudder sensor and reboot, the pi --> the motor start to spin at startup --> then I center the rudder sensor --> the motor stops !!!

So it looks like that pypilot sends a "center" command to the Arduino when I boot the pi. Does it make sense? Is it a normal behavior?

BTW: the gains in opencpn are still not visible.

Ciao.
Reply
#6
bravo massilia,
You did not waste your time and it seems that you have found the reason for the problem: I had not thought of that, because, on my assembly, I did not use a rudder sensor, and it is probably for that I have not encountered this malfunction.
I think that in your configuration where pypilot is connected directly to pypilot without going through opencpn it seems normal that the adjustment is made as soon as the 2 services (pypilot and signalK) are active, ie at the start of the pi. In my configuration, nothing happens before I have started Opencpn (which I did not put in automatic start).
But your experience is very useful to me because I will try to put a rudder sensor and your disasters will simplify my task!
For the gains in opencpn, I would look for a bug in the way Buster treats the plugin, because it works without problems on Openplotter 1.2, with the same version of the plugin !!
So wait for returns or software updates!
For my part, I regretted the unavailability of the Voyage Data Recorder (VDR) plugin on Opencpn 5 Buster version and I found a roundabout way to install it by downloading 'libvdr.so' from Cruiserforum and placing it in / usr / lib / opencpn /; I put it as an attachment because I can no longer find the direct link, if that interests you!

bravo massilia,
You did not waste your time and it seems that you have found the reason for the problem: I had not thought of that, because, on my assembly, I did not use a rudder sensor, and it is probably for that I have not encountered this malfunction.
I think that in your configuration where pypilot is connected directly to pypilot without going through opencpn it seems normal that the adjustment is made as soon as the 2 services (pypilot and signalK) are active, ie at the start of the pi. In my configuration, nothing happens before I have started Opencpn (which I did not put in automatic start).
But your experience is very useful to me because I will try to put a rudder sensor and your disasters will simplify my task!
For the gains in opencpn, I would look for a bug in the way Buster treats the plugin, because it works without problems on Openplotter 1.2, with the same version of the plugin !!
So wait for returns or software updates!
For my part, I regretted the unavailability of the Voyage Data Recorder (VDR) plugin on Opencpn 5 Buster version and I found a roundabout way to install it by downloading 'libvdr.so' from Cruiserforum and placing it in / usr / lib / opencpn /; I put it as an attachment because I can no longer find the direct link, if that interests you!
rename the attached file with so extension.
Ciao


Attached Files
.pdf   libvdr_pi.pdf (Size: 651.98 KB / Downloads: 305)
Reply
#7
Sincerely doesn't look to me to be normal. The autopilot cannot send a command to center the rudder when I boot the PI without the AP engaged. It is also dangerous I think.

Looking at this other post seems that somebody else experienced the same issue, even if for a short moment.
http://forum.openmarine.net/showthread.p...ght=center

BTW: I've also tried to change the connections in OPENCPN to Pypilot in only output, but it's the same.


Does the pypilot service is supposed to start at PI boot? and is that supposed to send at boot any kind of data to the motor controller?

Sorry if a make stupid questions but as I said I'm really not into programming. 

Thanks in advance

@kinefu: thanks for Voyage Data Recorder (VDR) file, looks interesting, I'll have a try.
Reply
#8
The center button is supposed to center the rudder.

The bug you describe where it centers at startup, I think I fixed already but it is in the new version which is unfortunately 4 months ahead of stable and has a huge amount of changes. I'm too busy making hardware to finish software!


For now I suggest disabling rudder feedback in motor.ino or grounding the rudder feedback pin if you don't have it. The center button shouldn't be visible if no rudder feedback exists.
Reply
#9
Hi Massilia,

I understand your concerns and I do not know the answer to your problem, because the engine code is something complicated and I do not understand all the subtleties!
Reading the post on the link you mention, I see that even the creator of the program does not yet have the answer, while he is gifted and knows his program very well!
I know that signalK is launched at the start of the pi as well as pypilot which depends on it. I think that one should not consider "the engagement of the pilot" like a general switch, but that it is advisable to put a switch on the supply of the arduino. By doing this, even if the program sends an order, it will not be interpreted by your engine because its controller will be inactive. All danger is therefore averted. When you decide to go under pilot, you just have to flip the arduino switch and engage the pilot on the software.
A pragmatic way to get around this problem!
I do not know if this solution seems satisfactory to you, but I can hardly offer you better!
Good research, and if you find, I'm interested, pending a possible correction of Sean's code.

cordially
Reply
#10
Hi,

the last days I started to build up a pypilot-system.

I use a Raspberry pi3b+ as a chartplotter, running opencpn 5.2.4 on it (not openplotter) with Buster as OS.
I bought a Raspberry Zero for running tinypilot (the beta Image 11.10.2020) on it and connected it with an IMU.
I also decided to start with the modified Motor.ino and an IBT_2 Bridge.

So since yet I got the pypilot on the Zero to run.
I got the Code on the Arduino and I connected the Pi3b+, the Zero and the Arduino together.


In OpenCPN then I installed the pypilotplugin (vers. 0.22.xx).

In the Settings of the Plugin I entered the networkadress of the Zero and in the Settings of OC I set a new TCP Connection to the Zero.

So with this all come together and "speak" together.

I have the same effect, that sometimes I don´t see the gain-settings in the OC-Plugin. Sometimes they are visible, sometimes not. Mostley after I restarted the Plugin and / or I restarted OC then they comes back.  
When they are invisble it´s possible to set the gains over the web gui.
When they are back, the changes made in the webgui are shown, so this way works.

I´ll investigate this deeper (the starter to make the gainseetings invisible) when I have finished my setup.

Regards

Andreas
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)