2022-05-11, 11:09 AM
(This post was last modified: 2022-05-11, 11:21 AM by Marty Peters.)
(2022-05-10, 11:33 AM)ironman Wrote: Just take an arduino nano, put motor.ino on it and pull D6 high. The arduino then outputs RC-style signals on D9, that I think you can feed to an RC-style servo. See https://github.com/pypilot/workbook/wiki...-motor.inoIronman, Sean, Thanks for your replies,
I like your thinking! Don't forget to correct your soundings for the tide ;-)
ok, so I flashed the nano with the motor.ino file after uncommenting the below to disable the alarms.
//#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
and changed;
#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
to set style 1 (RC). however I also, (mistakenly I think), a 5v onto pin 6 to pull it high. I since removed this 5v.
The Arduino connects to the pi via usb after I add a usb device in Pypilot, and the RX TX lights are flashing.
When I open the Pypilot control interface and connect the Arduino USB, it says "Arduino" in the top left, then very briefly in says "Engaged" but after about 1/2 a second switches to "Disengaged", and next to that it says "Sync Overcurrent_fault". When I press the AP to engage nothing happens because I think the fault stops the engagement.
I looked through the Arduino code and I am a beginner but I can't see anywhere where overcurrent fault can be uncommented. Do you have any suggestions?
I also read the following,
- There will be random error messages next to the word SYNC, and this can be expected. These error messages are called ‘flags’ in pypilot parlour, and at this point they are caused by the input pins on the Arduino being left open. Open input pins are bad practice in electronics; if they are left 'floating' they are susceptible to electrostatic influences and worse, damage.
I think I understand that by setting the D6 pin High via the Pwm_style=1 you get an output on D9 that is a PWM pulse of varying length that equates to servo position. I think this is similar to the servo.h library I am using in the IOT boat so hopefully it will work similar but see from the workbook wiki that its really untested. but first I think I need to get rid of the fault before proceeding.
Thanks for the help!
(2022-05-10, 01:17 PM)seandepagnier Wrote: you can do this, but keep in mind that driving a servo on absolute position is different from driving it a relative speed.
You will have to change all the gains to compensate but otherwise it should work.
Hi Sean,
I am not sure what this means, so I guess I have some googling about how servo's work and the differences of relative speed and absolute position.. this has all been a huge learning curve, but a rewarding one!
Are the Gains the sliders in the control interface?
Thanks