coding for mapping rc values to pwm values using simulink block diagram

2 ビュー (過去 30 日間)
Noor Amira Ilyanie
Noor Amira Ilyanie 2023 年 3 月 16 日
I had coded the programs in Arduino IDE software, but now I need to program the same thing in Simulink Matlab. I had stuck on how to mapping those value using the exact block at simulink matlab. I had provide the coding which i used in Arduino for reference. Thanks and have a good day.
void loop()
{
time_now = micros();
Serial.print(time_now);
Serial.print("\t");
PWM1 = 100;
PWM2 = 0;
receiver_input1 = map(PWM1, 255, -255, 1000, 2000);
receiver_input2 = map(PWM2, 255, -255, 2000, 1000);
MOVE();
Serial.print(receiver_input1);
Serial.print("\t");
Serial.println(receiver_input2);
while(micros()<= time_now+time_stop);

回答 (1 件)

Arun Kumar
Arun Kumar 2023 年 4 月 6 日
編集済み: Arun Kumar 2023 年 4 月 6 日
Hi Noor,
Please implement this equation in Simulink using math blocks.
long map(long x, long in_min, long in_max, long out_min, long out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
This is the defination of map function in arduino.
  1 件のコメント
Noor Amira Ilyanie
Noor Amira Ilyanie 2023 年 4 月 7 日
for the block, is it using the c function or math function block?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by