Using Two Thresholds with a Combination Trigger

This is a continuation from the Stopping a Robot if It Tips Over example. In this page, we'll set up an additional threshold trigger and combination trigger which will add pitch detection. The GPIO action will need to be modified to reference a new trigger.

 

NOTE: This example can be easily adapted to the 3DM-CV7 by substituting GPIO 1 or GPIO 2 for GPIO 4.

 

Add Another Threshold Trigger

We'll add pitch thresholds just like we did for roll. This time we'll use trigger instance 2 and the pitch parameter.

Command: Event Trigger Configuration (0x0C,0x2E)

  • Function: WRITE (0x01)
  • Instance: 2
  • Type: Threshold (0x02)
  • Parameters:
    • Descriptor Set: 0x80 (Sensor Dataset)
    • Field Descriptor: 0x0C (Euler Angles)
    • Parameter ID: 2 (Pitch)
    • Mode: WINDOW (0x01)
    • Low Threshold: +0.7853981 (+45 degrees)
    • High Threshold: -0.7853981 (-45 degrees)

Command bytes: 010202800c02013fe921fb323ae5afbfe921fb323ae5af
MIP Command: 75650c19 192e010202800c02013fe921fb323ae5afbfe921fb323ae5af e268

Enable the new threshold trigger

Command: Event Control (0x0C,0x2B)

  • Function: WRITE (0x01)
  • Instance: 2
  • Mode: ENABLE (0x01)

Command bytes: 010201
MIP Command: 75650c05 052b010201 1f84

 

Combination Trigger

We want to trigger the E-stop if either axis exceeds the threshold, so we'll need a combination trigger set to activate if any of its inputs are active. Referencing the "Common Logic Values" table on the Trigger: Combination page, we'll select the value 0xFFFE which means "any input". We'll assign the roll axis to input A and the pitch axis to input B. If you had additional trigger sources, they could be assigned slots C or D, but for this example they are set to 0.

Command: Event Trigger Configuration (0x0C,0x2E)

  • Function: WRITE (0x01)
  • Instance: 3
  • Type: Combination (0x03)
  • Parameters:
    • Logic Table: 0xFFFE
    • Inputs: [1 (roll), 2 (pitch), 0, 0]

Command bytes: 010303fffe01020000
MIP Packet: 75650c0b 0b2e010303fffe01020000 31f6

Enable the Combo Trigger

Command: Event Control (0x0C,0x2B)

  • Function: WRITE (0x01)
  • Instance: 3
  • Mode: ENABLE (0x01)

Command bytes: 010301
MIP Command: 75650c05 052b010301 2086

 

Modify the GPIO Action

The GPIO action needs to reference the new combination trigger.

Command: Event Action Configuration (0x0C,0x2F)

  • Function: WRITE (0x01)
  • Instance: 1
  • Trigger ID: 3 (must match the combo trigger above)
  • Type: GPIO (0x01)
  • Parameters:
    • Pin: 4
    • Mode: ONESHOT_HIGH

Command bytes: 010103010401
MIP Packet: 75650c08 082f010103010401 303f

 

Test it

Tipping the 3DM-CV7 past 45 degrees in any direction will set the GPIO output high. As in the original example, it must be reset with the GPIO State (0x0C,0x42) command.