This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV2624: Writing and playing waveforms using a microcontroller

Part Number: DRV2624
Other Parts Discussed in Thread: USB2ANY

Tool/software:

I have been trying use the DRV2624 to play custom waveforms. I seem to not be able to execute any vibration on the haptic motor except for when I run the auto calibration. I understand that there is an inbuilt RAM to which the waveforms have to be written to in the specific manner. I am a bit confused about the write operation order when it comes to the configuration byte for it and the waveform itself (the voltage-time pairs), as to what order the whole sequence is to be written in and the registers.

  • Hello,

    Are you using the EVM or a custom board?

    I recommend using our GUI Haptic Control Console. This makes changing between modes and playing waveforms very simple. It also has a RAM manager. www.ti.com/.../HAPTICS-CONSOLE

    Regards,
    Sydney Northcutt

  • I've integrated the DRV2624 as part of a system I'm developing, it's on a custom board as such. I cannot use the EVM to explore the DRV2624 and use the GUI Haptic Control Console. I would only be able to write to the IC using the microcontroller.

    Regards,

    Adithya

  • Hi Aditya,

    The GUI is connectable via I2C. You just need a USB2ANY to interface. If this is not possible we have two sections in the datasheet that will be helpful here which are Initialization Procedure and Typical Usage Examples.

    You can also tell me the mode you are trying to operate in and share your scripts with me so I can help debug.

    Regards,
    Sydney Northcutt

  • Currently, I am doing the following as a test. Please guide me on what could be wrong with it. The idea is to write to the RAM the header for the waveform and then the waveform, and verify increments to see if the effect is being written properly.

    // Write start location
        uint8_t write_buffer[2] = {0xfd, 0x00};
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write RAM location MSB");
            return;
        }
        ESP_LOGI("I2C", "Successfully written RAM start location MSB");
    
        write_buffer[0] = 0xfe;
        write_buffer[1] = 0x01;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write RAM location LSB");
            return;
        }
        ESP_LOGI("I2C", "Successfully written RAM start location LSB");
    
        // Read for increment
        uint8_t read_buffer;
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        // Write effect size
        write_buffer[0] = 0xff;
        write_buffer[1] = 0x08;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write effect size to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written effect size to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        // Write effect
        write_buffer[0] = 0xff;
        write_buffer[1] = 0x1f;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        write_buffer[0] = 0xff;
        write_buffer[1] = 120;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        write_buffer[0] = 0xff;
        write_buffer[1] = 0;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        write_buffer[0] = 0xff;
        write_buffer[1] = 80;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        write_buffer[0] = 0xff;
        write_buffer[1] = 0x3f;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        write_buffer[0] = 0xff;
        write_buffer[1] = 120;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        write_buffer[0] = 0xff;
        write_buffer[1] = 0;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);
    
        write_buffer[0] = 0xff;
        write_buffer[1] = 80;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write to RAM");
            return;
        }
        ESP_LOGI("I2C", "Successfully written to RAM");
    
        // Read for increment
        write_buffer[0] = 0xfe;
        if (i2c_master_transmit_receive(drv2624_handle, write_buffer, 1, &read_buffer, sizeof(read_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to read RAM location");
            return;
        }
        ESP_LOGI("I2C", "Successfully read RAM location: %d", read_buffer);

    And this is the output

    I am unsure of my understanding about the writes since when I write the effect size (configuration byte of the waveform), there is no increment in RAM. Is this expected behavior or is something wrong?

  • After the above, I am waking up the DRV2624 module and then setting GO bit to 1 to run the waveform. The sequence by default should be waveform index 1 at the beginning, and the rest zeroes. So, it should automatically stop after playing that waveform once.

    write_buffer[0] = 0x07;
        write_buffer[1] = 0b01001001;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to wake up DRV2624");
            return;
        }
        ESP_LOGI("I2C", "Successfully woke up DRV2624");
    
        write_buffer[0] = 0x0c;
        write_buffer[1] = 1;
        if (i2c_master_transmit(drv2624_handle, write_buffer, sizeof(write_buffer), 100) != ESP_OK)
        {
            ESP_LOGE("I2C", "Failed to write go bit");
            return;
        }
        ESP_LOGI("I2C", "Successfully started effect");

    I don't see the motor moving at all when I do this, though.

  • Hi Adithya,

    Since you are not seeing any result on the load, lets remove the RAM portion so we can ensure this is the issue. A simple mode to set is real time playback (RTP) mode. The below script sets RTP mode at a low amplitude (25%). Can you run the below script to ensure the load is vibrating correctly?

    w 5a e 1f        #RTP mode at 25%
    w 5a c 1         #trigger GO bit
    delay time 
    w 5a c 0         #stop GO bit 

    We also have the below document on RAM operation with DRV2624. 
    DRV26x4 RAM Operation - External.docx

    Regards,
    Sydney Northcutt