Posts: 2,419
Threads: 21
Joined: Jun 2016
Reputation:
76
I would suggest leaving the motor.ino as is. It uses interrupt driven dead time generation if driving mosfet h-bridge directly, so adding additional code is not really recommended. If you are using the pwm output to an external controller you have some more room for code, but I would really suggest using a separate arduino to convert the other stuff and have that talk to the raspberry pi. That way the system is more modular, and you have a working pypilot in the standard setup without compromising performance.
Posts: 12
Threads: 2
Joined: Nov 2022
Reputation:
0
Okay, thanks Sean. You probably know best, so I will follow your advice.
Posts: 12
Threads: 2
Joined: Nov 2022
Reputation:
0
Quick update:
As suggested, I have added a separate Arduino (for now an Arduino Mega, but can 'downgrade' to any other type that has at least 2 serial ports) for the SeaTalk handling.
I have used ironman's code to create the watchlist with the parameters I want to show. This works really well.
Instead of trying bitbanging the data from the Pi to 2nd Arduino (serial port of the Pi Zero is already used for communication with the motor Arduino), I have implemented the SMBus method to use I2C communication. This is now running, seems to be very stable and the time lag is very small allready, but I can even optimise something there. I have now a time.sleep(0.5) line in the code, but I can try how far this value can be reduced without any problems.
Upto now I run the python script through SSH, so I still need to make it running as a service. I'll fix that after optimizing the code some more, and after adding so more items in the watchlist. Then I will design and mill the final PCB for the additional Arduino and put it in an enclosure.
I am actually quite pleased that I can now controll PyPilot from the Raymarine ST7002 display. Response to button presses is quite fast, data updating speed is excellent (and can even be improved easily). I have still attached my 'normal' custom control box too, and by using optocouplers I can use either this display and buttons (in which I can also access the PyPilot setup) or the Raymarine ST7002 control head.
Thanks ironman and Sean for the help!
Posts: 12
Threads: 2
Joined: Nov 2022
Reputation:
0
Is there anywhere I can find information on how to run the Python script as a service in Tinypilot? I have found some methods, but the tools used in those methods don't seem to be included in Tinypilot, and I am not familiar into Linux at all...
Posts: 2,419
Threads: 21
Joined: Jun 2016
Reputation:
76
2024-02-25, 01:20 AM
(This post was last modified: 2024-02-25, 01:20 AM by seandepagnier.)
Are you trying to add an additional service? If so you will need to add files to /etc/sv You can find the other services there. Once you have created the files (create a new folder, add the run script, "touch down" to make it by default not start and add the log folder (with run script)) you will need to create a symlink in /service
It might be helpful to execute "sudo su" to give yourself root access. Finally, you will need to edit /opt/bootlocal.sh and start the service at the appropriate place (so it doesnt slow down booting the main autopilot) and load any additional packages needed to support it.
Once you do all that be sure to run "filetool.sh -b" before rebooting or any changes you have made to the ramdisk will be lost. Please post if you get stuck anywhere or face any issues.
Posts: 12
Threads: 2
Joined: Nov 2022
Reputation:
0
Thanks again for the help!
I understand I have some reading to do, and will try to get it working after that. I will keep you posted!
Regards,
Reinier
Posts: 12
Threads: 2
Joined: Nov 2022
Reputation:
0
Hi all,
it's been quite a while (serious medical issues...) but in the meantime I have nearly completed the custom NavPod for my Raymarine ST7002 control panel. However, I still cannot get my script to run as a service. After a couple of tries that ended up having a 'frozen' SD card that I could do nothing with anymore, I ask for help again.
Is there (somewhere) a 'line-to-line' description on how to change my Python script into a service that automatically stars on bootup?
Looking at the services already existing, I cannot deduct what I would have to do to get my own script working. I am by no means a Linux guy, but I would really like to get it working, given that I have already got the hardware ready and would just like to finish this last part of the software things.
Regards,
Reinier