Hello.lidar lite v3 product review. I have read the documents but could not understand the difference between pwm and i2c connections. What are the differences between pwm and i2c? What are the advantages of using pwm? How do I code if I use a pwm connection?
Hello @Cayir and welcome to the forum
There are lots of differences between PWM and I2C and in order to understand both I suggest reading the following material:
http://dlnware.com/dll/PWM-Pulse-Width-Modulation-Interface
http://dlnware.com/dll/I2C-Bus-Protocol
I’m not sure about the advantages of using PWM but I2C is probably much faster. Either way you have examples for both interfaces here:
Thanks for the answer. I know what I2C and pwm mean. But why would a user prefer i2c? Or why a user chooses the pwm interface. Which one is better in terms of speed, stability, controllability?
Hey @Cayir,
I’m assuming by now you’ve seen my answer here to your question.
In no particular order:
- Because you can get faster measurements out of the device (more specifically, read the resulting values faster)
- So you can access all of its registers and change their values / tune the device to your use case. You can also do this on the fly between measurements if needed in your robot/setup.
- Because you have a limited amount of pins available and need many sensors. I2C allows you to have multiple sensors/devices on just two GPIOs (the I2C lines).
There’s prob. a few more I didn’t think of at this time.
From what I understand people mostly choose PWM because previous hardware they used with their controller used a PWM based sensor and that way they don’t have to create new code (or they just can’t). Happens a lot with flight controllers and custom/semi-custom drones (such as quadcopters).
Definitely I2C hands down. You can choose the speed at which you communicate exactly. If there is too much noise or other issues you can switch to a lower speed.
It is digital comm and if your controller supports I2C in hardware you will get feedback about the data packets if there is any issue.
And of course you can configure and tweak the device during use which may be required in some use cases.
I hope this answers your question better / in a more complete way.
Sincerely,
thank you so much.