cancel
Showing results for 
Search instead for 
Did you mean: 

PWM signal randomly dropping.

ESpra.1
Senior

I'm working with an STM32L552ZET6Q and two DRV2605L vibration motor drivers (Adafruit breakout board version. Link to chip datasheet below).

https://www.ti.com/lit/ds/symlink/drv2605l.pdf?ts=1683119643574&ref_url=https%253A%252F%252Fwww.google.com%252F

The DRVs are configured to drive an LRA coin motor based on a PWM input from the L5 unit; A PWM signal is transmitted from the L5's TIM1 Channel 1 or 2 (pins E9 or E11, depending on which DRV2605L unit I'm using at a given moment). The DRV2605L then changes the strength of attached LRA motor's vibration based on the duty cycle of the PWM signal.

The PWM signal is adjusted via a voltage divider to bring it within a certain voltage range, as using the device without it would cause the DRV to get locked into a certain signal strength if the signal was too high.


_legacyfs_online_stmicro_images_0693W00000bjJzzQAE.pngFor some reason, over a prolonged period of operation, the PWM signal coming from the L5 will randomly drop to a zero duty-cycle before returning to its original level. These drops can occur in quick succession, or with several minutes in between occurrences.

Below is an image of the timer configuration for the PWM drivers in question.


_legacyfs_online_stmicro_images_0693W00000bjK0EQAU.pngI don't believe this is a power problem, as I am also driving three servo motors in this same setup, and they aren't even jittering when this happens. Whatever is happening appears to be limited to just timer 1.

Below is some of the firmware used to configure the DRV2605L and control the PWM signal to its input.

void init_LRA(struct DRV *lra)
{
	writeRegister8(lra, DRV2605_REG_MODE, 0x43);
	HAL_Delay(1);
	init_driver(lra);
	DRV2605_setMode(lra, DRV2605_MODE_PWMANALOG);
	HAL_Delay(1);
	writeRegister8(lra, DRV2605_REG_CONTROL3, 3);
	HAL_Delay(1);
	DRV2605_useLRA(lra);
	HAL_Delay(1);
	DRV2605_selectLibrary(lra, 6);
	HAL_Delay(1);
	writeRegister8(lra, DRV2605_REG_MODE, 0x03); //change to 0x03 to enable the DRV2605L, or 0x43 to disable the DRV2605L
	DRV2605_PWM_Start(lra);
	//smoothHaptics(lra, 65);
}
void init_driver(struct DRV *drv)
{
	writeRegister8(drv, DRV2605_REG_MODE, 0x00);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_RTPIN, 0x00);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_WAVESEQ1, 0x01);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_WAVESEQ2, 0x00);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_OVERDRIVE, 0x00);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_SUSTAINPOS, 0x00);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_SUSTAINNEG, 0x00);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_BREAK, 0x00);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_AUDIOMAX, 0X64);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_FEEDBACK, 0x80);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_REG_CONTROL3, 0xA3);
	HAL_Delay(1);
	writeRegister8(drv, DRV2605_MODE_PWMANALOG, 0x06);
	HAL_Delay(1);
}

This function is meant to smoothly move the vibration level up and down, rather than having it be so sudden.

If anyone has any explanations/suggestions, that would be great.

edit: Based on further research, I tried enabling auto-reload preload, but that hasn't fixed the problem either.

4 REPLIES 4

Sorry, but from your description I have no idea what do you do with the PWM, what influences it and how, what is the expected behaviour and how does the observed one depart from the expectation.

Observe the PWM output using a LA and try to capture the anomaly.

Try to reduce unknowns by reducing your program to absolute minimum which still exhibits the problem, e.g. is the PWM output stable if you don't try to change the PWM's duty?

JW

The PWM signal remains the same whenever this happens. For some reason, it just drops out for a brief moment before coming back.

I output a PWM signal from the L5 through a voltage divider and into the DRV2605L's input pin. I'm using the voltage divider because pushing the voltage too high appears to cause a glitch (not damage) where the signal gets stuck high and can't go back down.

I'll try to collect more information, but this is all I have right now.

> The PWM signal remains the same whenever this happens. For some reason, it just drops out

"Drops out" is not the same as "remains the same", IMO.

Doesn't the STM32 reset? Toggle a pin (blink a LED) after reset and observe it.

JW

I meant to say that I'm not changing the signal prior to it dropping out. It just drops out, then quickly returns to normal. The STM32 isn't resetting either. I attached a logic analyzer to see if these moments were happening in relation to communication with a sensor connected to the STM32 via UART; monitoring both the UART communication back and forth, as well as the PWM behavior. I'm still picking through analysis (it took at least 747 seconds before the signal dropped for the first time that session), but I haven't seen any evidence of a reset. I request data from the sensor via a command from my PC sent via USB. The STM32 then requests the data from the sensor via UART and transmits said data back through USB to the PC. At least to the naked eye, there isn't any evidence of that stream of requests and responses being interrupted. Besides, if it was a reset, I would have expected the other PWM channel connected to the LRA driver to exhibit the same behaviour at the same time. It has not. if it had, the LRA's buzzing would have undergone a similar rapid change to the one I was monitoring.

To be clear, both PWM channels can exhibit this behavior, but it's only one at a time. They don't both drop out at the same time.