2
\$\begingroup\$

I'm looking at the AS5311 magnetic field position sensor.

The IC presents a couple ways of getting the absolute position of the magnet in relation to the sensor. You can either read out a 12-bit value from the serial port, or use the 244Hz PWM output.

The datasheet says that you should average/filter the values to obtain an accurate result. Does using the PWM output make this easier or something?

In what situations would I want to use the PWM output instead of the simple digital interface?

\$\endgroup\$
5
\$\begingroup\$

I haven't read the data sheet in detail, but you barely need any code on a microcontroller to bring in the PWM signal. A capture interrupt is just about all you need. Can't get much simpler. No protocol to match, no baud rate ....

If you need to bring the data into a computer, however, you'd certainly use the serial protocol.

Read carefully, though. There may be ways to bring in MORE data or read settings and the like over the serial protocol that aren't accessible via PWM, and you certainly can't send any config info to the chip via a one-way PWM, so if you need to talk to the IC, you may have to implement a serial port anyway.

\$\endgroup\$
  • \$\begingroup\$ Ah, yes, that's true. The status bits and field "health" are reported over the serial interface. Kinda forgot about those. \$\endgroup\$ – dext0rb Nov 7 '13 at 18:37
  • \$\begingroup\$ I don't really see the point of the PMW output at all if you should read the serial interface to make sure everything is calibrated and working OK, though. \$\endgroup\$ – dext0rb Nov 7 '13 at 18:46
  • \$\begingroup\$ I think it would be a good bit easier to code the PWM on a microcontroller. In a production unit, you might not need the extra info and rest your laurels on Good Manufacturing Practice, instead. Maybe you'd be able to use a less expensive microcontroller if you just use a one pin CCP instead of a 2-pin serial port. It may also just plug in to existing servo controllers via PWM \$\endgroup\$ – Scott Seidman Nov 7 '13 at 18:54
  • \$\begingroup\$ Hmmm...ok! Thanks for explaining some reasons why you'd just use PWM. I understand now. \$\endgroup\$ – dext0rb Nov 7 '13 at 18:59
  • \$\begingroup\$ I think they provide the PWM output just in case you're trying to interface with analog circuitry. If your only choice is a PWM, then you're stuck. But personally, I would go with a serial port any day. Once you get it working, you're basically guaranteed to get the sensor's entire range and resolution without any added noise or distortion due to filtering and/or capturing the PWM data. \$\endgroup\$ – alex.forencich Nov 8 '13 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.