MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

icon
Avatar
Doon1
Posts: 53
My rudder pedals are done. I still have to tweak the forces a little bit and add ground roll vibration but otherwise they work very well. The issue I'm having though is that the PWM frequency is too low. I need to raise it to 20khz or so. Below are the changes that can make in the Arduino sketch to change the frequency of select pins. Can I just add that code to the Mobiflight mcc file? Is there an entry I can make to stay closer to the 16khz to 20khz range?
iconCode:
void setup() {
TCCR2B = TCCR2B & B11111000 | B00000001; // for PWM frequency of 31372.55 Hz
pinMode(9,OUTPUT);
TCCR2B = TCCR2B & B11111000 | B00000001; // for PWM frequency of 31372.55 Hz
pinMode(10,OUTPUT);
}

void loop() {
analogWrite(9,155);
analogWrite(10,155);
}
2022-04-17 17:22
Avatar
Doon1
Posts: 53
Holy Moly! I wouldn't even know where to begin adding this to the mcc file. There's another website where they mentioned adding it to the Arduino.h file. I need to go find that post again. Maybe there's a way to add it that way. I need 6 PWM pins with the higher frequency.
Some links for reference.

https://playground.arduino.cc/Code/PwmFrequency/

http://astro.neutral.org/arduino/arduino-pwm-pins-frequency.shtml?msclkid=5d7cc75ebe7011eca1e8f5029c8e4d64

https://www.etechnophiles.com/how-to-change-pwm-frequency-of-arduino-mega/
[Last edited by Doon1, 2022-04-17 19:34]
2022-04-17 18:51
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

this would need to rework the Mobiflight Firmware itself.

In theory you can do this.... Simply load our source Code from Github and rework it for your own usage.

there is definitly no way to handle this in the MCC File.
Good Luck !
2022-04-18 15:05
Avatar
Doon1
Posts: 53
I don't have a clue how to do that. If I could code, then I wouldn't need Mobiflight. ;)

I installed Visual Studio Code and PlatformIO software. Then I downloaded the 2.1.1. source code. I opened each of the files in the folder. The only one that I found that resembled an Arduino sketch was the Mobiflight.ccp file. So I added the PWM lines in the void setup section of the file. so it now looks like this.
iconCode:
void setup()
{
  Serial.begin(115200);
  attachCommandCallbacks();
  cmdMessenger.printLfCr();
  ResetBoard();

  TCCR3B = TCCR3B & B11111000 | B00000010;  // for PWM frequency of 3921.16 Hz on pins 2, 3, and 5
  TCCR4B = TCCR4B & B11111000 | B00000010;  // for PWM frequency of 3921.16 Hz on pins 6, 7, and 8

// Time Gap between Inputs, do not read at the same loop
  lastButtonUpdate = millis() + 0;
  lastEncoderUpdate = millis();           // encoders will be updated every 1ms

#if MF_SERVO_SUPPORT == 1
  lastServoUpdate = millis() + 2;
#endif

#if MF_ANALOG_SUPPORT == 1
  lastAnalogAverage = millis() + 4;
  lastAnalogRead = millis() + 4;
#endif

#if MF_INPUT_SHIFTER_SUPPORT == 1
  lastInputShifterUpdate = millis() + 6;
#endif

#if MF_SERVO_SUPPORT == 1
  lastServoUpdate = millis() + 8;
#endif
}


I didn't add anything into the void loop section as that seem to be what the Mobiflight UI does.
The question now is, "How do I compile and upload this to the board I'm using for force feedback to test it?"
Please keep in mind I have absolutely no clue what I'm doing. This is a guessing game for me.
Hey look!!! The directions are right there on the github page... :D
[Last edited by Doon1, 2022-04-19 13:29]
2022-04-19 03:52
Avatar
Doon1
Posts: 53
WOOHOO!! It works. At 3921.16 Hz I can't hear anything. My wife can though :cry: The next higher frequency for the Mega board is 32Khz That may be too high for the motors to function correctly. I think the Uno can run at 16 Khz, but only on 1 channel. I'm going to research what boards will run the PWM at 16 Khz.
There is one (non?) issue I'm having. I used the 2.1.0 main file for the firmware change. Yet the UI states that version is 0.0.1. The other 2 boards are reading 2.1.1. All is working. Is this something to worry about.
Thanks.
John
2022-04-20 03:01
Avatar
elral
From: near EDDL, Germany
Posts: 50
If you compile the firmware locally on your PC the version will be always 0.0.1 unless you change it manually in one file.
I would test with 32kHz, your motor will not be damaged.
Regards
Ralf
2022-04-20 11:13
Avatar
Doon1
Posts: 53
I was going to try 32kHz, but the motor driver is only rated up to 25kHz.
I'll have an Uno in hand tomorrow. The D9 and D10 pins are capable of 15.6kHz which should work out great. I will need three of them when I decide to make my own yoke from scratch. Which will be pretty soon I think. I haven't fired up F360 for at least a month.
[Last edited by Doon1, 2022-04-21 00:05]
2022-04-20 23:59
Avatar
Crvak
Posts: 8
Hello Friend.
How did you upload modified .ccp on arduino board?

Cheers
2022-11-23 23:48
icon