Digital PWM or PPM signal read for Arduino mega2560

5 次查看(过去 30 天)
Hi,
I am working on a project, where I need to read a signal of a radio receiver that outputs a PPM or PWM using Simulink. I don't know if there is a Simulink block that does that? I tried servo read block thinking that it might read PPM but it didn't work. I managed to write an Arduino code that reads it. Can someone guide me on how to make a S-Function block that reads PPM signal.
Thank you in advance,
Here is the Arduino code that reads PPM for 4 channels of the receiver:
int ch1; // Here's where we'll keep our channel values
int ch2;
int ch3;
int ch4;
byte ch[4];
void setup() {
pinMode(5, INPUT); // Set our input pins as such
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
Serial.begin(9600); // Pour a bowl of Serial
}
void loop() {
ch1 = pulseIn(5, HIGH, 25000); // Read the pulse width of
ch2 = pulseIn(6, HIGH, 25000); // each channel
ch3 = pulseIn(7, HIGH, 25000);
ch4 = pulseIn(8, HIGH, 25000);
}

回答(1 个)

Abhishek GS
Abhishek GS 2015-4-6
Hi Yaser,
Consider following this link which shows a step by step process on how to create Simulink Device Drivers. The examples in the above mentioned link correspond to Arduino itself, so it will make it easier to follow for you.
Thanks, Abhishek

社区

更多回答在  Power Electronics Control

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by