Servo with SSD1306 and TIMER_INPUT_FREQ_DUTY_MEASUREMENT

Post here first, or if you can't find a relevant section!
Post Reply
greenail
Posts: 2
Joined: Tue Jan 21, 2020 11:52 pm

Servo with SSD1306 and TIMER_INPUT_FREQ_DUTY_MEASUREMENT

Post by greenail »

I'm trying to turn a knob with a servo for ... reasons ... and while all of the features I want are working individually they do not work when combined.

My code is here: https://gist.github.com/jschoch/9afa3cf ... 2ef394956b

Right now the servo writes to the 0 position on setup. This is setup before my PWM measurment timer is started and configured. The signal works and the servo moves to the 0 position and I can see a good signal on my scope. After that setup routine and the timer has been started I cannot get the servo to move and the signal looks like this:

https://drive.google.com/open?id=18B-S0 ... 6U33V3ddXx

this is when the servo should be doing nothing.

https://drive.google.com/open?id=18A5oX ... iZfe1UdBTX

I'm wondering what may be causing this. I've tried a variety of pins with no effect on the servo signal. The PWM measurement works fine and the i2c display also works fine. I tried to pause the timer before I called servo.write but that did not seem to help. Any thoughts, is this a bug?
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Servo with SSD1306 and TIMER_INPUT_FREQ_DUTY_MEASUREMENT

Post by ag123 »

you did not mention your core or your board, no one can guess what are those.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Servo with SSD1306 and TIMER_INPUT_FREQ_DUTY_MEASUREMENT

Post by fpiSTM »

Looking at the code, it is for the STM32 core.

If it works individually, I guess you can have those kind of issues:
- IRQ priority
- TIMER shared ressource

The best would be you can debug to see exactly why you failed?
ABOSTM
Posts: 60
Joined: Wed Jan 08, 2020 8:40 am
Answers: 7

Re: Servo with SSD1306 and TIMER_INPUT_FREQ_DUTY_MEASUREMENT

Post by ABOSTM »

I agree with fpiSTM, also take care with frequency measurement:
if input frequency is too high, you may send most of your time in interrupt callbacks
greenail
Posts: 2
Joined: Tue Jan 21, 2020 11:52 pm

Re: Servo with SSD1306 and TIMER_INPUT_FREQ_DUTY_MEASUREMENT

Post by greenail »

It is a blue pill f103

I have it working now. I had to delay after the servo.write and I also changed the prescaler on the timer. Not sure which one fixed it or if both helped.

Now i need to get it in a shielded box since the EMI from the spindle motor creates noise and false readings when running > 80% speed.
Post Reply

Return to “General discussion”