Rajesh Anand
Hello, I have a small doubt.

Say I have used a delay in the program for 4s and the cycle time is fixed to 20ms (default time). Now the time it takes to execute the program will be more than 4 seconds right? and what happens to the cycle time in this case?
Quote 0 0
thiagoralves
There is no delay in PLC programming, otherwise it would mess up the whole system. Instead, to deal with temporary “stops” in PLC programming we use timers.
Quote 0 0
Rajesh Anand
oh yes, what if we program a timer for 4s, will the scan time be more than 4 seconds?

1. how does scan time depends on the timer time count?
2. Is there any way to find the scan time in openplc?
Quote 0 0
thiagoralves
That's not how a timer works. A timer is not a delay, where the program sits and waits for a determined amount of time. A timer sets an "alarm" per say for an event in the future. The scan cycle goes through the timer several times per second (according to your actual cycle time) to check if the timer has expired or not. If it is not expired, it just continues on with the program. Once the timer expires, the action associated with it is executed. So, creating a 4s timer won't delay your cycle time in 4s. That would be an absurd.
Quote 0 0
Rajesh Anand
Thank you. I have one more doubt,

How do I find the scan time of the ST program which I have implemented in OpenPLC?
I went into your main.cpp and when I wrote the program inside the infinite while loop, I'm not able to print anything. Am I missing anything?
Quote 0 0
thiagoralves
The scan time should be strictly the value you defined in the cyclic task parameter for your program. OpenPLC does its best (it is not a hard real time system, but gets close) to stay close to the number defined in there. Perhaps the easiest way to measure it would be to write an oscillator like this:
create BOOL var "oscillator" located at %QX0.0
    oscillator                    oscillator
|-----| \ |------------------------(       😉 -------| 

This will make the pin associated with %QX0.0 blink in the period of your cycle time. Grab an oscilloscope and measure the oscillation on the pin and you will have precisely your cycle time.
Quote 0 0
Rajesh Anand
Thank you. That was quite the way to calculate the scan time 🙂
Quote 0 0
Rajesh Anand
Hello, I would like some clarification on generally structured text programming implementation.

Is there any way to implement a system which is modelled by a set of differential equation in OpenPLC?
Quote 0 0
thiagoralves
That’s usually not the type of stuff you do on PLCs. Even though you have basic mathematical functions built in the language, you will lack several constructs (like matrix manipulation for example) to work with advanced calculations. You may want to check the OSCAT library here in the forum to see if it offers the blocks you need.

Now, if your differential equations boils down to a bunch of sums and subtractions every cycle (Z domain), of course that can be easily implemented.
Quote 0 0
Rajesh Anand
Okay, thank you 🙂
Quote 0 0
Rajesh Anand
Hello again, one more doubt again,

I have connected NI DAQ USB6002 to use along with Simulink for Analog Output data transfer from Simulink to Unipi. I generated PWM pulses from Simulink and looked at the signal in OpenPLC "monitoring" page.

1. The values are mentioned as '0' and FALSE (and not changing when I change it to other values in the program), where it should be the equivalent value of 3V and True respectively. But I can see the current values in Radzio Modbus simulator when I connect through Modbus TCP. Should I activate something in OpenPLC to see the values?

2. Unipi accepts and generates Analog Output value 0-10V whereas the values from Simulink through DAQ is -10 to +10V. How to set the values like 65536 = 5V or 65536 = 10V (but I'm correctly getting 19719 for 3V etc assuming 65536 = 5V)
Quote 0 0
thiagoralves
I don’t know if I understood correctly what you’re trying to do. For question 1, you can’t read PWM. That will look like a bunch of 1s and 0s in sequence. You need to filter your PWM signal first and then you’ll be able to read it from the analog input of the unipi. For the monitoring page, the values in there should always match what you see on radzio. There isn’t any setting to apply or activate.

For question 2, unipi is limited on hardware to output 0-10v. You can’t change that. If you want to have 65535 = 5V then you’ll have to modify the unipi driver on OpenPLC. However, if you do that you’ll lose resolution and precision.
Quote 0 0
Rajesh Anand
For the PWM pulse, I increased the time duration between ON and OFF to 2seconds so that I can see the 0 and 1 seperately before switching. But I was not able to see that difference in monitoring page.

I tried by applying a sine signal but still I couldn't see the values change in monitoring page but the values are changing in Radzio modbus simulator. (Currently I applied a sine wave of -4 to +4V through a saturator of 0 to 4V, will it be fine if I feed the -4 to +4v directly? as the Unipi accepts only 0-10v Analog input)

Even i set a relay as constant ON through plc program, I can see it is ON through the LED in Unipi board and Radzio but it shows False in the monitoring page.
Quote 0 0
thiagoralves
Your monitoring page might not be refreshing for some reason. Try using the latest google chrome version. Applying negative voltages to the UniPi inputs will probably burn it.
Quote 0 0
Rajesh Anand
Thank you 🙂
Quote 0 0