Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(P4S/P4P/P4A) #99

Closed
mEfis-afk opened this issue Dec 11, 2018 · 47 comments
Closed

(P4S/P4P/P4A) #99

mEfis-afk opened this issue Dec 11, 2018 · 47 comments

Comments

@mEfis-afk
Copy link

mEfis-afk commented Dec 11, 2018

I am looking for a person who sell the Software for calibration of Gimbal's DJI. I say calibration, when you change some module ESC of the engines. Example: ESC Yaw/Roll Gimbal Phantom 4 or Phantom 4 Pro and the Gimbal goes crooked. I saw that you made a gimbal Spark calibration Software available, would you sell some to calibrate gimbal from the other Drones?

@mefistotelis
Copy link
Collaborator

The method for calibrating each model is probably different. I don't know how to do this exactly, that would require some research. I'm not sure if I'll be looking into that.

Spark has a pre-made auto calibration function which is easy to trigger. Previous platforms seem to have less automated solution, but I never looked at details.

@mEfis-afk
Copy link
Author

And how much would you charge to make a script for calibration of Gimbal's Phantom 4 series, Phantom 3 and perhaps inspire? I pay you to do that, I don't want it for free!

@mefistotelis
Copy link
Collaborator

mefistotelis commented Dec 11, 2018

We would have to go with one platform at a time.
Also, you'd have to be involved in testing what various packets do. From the platforms you mentioned, I only have Ph3, and its gimbal is properly aligned - so not a good test subject.

About paying for the task - I'm not sure if I want to go this way; the time I can spend on this is limited. But I do accept donations.

Sign to Slack - we may talk further there; see Slack link in top menu here:
http://dji.retroroms.info/

I will try to find time for some initial research on the subject.

@mEfis-afk
Copy link
Author

The site to be faced with stability issues. I can not access the same! Could you pass your email or WhatsApp? I will help in what possible (testing with drones). About the donations, I will donate yes.

@mefistotelis
Copy link
Collaborator

The "hardware" channel on Slack is the place where many people discuss mods and repairs for DJI products.

But if you can't access it - we can talk here. I don't use any other messaging apps.

@mEfis-afk
Copy link
Author

I'm trying to access it, but I can't. What do you need to give the tip foot in the software for calibration? I have all the drones here to test....

@mefistotelis
Copy link
Collaborator

First I will look at gimbal module (m0400) for various platforms. I have the ones for Ph3, Ph4 and Inspire, but I don't think I have one for Ph2 Vision - and it could be helpful.

I will be searching for m0400 modules which are larger in size - this may indicate a version with more debugging messages left in the code.

I need to get a basic understanding of how the firmware works, then I'll get to figuring out the packets which can be sent to it.

@mEfis-afk
Copy link
Author

I have a great friend who also program in Python, if you need any other help, I can talk to him... I can help with the tests, since I have no advanced knowledge of software.

@mefistotelis
Copy link
Collaborator

It will take some time before I have anything to test. I still need to finish current tasks.

Anyway, at some point I'll want you to run comm_serialtalk.py - so you may want to prepare for it, to the point where the example instruction from README works.

And you can try searching Ph2 firmwares for me.

@mEfis-afk
Copy link
Author

Here on the website of DJI has some firmware of the Phantom 2 Plus which is the latest version of PH2

https://www.dji.com/phantom-2-vision-plus/info#downloads

@mefistotelis
Copy link
Collaborator

mefistotelis commented Dec 26, 2018

Here are ALL packets on which Phantom 3 Gimbal reacts. The table comes from version P3X_FW_V01.11.0030_m0400:

function cmdid cmdset
packet_exec_gimb_push_aetr
Sets 4 values from packet within gimbal RAM, each in range 364..1684: Aileron, Elevator, Throttle and Rudder. Supports payload encryption. No ACK possible.
0x06 Gimbal
packet_exec_gimb_control
Sets 3 values from packet within gimbal RAM, each in range 364..1684; meaning of them is unknown. Supports payload encryption. No ACK possible.
0x01 Gimbal
packet_exec_spec_special_app_control
Sets some values (10 bytes) from packet within gimbal RAM; unknown. No ACK possible.
0x01 Special
packet_exec_flyc_posture
Sets aircraft posture (4 float values) from packet within gimbal RAM; sent periodically during flight by Flight Controller. Supports payload encryption.
0x42 FlightCtrl
packet_exec_gimb_ext_ctrl_accel
Sets 3 angular values from packet within gimbal RAM; sets angular accelerations of each axis.
0x0C Gimbal
packet_exec_gimb_thirdp_magn
Sets 3 values from packet; does some processing on the values, influences many values stored in RAM. Maybe calibrates the gimbal for work with third party magnetometer?
0x0E Gimbal
packet_exec_gimb_calibration
Triggers auto-calibration, the same which can be triggered by mobile app. Calibrates only 2 axes.
0x08 Gimbal
packet_exec_gimb_adjust_roll
Receives a value from packet and shifts internal roll adjustment by it. The adjustment is not saved into persistent storage.
0x07 Gimbal
packet_exec_gener_version_inquiry
When received, the gimbal responds with a packet containing hardware and software versions.
0x01 Universal
packet_exec_gener_enter_loader
When received, the gimbal software sets startup parameters so that it starts to bootloader mode, and reboots the chip. This is initial step of a firmware update.
0x07 Universal
packet_exec_gener_update_confirm
Used during firmware update.
0x08 Universal
packet_exec_gener_update_transmit
Used during firmware update.
0x09 Universal
packet_exec_gener_update_finish
Used during firmware update.
0x0A Universal
packet_exec_gener_reboot_chip
When received, the gimbal mcu reboots.
0x0B Universal
packet_exec_gener_get_device_state
In response to this request, gimbal returns a dword value representing its state. It looks like this state value is not really used and has no real meaning.
0x0C Universal
packet_exec_gener_set_device_version
Its main purpose is to convince the device about which versions of SW and HW it should report; though only some of the set values are really used for reporting. It has additional magic value triggers which allow to overwrite internal storage, including calibration data. Very suspicious. Potentially very powerful.
0x0D Universal
packet_exec_gener_encrypt_config
Used for factory encryption pairing. Consists of 3 sub-commands: GetChipState, GetModuleState, Config.
0x30 Universal
packet_exec_gimb_cmd20
Sets 3 values from packet within gimbal RAM; meaning of them is unknown. No ACK possible.
0x20 Gimbal
packet_exec_gimb_ext_ctrl_degree
Sets 3 angular values and 3 additional values from packet within gimbal RAM. Resets values from packet 0x20 to 1 if ACK was requested (do you even design, Dji?).
0x0A Gimbal
packet_exec_gimb_get_ext_ctrl_status
In response to this request, gimbal returns a flag field and int value representing current ctrl status.
0x0B Gimbal
packet_exec_gimb_suspend_resume
Allow to suspend or resume gimbal motion when correct magic value is provided as payload. Sets a single flag in RAM. No ACK possible.
0x0D Gimbal
packet_exec_gimb_get_user_param
Given indexes of gimbal user params, returns a list of their values. Values have different size depending on their type. There are 12 gimbal user params defined in the firmware; they work in a similar way as FlyC Params.
0x10 Gimbal
packet_exec_gimb_set_user_param
Allows to set new values of gimbal user params. Index and size of each param must be provided. Also resets values from packet 0x20 to 1.
0x0F Gimbal
packet_exec_gimb_save_user_param
Stores values from user_param list, and additional values like the roll adjustment, to persistent storage. Requires one byte payload to send an ACK, but that byte value is not used (because why not.). Besides returning status code, also sets values from packet 0x20 to different numbers on success and on failure.
0x11 Gimbal
packet_exec_gimb_cmd21
Sets values of unknown 3-element list within RAM. Each list entry consists of 3 integers. No ACK possible.
0x21 Gimbal
packet_exec_gimb_resume_default_param
Restores values of all user params to defaults from persistent storage. Resets values from packet 0x20 to 1.
0x13 Gimbal
packet_exec_gimb_cmd14
Sets 3 angular values and 1 additional value from packet within gimbal RAM. Also contains flags field which influences which fields are set. Meaning of values is unknown. No ACK possible.
0x14 Gimbal

Now we can test what each of these does and find out which is used to calibration or position setting.

@mefistotelis
Copy link
Collaborator

Disclamer: This can damage the gimbal. I don't know what it does. I will just provide packets which look like they might trigger calibration or control the yaw arm.

Now, first check if taking to gimbal even works (this command is safe):

./comm_serialtalk.py COM5 -vv --receiver_type=Gimbal --seq_num=12341 --ack_type=ACK_After_Exec --cmd_set=General --cmd_id=1

If it does (versions are shown in response), then we can get to business.

I will provide proper commands as soon as I finish figuring them out. The idea I have is to enter work mode 5 - it looks like a different version of auto-calibration routine (which is work mode 3).

@mEfis-afk
Copy link
Author

Hey, buddy. How you doing, huh? Very good! I will test this command on some Phantom 3

@mefistotelis
Copy link
Collaborator

mefistotelis commented Dec 29, 2018

Please do.

My idea of switching to work mode 5 is not as easy as I anticipated - all packets which allow to control work mode are masking it to 2 bits (allowing only modes 0..3).

I am searching for alternatives.

Also, I don't have any firmware from Ph2 - that would require quite some work to get, as the FW is downloadable through Ph2 Assistant. So I think I'll skip it.

@mefistotelis
Copy link
Collaborator

Update:
I got all firmwares for Ph2, am looking at them now; will get back to looking at Ph3 gimbal code when I'm done with them.

@mEfis-afk
Copy link
Author

Tell me, my friend, how was your year-end? I wish you much health, peace and a lot of money that year. I arrived on a trip today, I was at the relatives ' house. I'm going to test the Phantom 3 code tomorrow, and I'll give you a return.

@mEfis-afk
Copy link
Author

Hi, how are you? I went to work. I'm going to take the test this week on a Phantom 3 Pro. It would be interesting if I had any other way to talk to you, I have a good proposition for this project.

@mefistotelis
Copy link
Collaborator

You can write me an e-mail.
mefistotelis@gmail.com

I am still working on pre-Ph3 firmwares; have limited time for that, so it takes quite long.

@cimona
Copy link

cimona commented Jan 25, 2019 via email

@mEfis-afk mEfis-afk reopened this Apr 18, 2019
@mEfis-afk
Copy link
Author

Hey, did you abandon the "project? "

@mefistotelis
Copy link
Collaborator

I am not working on it now. May be back when I have more time.

@o-gs o-gs deleted a comment from TheonlyAnkit Sep 13, 2019
@o-gs o-gs deleted a comment from lensherm Sep 13, 2019
@0n3-70uch
Copy link

Hi, did anyone found a solution? I replaced my YAW motor ad now I need to calibrate the motor.

@TheonlyAnkit
Copy link

TheonlyAnkit commented Sep 21, 2019 via email

@0n3-70uch
Copy link

Thanks for your quick answere.
Ok thats for mavic air right? Is there a solution for Phantom 4 Pro?

@0n3-70uch
Copy link

PS: Can you link me the video pls. Many wrong videos there...

@0n3-70uch
Copy link

Disclamer: This can damage the gimbal. I don't know what it does. I will just provide packets which look like they might trigger calibration or control the yaw arm.

Now, first check if taking to gimbal even works (this command is safe):

./comm_serialtalk.py COM5 -vv --receiver_type=Gimbal --seq_num=12341 --ack_type=ACK_After_Exec --cmd_set=General --cmd_id=1

If it does (versions are shown in response), then we can get to business.

I will provide proper commands as soon as I finish figuring them out. The idea I have is to enter work mode 5 - it looks like a different version of auto-calibration routine (which is work mode 3).

Here is my response:

Prepared binary packet:
55 0d 04 33 0a 04 35 30 40 00 01 91 94
Sending packet...
Waiting for reply...
Retrieved 16 packets (886b), dropped 0 fragments (0b)
Received response packet:
55 2c 04 36 04 0a 35 30 80 00 01 00 01 6e 6f 6e 65 00 b3 09 f2 36 35 00 55 66 3f 00 00 00 00 0c 01 11 0d 32 01 01 00 00 00 01 96 98
Parsed response  - DJIPayload_General_VersionInquiryRe:
        unknown0: 0
        unknown1: 1
      hw_version: b'none'
     ldr_version: 17563648
     app_version: 20057361
       unknown1A: 1
       unknown1E: 1

@TheonlyAnkit
Copy link

TheonlyAnkit commented Sep 21, 2019 via email

@0n3-70uch
Copy link

Yeah this works for Spark and Mavic Air.. but not for Phantom 4.
The topic ist "Calibration Gimbal Phantom 4 Series". Thats why I ask for the PH4PRO ;-).

I used following trick now:
https://youtu.be/uWCm0QlHTTM

@TheonlyAnkit
Copy link

TheonlyAnkit commented Sep 21, 2019 via email

@0n3-70uch
Copy link

Only the winding part. The cable was demaged. Now it's running fine and well centered.

@TheonlyAnkit
Copy link

TheonlyAnkit commented Sep 21, 2019 via email

@0n3-70uch
Copy link

Ok thank you. Have a nice weekend.

@lensherm
Copy link

Well well.... Although calibration kept starting but timing out on my Spark, regardless of the combinations of components I tried it with, including original gimbal/cam, different ribbon cable, brand new gimbal motor, brand new gimbal/cam; as soon as I got a replacement board, it worked like a charm. Looks like gremlins were out to get me and my 90 bucks :-). At least all's well with the world in the end.

@0n3-70uch
Copy link

Yeah the motor drivers are placed on the core board. Very bad solution... The same situation like the mavic air.

@TheonlyAnkit
Copy link

TheonlyAnkit commented Sep 21, 2019 via email

@vserena82
Copy link

vserena82 commented Feb 15, 2020

Hello, there is a solution for this problem?
I need to calibrate gimbal in P4Pro, I replaced yaw motor. On crash magnet of old yaw motor has broken so I can't use it with new winding part.
There is a way to calibrate gimbal or change its default parameteres (angles)? after replacing motors?
Thank you

@TheonlyAnkit
Copy link

TheonlyAnkit commented Feb 18, 2020 via email

@vserena82
Copy link

Thank you for your answer but I cant swap magnet: winding bumped into magnet ring and magnet has been broken, so I cant use it.
I tryed with another yaw motor but it is not in correct position.
I have also another gimbal to repair: I changed esc board for yaw motor, also in this case yaw motor is in wrong position.
Is it possible to make a "deep" calibration using some scripts?
Or is it possible to force yaw parameters manually on fw?

If there are no solutions I have to buy others yaw motors and hope the will be in correct position...

Thank you

@mEfis-afk mEfis-afk reopened this Mar 27, 2020
@TheonlyAnkit
Copy link

TheonlyAnkit commented Mar 27, 2020 via email

@sh88hoseini
Copy link

Hello
I also encountered this problem, but I can't open this help link.

@TheonlyAnkit
Copy link

TheonlyAnkit commented May 31, 2020 via email

@fargnoli1969
Copy link

Hi does anyone here able to write a simple program to calibrate after replacing esc or motors each or any of the dji range ?? Donations for programs on their way if you can help . Thanks
Fargnoli@scotlandunmanned.co.uk

@TheonlyAnkit
Copy link

Hie everyone, is there any programming script to calibrate the P4 Pro gimbal after replacing some damaged/fractured spares from the gimbal??

@krixiicsz
Copy link

Hello! I have tried to find some information, but haven't got anything. Now as I understand, that I had to replace magnets from old motor to new, but I have already put my old motor in trash bin. So. Is there any other solution that can work to center my gimbal. My drone have crashed, I have replaced yaw motor, flex cable and also esc board for gimbal. Is there some software where can manually calibrate motor?

@mefistotelis mefistotelis changed the title Calibration Gimbal Phantom 4 Series Gimbal Calibration for Phantom 4 Series (P4S/P4P/P4A) Mar 10, 2021
@mEfis-afk
Copy link
Author

Hi does anyone here able to write a simple program to calibrate after replacing esc or motors each or any of the dji range ?? Donations for programs on their way if you can help . Thanks
Fargnoli@scotlandunmanned.co.uk

How much are you selling for?

@mEfis-afk mEfis-afk changed the title Gimbal Calibration for Phantom 4 Series (P4S/P4P/P4A) (P4S/P4P/P4A) Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants