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
#51
@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?
Reply
#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
#53
HI Thank you for the explanation on the @@ and -+...

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

i modified the #define lines (which were no where near line 115 in my ide nor at line 155 in the link above that you posted before) but found the text and matched it up and made the changes.

for line 405 it looks like the new code in the link you attached matches, it is slightly different but didnt change anything as i pulled the code from the link.

nothing is lighting up on the vnh5019

could it be a bad vnh5019? since nothing is lighting up on the board?
Reply
#54
(2021-02-12, 02:52 AM)djdsails Wrote: i modified the #define lines (which were no where near line 115 in my ide nor at line 155 in the link above that you posted before) but found the text and matched it up and made the changes.

Sounds good

(2021-02-12, 02:52 AM)djdsails Wrote: nothing is lighting up on the vnh5019

could it be a bad vnh5019? since nothing is lighting up on the board?

Let's work backwards.  First, your motor.  If you connect the motor across 12V, does it turn?  If you reverse the connections, does it turn the other way?

Measure your 5V supply with a voltmeter.  Is it 5V (+/-0.2V will be fine)?

Next, connect the motor to the VNH5019 but don't connect the VNH5019 to the nano.  

On the VNH5019, power it by connecting pin 7 to 5V, and pin 10 to GND.  Then connect pin 3 (PWM) to 5V.

Next, with a wire connected to 5V, touch pin 1 (ENA).  The motor should turn one way, and one VNH5019 LED will go on.  Then take the wire off pin 1 (ENA) and touch pin 5 (ENB).  The motor should turn the other way, and the other VNH5019 LED will go on. (One LED is red and one is green. There's no power LED)

If this all worked, then you know your VNH5019 is fine.

The next step will be to connect the RPi W0 to the nano, and the nano to the VNH5019.  But let me know what happens with the VNH5019 test, and I'll help you more after that.
Reply
#55
Thank you!
All good till...
Touching pin 5 with 5v did nothing. Pin 5 is ebb/diagb. But I touched pin 6 which is inb and it went the other way and the red led lit up

Thank you thank you!! It works!! I must have had something plug in incorrectly! A year in the making compete!! Now onto the next fun thing to make a case for everything! And on to tuning as it is interesting how the tiller pilot moves(as compared to Raymarine)
Thank you for the detailed help and taking the time to help me!! Appreciate it!

Ohh and experimenting with the limit switches
Reply
#56
Hi Guys and CapnKernel
 I might be a bit naive but somewhere Sean said the motor controller can be connected directly to the TX and RX pins (or, via USB). Does this mean I can connect my motor controller (pololu jrk g2 21v3 and in picture) directly to RX/TX or do I still need to go via arduino nano as TinyPilot keeps saying no motor controller detected?
Many thanks
Richard


Attached Files Image(s)
   
Reply
#57
(2021-02-23, 04:48 PM)richarddaneel Wrote: Hi Guys and CapnKernel
 I might be a bit naive but somewhere Sean said the motor controller can be connected directly to the TX and RX pins (or, via USB). Does this mean I can connect my motor controller (pololu jrk g2 21v3 and in picture) directly to RX/TX or do I still need to go via arduino nano as TinyPilot keeps saying no motor controller detected?
Many thanks
Richard

Hi Richard,

I use a Pololu (1367) G2 24V19 to drive my autopilot with the Tinypilot.: 

I reported in this thread: 
https://forum.openmarine.net/showthread.php?tid=1734.

So to awnser your question short:
I still use the nano. 
The file motor.ino for the nano  ist compiled/uploded  with the option PWM-Style=RC
The connection btw. nano and pololu is two wires nano Pin 9 (RC-PWM) to Pololu RC 
and Nano GND to Pololu GND.

I don´t remember well if you need to set up the pololu with the software it comes with it.
Maybe you shoud first connect power and motor to the pololu and move it with the software

This should basicly work. If you want you can attach end limit switches (verry recomendet) and volt, current sensors .....

Save sailing
Andreas
Reply
#58
(2021-02-23, 06:44 PM)xfactor99 Wrote:
(2021-02-23, 04:48 PM)richarddaneel Wrote: Hi xfactor99
Thanks for your reply and suggestion to use the pololu software to set things up. Could I ask one more question - when you say - The file motor.ino for the nano  ist compiled/uploded  with the option PWM-Style=RC, what do you mean by this, I am not sure what you mean by option PWM-style=RC. Do you mean I must change a line inside the code?
Many thanks
Richard







 I might be a bit naive but somewhere Sean said the motor controller can be connected directly to the TX and RX pins (or, via USB). Does this mean I can connect my motor controller (pololu jrk g2 21v3 and in picture) directly to RX/TX or do I still need to go via arduino nano as TinyPilot keeps saying no motor controller detected?
Many thanks
Richard

Hi Richard,

I use a Pololu (1367) G2 24V19 to drive my autopilot with the Tinypilot.: 

I reported in this thread: 
https://forum.openmarine.net/showthread.php?tid=1734.

So to awnser your question short:
I still use the nano. 
The file motor.ino for the nano  ist compiled/uploded  with the option PWM-Style=RC
The connection btw. nano and pololu is two wires nano Pin 9 (RC-PWM) to Pololu RC 
and Nano GND to Pololu GND.

I don´t remember well if you need to set up the pololu with the software it comes with it.
Maybe you shoud first connect power and motor to the pololu and move it with the software

This should basicly work. If you want you can attach end limit switches (verry recomendet) and volt, current sensors .....

Save sailing
Andreas
Reply
#59
Hi Richard,

somwere in the motor.ino file you find this:

........
#define pwm_style_pin 6
// pwm style, 0 = hbridge, 1 = rc pwm, 2 = vnh2sp30
uint8_t pwm_style = 1; // detected to 0 or 1 unless detection disabled, default 2
.........

see that it is pwm_style = 1 ...... what means RC witch works with my pololu

As I dont use the latest motor.ino  I cant tell you the eact position of the code .....

Save sailing
Andreas
Reply
#60
(2021-02-23, 08:09 PM)xfactor99 Wrote: Hi Andreas
Once again thanks for your reply. In the motor.ino code you have to #include "crc.h". I can not seem to find this code where do I get it, 
Cheers
Richard
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)