Main Content

Results for

er
er
Last activity on 7 Dec 2023

How to Simulate a Synchronous Compensator in Simulink?

I have been having problems sending ThingSpeak alerts so I created a simple routine that demonstrates the problem. The code executes successfully but I never receive an email with the alert. What am I doing wrong?
% Set Thingspeak address, alerts API key, and options for the HTTTP call
alertUrl = "https://api.thingspeak.com/alerts/send";
alertApiKey = "TAKxxxxxxxxxxxxxxxx";
options = weboptions("HeaderFields",["ThingSpeak-Alerts-API-Key",alertApiKey]);
% Set content for email subject and body.
alertSubject = "ThingSpeak Alert Subject";
alertBody = "ThingSpeak Alert Body";
% Catch errors so the MATLAB code does not disable a TimeControl if it fails
try
webwrite(alertUrl, "body", alertBody, "subject", alertSubject, options);
catch Exception
fprintf("Failed to send alert: %s\n", Exception.message);
end
Am running multiple sensors in the field producing strings of data then sending them to a node. The node is an Arduino Uno on which SIM 800 is attached for internet connectivity. After computation, the result is several strings that i want to display to things speak. The code i have so far can only upload numerical data. Am in need of help to display these strings in Thingsspeak.Help me.
Dear Team,
I have populated my data on ThingsBoard platform using ESP8266, now I want to read that data using MATLAB Industrial Communication Toolbox. I have written a code for this purpose below,
% Replace these values with your ThingsBoard MQTT broker details
brokerAddress = "ssl://demo.thingsboard.io"; % Adjust the broker address
port = 1883; % Use the appropriate port for secure MQTT
% Replace these values with your ThingsBoard device details
clientID = "";
userName = "";
password = ""; % Leave empty if not required
% Replace this with the path to the root certificate you downloaded
rootCert = "";
% Create an MQTT client
mqClient = mqttclient(brokerAddress, 'Port', port, 'ClientID', clientID, ...
'Username', userName, 'Password', password, 'CARootCertificate', rootCert);
% Check if the connection is established
mqClient.Connected
% Expected output: ans = int32(1)
% Subscribe to the telemetry topic
topicToSub = "v1/devices/me/telemetry";
subscribe(mqClient, topicToSub);
% Wait for a while to receive messages (adjust the time as needed)
pause(60);
% Peek at the MQTT client to view received messages
peek(mqClient);
% Close the MQTT client
clear mqClient;
%%%%__________________Output Result______________________%%%%%
>> MQTT_Receive
Warning: Using a port that allows unencrypted communication. For confidential matters, considering using an encryption
enforcing port, such as 8883.
Error using MQTT_Receive
Failed to establish a connection with broker "ssl://demo.thingsboard.io".
I desperately seeking your assistance in this regard
I'm logging data which I'd like to see on a daily basis. ie each day the chart x axis resets to 12midnight to 12midnight for the current day and just shows todays data. Is this possible please ?
William Glass
William Glass
Last activity on 22 Nov 2023

Hello
I have been using ThingSpeak for about 2 years with no problems. I am observing sensor data and connecting widgets to some of the values. Since yesterday, there are some of the widgets that send blank values. Have you changed something?
Thank you
Elija
Elija
Last activity on 14 Feb 2024

Hello, all!
This is my first post after just joining this discussion, so please forgive me and provide kind assistance if I have posted to the wrong subsection!
I have a good interest in learning sql server course and right now I am taking help from various platforms like https://www.coursera.org/ https://www.udemy.com/
Also I have a doubt that is it a good option to learn from platforms like this or I should go for some sql server online training . I have searched for the solution of my queries in various above platforms which helped me up to some extent only as it was not directly given by any expert or trainer.
Hoping in getting a quick response
Thankyou in advance.
Adrian Segura
Adrian Segura
Last activity on 28 Nov 2023

Hello, I am a student and I am working on a neural network for a line follower car and I would like you to recommend a tutorial to implement it in simulink.
Hello, I would like to send temperature and humidity data from my ThingSpeak channel to the https://www.wunderground.com/ service. I managed to configure the initial connection through ThingHTTP, and on the WeatherUnderground website, there is information about data updates, but there are no actual values: https://www.wunderground.com/dashboard/pws/IKORON5/table/2023-11-19/2023-11-19/daily
I don't know how to correctly configure all the options in ThingHTTP and in the Apps - React section.
when I examine the data stream on an arduino ide I get a lot of "stuff" which I dont understand.
1 what does it mean?
2 how do I prevent it?
Hello,
i want to write the power data from my Tasmota IR Device to my channels, but it does not work.
I have created 3 channels and i use the correct write API in the script. I use the following script:
>D
>B
=>sensor53 r
>S
if upsecs%20==0
then
=>WebSend [api.thingspeak.com] /update.json? api_key=xxxxxxxxxxxxxxxx&field1=%sml[1]%&field2=%sml[2]%&field3=%sml[3]%
endif
>M 1
+1,3,s,0,9600,
1,77070100010800ff@1000,Total consumption,kWh,total_in,2
1,77070100020800ff@1000,Total feed-in,kWh,total_out,2
1,77070100100700ff@1,Power,W,power_curr,0
#
I get the messages in the console that the data was send but my channels stay empty.
What do i miss ?
Thanks for help
LAWAN HARUNA
LAWAN HARUNA
Last activity on 6 Nov 2023

good afternoon everyone my name is Dundu lawan haruna ,i'm a final year student at the department of computer engineering ABU Zaria, Nigerian , and i wanted to do my final year project based on computer vision : project topic , designing an eye glasses to help those people with visual imparement to be able to navigate enviroment efficiently , that's why i need a support from you guys ,all advised are highly well come , thank you for your support.
Edward
Edward
Last activity on 7 Nov 2023

I am collecting Data at 1 minute intervals using esp8266, the data is then sent to Thingspeak on the minute intervals. However I would like to store the data collection on the esp Ram. I am using batteries to power the circuits , if I can store the data and send it on demand I can save quite a bit of battery energy (used up by wifi) - (I already use sleep mode between intervals). As well as using Thingspeak to visuliase the data, I also use a third part app called Thingview which 'feeds' off thingspeak. I am looking for a way to trigger the 'data send' upon opening thinkspeak chanel,so rather than sending every minute it might need to be accessed two or three times a day, is this possible?
Thanks Edward
Luca
Luca
Last activity on 5 Nov 2023

Hi!
I can't see my data in the charts. I'm using arduino wifi and the connection works.
Maybe I did something wrong in this options

Is there a way to get a handle or link to the database each time I do a WRITE or group of WRITEs? I need to access the set of records that comprises a user session, which could be many WRITEs. My impression is that Thingspeak appears as a continuous stream with no way to mark a set of WRITEs as a group or session. Methods I have tried like retrieval (READs) using timestamps and other after-the-fact queries are not very accurate or user friendly. Thanks.

we are planning to design a drive for an EV using synchronous reluctance motor. To move further we need some drive circuits for simulating and comparing various motors with synchronous reluctance to justify our literature survey. can we get som circuit suggestions?
I am running the code from the following URL: https://kr.mathworks.com/help/comm/ref/comm.ricianchannel-system-object.html. I copied and executed the example to visualize the channel's impulse response. However, when I run the same code multiple times with the same path gains and delays, I get different impulse response results each time. What could be the reason for this?
This behavior is unexpected because the code and settings are the same for each run, and the impulse response should remain constant.
This is the code.
fs = 3.84e6; % Sample rate in Hz
pathDelays = [0 200 800 1200 2300 3700]*1e-9; % in seconds
avgPathGains = [0 -0.9 -4.9 -8 -7.8 -23.9]; % dB
kfact = 10; % Rician K-factor
fD = 50; % Max Doppler shift in Hz
ricianChan = comm.RicianChannel( ...
SampleRate=fs, ...
PathDelays=pathDelays, ...
AveragePathGains=avgPathGains, ...
KFactor=kfact, ...
MaximumDopplerShift=fD, ....
Visualization='Impulse and frequency responses');
ricianChan(0.1);
The two images below show the results of running the same code.
Hi,
I was wondering if anyone could help me with how I can simplify this part of my script, specifically scenario 1-3, so that it is easier to read. Perhaps with functions etc. (the comments are in swedish sorry heh. But the script works).
Thanks in advance!
F1_batt_till_P19 = zeros(8760,length(Effekt)); % det som batteriet laddar upp fastigheten med
F1_Elkons_batt = zeros(8760,length(Effekt)); % konsumtionen från nätet av batteriet
F1_batterilast_tot = zeros(8760,length(Effekt)); % batterilasten lagras kontenueligt.
F1_elkonsum = [];
for k = 1: length(Effekt) % går igenom alla olika effekter mellan 100 - 1000 kW
F1_last_batt = 0; % batteriet måste nollas efter varje ny effekt.
batterikapacitet = Kapacitet(k); % såhär stort är batteriet beroende på effekten. Beror på C rate (blir dubbelt så stort som effekten).
batterikapacitet_min = batterikapacitet * SOC_low/100; % undre gräns
batterikapacitet_max = batterikapacitet *SOC_high/100; % övre gräns
F1_last_batt = batterikapacitet_min; % hur mycket kapacitet har batteriet. Finns det något . Börjar tomt.
for i = 1:12 % gå igenom månaderna
mon = [31,28,31,30,31,30,31,31,30,31,30,31];
slut = mon(i)*24;
% medelkonsumtionen (i kW) per månad Elkons_months_eft(744,12)
medel_kons = mean(Elkons_months_eft(1:slut, i)); % Månadens medelkonsumtion
for m = 1:slut % gå igenom timmarna per månad
% går igenom varje timme (m), för varje månad (i).
% scenario 1 - batteriet laddar ur till medelvärdet
if Elkons_months_eft(m,i) > medel_kons
topp = Elkons_months_eft(m,i) - medel_kons; % storleken på toppen över medelvärde
% Om batteriet inte är tomt från början. Om det kan laddas ur.
if F1_last_batt > batterikapacitet_min
% Om batteriet kan laddas ur med hela efffekten utan att gå under min
if (F1_last_batt - Effekt(k)) >= batterikapacitet_min
% Om toppen är större eller lika med än vad som får kapas med batteriet - hela effekten används.
if topp >= Effekt(k) % A
F1_batt_till_P19( (24*sum(mon(1:i-1)) + m) ,k) = Effekt(k); % effekt under timmen som batteriet tillgodoser till Pyramiden 19
F1_last_batt = F1_last_batt - Effekt(k); % batteriet laddas ur med hela effekten den timmen
% Om toppen inte är större än effekten - hela toppen kapas.
else % B
F1_batt_till_P19((24*sum(mon(1:i-1)) + m) ,k) = topp;
F1_last_batt = F1_last_batt - topp;
end
% Om batteriet inte kan tömmas med hela effekten.
else
liten_effekt = F1_last_batt - batterikapacitet_min; % mängden som kan laddas ur.
% Om toppen är större än det vi kan använda – allt som är kvar används
if topp >= liten_effekt % C
F1_batt_till_P19((24*sum(mon(1:i-1)) + m) , k) = liten_effekt; % effekt under timmen som batteriet tillgodoser till Pyramiden 19
F1_last_batt = F1_last_batt - liten_effekt; % batteriet laddas ur till min
% Om toppen inte är större än det vi kan använda - hela toppen kapas
else % D
F1_batt_till_P19( (24*sum(mon(1:i-1)) + m) ,k) = topp;
F1_last_batt = F1_last_batt - topp;
end
end
end
% scenario 2 - batteriet laddar upp och tar från nätet
elseif Elkons_months_eft(m,i) < medel_kons
% Om batteriet inte är fullt
if F1_last_batt < batterikapacitet_max
% Om det får plats en laddning av hela effekten – Batteriet laddas upp
if (F1_last_batt + Effekt(k)) <= batterikapacitet_max
% Om uppladdningen inte överstiger medelvärdet – Batteriet laddas upp med effekten
if (Elkons_months_eft(m,i) + Effekt(k)) <= medel_kons % A
F1_Elkons_batt((24*sum(mon(1:i-1)) + m),k) = Effekt(k); % mängden som tas från nätet
F1_last_batt = F1_last_batt + Effekt(k);
% Om uppladdningen överstiger medelvärdet – Batteriet laddas upp med det som går
else % B
till_medel = medel_kons - Elkons_months_eft(m,i);
F1_Elkons_batt((24*sum(mon(1:i-1)) + m),k) = till_medel;
F1_last_batt = F1_last_batt + till_medel;
end
% Om det får plats mindre än hela efffekten i en laddning – Batteriet laddas fullt
else
plats = batterikapacitet_max - F1_last_batt; % det som får plats i batteriet
% Om elkonsumtionen ej överstiger medelvärdet – Batteriet laddas upp till max-taket
if (Elkons_months_eft(m,i) + plats) <= medel_kons % C
F1_Elkons_batt((24*sum(mon(1:i-1)) + m),k) = plats;
F1_last_batt = F1_last_batt + plats;
% Om elkonsumtionen överstiger medelvärdet – Batteriet laddas upp med det som går
else % D
till_medel = medel_kons - Elkons_months_eft(m,i);
F1_Elkons_batt((24*sum(mon(1:i-1)) + m),k) = till_medel;
F1_last_batt = F1_last_batt + till_medel;
end
end
end
% scenario 3 - om inget händer
elseif Elkons_months_eft(m,i) == medel_kons
% inget händer. Precis som jag vill ha det.
end
F1_batterilast_tot((24*sum(mon(1:i-1)) + m),k) = F1_last_batt; % lägger in batterilasten för timmen i en lista.
end % slut - for timmar per mån (m)
end %slut for - månaderna (i)
% tar bort den sista uppladdningen av batteriet så det kommer ner till min värdet iaf
% får ta bort min värdet kostnaden sen manuellt.
for p = 0:(8760-1)
% Om batteriet har laddning över min kvar i slutet
if F1_last_batt > batterikapacitet_min
over = F1_last_batt - batterikapacitet_min;
% Om platsen är större än eller lika med laddningen på batteriet – Batteriet töms ner till min
if F1_Elkons_batt(end-p,k) >= over
F1_Elkons_batt(end-p,k) = F1_Elkons_batt(end-p,k) - over;
F1_last_batt = batterikapacitet_min;
F1_batterilast_tot(end-p,k) = batterikapacitet_min;
% Om platsen är mindre än laddningen på batteriet – Batteriet töms med hela platsen
elseif F1_Elkons_batt(end-p,k) < over
F1_last_batt = F1_last_batt - F1_Elkons_batt(end-p,k);
F1_batterilast_tot(end-p,k) = batterikapacitet_min;
F1_Elkons_batt(end-p,k) = 0;
end
end
end
end % slut for - effekt (k)
% summerar ihop året till ett värde. Får ett värde för varje effekt.
F1_elkonsum_sum =[];
F1_batt_till_P19_sum =[];
F1_Elkons_batt_sum = [];
F1_effekttopp_medel_year = []; % medel effekttopp under året
for v = 1:length(Effekt)
F1_elkonsum(:,v) = (Elkonsumtion_eft(:,1) - F1_batt_till_P19(:,v)) + F1_Elkons_batt(:,v); % elnätskonsumtion under året
F1_elkonsum_sum(v) = sum(F1_elkonsum(:,v));
F1_batt_till_P19_sum(v) = sum(F1_batt_till_P19(:,v));
F1_Elkons_batt_sum(v) = sum(F1_Elkons_batt(:,v));
end
% figure; yyaxis right; plot(F1_elkonsum(:,20));
% hold on; plot(Elkonsumtion_eft(:,1));
% hold on; yyaxis left; plot(F1_batterilast_tot(:,20)); legend('Konsum','ladd');
% Beräknar maxeffekten (toppen) för varje månad för alla effekter. Blir en 12 x length(effekt) lista
% Den går per rad och tar maxeffekten för månaden för alla kolumner = för alla olika effekter.
F1_effekttopp_months = zeros(12,length(Effekt)); % effekttopp under månaden för alla olika effekter.
mon = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
for b = 1:12
F1_effekttopp_months(b,:) = max(F1_elkonsum( (24*sum(mon(1:b-1)) + 1) : 24*sum(mon(1:b)) , : ) ); % [kW]
end
% beräknar medeleffekten för året
for v = 1:length(Effekt)
F1_effekttopp_medel_year(v) = mean(F1_effekttopp_months(:,v));
end
Recently, I came across a post about the JIT compiler on this Korean blog. In the post. The writer discussed the concept of the "Compile Threshold" and how it is calculated.
"The JVM accumulates the number of calls for each method called and compiles when the number exceeds a certain number. In other words, there is a standard for checking how often it is called and then deciding, 'It is time to compile.' This standard is called the compilation threshold. But what is this and why should it be used as a standard?"
The concept of the "Compile Threshold," as used above, seems to be more commonly associated with Tracing just-in-time compilation.
The writer used the simple Java code below to calculate the threshold.
for (int i = 0; i < 500; ++i) {
long startTime = System.nanoTime();
for (int j = 0; j < 1000; ++j) {
new Object();
}
long endTime = System.nanoTime();
System.out.printf("%d\t%d\n", i, endTime - startTime);
}
Since the MATLAB execution engine uses JIT compilation, I just wanted to perform the same experiment that the writer did.
I experimented using simple codes based on the code in the blog. I iterated a function 500 time using for-loop and calculated the execution time for each iteration using tic and toc. Then I plotted the execution time for each loop as blow. First five execution times are much higher than followings (10 times!) The test is very rough so I am not sure that I can conclude "MATLAB has Compile Threshold and it is 5!" but this value is actually correct ;-)
t0 = 0;
tfinal = 10;
y0 = [20;20];
timeToRun = zeros(500,1);
for i = 1:500
tStart = tic;
[preypeaks,predatorpeaks] = solvelotka(t0, tfinal, y0);
tEnd = toc(tStart);
timeToRun(i) = tEnd;
end
VS Code Extension for MATLAB was introduced back in April and has been downloaded 75K times since. Do people here use VS Code for writing MATLAB code?