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
RPi4 not talking to arduino motor driver
#1
Hi All
I have just built a new OpenPlotter installation on a new RPi4 with RPi foundation i2c screen. I have the pypilot arduino board connected via UART0, GPIO14/15 (as per old RPi3 install) but cannot get it to work. If I plug a USB cable from arduino to RPi4 this works. I have tried a loopback on the UART and using a CuteCom terminal program I get characters returned, so I know the port is working. The UART comes up as /dev/ttyS0. I found the "servodevice" file and changed it to read ["/dev/ttyS0", 38400] but still no joy. Using the pypilot_servo utillity (making sure pypilot was not running) I can see it trying both /dev/ttyAMA0 and /dev/ttyS0 at both 4800 and 38400 baud but it gets a device busy or not available error. The arduino works via serial if I plug it back into the old RPi3. 

Looking at permissions on /dev/tty* all are owned by root and are in dialout group, both pi and bruce are members of dialout group.

Another problem is that the screen creates all sorts of rubbish on the i2c bus, it looks reasonable easy to create an additional i2c bus, is it possible to specifiy i2c2 (or i2c4) bus for the IMU? If so which file needs to be changed?

Thanks and all the work which went into this project is very much apprieciated.

Cheers
Bruce
Reply
#2
Further to the i2c question, I now added i2c bus3 and have the IMU connected to it. "i2cdetect -y 3" can see the MPU9255 at address 0x68. I have modified ITIMULib.ini to "I2CBus=3" but pypilot_boatimu says IMU not found, also "SPI bus not found" even though BusIsI2C=true. I have also tried setting "I2CSlaveAddress=68" but no joy. Any suggeestions?
Reply
#3
(2021-11-26, 01:16 AM)MacleayIslandBruce Wrote: Further to the i2c question, I now added i2c bus3 and have the IMU connected to it. "i2cdetect -y 3" can see the MPU9255 at address 0x68. I have modified ITIMULib.ini to "I2CBus=3" but pypilot_boatimu says IMU not found, also "SPI bus not found" even though BusIsI2C=true. I have also tried setting  "I2CSlaveAddress=68" but no joy. Any suggeestions?

I might be wrong but it looks like you are trying to connect your motor controller into rpi4 with i2c.
I don't think it will work that way since i2c will only work with your gyro and environmental sensors.
The Arduino and HH bridge connection to rpi4 is the serial port
i used pins #17 for 3.3v, #6 for ground 8 and 10 for serial rx / tx.
here are the info for the pypilot own motor controller

https://pypilot.org/schematics/hbridge_datasheet.htm

i have my i2c sensors wired to the 3.3v #1 gpio pin that is why i used #17 instead.
also when you are in the serial setup program you have to give a alias to the device and select nmea 0183 as data. then you go to the connection tab and add connection to pypilot.
I hope it helps.
Reply
#4
Thanks for your reply. There are two questions, 1, serial connection to arduino motor driver and 2, i2c connection to IMU (compass, accerometer/gyro).

The arduino board is connected to RPi4 serial port, physical pins 8, 10 (GPIO14, 15), this was working on old RPi3 with older opencpn/pypilot. This is not working on the RPi4 on the GPIO pins but does work via USB, the run between boards is longer than I would like to run a USB cable, I would prefer to use a serial connection but cannot get it to work.

The IMU is on i2c bus 3 (as default i2c bus is noisy with touch screen on it), I can see it with i2cdetect and can read it with a simple python script. I haven't found how to tell pypilot that it is on bus 3. Under "Autopilot" tab is says "Detected IMU: Auto discover" but if I go into calibration there is no data from the IMU.
Reply
#5
(2021-11-26, 04:19 AM)MacleayIslandBruce Wrote: The arduino board is connected to RPi4 serial port, physical pins 8, 10 (GPIO14, 15), this was working on old RPi3 with older opencpn/pypilot. This is not working on the RPi4 on the GPIO pins but does work via USB, the run between boards is longer than I would like to run a USB cable, I would prefer to use a serial connection but cannot get it to work.

You have dtoverlay=disable-bt in your /boot/config.txt, otherwise the bluetooth adapter is hogging the uart?
Reply
#6
rtimulib2 would need slight modifications to use i2c3. Most raspberry pi don't have this. What about using i2c3 for the touch screen?

It is true you don't want lots of devices on the same i2c bus as the sensors to ensure the data is not delayed.

serial problems are usually because the default settings on pi4 won't work. The pi4 does have several other hardware uart, so it would also be interesting to try these, such as /dev/ttyAMA1
Reply
#7
Thanks Sean, I now have the arduino working on ttyAMA1, it seems happy. Yes I had already added dtoverlay=disable-bt to config.txt.

I found the touch sensing and screen can both work on the DSI bus and leave the i2c bus free.

I now have the IMU on default i2c bus and it is detected by pypilot ("Detected IMU: InvenSence MPU-9250/MPU-9255") however there is no information from the IMU, if I go into Calibration there is no info from it, in Autopilot tab always read 0. However if I use pypilot_boatimu (after killall pypilot) it finds it imediately and displays info from it. If I put the card from old RPi3 into the RPi4 the IMU works. I tried to break it by apt update/upgrade and it still works. Pypilot is now v 2.1.1 on both sd cards, New card with OpenCPN 5.5.1129 on Raspberry Pi OS doesn't get info from IMU (except by pypilot_boatimu), card with OpenCPN 5.0.0 on buster works fine. I really want to get the new install working, suggestions?

Cheers
Bruce
Reply
#8
What exactly did you do so far and what changes? /dev/ttyAMA1 is not standard and only works in theory.


what messages does pypilot display when you run it directly (after stopping services) or review the log file.
Reply
#9
(2021-11-30, 05:26 AM)MacleayIslandBruce Wrote: Pypilot is now v 2.1.1 on both sd cards

That's not the pypilot version; it's the version of the openplotter pypilot wrapper applications.

The pypilot version can be determined when you type this; current version is 0.32:
Code:
cat /usr/local/bin/pypilot


If you want to upgrade to the latest version, try 
Code:
cd
sudo systemctl stop pypilot pypilot_web pypilot_hat pypilot_boatimu
sudo rm -Rf pypilot/ pypilot_data/
git clone https://github.com/pypilot/pypilot
cd pypilot
sudo python3 setup.py install
Reply
#10
Hi Guys
Log file? ttyAMA1 seems to work, arduino Tx/Rx leds flashing, sync ok, bad fuse error on workshop arduino, okay on board where I set the fuses.

Ahh I have just made a discovery! I shutdown pypilot processes and ran it from CLI, this told me (a) it wasn't finding the config file in pi/.pypilot and (b) sensors running too slowly. (a) was because I originally installed pypilot/openCPN as user "bruce" not "pi", the config files were in bruce/.pypilot not pi/.pypilot, so I moved them to pi. Problem (b) was because I had previously put in a dtoverlay to slow down the i2c bus when I was trying to get pypilot to work with i2c bus 3. i2c is now back to bus 1, I removed the dtoverlay and hey presto pypilot can now display compass heading and I can engage pilot successfully! From the CLI I can see pypilot is v0.16, should I upgrade?

Remaining problem is that while pypilot seems to work from pypilot control shortcut, it doesn't work from openCPN shortcut, it says disconnected and there is no compass heading. I have set local host (127.0.0.1) and forward NMEA. I can see Signal K sending info (NMEA gps sentences and $APHDM, $APXDR (probably others as well) on the openCPM NMEA debug window.



I know this is really an openCPM problem rather than a pypilot problem but if you have any ideas I would love to hear them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)