High frequency generation ( 100K ) and above using Simulink and deploying it on Arduino

64 views (last 30 days)
I trying to experment with simulink and interface it with arduino , my goal is to generate high frequency , but there is a limit and i know I saw a high frequency generated by arduino before , but how , is there any tutorial .
Walter Roberson
Walter Roberson on 25 Aug 2022
I am not clear on what it is that you wish to have happen at 100K? Is that 100K samples per second input? If so then how many channels, how many bits per channel, and what is the the acceptable latency?
Or is it a pwm output signal? If so then how frequently does it need to change pattern? If it is reacting to input, then how much latency of reaction is acceptable?
Ovaga Technologies
Ovaga Technologies on 6 Jun 2023
When it comes to generating high frequencies using Arduino and Simulink, there are a few considerations to keep in mind. Although Arduino boards are generally not designed for high-frequency applications, it is possible to generate relatively high frequencies with certain techniques. Here's a general approach you can follow:
1. Select the right Arduino board: Some Arduino boards, like the Arduino Uno, have limited processing power and may struggle to generate high frequencies. Consider using a board with a faster clock speed, such as the Arduino Mega or Arduino Due, as they are better suited for high-frequency applications.
2. Utilize timer/counters: Arduino boards have built-in timer/counters that can be configured to generate square wave signals at specific frequencies. By utilizing the timer/counters, you can achieve higher frequencies than using general-purpose I/O pins.
3. Employ direct port manipulation: If you require even higher frequencies, you can utilize direct port manipulation techniques to bypass the Arduino's digitalWrite() function, which can introduce significant overhead. Direct port manipulation allows for faster I/O operations, enabling you to generate higher frequencies.
4. Utilize external libraries: Arduino community libraries can provide additional functionalities for generating high frequencies. Libraries like the TimerOne and TimerThree libraries can help you leverage the built-in timer/counters more efficiently and generate precise high-frequency signals.

Sign in to comment.

Answers (4)

Walter Roberson
Walter Roberson on 16 Aug 2022
If you are using the USB connector, and if you are transfering each sample individually, not many people manage to get more than 40 Hz or so. The theoretical limit is 1000 packets per second (with roughly 1000 bytes of data each time.)
If you are using an ethernet connection, the theoretical rate is significantly higher. I do not know what the practical limit is.
Some people are getting higher serial port rates with add-on ports; https://www.avrfreaks.net/forum/mega2560-board-usb-connection-speed
  1 Comment
MUSTAFA on 19 Aug 2022
Can u please put a link for hardware and any other detachment that will be needed for this , another question after getting all of these ,can I still use simulink for flushing the codes , or there more thinks i may need to do in order to use the simulink , thanks

Sign in to comment.

Arun Kumar
Arun Kumar on 25 Aug 2022
Edited: Arun Kumar on 25 Aug 2022
Hi Mustafa,
Don you mean the PWM frequency?
If yes, then you can specify the PWM frequency in the PWM block by selecting the specify option.
Hope this helps!
MUSTAFA on 25 Aug 2022
Thank u all for ur reply , The question is , can I generate 100 K Hz with arduino . ?
How ?
Arun Kumar
Arun Kumar on 25 Aug 2022
In MATLAB 2020a and later releases, it is possible to generate PWM with higher frequencies on Arduino.
Simply change the desired frequency parameter of the PWM block.
Some pins have certain limitations which is mentioned in the following page: https://www.mathworks.com/help/supportpkg/arduino/ref/pwm.html
Hope this helps.

Sign in to comment.

Veswin Tang
Veswin Tang on 2 Aug 2023
Choose the Right Arduino Board: Some Arduino boards, like the Arduino Uno, have a limited clock speed (16 MHz), which restricts the achievable frequencies. Consider using boards with higher clock speeds, such as Arduino Due (84 MHz) or Arduino Zero (48 MHz), for higher-frequency applications.
Use Timer/Counter Hardware: To generate higher frequencies, utilize the built-in Timer/Counter hardware of the Arduino. It allows precise and efficient control over pulse width and frequency.
Timer Libraries: Arduino libraries like "TimerOne" or "TimerThree" can help you set up timers for generating PWM signals and higher frequencies.
Direct Port Manipulation: By manipulating the digital pins' states directly using port registers, you can generate simple square wave signals with higher frequencies.
Simulink Arduino Support Package: Simulink has an Arduino Support Package that allows you to interact with Arduino boards and run Simulink models on the hardware. This package provides blocks to control the Arduino's digital and analog pins and can be utilized to generate high-frequency signals.
Use External Oscillator: If higher frequencies are needed, consider using an external oscillator or clock source that can drive the Arduino's clock input.
My website: https://www.veswin.com/

Avaq Semiconductor
Avaq Semiconductor on 27 Sep 2023
Generating high-frequency signals with an Arduino can be challenging due to the limitations of the microcontroller's hardware. The Arduino Uno, for example, is based on the ATmega328P microcontroller, which has a maximum clock speed of 16 MHz. This clock speed determines the maximum frequency you can generate using the Arduino's built-in functions.
If you need higher frequencies, you can use techniques such as pulse width modulation (PWM) to generate square wave signals at frequencies higher than the Arduino's clock speed. However, the actual achievable frequency will depend on various factors, including the specific Arduino board you are using and the accuracy and stability of the generated signal.


Find more on Arduino Hardware in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!