Rotary encoder and PLC ( Orbit Merret OMC 8000) - plc

I have Orbit Merret PLC OMC 8000 and I need to use rotary encoder with it. But there is almost no documentation. Does anybody know how to do it? I'm programming the PLC in MULTIPROG (the program given with the PLC).
Thanks.

Related

MATLAB and Arudino, set registers (PWM)

I am using an Arduino MEGA with MATLAB for the first time to try and control a servo motor, the issue is that the default PWM frequency for the pin I am trying to use is at 976Hz, while I need it to be around 50Hz. I found code for changing the timer 0 B register that affects this frequency but only for use in the Arudino IDE.
So basically, I need to send the following command to the Arduino:
TCCR0B = TCCR0B & B11111000 | B00000101;
Does anyone know how to do this while using the Arduino MEGA through MATLAB? Is there not a way to have straight up Arudino code in the .m file through some function/syntax? Or is there another way to manipulate the TCCR0B register via MATLAB? I know I could do this on the Arduino IDE but I really need to use MATLAB for the rest of this project.
Thank you for your time.

Serial Port Communication understanding

i need some help understanding a specific serial port connection from a sensor. I need to read data from the sensor and make some calculations in matlab or c++ (i will decide later)
The manufacturer only gives a chart with the following details:
Sensor Serial Port
Pin Number Mode Pin Description
I Trigger Input
I RS-232 Receive
O RS-232 Transmit
PWR Sensor Power (DTR)
PWR/GND Signal Ground
Not Used (Reserved)
Not Used (Reserved)
I/O RS-485 B Signal Pin
I/O RS-485 A Signal Pin**
So my question is: OK i know that pin 2 is used to receive data but how am i going to decode the volts stream into integers for example for my program? Also, i know that pin 4 gives power to the sensor. How do i know how many volts it has to give? Generally how am i going to learn all these details since the manufacturer does not give it?
Do you think Serial Port Analyzer Software will help?
Thanks very much in advance.
You might want to search for "DE-9 pinout YourSensorNameHere" in google or This page might be of some use to you. With most RS-232 you only need pins 2,3 and 5. With out more specifics about your sensor there isn't much SO can do for you.

Call Arduino SPI functions with MATLAB

I have successfully connected MATLAB with my Arduino. So far, I have only sent simple tasks to the Arduino such as digitalWrite and such.
The code I have been using is as follows:
%-- connect to the board
a = arduino('COM9')
%-- specify pin mode
a.pinMode(9,'output');
%-- write 0 (off) to pin 9
a.digitalWrite(9,0);
%-- dummy variable
on = false;
%-- simple loop to make LED flash 5 times
for m in 1:5
if on
a.digitalWrite(9,0); % turn LED off
on = false;
else
a.digitalWrite(9,1); % turn LED on
on = true;
end
%-- close session
delete(a)
Now that this basic test successfully passed, I wanted to get the SPI Arduino library to work with MATLAB. Is it possible to call a function from the Arduino SPI library in my MATLAB code? Specifically, I want to get SPI.begin(); and SPI.end(); to work from MATLAB, but a.SPI.begin() is not working. Is there some step I am missing?
To get the SPI library into an Arduino program, one must use #include <SPI.h>, but how can we make sure MATLAB knows all of the functions available in the SPI library? Hopefully it is not a problem that the Arduino SPI Library code is written in a different language than what MATLAB files are written in.
References:
MATLAB Support Package for Arduino (aka ArduinoIO Package)
Arduino SPI Library
The library "ArduinoIO" does not support SPI.
That library is just a serial port listener, and every matlab/arduino instruction send a code by serial, that is readed in the sketch on the arduino, translated in the corresponding arduino's instruction, and then executed.
You can create your own block that send some your-choise-spi-command, you'll also have to edit the arduino's sketch to execure the corrisponding SPI command. But you'll have to understand how the library works, change it's code, and so on.
It is way more faster (in execution speed, as serial comunication really is slow, and coding time) to code a "specialized" arduino sketch, that send back to Serial just the value you need, and then read serial and to pc-side computation.
To communicate with SPI device using Matlab support package you can use the following code:
a = arduino();
Spi_Device = spidev(a, 'D5'); % D5 is the pin number that you want to use for chip select
writeRead(Spi_Device,[hex2dec('00'), 100]); % 100 is the value that you want to send to the device
% When you done clear the spi object
clear Spi_Device
The Legacy MATLAB and Simulink Support for Arduino is no longer supported. I would recommend using the MATLAB Support Package for Arduino Hardware as that has built-in support for basic SPI communication.
There are getting started type of examples that comes with the support package and one of them shows how to use SPI.
Disclaimer: Even though I work for MathWorks, these posts are based on my experience with the software as a user. For actual Technical Support, please contact Mathworks' TS.

simulate CoMP (Coorinated Multipoint) scenario using Matlab

Im new to matlab, and needs to simulate a scenario, in which a mobile communicates with two base stations at the same time. I need to compare with the performance of communicating with just one base station. can someone please please tell me how to do this using Matlab?
Thank you
You can use the spatial channel model (SCM) implementation:
[1] “Spatial channel model for multiple input multiple output (MIMO) simulations”, 3GPP TR 25.996 V6.1.0, Sep. 2003. [Online]. Available: http://www.3gpp.org/ftp/Specs/html-info/25996.htm
Most of the code is in Matlab, but some computationally-intensive parts are also written in C to speed up the simulations.

Connecting an accelerometer to a microcontroller pull up voltages

Im trying to connect a MMA852Q accellerometer to a 18F2550 microcontroller. According to accellerometer datasheet i2c clock and data lines would not tolerate voltages more than 1.6- 3.7 (+0.3). Those lines have to be pulled up to 5v for microcntroller to work. Im new in to this subject and your advice to overcome this issue would be really helpful.
You could look for "I2C level shifter" for attaching buses with different voltages together.
NXP appnote 10441 (pdf) has a very neat generic one, for example.