Skip to content

Command 13 Extra Basal

Joe Moran edited this page Sep 9, 2022 · 86 revisions

0x13 Set Basal Schedule Follow-on Command

The 0x13 command is the follow-on command for the Command 0x1A Table 0 case to set the basal schedule. This command always immediately follows the 0x1A command with Table 0 (basal schedule) in the same message.

The generic format of the 0x13 basal schedule follow-on command format is:

00 01 02 03 0405 06070809 0A0B 0C0D0E0F  1011 12131415
13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ [YYYY ZZZZZZZZ ...]
  • 13 (1 byte): Mtype value of $13 specifies set basal schedule follow-on command for a Command 0x1A Table 0.
  • LL (1 byte): Length of command.
  • BO (1 byte): Beep Options acrrrrrr, formerly RR Reminders, (typical PDM values $00, $3c, $40 and $7c):
    • a bit ($80) for acknowledgement beep (basal command received), not used by PDM (see below).
    • c bit ($40) for completion beep (doesn't actually do anything, see below).
    • rrrrrr (6 bits) # of minutes ($3c = 60 minutes) between Program Reminder beeps.
  • MM (1 byte): Schedule entry index [0 .. number_of_schedule_entries - 1].
  • NNNN (2 bytes): Remaining 1/10th of a pulse of insulin to deliver for current entry (i.e., # of pulses x 10).
  • XXXXXXXX (4 bytes): Delay until next 1/10th of a pulse, expressed in microseconds.
  • YYYY (2 bytes): Total 1/10th of a pulses of insulin for this schedule entry (i.e., # of pulses x 10).
  • ZZZZZZZZ (4 bytes): Delay between 1/10th of a pulse, expressed in microseconds. Example: 3.0 U/hr = 60 pulses per hour = 1 min between pulses = 6 secs for 1/10th of a pulse = 6,000,000 uS = 0x5b8d80

The PDM does not use the a acknowledgement beep bit ($80) on the BO Beep Options byte to implement Confidence Reminders. Rather, the PDM itself will beep at the start of the basal (presumably when this command has been acknowledged by the Pod). The PDM does use the c completion beep bit ($40) for Confidence Reminders, however it is actually meaningless as the basal program never completes normally. When a basal (or other insulin delivery) is stopped using the 0x1F Cancel Command, the beep option specified in the cancel command is used and the c completion beep bit is never checked.

The XXXXXXXX and ZZZZZZZZ values have a minimum value of 0x30d40 (=200,000 uS, i.e., 0.2 secs between 1/10th of a pulse or 2 secs between pulses) and a maximum value of 0x6b49d200 (=1,800,000,000 decimal, i.e., 5 hours between pulses).

As many sets of YYYY ZZZZZZZZ schedule entries are used as needed to fill out an entire 24 hour schedule. There is typically one YYYY ZZZZZZZZ pair for each InsulinScheduleElement in the Insulin Schedule of the $1A Command, but this is not necessarily the case as the PDM always tries to use the smallest length encoding possible. Since a single InsulinScheduleElement can only describe a maximum of 8 hours (see details here), adjacent napp elements with the same rate can have their pulse schedule specified by a single schedule entry.

NNNN and XXXXXXXX Calculation

The Pod internally deals with tenths of pulses and thus the time between pulses divided by ten. The XXXXXXXX (delayUntilNextTenthOfPulse) and NNNN (remainingPulses) values can be computed by the following Swift calculations:

delayUntilNextTenthOfPulse = timeRemainingInEntry.truncatingRemainder(dividingBy: (timeBetweenPulses / 10))
remainingPulses = pulsesPerHour * (timeRemainingInEntry-delayUntilNextTenthOfPulse) / .hours(1) + 0.1

Examples

0.05 U/hr for 24 hours

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ
2018-03-09T21:47:44 13 0e 40 00 0017 01036640 00f0 15752a00
2018-03-09T21:52:31 13 0e 40 00 0016 055d4a80 00f0 15752a00
2018-03-09T22:04:07 13 0e 40 00 0014 06dac2c0 00f0 15752a00
2018-03-09T22:23:32 13 0e 40 00 0011 01ba8140 00f0 15752a00
2018-03-09T22:47:44 13 0e 40 00 000d 0112a880 00f0 15752a00
2018-03-09T23:13:28 13 0e 40 00 0008 1054e880 00f0 15752a00
2018-03-09T23:20:01 13 0e 40 00 0007 0e4e1c00 00f0 15752a00
2018-03-24T00:48:35 13 0e 40 00 00e8 13ab6680 00f0 15752a00

3.0U/hr - 24 hours

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ
2018-03-10T12:31:07 13 0e 40 00 1aea 001e8480 3840 005b8d80
2018-03-10T22:03:09 13 0e 40 00 0492 000f4240 3840 005b8d80
2018-03-10T22:08:03 13 0e 40 00 0461 001e8480 3840 005b8d80
2018-03-10T22:27:39 13 0e 40 00 039d 000f4240 3840 005b8d80
2018-03-24T00:50:25 13 0e 40 00 3649 002dc6c0 3840 005b8d80
2018-03-24T11:01:12 13 0e 40 00 1e6d 005b8d80 3840 005b8d80
2018-03-24T17:44:23 13 0e 40 00 0eae 001e8480 3840 005b8d80
2018-03-24T17:48:23 13 0e 40 00 0e86 001e8480 3840 005b8d80
2018-03-24T17:54:38 13 0e 40 00 0e47 004c4b40 3840 005b8d80

29.95U/hr for 24 hours

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ
2018-03-29T10:25:58 13 1a 40 00 01bb 00056ce1 f5af 00092ba9 f5af 00092ba9 4632 00092ba9
2018-03-29T10:30:13 13 1a 40 00 0013 0002bf09 f5af 00092ba9 f5af 00092ba9 4632 00092ba9

30U/hr for 24 hours

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ
2018-03-24T17:38:27 13 1a 40 01 4ec5 000927c0 f618 000927c0 f618 000927c0 4650 000927c0
2018-03-24T17:46:38 13 1a 40 01 4b95 00030d40 f618 000927c0 f618 000927c0 4650 000927c0
2018-03-24T17:52:25 13 1a 40 01 4954 00061a80 f618 000927c0 f618 000927c0 4650 000927c0
2018-03-29T10:21:51 13 1a 40 00 0357 000927c0 f618 000927c0 f618 000927c0 4650 000927c0
2018-03-29T10:28:38 13 1a 40 00 00af 000927c0 f618 000927c0 f618 000927c0 4650 000927c0
2018-03-29T10:31:35 13 1a 40 01 f5a2 00061a80 f618 000927c0 f618 000927c0 4650 000927c0

3.0U/hr for 1 hour, 0.05U/hr for 23 hours

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ YYYY ZZZZZZZZ
2018-03-24T01:24:37 13 14 40 01 00e2 138ce200 0258 005b8d80 00e6 15752a00
2018-03-24T01:34:22 13 14 40 01 00e1 0623a7c0 0258 005b8d80 00e6 15752a00

0.05U/hr for 1 hour, 3U/hr for 23 hours

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ YYYY ZZZZZZZZ
2018-03-24T01:32:07 13 14 40 01 34a8 003d0900 000a 15752a00 35e8 005b8d80

3.0U/hr for 1 hour, 0.1 for 1 hour, 0.05U/hr for 22 hours

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ
2018-03-24T09:59:51 13 1a 40 02 008d 00d59f80 0258 005b8d80 0014 0aba9500 00dc 15752a00

3.0U/hr for 1 hour, 0.1 for 1 hour, 0.05U/hr for 21 hours, 3.0U/hr for 1 hour

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ
2018-03-24T10:05:42 13 20 40 02 0082 016e3600 0258 005b8d80 0014 0aba9500 00d2 15752a00 0258 005b8d80

1 hour each: 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, then 0.05 from 2pm to 12am

                    13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ
                                                   0.05          0.10          0.15          0.20          0.25          0.30          0.35          0.40          0.45          0.50          0.55          0.60          0.65          0.70          0.05              
2018-03-29T11:50:34 13 62 40 0b 0014 01406f40 000a 15752a00 0014 0aba9500 001e 07270e00 0028 055d4a80 0032 044aa200 003c 03938700 0046 0310bcdb 0050 02aea540 005a 02625a00 0064 02255100 006e 01f360e8 0078 01c9c380 0082 01a68d13 008c 01885e6d 0064 15752a00

Real World Example

This real world example was taken from here.

  • 00:00-02:59 @ 0.80 U/h
  • 03:00-04:59 @ 0.90 U/h
  • 05:00-07:29 @ 0.85 U/h
  • 07:30-12:29 @ 0.85 U/h
  • 12:30-14:59 @ 0.85 U/h
  • 15:00-17:59 @ 0.70 U/h
  • 18:00-19:59 @ 0.90 U/h
  • 20:00-23:59 @ 1.10 U/h
1a LL NNNNNNNN 00 CCCC HH SSSS PPPP napp napp napp napp napp napp napp
1a 1a 851072aa 00 0242 2a 1e50 0006 5008 3009 f808 3808 5007 3009 700b

13 LL BO MM NNNN XXXXXXXX YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ YYYY ZZZZZZZZ
13 2c 40 05 0262 00455b9c 01e0 015752a0 0168 01312d00 06a4 01432096 01a4 01885e6d 0168 01312d00 0370 00f9b074

See here for details on how the $1A portion of this command is encoded which involved merging the adjacent segments for the same 0.85 U/h rate and then splitting that result segment when encoding because it exceed the maximum 8 hour limit of a single InsulinScheduleElement.

The MM of 05 specifes the index #5 of the six YYYY ZZZZZZZZZ schedule entries. In this example, this is the last one of YYYY ZZZZZZZZ = $0370 $00f9b074 which works out to have 880 one-tenths of a pulse and 16.363636 seconds per one-tenth of pulse.

NNNN     $0262 => 610 tenths of pulses (61 pulses) to deliver in initial segment
XXXXXXXX $00455b9c => 4,545,436 uS or 4.545436 seconds to the next tenth of a pulse

YYYY     $01e0 => 480 / 10 = 48 total pulses
ZZZZZZZZ $015752a0 => 22,500,000 uS per 1/10 pulse or 225 sec/pulse
225 sec/pulse x 48 total pulses = 10,800 total seconds or 3 hours which corresponds to the
napp of $5008 [6 half hours at 8 pulses per half hour or 3 hours at 0.8 U/h]

YYYY     $0168 => 360 / 10 = 36 total pulses
ZZZZZZZZ $01312d00 => 20,000,000 uS per 1/10 pulse or 200 sec/pulse
200 sec/pulse x 36 total pulses = 7,200 total seconds or 2 hours which corresponds to the
napp of $3009 [4 half hours at 9 pulses per half hour or 2 hours at 0.9 U/h]

YYYY     $06a4 => 1700 / 10 = 170 total pulses
ZZZZZZZZ $01432096 => 221,176,470 uS per 1/10 pulse or 211.76470 sec/pulse
211.76470 sec/pulse x 170 total pulses = ~36,0000 total seconds or ~10 hours which corresponds to the adjacent
napp of $f808 [16 half hours at 8.5 pulses per half hour or 8 hours at 0.85 U/h] and the
napp of $3808 [4 half hours at 8.5 pulses per half hour or 2 hours at 0.85 U/h]

YYYY     $01a4 => 420 / 10 = 42 total pulses
ZZZZZZZZ $01885e6d => 25,717,285 uS per 1/10 pulse or 257.17285 sec/pulse
257.17285 sec/pulse x 42 total pulses = ~10,800 total seconds or ~3 hours which corresponds to the
napp of $5007 [10 half hours at 7 pulses per half hour or 5 hours at 0.7 U/h]

YYYY     $0168 => 360 / 10 = 36 total pulses
ZZZZZZZZ $01312d00 => 20,000,000 uS per 1/10 pulse or 200 sec/pulse
200 sec/pulse x 36 total pulses = 7,200 total seconds or 2 hours which corresponds to the
napp of $3009 [4 half hours at 9 pulses per half hour or 2 hours at 0.9 U/h]

YYYY     $0370 => 880 / 10 = 88 total pulses (8 half hours at 11 pulses per half hour)
ZZZZZZZZ $00f9b074 => 16,363,636 uS per 1/10 pulse or 163.63636 sec/pulse
163.63636 sec/pulse x 88 total pulses = ~14,400 total seconds or ~4 hours which corresponds to the
napp of $700b [8 half hours at 11 pulses per half hour or 4 hours at 1.1 U/h]

Restrictions

The $13 subcommand to set the basal schedule can only be used when the current Pod Progress State is 5, 6 or between 8 and 12. The $13 subcommand must always appear directly after the $1A Command for Table 0 (Basal Schedule) and cannot be combined with any other commands in the same message.

Clone this wiki locally