Share:
Notifications
Clear all

Matlab control


f06da65d0d775cac116a200e8cac252c?s=80&d=mm&r=g
(@marmouli)
New Member
Joined: 1 week ago
Posts: 4
Topic starter  

Hello everyone, it has been two full days that I am trying to communicate with the blimpduino with Matlab and all the solutions given for communicating with Arduino boards, in general, are not working. Has anyone done a Matlab code to control (receive and send udp packets between Matlab and the Wifi module) the blimpduino? I have tried to use the udp functions by using the instrumental toolbox as well as the DSP toolbox but I can’t find a way to make this communication work.

I tried both Destination IP: 192.168.4.1, port 2222 and IP: 192.168.4.2, port 2223  to receive data but I don’t get the telemetry packet, instead it says that nothing is received. I haven’t tried to send packets, my main goal at the moment is to receive the packet. But if someone has a code that already controls the blimp via matlab which is well commented, it would be awesome.


Quote
f06da65d0d775cac116a200e8cac252c?s=80&d=mm&r=g
(@marmouli)
New Member
Joined: 1 week ago
Posts: 4
Topic starter  

Hello, so I succeed in communicating with the Blimpduino. Problem was the Firewall, so if any of you have the same problem try to deactivate the firewall to see if it solves the problem.


ReplyQuote
f06da65d0d775cac116a200e8cac252c?s=80&d=mm&r=g
(@marmouli)
New Member
Joined: 1 week ago
Posts: 4
Topic starter  

So now, I can read what the Blimpduino sends and I succeeded in sending a command to the motors via Matlab. Except that the motors do not behave as intended. I tried with the python code available on this forum and it works. I tried creating the equivalent code in Matlab (see below), but whatever method, it doesn’t work. Any idea?

Thanks.

/code

clear all; close all; clc;

%% UDPPORT %%

%Sending the info to the Blimp
remPort=2222;
remHost=’192.168.4.1′;

echoudp(‘on’,2222)
uOUT = udp(remHost,remPort);
fopen(uOUT)
[name, address] = resolvehost(remHost);

%Defining the 8 channels and header to send to Blimpduino
Header = ‘JJBA’; %double/ascii equivalent of JJBA: 74746665 (for JJBM: 74746677)

int16 throttle; %iCH1
throttle = int16(127);
binCH1 = dec2bin(throttle,16);

int16 steering; %iCH2
steering = int16(0);
binCH2 = dec2bin(steering,16);

int16 height; %iCH3
height = int16(0);
binCH3 = dec2bin(height,16);

int16 iCH4; %iCH4
iCH4 = int16(0);
binCH4 = dec2bin(iCH4,16);

int16 MODE; %iCH5
MODE = int16(0);
binCH5 = dec2bin(MODE,16);

int16 iCH6;
iCH6 = int16(0);
binCH6 = dec2bin(iCH6,16);

int16 iCH7;
iCH7 = int16(0);
binCH7 = dec2bin(iCH7,16);

int16 iCH8;
iCH8 = int16(0);
binCH8 = dec2bin(iCH8,16);

Channels = [dec2bin(throttle,16), dec2bin(steering,16), dec2bin(height,16), dec2bin(iCH4,16), dec2bin(MODE,16), dec2bin(iCH6,16), dec2bin(iCH7,16), dec2bin(iCH8,16)]
%Channels = [str2num(binCH1), str2num(binCH2), str2num(binCH3), str2num(binCH4), str2num(binCH5), str2num(binCH6), str2num(binCH7), str2num(binCH8)]
%Info = [Header, Channels]
Info = [Header, throttle, steering, height, iCH4, MODE, iCH6, iCH7, iCH8]
Message = join(Info)
%Message = sprintf(‘%s%2d%2d%2d%2d%2d%2d%2d%2d’, Header, throttle, steering, height, iCH4, MODE, iCH6, iCH7, iCH8)

%fwrite(uOUT, Message)
fprintf(uOUT, Message)

% Receive a single UDP packet
% packetData = fread(uOUT)
% fscanf(uOUT)
% fgets(uOUT)
% fread(uOUT, 10)

fclose(uOUT);
delete(uOUT);
echoudp(‘off’)

%Reading the info sent by Blimp
LHost = ‘192.168.4.2’;
LPort = 2223;
uIN = udpport(‘LocalHost’,LHost,’LocalPort’,LPort);
while true
data = readline(uIN);
disp(data);
end

\code

This post was modified 2 days ago 2 times by marmouli

ReplyQuote
Share: