9 years, 4 months ago.

Encoder problems. Counter methods.

I'm controlling a MIT with a inverter that I constructed. Then I need two things, read the actual speed rotor and, after a good math, write the correct spwm. My problem begin when I have to read the pulses of the encoder to calculate the actual speed rotor: I lost pulses in my rise interrupt, because when my program calculates and writes the spwm, it leave to read pulses. My solution probably is change this read method. Someone can help me? What about hardware counter? And How? My MBED is F401.

1 Answer

9 years, 4 months ago.

There is a hardware counter in the F401 that can do what you want with no meaningful CPU loading.

However that function isn't included in the mbed libraries. in order to use it you would need to access the CPU registers directly, if you've not done anything like this before it will be a learning experience.

The documentation is here: http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1577/LN1810/PF258797# look for the programming manual about 1/3 of the way down.

Accepted Answer

The pin responsable is PA_0, but I can't find this in the documentation and can't find examples to do this. I'm a litle beginner in programming. I'm better with pcb confection.

posted by Patrick Rodrigues 14 Jul 2015