Eloy Oliveira fala sobre Simulação e desenvolvimento de
algoritmos de tempo real usando
Matlab/Simulink através de bibliotecas
externas no openday modelagem e requisitos na industria de alta tecnologia realizado no INPE dia 28 de setembro de 2017
DeClara n.º 75 Abril 2024 - O Jornal digital do Agrupamento de Escolas Clara ...
Simulação e desenvolvimento de algoritmos de tempo real usando Matlab/Simulink através de bibliotecas externas
1.
2. Simulação e desenvolvimento de algoritmos de
tempo real usando Matlab/Simulink através de
bibliotecas externas
Eloy M. de Oliveira Jr.
3. Agenda
• Introdução
• Biblioteca True Time
• Algoritmo de Sincronização Desenvolvido
• Desenvolvimento de suas próprias bibliotecas
• Simscape
• Conclusão
6. – INDUSTRIA 4.0
– SISTEMA CIBERNÉTICOS-FÍSICOS :
» Integra computação, comunicação e controle em tempo real em diferentes níveis de operação,
usando um grande número de atuadores, sensors e controladores implementados em processadores
que se comunicam.
» Demandam alto desempenho, precisão, acuracia, modularidade, integração, dependabilidade,
segurança e outras habilidades.
» Requerem previsibilidade no dominio lógico e no domínio TEMPORAL.
INTRODUÇÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
7. – INDUSTRIA 4.0
– SISTEMA CIBERNÉTICOS-FÍSICOS :
» Integra computação, comunicação e controle em tempo real em diferentes níveis de operação,
usando um grande número de atuadores, sensors e controladores implementados em processadores
que se comunicam.
» Demandam alto desempenho, precisão, acuracia, modularidade, integração, dependabilidade,
segurança e outras habilidades.
» Requerem previsibilidade no dominio lógico e no domínio TEMPORAL.
INTRODUÇÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
Sistemas Complexos e Altamente Integrados
(SAE-ARP4754a)
8. – Exemplo: Steering-by-wire
– Sistemas Automotivos
INTRODUÇÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
Fonte:
Authors: Dilger, E.; Führer T. ; Müller, B.
Paper: The X-By-Wire Concept: Time-Triggered
Information Exchange and Fail Silence Support
by new System Services
Site:
http://www.vmars.tuwien.ac.at/projects/xbywire/
projects/new-bosch.htm
9. – Exemplo: Fly-by-Wire
– Sistemas Aeronáuticos
INTRODUÇÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
Fonte:
CONCORDE FLY-BY-WIRE SYSTEM
Site: http://heritageconcorde.com/?page_id=878
10. – Exemplo: Orion Spacecraft
– Sistemas Espaciais
INTRODUÇÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
Source:
Orion Mission - http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20100040584.pdf
11. – Exemplo: Cadeia de processo têxtil
– Sistemas Industriais
INTRODUÇÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
Source:
“Cyber-Physical Systems in textile production – the next industrial revolution? “ - Yves-
Simon Gloy, Anne Schwarz, Thomas GrieInstitut für Textiltechnik, RWTH Aachen University,
Aachen, GermanyCorresponding Author. Email: yves.gloy@ita.rwthaachen.de
https://www.textile-future.com/textile-manufacturing.php?read_article=1829
12. INTRODUÇÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
Domínio
Computacional
Domínio de
Controle
(Físico)
Domínio de
Comunicação
Domínio
Computacional
14. • Simulador baseado no Matlab/Simulink para sistemas de controle em tempo real.
• Desenvolvida por Henriksson, Cervin e Arzén (2002) – Universidade de Lund – Suécia;
• Desenvolvida na linguagem C/C++;
• Open Source;
• Integrada ao Matlab/Simulink – Com ela é possível usar outras toolboxes e capacidades do Matlab/Simulink
para o desenvolvimento das simulações.
TRUETIME
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
15. • Com o TrueTime é possível:
– Simular a execução de tarefas em núcleos (kernel) de tempo real
– Simular a transmissão por redes de comunicação
– Integrar tudo a uma planta dinâmica
• O Simulador inclui ainda:
– Possibilidade de similuar controles complexos e as influencias temporais sobre agendamento de
tarefas, redes de comunicação;
– Possibilidade de escrever tarefas utilizando arquivos .M ou funções C++;
– Usar blocos do Simulink junto aos blocos do truetime
– Simular as redes Ethernet, CAN, TDMA, FDMA, Round Robin, Switched Ethernet, FlexRay and
PROFINET)
– Wireless network block (802.11b WLAN and 802.15.4 ZigBee
– Simulação de dispositivos com bateria, Dynamica Voltage Scaling e relógios locais.
TRUETIME
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
20. • Algoritmo FTM.
0 0.2 0.4 0.6 0.8 1
-4
-3
-2
-1
0
1
2
3
4
Relógio de Referência (segundos)
Controle
Controle PID
Controle
0 0.2 0.4 0.6 0.8 1
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
Relógio de Referência (segundos)
RespostaDinâmica(graus)
Dinâmica
Referência
Resposta
Overshoot > 50%
Reference Clock (seconds) Reference Clock (seconds)
Dynamics PID Controller
Controller
Reference
Response
DynamicResponse
(degree)
Controller
ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
21. • O Algoritmo FTM sincroniza o sistema!
• Em contrapartida degrada a resposta do sistema de controle!
• Causa Principal:
–Viés Inicial do Relógio!
ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
22. ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
STM
NOMO
T1
T4
STM – DEADBEAT CONTROLLER
NOMO - FTM ALGORITHM
NOMO mode -
Algoritmo PReS
23. • Projeto do Controlador
D(z) μT(z)
-
R(z) E(z) C(z)+
Modelo do RelógioControlador
ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
24. • Modelo de Recorrências do Relógio Clock Model:
MICROTICK (mt)
MACROTICK (MT)
LOCAL TIME (LT)
GLOBAL TIME (GT)
Controlador Deadbeat
ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
25. • Projeto do Controlador
D(z) μT(z)
-
R(z) E(z) C(z)+
Função de Ajuste para modo STM:
u(k): valor de ajuste no instante k;
ρ: deriva do relógio;
μt(0): offset inicial;
e(k): erro entre o relógio local e de referência.
ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
26. • Algoritmo PReS
0 0.2 0.4 0.6 0.8 1
-15
-10
-5
0
5
10
Relógio de Referência (segundos)
CorreçãoDeadbeat(segundos)
Deadbeat
C2
C3
C4
0 0.2 0.4 0.6 0.8 1
-0.04
-0.03
-0.02
-0.01
0
0.01
0.02
0.03
0.04
0.05
Relógio de Referência (segundos)
CorreçãoFTM(segundos)
Algoritmo FTM
C2
C3
C4
0 0.2 0.4 0.6 0.8 1
-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
Relógio de Referência (segundos)
RelógioLocal(macrotick)
Macrotick
C1
C2
C3
C4
Transição
Reference Clock (seconds)
FTMCorrection(seconds)
FTM Algorithm
Reference Clock (seconds)
DeaheatCorrection
(seconds)
ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
27. • Algoritmo PReS
0 0.2 0.4 0.6 0.8 1
-3
-2
-1
0
1
2
3
4
Relógio de Referência (segundos)
Controle
Controle PID
Controle
0 0.2 0.4 0.6 0.8 1
-1.5
-1
-0.5
0
0.5
1
1.5
Relógio de Referência (segundos)
RespostaDinâmica(graus)
Dinâmica
Referência
Resposta
Overshoot << 50%
Reference Clock (seconds) Reference Clock (seconds)
Dynamics
PID Controller
DynamicResponse
(degree)
Controller
ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
28. • Algoritmo PReS
• Melhor Paper Nacional Congresso SAE Brasil 2015
• Apresentado no Congresso Internacional do SAE 2016 – Detroit – MI - EUA
ALGORITMO DESENVOLVIDO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
Em comparação com o algoritmo FTM, ao incluir o modo STM
utilizando o controlador deadbeat, o algoritmo PreS melhora a lei
de controle reduzindo o overshoot sobre a resposta dinâmica.
A New Clock Synchronization Algorithm to Compensate the Initial
De-Synchronization of Clocks Based on a Deadbeat Controller for
Networked Control Systems
Eloy M. Oliveira Jr e Marcelo L. O. Souza
Congresso SAE Brasil 2015
29. DESENVOLVIMENTO DE SUAS
PRÓPRIAS BIBLIOTECAS
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO
MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS EXTERNAS
30. • O Matlab/Simulink permite você criar suas próprias bibliotecas
• Você pode, opcionalmente, inclusive adicionar ao Simulink® Library Browser e usar em seus modelos
quando quiser.
DESENVOLVIMENTO DE SUAS PRÓPRIAS BIBLIOTECAS
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
31. • Vantagens:
– Reuso de código e simulações.
– Integrar em simulações mais avançadas.
• Desvantagens:
– Geração de Código pode não ser possível
– Você precisa validar o resultado.
DESENVOLVIMENTO DE SUAS PRÓPRIAS BIBLIOTECAS
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
33. • O Simscape provê uma conjunto de biblioteca de components que cobrem mais de 10 domínios físicos
diferentes;
– Mecânico
– Elétrico
– Hidráulico
– Pneumático,
– Entre outros
• A biblioteca é especialmente projetada para ajudar o usuário a criar components personalizados..
• Todos os components são definidos usando a linguagem Simscape.
• Permite você balancear fidelidade e velocidade de simulação.
• Você pode converter modelos Simscape em Código C, utilizando o Simulink Coder..
SIMSCAPE
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
34. • Linguagem Simscape:
• Linguagem textual para modelar sistemas físicos
• Contém construções especificas para modelagem física
• Incorpora-se dentro da interface de modelagem Simscape
• Não é focado no desenvolvimento do algoritmo
SIMSCAPE
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
37. • Os sistemas estão cada vez mais integrando elementos de pelo menos três domínios de conhecimento, tais
como controle, comunicação e computação.
• A implementação distribuída, a integração de sistemas, a complexidade e o aumento do requisito de
confiabilidade tornam relevantes diversos problemas que antes não o eram, demandando o desenvolvimento
de novas tecnologias, técnicas e algoritmos.
• Com isso, vem de encontro com a necessidade de simulações cada vez mais complexas;
• O ambiente Matlab/Simulink esta se tornando cada vez mais uma ótima ferramenta para se fazer a
modelagem e simulação deste tipo de sistema;
CONCLUSÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS
38. • O ambiente Matlab/Simulink esta se tornando cada vez mais uma ótima ferramenta para se fazer a
modelagem e simulação deste tipo de sistema;
• O conjunto de toolboxes e o fácil uso de bibliotecas de terceiros e também de criação de suas próprias
bibliotecas, torna o Matlab/Simulink cada vez mais atrativos;
• O algoritmo desenvolvido, como parte da minha Tese de Doutorado no INPE, só foi possível graças ao uso
da biblioteca TrueTime, desenvolvida pela Universidade de Lund na Suécia.
– Pois requeriu um conjunto de simulações e conhecimento dos três domínios: Controle, Computação e
Comunicação;
• Neste trabalho, explorou-se a sincronização de relógios, mas outras áreas podem ser facilmente exploradas
com a simulação desenvolvida.
CONCLUSÃO
SIMULAÇÃO E DESENVOLVIMENTO DE ALGORITMOS DE TEMPO REAL USANDO MATLAB/SIMULINK ATRAVÉS DE BIBLIOTECAS
EXTERNAS