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:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pypilot working on my Nicholson 44
#51
what do you mean the other way around for pin faults?

There is currently only clutch pwm not clutch time.

You can simply run:

pypilot_client servo.clutch_pwm=50

if pypilot is running

if not running edit ~/.pypilot/pypilot.conf
Reply
#52
Thank you so much for your help! I will be back with the results on the PWM clutch soon.

I am pairing this Pypilot installation with the Neco drive that already has built-in end switches and a rudder position potentiometer. The end switches short out when the end of travel is reached, so they work just the other way than your code was written. I have deleted the exclamation mark in your code as follows:

Altered code:

// test fault pins
if(digitalRead(port_fault_pin)) {
stop_port();
flags |= PORT_PIN_FAULT;
} else
flags &= ~PORT_PIN_FAULT;

if(digitalRead(starboard_fault_pin)) {
stop_starboard();
flags |= STARBOARD_PIN_FAULT;
} else
flags &= ~STARBOARD_PIN_FAULT;

Original code:

// test fault pins
if(!digitalRead(port_fault_pin)) {
stop_port();
flags |= PORT_PIN_FAULT;
} else
flags &= ~PORT_PIN_FAULT;

if(!digitalRead(starboard_fault_pin)) {
stop_starboard();
flags |= STARBOARD_PIN_FAULT;
} else
flags &= ~STARBOARD_PIN_FAULT;
Reply
#53
(2021-05-25, 02:44 PM)seandepagnier Wrote: You can simply run:

pypilot_client servo.clutch_pwm=50

if pypilot is running

if not running edit ~/.pypilot/pypilot.conf

I have Pypilot 2.1.1-beta. The arduino code is the one on github updated a few days ago.

Editing pypilot.conf there is no variable that resembles servo.clutch_pwm. I only have:

"servo.faults": 26179,

 "servo.max_current": 20.0,
 "servo.current.factor": 1,
 "servo.current.offset": 0,
 "servo.voltage.factor": 1,
 "servo.voltage.offset": 0,
 "servo.max_controller_temp": 60,
 "servo.max_motor_temp": 60,
 "servo.max_slew_speed": 10.236220472440944,
 "servo.max_slew_slow": 8.267716535433072,
 "servo.gain": 1,
 "servo.period": 1.0,
 "servo.compensate_current": false,
 "servo.compensate_voltage": false,
 "servo.amp_hours": 121.23307400571649,
 "servo.speed.min": 25.0,
 "servo.speed.max": 100,
"servo.position.p": 0.15,

 "servo.position.i": 0,
 "servo.position.d": 0.02,
 "servo.use_eeprom": true,
 "servo.disengage_on_timeout": true,

Running pypilot_client servo.clutch_pwm=50 in the Terminal gives me:

Traceback (most recent call last):

  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 156, in receive_line
    msg = json.loads(line.rstrip())
  File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/pypilot_client", line 11, in <module>
    load_entry_point('pypilot==0.16', 'console_scripts', 'pypilot_client')()
  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 383, in main
    msg = client.receive_single(.1)
  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 207, in receive_single
    line = self.receive_line(timeout)
  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 172, in receive_line
    return self.receive_line(timeout - dt)
  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 158, in receive_line
    raise Exception('invalid message from server:', line)
Exception: ('invalid message from server:', 'invalid request: set unknown value: servo.clutch_pwm')

Uninstalling and reinstalling Pypilot did not solve the issue.
Reply
#54
(2021-05-30, 07:07 AM)Kris Wrote: Thank you so much for your help! I will be back with the results on the PWM clutch soon.

I am pairing this Pypilot installation with the Neco drive that already has built-in end switches and a rudder position potentiometer. The end switches short out when the end of travel is reached, so they work just the other way than your code was written. I have deleted the exclamation mark in your code as follows:

Altered code:re
It is normal for the switch to short at end of travel. You should short the pin to gnd so it goes low when the switch is closed and the internal pullup keeps it high when open. i'm not sure how you wired it, but I don't think you want to change the code since there are not internal pulldowns, or at least you are complicating the design with external resistors.

Unless you mean your switch is normally closed and only opens at end of travel??
(2021-05-30, 04:18 PM)Kris Wrote: Traceback (most recent call last):
  File "/usr/local/bin/pypilot_client", line 11, in <module>
    load_entry_point('pypilot==0.16', 'console_scripts', 'pypilot_client')()
  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 383, in main
    msg = client.receive_single(.1)
  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 207, in receive_single
    line = self.receive_line(timeout)
  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 172, in receive_line
    return self.receive_line(timeout - dt)
  File "/usr/local/lib/python3.7/dist-packages/pypilot-0.16-py3.7-linux-armv7l.egg/pypilot/client.py", line 158, in receive_line
    raise Exception('invalid message from server:', line)
Exception: ('invalid message from server:', 'invalid request: set unknown value: servo.clutch_pwm')

Uninstalling and reinstalling Pypilot did not solve the issue.

You have to run "sudo python3 setup.py install" twice
Reply
#55
Quote:It is normal for the switch to short at end of travel.   You should short the pin to gnd so it goes low when the switch is closed and the internal pullup keeps it high when open.   i'm not sure how you wired it, but I don't think you want to change the code since there are not internal pulldowns, or at least you are complicating the design with external resistors.

Unless you mean your switch is normally closed and only opens at end of travel??

Sorry for taking up your time on this while I did not remember all the details right. I made a big switch box in order to be able to switch back to the good old trusty Neco control box for redundancy reasons. The switch box is already quite big and complicated. It switches the power, the main coil, the shunt coil and serial coil, the clutch coil, the end of travel switches and the rudder angle back and forth between the PyPilot and the Neco control box. I could not easily change to where and when the end of travel switches short to while keeping the Neco control box operational as well. Changing the code was easier than more wiring. Now that I started 3d printing everything, I will make a new separate rudder position sensor as well as separate end switches for the Pypilot, and keep the old end switches and rudder position sensor wired permanently to the Neco control box. It will be great for redundancy and simplicity of the switch box, and I will get to keep your original code.


Quote:You have to run "sudo python3 setup.py install" twice

Running this in the terminal gives me: "python3: can't open file 'setup.py': [Errno 2] No such file or directory"

I also tried typing "sudo apt-get install python3"
It gives me this:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3 is already the newest version (3.7.3-1).
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.

I then tried to upgrade to python 3.9.5. following instruction here: https://itheo.nl/install-python-3-9-on-raspberry-pi

When I get to: "sudo update-alternatives --config python"

It says: "update-alternatives: error: no alternatives for python"

Then I follow the troubleshooting part and: nano ~/.bashrc
But there is nothing that looks like "alias python=/usr/bin/python-3.8" in the file.

I think I am thrown a bit off course, or am I not? I am a newbie to the Linux ecosystem.
Reply
#56
Sean and Kris, I've been reading this thread with great interest. I have a Nicholson 38 ketch with a 12v Neco installation and have a Tinypilot with Sean's Pypilot motor controller ready to connect up to the existing Neco relays once I manage to get down to the boat for a prolonged period. I'm very interested in not using relays and benefiting from motor current sensing, reduced power etc, but I'm not experienced enough with this stuff to fully understand. Are you using the IBT-2 motor controller or the Pololu one? How is it connected to the Pypilot and to the Neco motor unit? Do you have any diagrams? Thanks in advance for any tips and pointers.
Reply
#57
(2021-06-01, 08:23 PM)Phil_Shotton Wrote: Sean and Kris, I've been reading this thread with great interest. I have a Nicholson 38 ketch with a 12v Neco installation and have a Tinypilot with Sean's Pypilot motor controller ready to connect up to the existing Neco relays once I manage to get down to the boat for a prolonged period. I'm very interested in not using relays and benefiting from motor current sensing, reduced power etc, but I'm not experienced enough with this stuff to fully understand. Are you using the IBT-2 motor controller or the Pololu one? How is it connected to the Pypilot and to the Neco motor unit? Do you have any diagrams? Thanks in advance for any tips and pointers.

Hey Phil, I can only encourage you to install the Tinypilot, as it is a far superior solution to the Neco control unit. Current sensing is great, but I think controlling motor PWM is waaaay cooler, as it lets you drive to motor much more smoothly and efficiently. I am not sure if Sean·s motor controller lets you drive the Neco to the max as I do not remember the max current. My Neco takes 24 volts and peaks around 200-300watts, so that should be around 20 amps on your 12 volt system. I use the IBT2 that handles up to 44 amps. My Neco on 24 volt only takes around 10 amps max, so the IBT2 is ample strong and probably long lived.

The Neco has a motor that is a bit more complex. There is a diagram and a description that was done by Daniele Fua, a really cool guy who was of much help to the community. You can find the documents posted earlier here in this thread. If your Neco control unit does not work anymore, you can just convert to the Tinypilot. I am a liveaboard cruiser and I opted for a switch box to be able to use both controls for redundancy. If you go for the full conversion, you can relatively easily reuse the end switches and the rudder angle sensor integrated into the Neco drive unit.

With the relays the motor is controlled at 100% juice and then forced to a halt, as the relays short the coil of the motor, thus magnetically braking the movement of the motor. This is a reliable but power hungry solution. The H-Bridge in Sean·s driver can nicely start and stop the motor and does not brake the motor like using the relays does. On the other hand there is a voltage drop on the H-Bridge but given how little the motor controller heats up during use, I do not think there is much energy lost there.

At the moment I am just trying to implement the last update of Sean, and drive the clutch with a PWM signal instead of an always-on signal when engaged. My clutch coil takes around 30-40 watts. It stays engaged with around 33% PWM so there is around 20 last watts to be saved with this last update.
Reply
#58
oh, be careful I think it only works at 8mhz currently reliably I need to review it again
Reply
#59
(2021-06-01, 09:34 PM)Kris Wrote:
(2021-06-01, 08:23 PM)Phil_Shotton Wrote: Sean and Kris, I've been reading this thread with great interest. I have a Nicholson 38 ketch with a 12v Neco installation and have a Tinypilot with Sean's Pypilot motor controller ready to connect up to the existing Neco relays once I manage to get down to the boat for a prolonged period. I'm very interested in not using relays and benefiting from motor current sensing, reduced power etc, but I'm not experienced enough with this stuff to fully understand. Are you using the IBT-2 motor controller or the Pololu one? How is it connected to the Pypilot and to the Neco motor unit? Do you have any diagrams? Thanks in advance for any tips and pointers.

Hey Phil, I can only encourage you to install the Tinypilot, as it is a far superior solution to the Neco control unit. Current sensing is great, but I think controlling motor PWM is waaaay cooler, as it lets you drive to motor much more smoothly and efficiently. I am not sure if Sean·s motor controller lets you drive the Neco to the max as I do not remember the max current. My Neco takes 24 volts and peaks around 200-300watts, so that should be around 20 amps on your 12 volt system. I use the IBT2 that handles up to 44 amps. My Neco on 24 volt only takes around 10 amps max, so the IBT2 is ample strong and probably long lived.

The Neco has a motor that is a bit more complex. There is a diagram and a description that was done by Daniele Fua, a really cool guy who was of much help to the community. You can find the documents posted earlier here in this thread. If your Neco control unit does not work anymore, you can just convert to the Tinypilot. I am a liveaboard cruiser and I opted for a switch box to be able to use both controls for redundancy. If you go for the full conversion, you can relatively easily reuse the end switches and the rudder angle sensor integrated into the Neco drive unit.

With the relays the motor is controlled at 100% juice and then forced to a halt, as the relays short the coil of the motor, thus magnetically braking the movement of the motor. This is a reliable but power hungry solution. The H-Bridge in Sean·s driver can nicely start and stop the motor and does not brake the motor like using the relays does. On the other hand there is a voltage drop on the H-Bridge but given how little the motor controller heats up during use, I do not think there is much energy lost there.

At the moment I am just trying to implement the last update of Sean, and drive the clutch with a PWM signal instead of an always-on signal when engaged. My clutch coil takes around 30-40 watts. It stays engaged with around 33% PWM so there is around 20 last watts to be saved with this last update.

Thanks for the update Kris. I've had long email exchanges with Daniele Fua, a really helpful guy. I went with Sean's motor controller planning to use the Neco relays, but the lower current consumption and better control of direct motor control seems like a good idea. The Neco drive unit is fused at 25 amps and probably peaks at around 20, so I don't think the motor controller will handle that. I'm looking at a Pololu unit to handle the current. Any info on the best way to control it would be really helpful.
Reply
#60
(2021-06-03, 09:05 PM)Phil_Shotton Wrote:
(2021-06-01, 09:34 PM)Kris Wrote:
(2021-06-01, 08:23 PM)Phil_Shotton Wrote: Sean and Kris, I've been reading this thread with great interest. I have a Nicholson 38 ketch with a 12v Neco installation and have a Tinypilot with Sean's Pypilot motor controller ready to connect up to the existing Neco relays once I manage to get down to the boat for a prolonged period. I'm very interested in not using relays and benefiting from motor current sensing, reduced power etc, but I'm not experienced enough with this stuff to fully understand. Are you using the IBT-2 motor controller or the Pololu one? How is it connected to the Pypilot and to the Neco motor unit? Do you have any diagrams? Thanks in advance for any tips and pointers.

Hey Phil, I can only encourage you to install the Tinypilot, as it is a far superior solution to the Neco control unit. Current sensing is great, but I think controlling motor PWM is waaaay cooler, as it lets you drive to motor much more smoothly and efficiently. I am not sure if Sean·s motor controller lets you drive the Neco to the max as I do not remember the max current. My Neco takes 24 volts and peaks around 200-300watts, so that should be around 20 amps on your 12 volt system. I use the IBT2 that handles up to 44 amps. My Neco on 24 volt only takes around 10 amps max, so the IBT2 is ample strong and probably long lived.

The Neco has a motor that is a bit more complex. There is a diagram and a description that was done by Daniele Fua, a really cool guy who was of much help to the community. You can find the documents posted earlier here in this thread. If your Neco control unit does not work anymore, you can just convert to the Tinypilot. I am a liveaboard cruiser and I opted for a switch box to be able to use both controls for redundancy. If you go for the full conversion, you can relatively easily reuse the end switches and the rudder angle sensor integrated into the Neco drive unit.

With the relays the motor is controlled at 100% juice and then forced to a halt, as the relays short the coil of the motor, thus magnetically braking the movement of the motor. This is a reliable but power hungry solution. The H-Bridge in Sean·s driver can nicely start and stop the motor and does not brake the motor like using the relays does. On the other hand there is a voltage drop on the H-Bridge but given how little the motor controller heats up during use, I do not think there is much energy lost there.

At the moment I am just trying to implement the last update of Sean, and drive the clutch with a PWM signal instead of an always-on signal when engaged. My clutch coil takes around 30-40 watts. It stays engaged with around 33% PWM so there is around 20 last watts to be saved with this last update.

Thanks for the update Kris. I've had long email exchanges with Daniele Fua, a really helpful guy. I went with Sean's motor controller planning to use the Neco relays, but the lower current consumption and better control of direct motor control seems like a good idea. The Neco drive unit is fused at 25 amps and probably peaks at around 20, so I don't think the motor controller will handle that. I'm looking at a Pololu unit to handle the current. Any info on the best way to control it would be really helpful.

Yes: Hello Daniele Fua if your read this! And thanks for everything! Smile

I am using an IBT2 controller. It costs around 10 euros on Amazon, and available mostly everywhere. It is quite easy to set up. 
LPWM and RPWM on the IBT2 controller go to D9 and D10 on the Arduino
L_EN and R_EN go to 5V or you can wire that to the H-bridge lower pins.
R_IS and L_IS can be wired together and they can then go through a resistor (1K maybe?) to analog 1 pin on the Arduino, the current sense pin (my measurements are not accurate, but it still lets me limit the current for safety or end-switch function)

Then for the Shunt coil, you can drive that either from the clutch, so it is on when the pilot is engaged. Or it is better to wire 2 diodes to the lower H-Bridge pins and then drive the shunt coil through a MOSFET or NPN transistor. You can also use a little NPN transistor circuit board ready made, available on Amazon or Ebay. In this case the shunt coil is energized every time the pilot asks for movement, but when the pilot is engaged but idle, there is no extra consumption on this coil. The polarity of the shunt coil is always the same regardless the rotation direction. The shunt coil creates a basic magnetic field for the motor to be able to start. Like in a permanent magnet motor, this field always has the same polarity (or direction).

I drive the clutch just from the clutch pin though the same NPN transistor.

And then for the serial coil on the Neco drive, you have to wire that in serial with the IBT2 motor controller. So from your battery you go to serial coil positive, from serial coil negative, you go to IBT2 battery positive, then from IBT2 battery negative you go to your battery negative on the boat.

Use leds with little resistors to figure out how the arduino controls everything. Please double check this description of mine with Daniele Fua's wiring diagram to guess the positive and negative.

I had a bit of trouble setting up the motor.ino code. I think in the end I went with PWM style 2 and 2NV2HN (or similar thing) active.

Oh and then I also found out that the rudder feedback pin expects a voltage that is lower than 1.2V if I remember correctly. So you have to do a voltage divider there or add some resistors. I think Sean had low resistance potentiometers on hand and wanted to reduce current even more, so he stuck resistors before the potentiometer to even further lower the consumption. Maybe I will use an automotive style rotary encoder for this purpose later for better accuracy and longevity.

I have no experience with the Pololu, sorry. Let me know if you need more help with anything.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)