Converting Decimals to mA - plc

I want to operate a actuator i.e. proportional valve with pwm module.
The input signal to my pwm module are standard signals 0..20mA, 4...20mA, 0..5V and 0..10V.
So to operate the valve I need to give value from my system. The D/A module then converts this into analog values.
How are these values converted from decimal to analog values?
I have attached the technical data of my actuator and my D/A module.
AC2218
PWM

Related

How to see voltage wave in simulink/simscape?

I'm analyzing the bahaviour of a RLC circuit and I need to observe the voltage and current wave of the circuit but I cannot find a way to do this. I need something like an oscilloscope but the scope does not work with the elements i am working with. What can I do?
The link below is my circuit, I'm using Simscape/Foundation Library elements
This is my circuit
Simscape and Simulink has different domains. To be able to use each one in the other domain, you need to use Simulink-PS Converter or PS-Simulink converter.
In that example, you have voltage sensor in Simscape and Scope or display in Simulink. To be able to connect them use PS-Simulink Converter.

DAC Output on Arduino MKR Zero in Simulink

I am trying to use the Arduino MKR Zero in Simulink using the Simulink Support Package for Arduino Hardware. So far I have been successful at get a led to blink using a pulse wave in Simulink and the Digital output of the Arduino. I have also been able to vary a potentiometer connected to the Analog input of the Arduino and see the voltage plotted on a scope.
Now I am trying to output a sine wave from the DAC and then view that sine wave back through the ADC. The image below shows my setup. I know that the DAC takes value between 0 and 1023 and converts it to a voltage with reference 3.3V for the Arduino MKR Zero. So I have set up the sine wave block with Amplitude 307 and bias of 307 to get a 2V pk to pk waveform with offset of 1V. I have also included the Byte pack to convert this value to a Unit16 value for the DAC.
Now for the output I have done a similar setup to what I had for the potentiometer experiment. In this section, K = 3.3/4095. However, when looking at the scopes for the input and output, they are completely different. The input scope shows a sine wave with a 2V pk to pk waveform with offset of 1V while the output doesn't make any sense.
I should point out, for the physical setup, I have simple connected the DAC pin to the A6 pin on the Arduino. Any advice on what I am doing wrong is welcome.
Simulink Setup:
This is an image of the waveforms on the scopes:

How to pulse generator block generate a pulse 40khz?

I tried to generate a 40khz pulse to the GPIO pin of my ultrasonic sensor in raspberry pi. I used the pulse generator instrumentation, but the pulse is not accurate: the oscilloscope displays only 10khz.
I modified configuration parameters:
fixed-step
sample time is auto/1e-08
solver is auto/discrete
I also have tried various ways to create a square pulse: function sign(sin(2*pi*40000t)), PLL block, repeating sequence, signal generator combined with sum, compare to zero, etc.
All of these display correctly on the scope, but do not deploy accurately.
I doubted the raspberry pulse generatior, so I used python to drive the GPIO pin; results are very accurate. I worry that the Simulink complier doesn't properly support raspberry or the sample time.
Any suggestions?
This is the model I used to generate 40khz pulse.
with period is 0.000025s,pulse width 50%, Solver type is fixed-step.
The oscilloscope display as the following figure:

How to implement math operations to bus signal MATLAB

I work in Simulink and have bus signal (now it consists of 11 signals, every signals is a vector). And I want to make some operations on this bus. It means to make the same operations at each of this 11 signals included in Bus.
I tried this way:
Just implement all my functions and operations at whole Bus. And some blocks (for example, Zero-Order Hold) works fine (it implements correctly to all it's signals). but next block - integrator - works fine (it really integrate all signals) but that crashes my Bus! It returns one vector. It has size equal to the sum of all Bus's signals.
I know I can use Bus Selector block to create 11 parallel signals and copy all my operations for each of them.
How to get Bus signal in more efficient way?
I made it this way (don't attach it like an answer, because Corey Z give the answer at the same time):
Is there any reason that you don't want to convert your bus to a vector to put it through the integrator?
Each vector signal in the bus will be appended to a 1-dimensional vector signal. The vector will come out of the integrator in the same dimensions that it went in and then can be turned back into a bus if need be using the bus creator tool under the signal routing toolbox.
On another note, it seems that you have some discrete time domain elements mixed into your block model along with your continuous-time integrator. If that gives you errors you may need to look into the Discrete-Time Integrator block.

How to use Simulink to output to real time microcontroller

I want to design a system that has to read some values from sensors through Arduino microcontroller using Matlab.
I want to use the simulink inputs as the sensors and the output to the motors,
I wrote an app to do that on Arduino, and also I wrote some functions in Matlab to read these sensors and to control the output, but I want to use simulink to implement a Fuzzy logic Controller the input is the values of sensors and the output is the speed.
If you wrote the functions for MATLAB in C, you can put your code in an S-Function, whether it is for sensor input or actuator output.
Otherwise, either use Embedded M file or S-function in your Simulink model.