OpenMarine
Motor Controller Not Found - Printable Version

+- OpenMarine (https://forum.openmarine.net)
+-- Forum: Pypilot (https://forum.openmarine.net/forumdisplay.php?fid=17)
+--- Forum: General discussion (https://forum.openmarine.net/forumdisplay.php?fid=18)
+--- Thread: Motor Controller Not Found (/showthread.php?tid=4380)

Pages: 1 2 3


Motor Controller Not Found - Redline - 2022-12-21

Hi got stuck on this maybe a year ago and gave  up.
 
But this week Ire-formatted my SD card and got the latest headless download of OpenPlotter/Pypilot. 

I have one of Seans Motor controllers.  

1/ Pi 3b Running  Pypilot OpenCPN  3.2.8 ( Pypilot shows 0.36). having to run Pypilot from a Cmd line in this release of OpenCPN
2/ Motor Controller Wiring
                1/Red to Pin 17 (+3.3V)
                2/Black to Pin 9
                3/ Green Pin 8
                4/ Blue Pin 10
3/ Uart 0 is enabled ( Blue-tooth is disabled)
4/Ive tried creating an Alias in Serial (for the motor controller) but not sure if its data should be set to NMEA or SignalK or even if I need to set-up an Alias for the motor controller. ?
5/ IF I start from browser its got IMU data from my 9250 IMU, but it always says no motor controller?
6/ Ive tried swapping the rx/tx around but makes no difference. When starting up it shows that UART0 port is detected in Pypilot.
7/ in Signal k there is a ClientID and its assigned to OpenPlotter PYPILOT and has read/write access?
 
Run out of ideas again on how to get  the motor controller to talk to the RPI.  I have a 12v Power Supply hooked up to the Motor controller board in case it get its power from the 12v rather than GPIO.
 
At a loss at what to try next  Huh

See output log from pypilot_servo attached


RE: Motor Controller Not Found - Redline - 2022-12-22

note I also have a USB GPS /dongle plugged into the RPI USB port . So perhaps they are both conflicting ?


RE: Motor Controller Not Found - Redline - 2022-12-22

More output from trying to debug this issue from SSH

pi@openplotter:~/openplotter-pypilot $ ps aux | grep pypilot
pi 134 5.0 1.5 22756 14420 ? Ss 05:00 1:33 /usr/bin/python3 /usr/local/bin/pypilot
pi 135 0.4 2.8 47396 27140 ? Ssl 05:00 0:07 /usr/bin/python3 /usr/local/bin/pypilot_web 8000
pi 204 1.8 3.9 67300 36996 ? S 05:00 0:33 /usr/bin/python3 /usr/local/bin/pypilot
pi 208 1.9 0.9 21088 9304 ? D 05:00 0:34 /usr/bin/python3 /usr/local/bin/pypilot
pi 218 0.0 0.9 21348 8568 ? S 05:00 0:00 /usr/bin/python3 /usr/local/bin/pypilot
pi 219 0.8 1.9 57496 18476 ? Sl 05:00 0:15 /usr/bin/python3 /usr/local/bin/pypilot
pi 220 0.2 1.0 21640 10208 ? S 05:00 0:04 /usr/bin/python3 /usr/local/bin/pypilot
pi 221 0.4 2.2 41632 21068 ? S 05:00 0:08 /usr/bin/python3 /usr/local/bin/pypilot
pi 222 0.9 1.3 87732 12872 ? Sl 05:00 0:16 /usr/bin/python3 /usr/local/bin/pypilot
pi 2254 0.0 0.0 7452 552 pts/0 S+ 05:30 0:00 grep --color=auto pypilot
pi@openplotter:~/openplotter-pypilot $ ^C
pi@openplotter:~/openplotter-pypilot $ pypilot
autopilot start 1908.907175076
world magnetic model not available
ERROR loading wind.py cannot import name 'HeadingOffset' from partially initialized module 'pypilot.autopilot' (most likely due to a circular import) (/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py) cannot import name 'HeadingOffset' from partially initialized module 'pypilot.autopilot' (most likely due to a circular import) (/usr/local/lib/python3.9/dist-packages/pypilot/autopilot.py)
imu process 2258
nmea process 2263
nmea server on port 20220: bind failed.
gps process 2265
loading servo calibration /home/pi/.pypilot/servocalibration
WARNING: using default servo calibration!!
made imu process realtime
Using settings file RTIMULib.ini
Settings file RTIMULib.ini loaded
Available Pilots: ['basic', 'absolute']
Detected MPU9250/MPU9255 at standard address
warning: failed to open special file /dev/watchdog0 for writing
cannot stroke the watchdog
Using fusion algorithm Kalman STATE4
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
pypilotServer process 2271
pypilot_server: bind failed; already running a server?
autopilot init complete 1909.529218116
serialprobe removing gps device /dev/serial/by-id/usb-u-blox_AG_-_www.u-blox.com_u-blox_GNSS_receiver-if00
autopilot iteration running too slow 0.08062609700004941
autopilot iteration running too slow 0.10416113500014035
MPU-925x init complete
autopilot iteration running too slow 0.08566705799989904
read imu running too _slowly_ 0.06231535099982466 0.05
autopilot iteration running too slow 0.07953929199993581
read imu running too _slowly_ 0.047197312999969654 0.05
autopilot iteration running too slow 0.07240253300005861
read imu running too _slowly_ 0.05752741099990999 0.05
autopilot iteration running too slow 0.07573930699982157
gps filter process 2266
read imu running too _slowly_ 0.04681164599992371 0.05
autopilot iteration running too slow 0.07093131200008429
nmea server on port 20220: bind failed.
read imu running too _slowly_ 0.05663179999987733 0.05
autopilot iteration running too slow 0.07669736399998328
failed to read IMU! 1910.508612582
Detected MPU9250/MPU9255 at standard address
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
autopilot iteration running too slow 0.09414317900018432
autopilot iteration running too slow 0.09262643200008824
I2C read error from 12, 16 - Failed to read compass fuse ROM
autopilot iteration running too slow 0.09308777899991583
ERROR: IMU Init Failed, no inertial data available 1910.509780428
imu process failed to keep time 0.3143623060000209 1910.508597062 1910.82277786 1910.822861557 1910.822956816
autopilot iteration running too slow 0.09307736300002034
autopilot iteration running too slow 0.09306939299995065
autopilot iteration running too slow 0.09316147799995633
autopilot iteration running too slow 0.09319122200008678
nmea server on port 20220: bind failed.
gpsd connected
autopilot iteration running too slow 0.09320116899993991
GPSD devices ['/dev/ttyACM0']
IMURead failed!
Detected MPU9250/MPU9255 at standard address
autopilot iteration running too slow 0.09436005699990346
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
autopilot iteration running too slow 0.09207092800011196
autopilot iteration running too slow 0.09418526900003599
autopilot iteration running too slow 0.09213306199990257
MPU-925x init complete
imu process failed to keep time 0.473758068999814 1911.523605772 1911.997177385 1911.997265144 1911.997361133
autopilot iteration running too slow 0.0941790189999665
read imu running too _slowly_ 0.052199483999856966 0.05
autopilot iteration running too slow 0.07334310600003846
read imu running too _slowly_ 0.05207042300003195 0.05
autopilot iteration running too slow 0.07433710100008284
sensor found gps gpsd /dev/ttyACM0 Thu Dec 22 05:32:05 2022
nmea server on port 20220: bind failed.
read imu running too _slowly_ 0.05169725199993991 0.05
autopilot iteration running too slow 0.07388554600015595
pypilot_server: bind failed; already running a server?
read imu running too _slowly_ 0.05170928300003652 0.05
autopilot iteration running too slow 0.07308264099992812
failed to read IMU! 1912.598042784
Detected MPU9250/MPU9255 at standard address
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
autopilot iteration running too slow 0.09345872500011865
autopilot iteration running too slow 0.09336679900002309
I2C read error from 12, 16 - Failed to read compass fuse ROM
autopilot iteration running too slow 0.09327404000009665
ERROR: IMU Init Failed, no inertial data available 1912.599156151
imu process failed to keep time 0.31396267200011607 1912.598026794 1912.911793063 1912.911887645 1912.911986706
autopilot iteration running too slow 0.09349346400017566
autopilot iteration running too slow 0.09329898800001502
autopilot iteration running too slow 0.09351300200000878
autopilot iteration running too slow 0.0938229969999611
nmea server on port 20220: bind failed.
autopilot iteration running too slow 0.09247150800001691
IMURead failed!
autopilot iteration running too slow 0.09444064300009813
Detected MPU9250/MPU9255 at standard address
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
autopilot iteration running too slow 0.09299951999992118
autopilot iteration running too slow 0.0941132010000274
autopilot iteration running too slow 0.09298686500005715
MPU-925x init complete
imu process failed to keep time 0.47451140900011524 1913.612716294 1914.087009269 1914.087119059 1914.087224943
autopilot iteration running too slow 0.09404153499986023
autopilot iteration running too slow 0.050408895000146
read imu running too _slowly_ 0.05272000500008289 0.05
autopilot iteration running too slow 0.0731359850001354
nmea server on port 20220: bind failed.
read imu running too _slowly_ 0.05266458899995996 0.05
autopilot iteration running too slow 0.07507767399988552
read imu running too _slowly_ 0.05234084299991082 0.05
autopilot iteration running too slow 0.0726946909999242
server/client is running too _slowly_ 0.12773085599997103
autopilot iteration running too slow 0.1304317510000601
failed to read IMU! 1914.788104802
Detected MPU9250/MPU9255 at standard address
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
autopilot iteration running too slow 0.09356056000001445
autopilot iteration running too slow 0.09479736299999786
I2C read error from 12, 16 - Failed to read compass fuse ROM
autopilot iteration running too slow 0.09375243199997385
ERROR: IMU Init Failed, no inertial data available 1914.789231191
imu process failed to keep time 0.314806924000095 1914.788089386 1915.102635689 1915.102775791 1915.102893706
autopilot iteration running too slow 0.0936354590000974
autopilot iteration running too slow 0.09442294899986337
nmea server on port 20220: bind failed.
signalk process 2264
autopilot iteration running too slow 0.09373920999996699
pypilot_server: bind failed; already running a server?
calibration loaded, starting 2257
signalkread token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2UiOiI2ZjkxNDlhNy0xMTAzLTRlNmQtODc1NC03ODcwMjRkNDM1NjQiLCJpYXQiOjE2NzE1MTQ5MjksImV4cCI6MTcwMzA3MjUyOX0.KeRv5Sl2Wn4Hl7NZPL1G1rrMdgc5mvaR9yIpMvrutYo


RE: Motor Controller Not Found - seandepagnier - 2022-12-22

if you see "bind_failed" it means another instance of pypilot is running.

First verify the serial port:
ls -l /dev/serial0

it should point to /dev/ttyAMA0

Next stop pypilot:
sudo service pypilot stop


Now try running on the console pypilot_servo, and check the results. You may need to add /dev/ttyAMA0 to the list of serial ports pypilot can use.


RE: Motor Controller Not Found - Redline - 2022-12-22

(2022-12-22, 04:00 PM)seandepagnier Wrote: if you see "bind_failed"   it means another instance of pypilot is running.

First verify the serial port:
ls -l /dev/serial0

it should point to /dev/ttyAMA0

Next stop pypilot:
sudo service pypilot stop


Now try running on the console pypilot_servo, and check the results.    You may need to add /dev/ttyAMA0 to the list of serial ports pypilot can use.

Hi Sean 

Thanks for taking the time to look at this.  Probably when I last ran the servo diagnostic, I may have already been runnnig the service directly on the pi then tried the servo cmd from SSH. Anyhow having made sure no Pypilot service was running this is still the output :

pi@openplotter:~/openplotter-pypilot $ pypilot_servo
pypilot Servo
world magnetic model not available
nmea process 1988
listening on port 20220 for nmea connections
gps process 1990
loading servo calibration /home/pi/.pypilot/servocalibration
WARNING: using default servo calibration!!
serialprobe removing gps device /dev/serial/by-id/usb-u-blox_AG_-_www.u-blox.com_u-blox_GNSS_receiver-if00
pypilotServer process 1992
server setup has 4 pipes
zeroconf addresses ['127.0.0.1', '192.168.1.86', '10.10.10.1'] 3
gps filter process 1991
gpsd connected
GPSD devices ['/dev/ttyACM0']
sensor found gps gpsd /dev/ttyACM0 Thu Dec 22 20:29:37 2022
servo probe ('/dev/ttyAMA0', 38400) 249.440488942
signalk process 1989
signalkread token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2UiOiI2ZjkxNDlhNy0xMTAzLTRlNmQtODc1NC03ODcwMjRkNDM1NjQiLCJpYXQiOjE2NzE1MTQ5MjksImV4cCI6MTcwMzA3MjUyOX0.KeRv5Sl2Wn4Hl7NZPL1G1rrMdgc5mvaR9yIpMvrutYo
signalk server found 127.0.0.1:3000
signalk server found 192.168.1.86:3000
signalk found ws://192.168.1.86:3000/signalk/v1/stream?subscribe=none
signalk connected to ws://192.168.1.86:3000/signalk/v1/stream?subscribe=none
servo probe ('/dev/ttyAMA0', 38400) 263.763158924
failed to open servo on: ('/dev/ttyAMA0', 38400) [Errno 16] could not open port /dev/ttyAMA0: [Errno 16] Device or resource busy: '/dev/ttyAMA0'
servo probe ('/dev/ttyAMA0', 38400) 273.963329599
failed to open servo on: ('/dev/ttyAMA0', 38400) [Errno 16] could not open port /dev/ttyAMA0: [Errno 16] Device or resource busy: '/dev/ttyAMA0'
^CProcess Process-5:
Process Process-2:
Traceback (most recent call last):
  File "/usr/local/bin/pypilot_servo", line 33, in <module>
Traceback (most recent call last):
  File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/dist-packages/pypilot/server.py", line 411, in run
    time.sleep(st)
KeyboardInterrupt
    sys.exit(load_entry_point('pypilot==0.36', 'console_scripts', 'pypilot_servo')())
  File "/usr/local/lib/python3.9/dist-packages/pypilot/servo.py", line 820, in main
    time.sleep(dt)
KeyboardInterrupt
Traceback (most recent call last):
  File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/dist-packages/pypilot/signalk.py", line 261, in process
    self.poll(1)
  File "/usr/local/lib/python3.9/dist-packages/pypilot/signalk.py", line 288, in poll
    self.client.poll(timeout)
  File "/usr/local/lib/python3.9/dist-packages/pypilot/client.py", line 277, in poll
    events = self.poller.poll(int(1000 * timeout))
KeyboardInterrupt

In the end I'm not so much interested with this working with openplotter. 

I just ideally want a working instance of Pypilot. 

So if installing it on a clean RPI image would work better, then happy to do that. Ive seen you have a tinypilot that works on a Pi ZeroW, but they are hard to find these days in Nz.

Anyhow, I've tried so many different options with the serial ports that I'm gradually making things worse, and might be time to start from scratch with a clean install again?


RE: Motor Controller Not Found - Redline - 2022-12-23

I have never seen anything other than a RED led light on the motor controller board (when its hooked upto 12v)
I'm assuming you don't need to have 12V hooked up unless wanting to test the actual motor drive, as the motor contoller board is hooked up to the 3.3V Supply on the RPI?

Swapping the serial UART RX/TX pins also so far hasn't made a difference.

I've even unplugged the USB/GPS  and deleted it from the Serial 3.2.0 Console , so that if that's the source of the conflict, then I'll happily run without, but assumed some basic COG/SOG data would be needed by Pypilot? 

When you say  You may need to add /dev/ttyAMA0 to the list of serial ports pypilot can use, where should I do that, in Serial,  Signal K, or a config file  or a .PY etc? 

Thanks


RE: Motor Controller Not Found - seandepagnier - 2022-12-23

You do need to supply 12 volts to the motor controller for it to have power. The power is isolated from the raspberry.

You can add /dev/ttyAMA0 to ~/.pypilot/serial_ports or it should be possible to add using the openplotter-pypilot gui.

You have:
failed to open servo on: ('/dev/ttyAMA0', 38400) [Errno 16] could not open port /dev/ttyAMA0: [Errno 16] Device or resource busy: '/dev/ttyAMA0'


Maybe you are running bluetooth services which are trying to use /dev/ttyAMA0 ? I would find out why the device is busy.


RE: Motor Controller Not Found - ironman - 2022-12-23

I thought there was someting with the gps module having hi-jacked the serial. Never got that part really:


Code:
gpsd connected
GPSD devices ['/dev/ttyACM0']
sensor found gps gpsd /dev/ttyACM0 Thu Dec 22 20:29:37 2022



RE: Motor Controller Not Found - Redline - 2022-12-24

Reformatted my SD Card and again put latest OpenPlotter 3.x on the card

then installed Pypilot as per :
https://forum.openmarine.net/showthread.php?tid=4210&pid=23542#pid23542.

Have not as yet plugged anything into the RPI so should be no com port conflicts.  
Don't think its installed Pypilot correctly now see below.  

Following those instructions to the letter it completes the install but there is an error in the Post installtion actions window.
So now I cant even run any of the utils to chk what port are in use.

pi@openplotter:~ $ cd openplotter-pypilot
pi@openplotter:~/openplotter-pypilot $ sudo service pypilot stop
Failed to stop pypilot.service: Unit pypilot.service not loaded.
pi@openplotter:~/openplotter-pypilot $
pi@openplotter:~/openplotter-pypilot $
pi@openplotter:~/openplotter-pypilot $ ls -l /dev/serial0
lrwxrwxrwx 1 root root 7 Dec 24 03:27 /dev/serial0 -> ttyAMA0
pi@openplotter:~/openplotter-pypilot $ pypilot
-bash: pypilot: command not found
pi@openplotter:~/openplotter-pypilot $ py_pilot_servo
-bash: py_pilot_servo: command not found
pi@openplotter:~/openplotter-pypilot $

(2022-12-24, 04:50 AM)Redline Wrote: Reformatted my SD Card and again put latest OpenPlotter 3.x on the card

then installed Pypilot as per :
https://forum.openmarine.net/showthread.php?tid=4210&pid=23542#pid23542.

Have not as yet plugged anything into the RPI so should be no com port conflicts.  
Don't think its installed Pypilot correctly now see screen cap .      

Following those instructions to the letter it completes the install but there is an error in the Post installation actions window.
So now I cant even run any of the utils to chk what port are in use.

pi@openplotter:~ $ cd openplotter-pypilot
pi@openplotter:~/openplotter-pypilot $ sudo service pypilot stop
Failed to stop pypilot.service: Unit pypilot.service not loaded.
pi@openplotter:~/openplotter-pypilot $
pi@openplotter:~/openplotter-pypilot $
pi@openplotter:~/openplotter-pypilot $ ls -l /dev/serial0
lrwxrwxrwx 1 root root 7 Dec 24 03:27 /dev/serial0 -> ttyAMA0
pi@openplotter:~/openplotter-pypilot $ pypilot
-bash: pypilot: command not found
pi@openplotter:~/openplotter-pypilot $ py_pilot_servo
-bash: py_pilot_servo: command not found
pi@openplotter:~/openplotter-pypilot $

Not sure anyone has tried to install Openplotter 3.x and OpenPlotter-Pypilot  3.2.9 on a clean build with a motor controller attached as its either not working or latest builds have bugs.   Not really sure where to go from here?  As after a clean install Im even further away from being able to do anything with pypilot at all.  Withotu a functional motor contoller interface I cant use it.  Off away on the boat tomorrow, but with no functional Autopilot.  Happy to be a bug tester if there are functional builds. 
Cheers



RE: Motor Controller Not Found - seandepagnier - 2022-12-25

Hi

Sorry this is because... I use spaces and sailoog uses tabs and I made a mistake merging some scripts.

I corrected in git, if you can pull from:
https://github.com/pypilot/openplotter-pypilot

Just issue
sudo python3 setup.py install


Also consider using a tinypilot image for a pi 3b at least as backup on another sd card since it would avoid configuration and pitfalls.

I will try to make a video setting up openplotter