## Protocol - PWM over UDP (port 2116)

#### PWM - Set PWMs

00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

'e' | 'F' | 'i' | 'r' | ||||||||||||||||||||||||||||

'm' | 'a' | 't' | 'a' | ||||||||||||||||||||||||||||

'P' | 'W' | 'M' | Version = 0 | ||||||||||||||||||||||||||||

Reserved = 0 | |||||||||||||||||||||||||||||||

PWM Batch(es) ... ... (each batch is 36 octets) ... |

Each batch controls up to 32 PWM values.

The number of batches is inferred from the packet length.

#### a PWM Batch

00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

Bitmask (1=set pwm, 0=ignore) | |||||||||||||||||||||||||||||||

PWM[0] | PWM[1] | PWM[2] | PWM[3] | ||||||||||||||||||||||||||||

PWM[4] | PWM[5] | PWM[6] | PWM[7] | ||||||||||||||||||||||||||||

PWM[8] | PWM[9] | PWM[10] | PWM[11] | ||||||||||||||||||||||||||||

PWM[12] | PWM[13] | PWM[14] | PWM[15] | ||||||||||||||||||||||||||||

PWM[16] | PWM[17] | PWM[18] | PWM[19] | ||||||||||||||||||||||||||||

PWM[20] | PWM[21] | PWM[22] | PWM[23] | ||||||||||||||||||||||||||||

PWM[24] | PWM[25] | PWM[26] | PWM[27] | ||||||||||||||||||||||||||||

PWM[28] | PWM[29] | PWM[30] | PWM[31] |

The bitmask allows us to change some PWM values, while leaving others alone. If the mask is 1, then we are setting the value, based on the data in the packet. If the mask is 0, then the eFirmata will leave that PWM alone.

The bitmask is big-endian which, sadly, means that the right-most bit (lsb) corresponds to PWM#0 (the first PWM value) and the left-most bit (msb) corresponds to to PWM#31 (the last PWM value).

Each pwm value is an unsigned, 8 bit integer. 0 is a duty cycle of 0%. 127 is a duty cycle of 49.8%. 255 is a duty cycle of 100%.

For the LPC1768 / LPC1769 microcontroller, we ignore PWM#0. We start counting at PWM#1 (going up to PWM#6). This allows us to have consistent numbering with the LPC datasheet. (And, of course, we ignore PWMs #7 through #31, because the LPC only has 6 physical outputs.)

#### Response

There is no response packet. Good luck.