Posts: 18
Threads: 4
Joined: Aug 2018
Reputation:
1
2018-09-08, 04:10 PM
(This post was last modified: 2018-09-11, 06:12 PM by nvelthuijsen.)
I like to use the GPIO outputs on a raspberry pi to drive an electrical hydraulic pump which allready has two relays for polarisation. I will put in a couple of transistors to drive the relays. But how about the sw? I have no experience with python etc. so do not know how to start.
Anyone experience with using the outputs in OpenPlotter?
Niels.
Posts: 229
Threads: 57
Joined: Mar 2016
Reputation:
7
2018-09-08, 04:46 PM
(This post was last modified: 2018-09-08, 04:49 PM by affinite.)
Welcome to the forum
You dont need to do any Python programming.
A Node Red node can be used to drive the GPIO pins. I do this to control (using PWM) a cooling fan for the Pi
see this post http://forum.openmarine.net/showthread.php?tid=1093
Posts: 2,314
Threads: 21
Joined: Jun 2016
Reputation:
72
For the autopilot you would not be using node red. While in theory it is possible, there is too much lag and node read is not meant for real time applications.
Yes you can use the pi gpio directly, but you still need a way to detect the rudder stops. If you use switches, you can use gpio input for those. Otherwise, rudder-feedback and motor stall detection both require analog to digital converter as well as monitoring temperature and voltages, and a way to isolate the raspberry. So for my controllers I already have a uC no reason to use the raspberry gpio, that is why I don't use it.
Posts: 229
Threads: 57
Joined: Mar 2016
Reputation:
7
2018-09-08, 09:14 PM
(This post was last modified: 2018-09-08, 09:16 PM by affinite.)
Woops, I hadnt spotted that this was in the PyPilot forum, it just came up in my "new posts" list
Posts: 18
Threads: 4
Joined: Aug 2018
Reputation:
1
2018-09-09, 09:58 AM
(This post was last modified: 2018-09-09, 10:09 AM by nvelthuijsen.)
(2018-09-08, 06:01 PM)seandepagnier Wrote: For the autopilot you would not be using node red. While in theory it is possible, there is too much lag and node read is not meant for real time applications.
Yes you can use the pi gpio directly, but you still need a way to detect the rudder stops. If you use switches, you can use gpio input for those. Otherwise, rudder-feedback and motor stall detection both require analog to digital converter as well as monitoring temperature and voltages, and a way to isolate the raspberry. So for my controllers I already have a uC no reason to use the raspberry gpio, that is why I don't use it.
Hi Sean,
Thanks for your reply. I indeed want to use switches to detect the rudderstops and use the GPIO inputs.
Can you tell me how to configure openplotter/pypilot on a raspberry pi to use these GPIO pins for input and output?
Thanks and keep up the good work!
Posts: 2,314
Threads: 21
Joined: Jun 2016
Reputation:
72
Currently the "arduino" motor controller is what is supported by pypilot, but other controller setups like rpi gpio could be supported.
For your case, you need 2 outputs. This could be one to move the motor in each direction, or one output to engage, and another to specify the motor direction. The second way is safer in case you activate both outputs at the same time it will not cause a short.
I recommend using a magnet and magnetic reed switches for the end of travel stops but hall sensors are possible.
You may wish to make the schematic so that the reed switches actually deactivate the output signal. This way it doesn't rely on software to deactivate the rudder movement which has a lag, and might not work if there is a software issue. This is the best fail-safe. You can do this with 2 resistors. Let me know if you need a schematic.
At this point you should be able to control the rudder just using the gpio command. Once you get to this point it is really easy to write a simple driver for the pypilot servo... I can even do this bit once you get there, keep posting your progress and pictures if possible would be nice.
You may also wish to wire these reed sensor inputs to gpio inputs to report the end of travel condition through software so you will see it when controlling the autopilot. This part is optional since I don't recommend using software on the raspberry to react to the end of travel (better to use resistors)
Posts: 18
Threads: 4
Joined: Aug 2018
Reputation:
1
(2018-09-10, 06:50 PM)seandepagnier Wrote: Currently the "arduino" motor controller is what is supported by pypilot, but other controller setups like rpi gpio could be supported.
For your case, you need 2 outputs. This could be one to move the motor in each direction, or one output to engage, and another to specify the motor direction. The second way is safer in case you activate both outputs at the same time it will not cause a short.
I recommend using a magnet and magnetic reed switches for the end of travel stops but hall sensors are possible.
You may wish to make the schematic so that the reed switches actually deactivate the output signal. This way it doesn't rely on software to deactivate the rudder movement which has a lag, and might not work if there is a software issue. This is the best fail-safe. You can do this with 2 resistors. Let me know if you need a schematic.
At this point you should be able to control the rudder just using the gpio command. Once you get to this point it is really easy to write a simple driver for the pypilot servo... I can even do this bit once you get there, keep posting your progress and pictures if possible would be nice.
You may also wish to wire these reed sensor inputs to gpio inputs to report the end of travel condition through software so you will see it when controlling the autopilot. This part is optional since I don't recommend using software on the raspberry to react to the end of travel (better to use resistors)
Check. But......
Yesterday i received a Arduino UNO from a colleague. So i can built the controller with the Arduino. I managed to get your software on the Arduino and it looks like OpenPlotter is communicating, i can see serial communication going on on the Arduino. I'm now looking into your sw. I noticed that you can drive the H Bridge as well, so my intention now is to use this setup.
I pulled the sensing pin 6 down (0) to "enable HBridge mode". I expected pins 2,3,9,10 to react when moving the rudder in OpenPlotter PyPilot Autopilot control. Nothing happens. Do i need to pull up or pull down other sensing lines before motorcontrol will be initiated? I tried to find out in the code, but it is a bit difficult to reverse-engineer the sw.
Kind regards, Niels.
Posts: 801
Threads: 46
Joined: Jun 2017
Reputation:
25
2018-09-11, 02:08 PM
(This post was last modified: 2018-09-11, 02:10 PM by jim321.)
i think you need to edit program not ground the pin.
Sean will correct me if i am wrong..
#define rc_pwm_pin 6 // todo: use this pin to detect rc pwm
uint8_t rc_pwm = 0; // remote control style servo
Posts: 18
Threads: 4
Joined: Aug 2018
Reputation:
1
(2018-09-11, 02:08 PM)jim321 Wrote: i think you need to edit program not ground the pin.
Sean will correct me if i am wrong..![Smile Smile](https://forum.openmarine.net/images/smilies/smile.png)
#define rc_pwm_pin 6 // todo: use this pin to detect rc pwm
uint8_t rc_pwm = 0; // remote control style servo
Mmmm, makes sense! Hope the Arduino is still alive....
Thx Jim
73s Niels.
Posts: 18
Threads: 4
Joined: Aug 2018
Reputation:
1
(2018-09-11, 02:23 PM)nvelthuijsen Wrote: (2018-09-11, 02:08 PM)jim321 Wrote: i think you need to edit program not ground the pin.
Sean will correct me if i am wrong..![Smile Smile](https://forum.openmarine.net/images/smilies/smile.png)
#define rc_pwm_pin 6 // todo: use this pin to detect rc pwm
uint8_t rc_pwm = 0; // remote control style servo
Mmmm, makes sense! Hope the Arduino is still alive....
Thx Jim
73s Niels. Arduino still OK! Though i'm still doubting how this should work. I still think i have to wire the pin otherwise it cannot be read.....
Maybe Sean can fill me in.
Anyone already figured out which pins are mandatory and which are optional? I want to use it as driver for a H Bridge controller. It is difficult to figure this out. A schematics with mandatory and optional wiring would be nice. Anyone? Sean?
|