0

Motor Shield V2.3
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Motor Shield V2.3

by tannenba on Fri Jul 19, 2019 12:55 pm

What is the frequency range of the AFMS.begin? I find anything below 1 KHz gets a segment fault on compile. Trying different frequencies to see If I can eliminate noise when using this as a Model Train Throttle. Naturally, after I asked, found if I disconnected the Arduino and reconnected, I could change frequency.

tannenba
 
Posts: 22
Joined: Wed Dec 19, 2018 12:58 pm

Re: Motor Shield V2.3

by adafruit_support_bill on Fri Jul 19, 2019 1:29 pm

Not sure what the low limit is. The maximum is about 1.6KHz. The PWM frequency is derived by subdividing the main clock on the chip. So although you can specify any value, the library will determine the clock configuration that comes as close as possible to the requested frequency.

I don't know how a simple change like that would cause a seg-fault in the compiler. What OS are you running?

adafruit_support_bill
 
Posts: 74326
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield V2.3

by tannenba on Fri Jul 19, 2019 2:04 pm

Running Windows 10 V 1903. Don't know either, but was consistent before I posted. I compiled at 100 Hz and the locomotives are quiet now, and start off slower. I am running them automated such as https://www.instructables.com/id/Simple ... duino-Cont .

tannenba
 
Posts: 22
Joined: Wed Dec 19, 2018 12:58 pm

Re: Motor Shield V2.3

by adafruit_support_bill on Fri Jul 19, 2019 2:20 pm

In general, smaller motors tend to run better at higher frequencies. But there are lots of variables, so it is hard to predict how a given motor will do in a particular case. Most often you need to experiment a bit to find the best compromise between performance and noise.

I've got Win10 on several of my machines here and have not seen that problem. Which version of the IDE are you running?

adafruit_support_bill
 
Posts: 74326
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield V2.3

by tannenba on Fri Jul 19, 2019 2:52 pm

Version 1.8.9. The train motors make a singing at 500 Hz to 1.6 KHz , at 100 Hz it is a quieter hum. Still experimenting.

tannenba
 
Posts: 22
Joined: Wed Dec 19, 2018 12:58 pm

Re: Motor Shield V2.3

by tannenba on Fri Jul 19, 2019 5:38 pm

I just tried 200 Hz. Here is the error:

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Tannenba\Documents\Arduino\Simple-Automated-Oval-AFMS\Simple-Automated-Oval-AFMS.ino: In function 'motor_go':

C:\Users\Tannenba\Documents\Arduino\Simple-Automated-Oval-AFMS\Simple-Automated-Oval-AFMS.ino:34:1: internal compiler error: Segmentation fault

}

^

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://gcc.gnu.org/bugs.html> for instructions.

lto-wrapper.exe: fatal error: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


Maybe when the library is dividing for the frequency, getting a divide error? It will compile fine at 100 Hz but fail at 150 or 200 Hz. and ok at 300 Hz. Looking like a divide error.

Note: compiling at 100 Hz gives a frequency of 91.9 Hz and 300 Hz gives 271.7 Hz.

tannenba
 
Posts: 22
Joined: Wed Dec 19, 2018 12:58 pm

Re: Motor Shield V2.3

by adafruit_support_bill on Sat Jul 20, 2019 6:32 am

The frequency calculation is done at run-time. That is a bug somewhere in the compiler itself - something that the GNU folks would need to look into.

adafruit_support_bill
 
Posts: 74326
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield V2.3

by tannenba on Sat Jul 20, 2019 11:17 am

Well, turned on all verbosity, and tried again so I could enter a bug report and....It ran fine???

tannenba
 
Posts: 22
Joined: Wed Dec 19, 2018 12:58 pm

Re: Motor Shield V2.3

by adafruit_support_bill on Sat Jul 20, 2019 11:57 am

Ah yes. A Heisenbug.

adafruit_support_bill
 
Posts: 74326
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield V2.3

by tannenba on Sat Jul 20, 2019 12:31 pm

:-) Timing of my PC??

tannenba
 
Posts: 22
Joined: Wed Dec 19, 2018 12:58 pm

Re: Motor Shield V2.3

by adafruit_support_bill on Sat Jul 20, 2019 1:22 pm

The "segmentation fault" is most likely a dangling pointer reference into the heap. If that particular piece of memory gets re-allocated, things may blow-up when you reference it. If not - it may continue on as if nothing is wrong. Those are some of the nastiest bugs to track down.

adafruit_support_bill
 
Posts: 74326
Joined: Sat Feb 07, 2009 10:11 am

Re: Motor Shield V2.3

by tannenba on Sat Jul 20, 2019 1:28 pm

Yep, and I haven't done any serious programming in at least 20 yrs.

tannenba
 
Posts: 22
Joined: Wed Dec 19, 2018 12:58 pm

Please be positive and constructive with your questions and comments.