deltaphi / c6021light

Feature-compact DIY version of the c6021
GNU General Public License v3.0
3 stars 3 forks source link

Speed levels requested by LN devices always answered with one speed level lower #15

Closed glaserf closed 3 years ago

glaserf commented 3 years ago

It seems speed levels requested from LN get answered with the level below. This leads to a "stiff" control behavior when increasing the speed of an engine; you basically have to beat the speed of the bus. When decelerating, slowing down is consequently accelerated by a factor of 2. Here is an example, RX are requested speed steps from LN:

LN RX:  a0 1 4 5a [OPC_LOCO_SPD] Slot: 1 Speed: 4
LN TX:  a0 1 3 20 [OPC_LOCO_SPD] Slot: 1 Speed: 3
LN RX:  a0 1 5 5b [OPC_LOCO_SPD] Slot: 1 Speed: 5
LN TX:  a0 1 4 20 [OPC_LOCO_SPD] Slot: 1 Speed: 4
LN RX:  a0 1 6 58 [OPC_LOCO_SPD] Slot: 1 Speed: 6
LN TX:  a0 1 5 20 [OPC_LOCO_SPD] Slot: 1 Speed: 5
LN RX:  a0 1 7 59 [OPC_LOCO_SPD] Slot: 1 Speed: 7
LN TX:  a0 1 6 20 [OPC_LOCO_SPD] Slot: 1 Speed: 6
LN RX:  a0 1 7 59 [OPC_LOCO_SPD] Slot: 1 Speed: 7
LN RX:  a0 1 8 56 [OPC_LOCO_SPD] Slot: 1 Speed: 8
LN TX:  a0 1 7 20 [OPC_LOCO_SPD] Slot: 1 Speed: 7
LN RX:  a0 1 8 56 [OPC_LOCO_SPD] Slot: 1 Speed: 8
LN RX:  a0 1 9 57 [OPC_LOCO_SPD] Slot: 1 Speed: 9
LN TX:  a0 1 8 20 [OPC_LOCO_SPD] Slot: 1 Speed: 8

As a consequence, an engine will lose one speed step per LN refresh cycle and will eventually stop:

LN RX:  a0 1 8 56 [OPC_LOCO_SPD] Slot: 1 Speed: 8
LN TX:  a0 1 7 20 [OPC_LOCO_SPD] Slot: 1 Speed: 7
- pause -
LN RX:  a0 1 7 59 [OPC_LOCO_SPD] Slot: 1 Speed: 7
LN TX:  a0 1 6 20 [OPC_LOCO_SPD] Slot: 1 Speed: 6
- pause -
LN RX:  a0 1 6 58 [OPC_LOCO_SPD] Slot: 1 Speed: 6
LN TX:  a0 1 5 20 [OPC_LOCO_SPD] Slot: 1 Speed: 5
- pause -
LN RX:  a0 1 5 5b [OPC_LOCO_SPD] Slot: 1 Speed: 5
LN TX:  a0 1 4 20 [OPC_LOCO_SPD] Slot: 1 Speed: 4
- pause -
LN RX:  a0 1 4 5a [OPC_LOCO_SPD] Slot: 1 Speed: 4
LN TX:  a0 1 3 20 [OPC_LOCO_SPD] Slot: 1 Speed: 3
- pause -
LN RX:  a0 1 3 5d [OPC_LOCO_SPD] Slot: 1 Speed: 3
LN TX:  a0 1 2 20 [OPC_LOCO_SPD] Slot: 1 Speed: 2
- pause -
LN RX:  a0 1 2 5c [OPC_LOCO_SPD] Slot: 1 Speed: 2
LN TX:  a0 1 1 20 [OPC_LOCO_SPD] Slot: 1 Speed: 1
- pause -
LN RX:  a0 1 1 5f [OPC_LOCO_SPD] Slot: 1 Speed: 1
LN TX:  a0 1 0 20 [OPC_LOCO_SPD] Slot: 1 Speed: 0
- pause -
LN RX:  a0 1 0 5e [OPC_LOCO_SPD] Slot: 1 Speed: 0
LN TX:  a0 1 0 20 [OPC_LOCO_SPD] Slot: 1 Speed: 0
deltaphi commented 3 years ago

Can at least partially be reproduced with test cases added in 9e475f89cabccccb2c08a42db4349208e6de9056. There may be additional issues related to devices on the bus that are not reflected in unit testing.