Hi,
I intend to utilise PowerVision 's Expression Language.
I build a test setup. A microcontroller board sends extended CAN messages periodically to PV780 's CAN2 port at 250kbps . Message 's ID is: 0x18FF0102. There are 3 Bytes data in the message; they are speed, torque and power.
According to Programming Reference Manual 2.7 (pg: 34). I have to trigger an event for using these calculations. I assigned events to keys, but they did not work. Can you please help me about Calculation Event activation? You can see my PowerVision configuration in the attachment.
I can do same data processing via script. What is your suggestion for script vs. calculation event (or expression language)?
Regards.
Murat
Expression Language and Received Data Processing
- MuratE
- Posts: 25
- Joined: Mon Jan 05, 2015 5:57 am
Expression Language and Received Data Processing
- Attachments
-
- Test_Calculation_Event.zip
- (678.12 KiB) Downloaded 10 times
Eppur Si Muove
- stalley
- Enovation Controls Development
- Posts: 618
- Joined: Tue Mar 18, 2014 12:57 pm
Re: Expression Language and Received Data Processing
Hello Murat,
The result of the expression will be the value stored in the variable.
In the document, it shows 1 for the Expression in the Calculate Day/Night Day. It doesn't show Day/Night = 1. In your configuration, you had
I would recommend using processing provided by the PowerVision system applications to simplify your configuration. I added the TestMsg.ReceiveComplete event. If you look at what it does in the Programming, under Actions, you find the three calculation events to parse out the bytes and set the values. The Complete Event is there so that you know in the config when the whole message data is ready. Most times this doesn't matter too much, incoming parameters are processed as they are ready, not when all of the parameters of a message have been received and stored in the database so the config can use it. I used it here as a way to know when to update the variables. I could have used an On change event on the ReceivedData variable. Either way would work in this situation.
I think the use of scripts vs. calculation events depends on the amount and type of processing needed. Personally, I try to do as much as I can with events, actions, calculation events and simple state machines. If I need more complex logic, I will use scripts or activity programs.
Looks like you are learning and making progress! Keep up the good work.
The result of the expression will be the value stored in the variable.
In the document, it shows 1 for the Expression in the Calculate Day/Night Day. It doesn't show Day/Night = 1. In your configuration, you had
The expression "compilor" will see this as a logical expression because of the =, so you would always see 0 or 1. I am sending your config back with a few changes so that it will parse the three bytes from the message into the one byte variables. It is rather complicated by the BitAnd and BitShift functions.power = BitwiseAnd(ReceivedData, 0xFF00)
I would recommend using processing provided by the PowerVision system applications to simplify your configuration. I added the TestMsg.ReceiveComplete event. If you look at what it does in the Programming, under Actions, you find the three calculation events to parse out the bytes and set the values. The Complete Event is there so that you know in the config when the whole message data is ready. Most times this doesn't matter too much, incoming parameters are processed as they are ready, not when all of the parameters of a message have been received and stored in the database so the config can use it. I used it here as a way to know when to update the variables. I could have used an On change event on the ReceivedData variable. Either way would work in this situation.
I think the use of scripts vs. calculation events depends on the amount and type of processing needed. Personally, I try to do as much as I can with events, actions, calculation events and simple state machines. If I need more complex logic, I will use scripts or activity programs.
Looks like you are learning and making progress! Keep up the good work.
- Attachments
-
- Test_Calculation_Event2.zip
- (680.23 KiB) Downloaded 9 times
Sara Talley
Software Engineer
Enovation Controls
Software Engineer
Enovation Controls
- MuratE
- Posts: 25
- Joined: Mon Jan 05, 2015 5:57 am
Re: Expression Language and Received Data Processing
Hi Sara,
Thanks for your help and detailed explanation.
I am familiar with C and I tend to do everything with script. But your event based system very useful and practical after learning syntax and fundamentals of your system.
I tried Fire On Change option receivedData in my configuration and it seems more efficent for me.
Now, I try to create conditional event. I made some changings in my previous configuration. There are Turning Signals in my current configuration. I want to activate them according to received speed value conditions below:
I have tried different combinations but I could not achieve. Can you please help me about the problem? You can see the current configuration in the attachment.
Regards.
Murat
Thanks for your help and detailed explanation.
I am familiar with C and I tend to do everything with script. But your event based system very useful and practical after learning syntax and fundamentals of your system.
I tried Fire On Change option receivedData in my configuration and it seems more efficent for me.
Now, I try to create conditional event. I made some changings in my previous configuration. There are Turning Signals in my current configuration. I want to activate them according to received speed value conditions below:
Code: Select all
while (speed > 50 && speed < 150)
Turning Signals blink (ON/OFF) on display with 500ms periods.
Regards.
Murat
- Attachments
-
- Test_Calculation_Event.zip
- (679.4 KiB) Downloaded 7 times
Eppur Si Muove
- stalley
- Enovation Controls Development
- Posts: 618
- Joined: Tue Mar 18, 2014 12:57 pm
Re: Expression Language and Received Data Processing
Hello Murat,
I'm sending an update to your config. I only have a PV450 with CAN 2, it was easier to change the screen a little. I hope you can see what I have done, easily.
There is a state machine to control flashing the turn signal Image widget, Flashing.
The on change event for the speed variable is the condition event that checks the speed on the Start Flashing event in the state machine.
I changed the turningSignal variable to be turnLampControl. This variable controls the visibility of the turning signal Image Widget. I put a couple of calculation events on the turnLampControl variable. The calculation events on the turnLampControl are used in the Flashing state machine.
I usually have to take some time to think about how the condition event and the events are tied together. We fire the condition event which controls whether or not the parent event will be fired.
Hope this helps clarify how to use the Condition Events.
I'm sending an update to your config. I only have a PV450 with CAN 2, it was easier to change the screen a little. I hope you can see what I have done, easily.
There is a state machine to control flashing the turn signal Image widget, Flashing.
The on change event for the speed variable is the condition event that checks the speed on the Start Flashing event in the state machine.
I changed the turningSignal variable to be turnLampControl. This variable controls the visibility of the turning signal Image Widget. I put a couple of calculation events on the turnLampControl variable. The calculation events on the turnLampControl are used in the Flashing state machine.
I usually have to take some time to think about how the condition event and the events are tied together. We fire the condition event which controls whether or not the parent event will be fired.
Hope this helps clarify how to use the Condition Events.
Sara Talley
Software Engineer
Enovation Controls
Software Engineer
Enovation Controls
- MuratE
- Posts: 25
- Joined: Mon Jan 05, 2015 5:57 am
Re: Expression Language and Received Data Processing
Hello Sara,
Thanks for your explanation. It is very clear.
I adapted your configuration to my PV780. It works as I expected.
Have a nice day.
Regards.
Murat
Thanks for your explanation. It is very clear.
I adapted your configuration to my PV780. It works as I expected.
Have a nice day.
Regards.
Murat
Eppur Si Muove