is it possible to slow down CPU to an arbitrary pace?
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
Hi, 
I would like to run a simulation with my pc but I have to test that this works fine and sufficiently fast also on an arduino device, which by now I don't have. 
I was wondering if there is a way to limit the processor frequency through some matlab command in order to test if the code could run and do the job properly on arduino. 
This could also be helpful because the microcontroller device may change and having the possibility to set the max speed of the processor to the max speed of the microcontroller would be a big deal for testing scenarios.
댓글 수: 0
채택된 답변
  DGM
      
      
 2022년 3월 22일
        
      편집: DGM
      
      
 2022년 3월 23일
  
      In order to know how it's going to run on an AVR, you'd have to emulate the microcontroller.  Like Jan said, even if you were to somehow tell MATLAB to only use 1 CPU core and were somehow able to make your CPU run at (e.g.) 8MHz, your CPU is a vastly different architecture, so the same operations may take many times longer than expected ("longer" meaning both in terms of real time and clock cycles).  Consider that your AVR has 1/8 the register width and no FPU.    
That might even seem kind of trivial, but my experience with a lot of older Arduino code generation tools is that they tend to generate code that does a terrible job of avoiding these weaknesses.  So you shouldn't assume that the degree to which your mcode is optimized for your CPU is related to the degree to which the resultant binary is optimized for your AVR.   It's been a decade since I've messed with the MATLAB Arduino stuff, so maybe it's better now, idk.
I'm sure there are various AVR/Arduino emulators out there.  I'm not going to recommend one, because I've never used one.  You'll have to see if there are any that you find useful if that's something you want to pursue.
댓글 수: 1
  Jan
      
      
 2022년 3월 23일
				Yes, an emulator should be the way to go, because it can simulate the real processing on the micro-controller more realistically. The best test is the real hardware, of course.
참고 항목
카테고리
				Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


