Digital PWM or PPM signal read for Arduino mega2560

5 vues (au cours des 30 derniers jours)
Yaser
Yaser le 1 Avr 2015
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);
}

Réponses (1)

Abhishek GS
Abhishek GS le 6 Avr 2015
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

Communautés

Plus de réponses dans  Power Electronics Control

Catégories

En savoir plus sur Arduino Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by