VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Send custom device message from Stimulus Editor

Solved!
Go to solution

Hello,

 

We are currently implementing a Modbus Custom Device for Veristand. We have a working .vi for reading modbus data. 

What we want to achieve is a request / response kind of stimulus sequence, to read different registers based on their register ID.

 

Based on the register, we don't need to read them all periodically.

 

Based on what I have read so far; using channels seem like an inconvenient way to do this. My new approach is based on creating  a custom workspace component where I am able to communicate through the "Send custom device message.vi". This enables me to do the request / response kind of approach.

 

The problem however seems to be connecting this to the real-time sequence executor. Does anyone have a good way to do this? Either by sending custom device message directly from a real-time sequence, or by utilizing the variables in the workspace?

 

The other alternative is to establish a channel that indicates to the RT Veristand Engine when to request, and when a response is present.

 

Best Regards,

Jørgen

0 Kudos
Message 1 of 4
(5,464 Views)
Solution
Accepted by topic author JorgenG

The problem is that the real-time sequences are executed directly on the target, they have no connection with the workspace.

 

I would say that the custom device channel approach is the only one. Your custom device does not have to read all registers periodically, just create 2 output channel and 2 inputs,

 

on the inputs you set RegisterID and Updated? and on the output you set Data and Updated?.

 

Any time you want to read something set  the RegisterID and input Updated? to TRUE to tell the custom device to actually read something and then wait for the output Updated? to become true

 

PSEUDO CODE

 

timeout = 0.5

RegisterID = 1

in_Updated? = true

yeld     --ensure in_Updated? is set to true for 1 veristand engine cycle

in_Updated? = false

--then you just wait for the custom device to signal that Data is updated

multitask

task1

    while out_Updated? == false do

    stoptask(task2)

    [at this point you have valid updated data in Data from the custom device]

task2

    wait(timeout)

    stoptask(task1)

 

Message 2 of 4
(5,456 Views)

Thanks for the reply! 

 

Seems like your suggestion is the way to go! 🙂

0 Kudos
Message 3 of 4
(5,451 Views)

BTW we implemented something like that for something else and on top of my head I remeber we implemented an edge detector in the custom device on the in_updated? to make sure to update just once on request (even if someone forgot to reset the in_update? right after the yield.

0 Kudos
Message 4 of 4
(5,449 Views)