question

Ryusuke T avatar image
0 Likes"
Ryusuke T asked Felix Möhlmann answered

How to avoid draining battery when AGV is blocked

Hi,

I don't want the battery to be drained when the AGV is blocked.

I added a load type in the AGV network settings, where I set the battery consumption to 0.

blocked.png

I set it to change to the newly set load type when it is blocked by Initialize Travel, but since Initialize Travel is triggered when the movement starts, it does not move as intended. What should I do?

1677489623191.png

FlexSim 22.0.11
blockedagv battery level
blocked.png (5.2 KiB)
1677489623191.png (21.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

This is a sort of "hacky" solution, so no guarantees that this will work flawlessly in every situation and no guaranteed forward compatability.

You can manipulate the discharge rate by changing the values in the respective AGVs node of the AGVNetwork. These keep track of when the rate last changed, what charge level the AGV was at at that point and the current rate. Inbetween the points when the rate changes, these values are used to calculate the "current" charge level when it is accessed.

1677496497538.png

The code (in the "On State Change" trigger) below changes these values when the AGV state changes "blocked". It then also stores the previous discharge rate in a label so it can be restored when the AGV changes out of the "blocked" state.

if(toState == STATE_BLOCKED && fromState != STATE_BLOCKED)
{
    treenode agvNode = AGV(current);
    AGV agv = agvNode;
    double curAmpHours = agv.ampHours;
    current.lastAmps = getsdtvalue(agvNode, "curAmps");
    setsdtvalue(agvNode, "lastAmpChangeTime", Model.time);
    setsdtvalue(agvNode, "lastAmpHours", curAmpHours);
    setsdtvalue(agvNode, "curAmps", 1);
}
if(fromState == STATE_BLOCKED && toState != STATE_BLOCKED)
{
    treenode agvNode = AGV(current);
    AGV agv = agvNode;
    double curAmpHours = agv.ampHours;
    setsdtvalue(agvNode, "lastAmpChangeTime", Model.time);
    setsdtvalue(agvNode, "lastAmpHours", curAmpHours);
    setsdtvalue(agvNode, "curAmps", current.lastAmps);
}

blocked_discharge_change_fm.fsm


5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.