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.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using pi gpio outputs / pins arduino
#1
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.
  Reply
#2
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
  Reply
#3
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.
  Reply
#4
Woops, I hadnt spotted that this was in the PyPilot forum, it just came up in my "new posts" list
  Reply
#5
Photo 
(09-08-2018, 01: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
  Reply
#6
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)
  Reply
#7
(09-10-2018, 01: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.
  Reply
#8
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
  Reply
#9
(09-11-2018, 09:08 AM)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.
  Reply
#10
(09-11-2018, 09:23 AM)nvelthuijsen Wrote:
(09-11-2018, 09:08 AM)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?
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)