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:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Motor controller
#52
(2021-02-12, 12:01 AM)djdsails Wrote: @capnkernel, i am viewing your post #5, i was wondering since a vnh5019 arrived, how do i insert the code into the original motor.ino? i see some + and - signs so i am assuming some stuff gets deleted and added, but where do i add in your code and do i have to remove any original code?

The software which runs on the nano for PyPilot is an Arduino sketch stored in a file on your computer called "motor.ino".  This file is part of the PyPilot software (Raspberry Pi Zero W and the Arduino nano) that's held on github.  You'll need to make a copy to your computer from here:

  https://github.com/pypilot/pypilot/

You'll be altering the motor.ino that's on your computer, but you can also view the file here:

  https://github.com/pypilot/pypilot/blob/.../motor.ino

I've repeated the changes you need here:

Code:
@@ -115,10 +115,10 @@ PWR+             VIN



-//#define VNH2SP30 // defined if this board is used
+#define VNH2SP30 // defined if this board is used
//#define DISABLE_TEMP_SENSE    // if no temp sensors avoid errors
//#define DISABLE_VOLTAGE_SENSE // if no voltage sense
-//#define DISABLE_RUDDER_SENSE  // if no rudder sense
+#define DISABLE_RUDDER_SENSE  // if no rudder sense


// run at 4mhz instead of 16mhz to save power,
@@ -405,10 +405,14 @@ void setup()
#if 1
    // setup adc
    DIDR0 = 0x3f; // disable all digital io on analog pins
+#ifndef VNH2SP30
    if(pwm_style == 2 || ratiometric_mode)
        adcref = _BV(REFS0); // 5v
    else
        adcref = _BV(REFS0)| _BV(REFS1); // 1.1v
+#else
+    adcref = _BV(REFS0)| _BV(REFS1); // 1.1v
+#endif
    ADMUX = adcref | _BV(MUX0);
    ADCSRA = _BV(ADEN) | _BV(ADIE); // enable adc with interrupts
#if DIV_CLOCK==4

The changes are in a format called "unified diff".  It shows how to modify a file to go from one version of a file to another.  You can read about it here:

  https://unix.stackexchange.com/questions...ut-of-diff

Regarding the motor.ino diff, the "@@ -115,10" means "look at the 10 lines in the original motor.ino file starting from line 115, and the - and + lines mean "change what's on the - line to be what's on the + line, ie:

  1. Change "//#define VNH2SP30 // defined if this board is used" to "#define VNH2SP30 // defined if this board is used" and

  2. Change "//#define DISABLE_RUDDER_SENSE  // if no rudder sense" to "#define DISABLE_RUDDER_SENSE  // if no rudder sense".

  Other lines until the next "@@" are the same between the old and new file versions.  Next, "@@ -405,10 +405,14 @@" means "look at the 10 lines in the original motor.ino file starting from line 405, and change the text shown on the - lines to the text on the + lines.  So essentially, it's instructions for the exact changes to make to a file.

Please note that recently the motor.ino on github was changed to fix the voltage/current reading bug, so while you'll still need to make the changes from line 115, if you have a recent version of the PyPilot source, you won't need to make the changes from line 405.

After these changes have been made, you'll need to start the Arduino software on your computer and open motor.ino (or you can use the Arduino software's editor to make the changes).  Connect the nano via USB to your computer, set the board type and port, then select "Upload".  The Arduino software will compile motor.ino, and transfer it to the nano.  The nano is then ready for use with PyPilot.

It's probable that some of what I've said will make sense, and some won't.  Or you'll have trouble doing a step.  If so, just let me know what you're stuck on and I'll help you with that.
Reply


Messages In This Thread
Motor controller - by djdsails - 2021-01-18, 01:13 AM
RE: Motor controller - by seandepagnier - 2021-01-18, 03:35 AM
RE: Motor controller - by CapnKernel - 2021-01-19, 07:00 AM
RE: Motor controller - by djdsails - 2021-01-20, 01:55 AM
RE: Motor controller - by CapnKernel - 2021-01-20, 03:08 AM
RE: Motor controller - by djdsails - 2021-01-28, 08:34 PM
RE: Motor controller - by seandepagnier - 2021-01-28, 10:46 PM
RE: Motor controller - by rastam4n - 2021-01-28, 11:33 PM
RE: Motor controller - by seandepagnier - 2021-01-28, 11:46 PM
RE: Motor controller - by djdsails - 2021-02-02, 02:44 PM
RE: Motor controller - by ironman - 2021-02-03, 08:51 AM
RE: Motor controller - by djdsails - 2021-02-03, 12:55 PM
RE: Motor controller - by ironman - 2021-02-03, 04:42 PM
RE: Motor controller - by djdsails - 2021-02-03, 05:11 PM
RE: Motor controller - by ironman - 2021-02-03, 05:55 PM
RE: Motor controller - by djdsails - 2021-02-03, 06:27 PM
RE: Motor controller - by djdsails - 2021-02-03, 08:08 PM
RE: Motor controller - by ironman - 2021-02-03, 10:24 PM
RE: Motor controller - by djdsails - 2021-02-04, 01:07 AM
RE: Motor controller - by ironman - 2021-02-04, 06:42 AM
RE: Motor controller - by djdsails - 2021-02-04, 02:15 PM
RE: Motor controller - by Andreas29 - 2021-02-04, 10:50 AM
RE: Motor controller - by Andreas29 - 2021-02-04, 04:56 PM
RE: Motor controller - by djdsails - 2021-02-04, 05:09 PM
RE: Motor controller - by ironman - 2021-02-04, 05:48 PM
RE: Motor controller - by djdsails - 2021-02-04, 06:15 PM
RE: Motor controller - by Andreas29 - 2021-02-04, 06:24 PM
RE: Motor controller - by djdsails - 2021-02-04, 07:00 PM
RE: Motor controller - by Andreas29 - 2021-02-04, 07:09 PM
RE: Motor controller - by ironman - 2021-02-04, 07:22 PM
RE: Motor controller - by Andreas29 - 2021-02-04, 07:35 PM
RE: Motor controller - by djdsails - 2021-02-04, 07:47 PM
RE: Motor controller - by ironman - 2021-02-04, 08:16 PM
RE: Motor controller - by djdsails - 2021-02-04, 08:23 PM
RE: Motor controller - by ironman - 2021-02-04, 09:34 PM
RE: Motor controller - by xfactor99 - 2021-02-04, 09:44 PM
RE: Motor controller - by CapnKernel - 2021-02-05, 12:10 AM
RE: Motor controller - by rastam4n - 2021-02-05, 12:16 AM
RE: Motor controller - by Andreas29 - 2021-02-05, 07:12 AM
RE: Motor controller - by ironman - 2021-02-05, 08:52 AM
RE: Motor controller - by CapnKernel - 2021-02-10, 02:31 AM
RE: Motor controller - by djdsails - 2021-02-05, 05:30 PM
RE: Motor controller - by xfactor99 - 2021-02-05, 06:26 PM
RE: Motor controller - by ironman - 2021-02-05, 06:28 PM
RE: Motor controller - by hreuver - 2021-02-05, 07:05 PM
RE: Motor controller - by djdsails - 2021-02-05, 07:18 PM
RE: Motor controller - by Andreas29 - 2021-02-05, 08:09 PM
RE: Motor controller - by djdsails - 2021-02-08, 09:36 PM
RE: Motor controller - by djdsails - 2021-02-08, 11:06 PM
RE: Motor controller - by ironman - 2021-02-09, 11:07 AM
RE: Motor controller - by djdsails - 2021-02-12, 12:01 AM
RE: Motor controller - by CapnKernel - 2021-02-12, 02:21 AM
RE: Motor controller - by djdsails - 2021-02-12, 02:52 AM
RE: Motor controller - by CapnKernel - 2021-02-12, 06:04 AM
RE: Motor controller - by djdsails - 2021-02-12, 12:37 PM
RE: Motor controller - by richarddaneel - 2021-02-23, 04:48 PM
RE: Motor controller - by xfactor99 - 2021-02-23, 06:44 PM
RE: Motor controller - by richarddaneel - 2021-02-23, 07:39 PM
RE: Motor controller - by richarddaneel - 2021-02-24, 09:15 AM
RE: Motor controller - by xfactor99 - 2021-02-24, 09:31 AM
RE: Motor controller - by richarddaneel - 2021-02-24, 12:57 PM
RE: Motor controller - by richarddaneel - 2021-02-24, 09:02 AM
RE: Motor controller - by xfactor99 - 2021-02-24, 09:14 AM
RE: Motor controller - by xfactor99 - 2021-02-23, 08:09 PM
RE: Motor controller - by richarddaneel - 2021-02-24, 07:31 AM
RE: Motor controller - by richarddaneel - 2021-02-24, 02:52 PM
RE: Motor controller - by rastam4n - 2021-02-25, 03:48 AM
RE: Motor controller - by richarddaneel - 2021-03-02, 02:03 PM
RE: Motor controller - by seandepagnier - 2021-02-25, 03:29 AM
RE: Motor controller - by seandepagnier - 2021-03-02, 08:45 PM
RE: Motor controller - by badutis - 2024-01-24, 12:15 PM
RE: Motor controller - by Max1947 - 2024-01-24, 12:18 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)