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

Motor detection via back EMF #1

Closed
LorenzMeier opened this issue Jul 10, 2014 · 4 comments
Closed

Motor detection via back EMF #1

LorenzMeier opened this issue Jul 10, 2014 · 4 comments

Comments

@LorenzMeier
Copy link
Member

I would like to propose a button-less and very easy (from the customer perspective) motor detection approach:

  • Send a command to all units on the bus (broadcast) to reconfigure. This means resetting their address / state (not to zero, but to "unconfigured") so that an aborted config should result in a refusal to spin.
  • for i=0..N: Send "detect motor #N" as broadcast. All unconfigured motors enter detection mode (which times out after ZZ seconds)
  • The user then turns the motor. The user is instructed to start with a specific motor and follow a specific order. It gets visual feedback about which motor was detected and which ones still need handling. The next motor to handle is indicated visually in the GUI. By comparing the GUI and the frame he will also notice mismappings and is able to fix them.
  • The motor beeps upon detection of the turn and changes its LED indication from unconfigured to standby.

On the technical side this needs a reconfigure and configure motor #N packet via CAN and the back-EMF detection.

@pavel-kirienko
Copy link
Member

The network may contain other UAVCAN nodes, not only ESC. We need to restrict the enumeration process so that only ESCs are affected. One possible solution is to define a vendor-specific message/service for that (only ESC will be able to recognize it), but generally it is preferred to reduce the number of vendor specific data types when possible to improve cross-vendor compatibility.

So I propose a generic approach based on a single new standard message. It is suitable for any node that can receive some confirmation from the user (e.g. motor turn, button press).

Here's the new message uavcan.protocol.EnumerationRequest:

uint8 timeout_sec
uint7 node_id

Let the default node config contain an invalid Node ID, so the node starts in passive mode (i.e. it can listen the bus but can't transmit anything). If the node is in passive mode, it subscribes to uavcan.protocol.EnumerationRequest and is ready to get a new Node ID. The node shall not subscribe to that message if it is already configured to avoid spurious reconfiguration.

The algorithm then (essentially it's just a variation of your proposed approach):

  1. The main node (e.g. a Pixhawk) performs network discovery to find all ESCs that are already configured (unconfigured ESC will not be discovered).
  2. Each discovered ESC is reset to default config (using uavcan.protocol.param.*) and restarted, so it enters passive mode and awaits uavcan.protocol.EnumerationRequest. Now all ESC are unconfigured and are ready for enumeration.
  3. For i=0..N (where N is provided by the user):
    1. Pixhawk broadcasts uavcan.protocol.EnumerationRequest with node_id set to an appropriate value.
    2. The user turns the motor; ESC assigns itself the requested Node ID, saves the config, and restarts (not in passive mode this time).
    3. Pixhawk makes sure that ESC is now online with proper Node ID.
  4. Enumeration is done now; however, the ESC are not ready to work yet because we need to assign motor indices. This is done automatically with no attention from the user. For each ESC:
    1. Set the config param uavcan_esc_index.
    2. Set the config param uavcan_light_index (optional, for RGB LED control).
    3. Save the config params into the non-volatile memory.
    4. Restart this ESC.
  5. Make sure that all N ESCs are online and have status code OK.

Note that this algorithm can be safely restarted from any stage.

@LorenzMeier
Copy link
Member Author

@pavel-kirienko The user will need to identify the ESCs not only in their order, but also regarding their position - therefore assigning an ID and a position is linked (since the flight code has a fixed mapping of ID to position). So step 3+4 will happen at the same time.

@pavel-kirienko
Copy link
Member

@LorenzMeier Yes, essentially it doesn't matter whether 3&4 happen at the same time or subsequently. It's just important to realize that Node ID and motor index are not the same thing.

A new idea: since we're asking user to turn the prop, we could also ask them to turn the prop in the right direction (CW/CWW) so we can configure the direction of rotation automatically too. It shouldn't be hard to implement.

@pavel-kirienko
Copy link
Member

Done.

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

2 participants