State Machine Priority

Discuss issues and ideas you have to configuring displays with PowerVision
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

State Machine Priority

Post by cconner_aie » Fri Apr 22, 2016 9:11 am

Hello,

Can you tell me how priorities work in state machines. Here is a mock up of our start sequence. Some of it may not make sense because this isn't the actually state machine, just a layout out to give you an idea of what I'm doing.
Image

Specifically here:
Image

In the "Timer Inc + 50" state, I will have three exit conditions:
  • Timer < 10s - Condition ran if a timer variable is less than 10000
    Timer >= 10s - Condition ran if timer variable is greater than or equal to 10000
    Engine RPM > 600 - Condition ran if engine RPM is greater than 600
The first two can not overlap, however there will be a case when the engine RPM is greater than 600 and timer variables fits one of the first two conditions. I need the engine rpm to be priority, otherwise our starter will stay engaged while the engine is running.

This would be easier with an activity program using the logic if blocks but I don't see a way to use timers within an activity.

Thanks,
Coleby Conner
Controls Engineer, Anderson Industrial Engines
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

Re: State Machine Priority

Post by cconner_aie » Fri Apr 22, 2016 9:33 am

To add to this,

I have safety checks to add and a few other things which will start to get very messy. It could all be cleaned up and condensed into a 20 line or so script, however I see some issues with that.

Using a PV480 for reference and Power Vision 2.8 OEM.

IO Control
Digital outputs appear to be read only and can only be accessed with the IO Port Manager, which is fine, but wouldn't that mean I should be able to use the SendAction function? E.G.

Code: Select all

SendAction(ApplicationIDs.IO, ActionIDs.IO_Digital_Output_High, VariableIDs.IO_Digital_Output_1);
I tried this in another area and it wouldn't work, the only way I can toggle a output is by a setting up an event with the IO function defined as an action which I can call from a state machine or button press, but again this will not work.

Code: Select all

SendAction(ApplicationIDs.CCM, ActionIDs.CCM_Fire_Event, EventIDs.StartSigHigh);
Forcing me to use a state machine, activity program, or button press.

Stability With Timers
I think I can set up a timer using a state machine to increment a variable that can then be read from the script, however that would mean I'd have to sit in a loop within the script like this.

Code: Select all

	int timerVar, timerMax;
	smRead(VariableIDs.TimerVar, timerVar);
	smRead(VariableIDs.TimerMax, timerMax);
	
	SendAction(ApplicationIDs.CCM, ActionIDs.CCM_Start_Timer, VariableIDs.Start_Timer);
	
	while (timerVar < timerMax);
	
	SendAction(ApplicationIDs.CCM, ActionIDs.CCM_Stop_Timer, VariableIDs.Start_Timer);
With no way to delay the script I think this would be very resource intensive on the panel, also I'm not sure how threading works in the background and I'm not sure if sitting in a loop like this would prevent any UI feed back.

I haven't put a lot of time into writing this as a script because I've tried something similar before and the scripting side seems somewhat limited to what you can do even though the functions are available, which is a little disappointing.

Just looking for confirmation on working on the scripting side, I'd prefer to work with scripts rather than state machines due to increasing complexity but can work around it if it's not an option.
Coleby Conner
Controls Engineer, Anderson Industrial Engines
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: State Machine Priority

Post by stalley » Fri Apr 22, 2016 9:41 am

Hi Coleby,

Post 1:
If I understand your question, I would make the Engine > 600 the first state after the timer expires (I'm assuming). Check the RPMs there and transition to the Engine Running or Timer Inc + 50.

Post 2:
Since you are designing an engine controller, I would recommend doing something similar to the MPC10 and MPC20 configurations. The monochrome displays don't have scripting so everything is done with activity programs and a few state machines.

Look in the Engine App folder. The controlling activity is the __Engine App. It is run on a 250ms timer. There is a big switch shape for the different states that the engine needs to go through. Different states have different activity programs. You could do something similar with scripts.
Sara Talley
Software Engineer
Enovation Controls
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

Re: State Machine Priority

Post by cconner_aie » Fri Apr 22, 2016 9:47 am

Ah, yes. That would be a simple solution - not sure why I didn't think of that.

I can work with that. Any comment on my additional post in my reply about the scripting side, I assume I'm out of luck but it'd be great if I was wrong.

Thanks again Sara,
Coleby Conner
Controls Engineer, Anderson Industrial Engines