protocol
protocol copied to clipboard
High Resolution PWM control
I have a problem with the current protocol to control Arduino to generate high-resolution PWM. Since some Arduino can config some timers from 8-bit to 16-bit such that PWM can be controlled more accurately. However, due to the current protocol design, it can only transfer 14-bit of data for PWM control.
In my project, I have to change Arduino Firmata Express and Python Pymata4 to achieve a maximum transfer of 21-bit to achieve this case of use.
Just wondering if anyone else needs this feature.
I'm not sure I understand your requirement. Do you need a higher resolution of the duty cycle (e.g 16 bits) or a way to set the frequency (for which there's currently no option in the protocol)?
I'm not sure I understand your requirement. Do you need a higher resolution of the duty cycle (e.g 16 bits) or a way to set the frequency (for which there's currently no option in the protocol)?
Yap, I need a high-resolution duty cycle and the current protocol does not directly support it. (But it is not a problem, can be easily modified to achieve that )
Yap, I need a high-resolution duty cycle and the current protocol does not directly support it.
That's not exactly correct. To use more than 14 bits for the PWM resolution, you can use the EXTENDED_ANALOG message (described here) instead of the fixed-length ANALOG_MESSAGE. To take advantage of this, you need a board that supports the higher resolution, of course.
Yap, I need a high-resolution duty cycle and the current protocol does not directly support it.
That's not exactly correct. To use more than 14 bits for the PWM resolution, you can use the EXTENDED_ANALOG message (described here) instead of the fixed-length ANALOG_MESSAGE. To take advantage of this, you need a board that supports the higher resolution, of course.
I used an Arduino MEGA2560 and I can change some registers to let it support higher resolution. After that, it becomes a little bit different since I cannot directly call Arduino analogWrite() method.
analogWrite() takes an int (16 bit) as the second argument, so this should actually work. Have you created a test sketch that uses analogWriteResolution and analogWrite to test how this works with 16 bits?