OpenMarine
using pi gpio outputs / pins arduino - 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: using pi gpio outputs / pins arduino (/showthread.php?tid=1463)

Pages: 1 2


using pi gpio outputs / pins arduino - nvelthuijsen - 2018-09-08

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.


RE: using gpio outputs - affinite - 2018-09-08

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


RE: using gpio outputs - seandepagnier - 2018-09-08

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.


RE: using gpio outputs - affinite - 2018-09-08

Woops, I hadnt spotted that this was in the PyPilot forum, it just came up in my "new posts" list


RE: using gpio outputs - nvelthuijsen - 2018-09-09

(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! Wink


RE: using gpio outputs - seandepagnier - 2018-09-10

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)


RE: using gpio outputs - nvelthuijsen - 2018-09-11

(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.


RE: using gpio outputs - jim321 - 2018-09-11

i think you need to edit program not ground the pin.
Sean will correct me if i am wrong..Smile

#define rc_pwm_pin 6 // todo: use this pin to detect rc pwm
uint8_t rc_pwm = 0; // remote control style servo


RE: using gpio outputs - nvelthuijsen - 2018-09-11

(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

#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.


RE: using gpio outputs - nvelthuijsen - 2018-09-11

(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

#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?