RPi UART doesnt work propperly with V2L4 Block in the System

4 views (last 30 days)
Hello to everyone,
as the title says, i have a problem with my UART communication between my Pi and my Arduino Uno as soon as the V4L2 Block is used in the Pi Model.
Basicly i use the Visual Theremin as shown in here. I modified it a bit, so i can also scan the height and the width of the object detectet. This works fine and since i know the diameter of the Objekt i can tell the distance. Now my RPi has to send the distance and the column number to the Arduino via UART.
I tested the UART communication with setting the values for position and distance per constant blocks, and i tested the image processing too. Both work as they should, but as soon as I use them together, it somehow doesnt send the distance as it should. But the position is works fine.
I can also tell that the Problem occurs with the V4L2 Block because if i have the test version for the UART communication it also doesnt work once this Block is in the system, although the RGB signal are either terminated or send to the SDL Video Block to view the image.
UART.PNG
This shows how the position(1) and the Distance(2) are sent to the UART Transceive Block, which is located directly behind exit 1.
state.PNG
This is the statemachine use to switch between sending the position and the distance. this happens with a fixed sample time.
The following code is the one of the Matlab function.
function y = fcn(u)
if u(1) == -1
y = 128;
else
y = (127/240)*u(1)+128; %scaling the column number to 128 steps and adding the first bit of the uint8.
end
end
It simply sets an default value if the position is set to -1 (no object detected) and scales the value. The MSB is used to identify wheather its a distance value or a postion value.
all.PNG
This is the Whole system as it shoulb run on the Pi. The Block above the Serial Transceive is just to check the conversion of the UART signal to the position and distance values.
I hope some of you can help me.

Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!