Sammy1Am / MoppyClassic

Moppy has been replaced with Moppy 2.0!
568 stars 190 forks source link

Scanner stepper motor compatibility #173

Closed Lothean closed 6 years ago

Lothean commented 7 years ago

Hey everyone I recently made a setup with a stepper motor and a DRV8825 board to make my scanner work with Moppy but it turns out that I can't figure out a couple of things.. I didn't understood the working behavior of the steps counter in the Arduino sketch, it talks about tracks, I did a few researches and tried different numbers but couldn't get it to work. What number am I supposed to use if my motor is 200 steps ? Also, I looked in the Java code and I was again a little bit confused : how can I increase the "semitones" played on a particular channel ? Because my scanner is horribly low-pitched and it just goes ape shit when playing something. Thanks to SolidSnake and Sammy for this cool software :)

Sammy1Am commented 7 years ago

Hey there!

Each tick in the Arduino code is half a step (the tick will either turn the pin to LOW or to HIGH), so the MAX_POSITION values are twice as many steps as are available. (So for the floppy drives that have 80 tracks, the maximum number of ticks in either direction would be 160-- I put 158 just to build in a little buffer to avoid banging the heads against the ends of their tracks quite so much).

I'm not sure I understand what you're asking with your second question though. The frequency of the notes is derived from the MIDI file-- if you want a higher or lower note, you should just edit the MIDI file to where it needs to be. Because floppy drives generally have a maximum pitch somewhere around B4, I only input period information for notes up to that point. If your scanner and play higher notes, you can fill in the appropriate values in the array in MoppyPlayerOutput.java.

Lothean commented 7 years ago

Thanks a lot!

Lothean commented 7 years ago

Well, I added my micro periods and it freeze when hitting higher notes (although my scanner holds up well) Here's what I've added so far

public static int[] microPeriods = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30578, 28861, 27242, 25713, 24270, 22909, 21622, 20409, 19263, 18182, 17161, 16198, //C1 - B1 15289, 14436, 13621, 12856, 12135, 11454, 10811, 10205, 9632, 9091, 8581, 8099, //C2 - B2 7645, 7218, 6811, 6428, 6068, 5727, 5406, 5103, 4816, 4546, 4291, 4050, //C3 - B3 3823, 3609, 3406, 3214, 3034, 2864, 2703, 2552, 2408, 2273, 2146, 2025, //C4 - B4 1911, 1804, 1703, 1607, 1517, 1432, 1351, 1276, 1204, 1136, 1073, 1012, //C5 - B5 956, 902, 851, 804, 758, 716, 676, 638, 602, 568, 536, 506, //C6 - B6 478, 451, 426, 402, 379, 358, 338, 319, 301, 284, 268, 253 //C7 - B7 };

Sammy1Am commented 7 years ago

I'm not sure what you mean by "it freeze when hitting higher notes". What freezes?

Lothean commented 7 years ago

@SammyIAm Sorry for not beeing precise.. the Java application just stop responding (time not updating on the UI and no button can be used) It occurs only when I disable constrain notes, and when it plays a note that's not supposed to be played (so the one that I added) And, on the Arduino side, this note just continues until I reset the Arduino.

Sent from my Samsung SM-G925F using FastHub

Lothean commented 6 years ago

a bit of an update - this seems to be on the Java side since it also does that with MoppySim

Sammy1Am commented 6 years ago

Huh, weird. A couple thoughts:

Lothean commented 6 years ago

Between my last reply and yours, I looked a bit and found out that reducing the amount of channels sent via Moppy Serial just solves the problem... Maybe split out the work between multiple COM ports might work, i'll try with my complete setup. Anyway, now with 5 channels (1 scanner, and 4fdd) it works just fine! I'm still gonna do what you advised me though, that's still useful if the setup gets bigger, I'll let you know if there's anything new And I tried out with a couple of midis and everytime a high note would come, a freeze would follow it.

Sammy1Am commented 6 years ago

Hmm, I was reading through this again (I know you just technically closed it, but just in case this is useful):

Your microPeriods array only has 108 elements, but MIDI supports 128 notes. Those highest 20 notes are really high, but if your MIDI file actually contains one of those, it'd result in an out of bounds exception when trying to look up the period, and could potentially crash the application. If that were the issue though, reducing the channels doesn't seem like it would help, unless the especially-high note is in one of the channels you eliminated.

Glad it's working for now at least; I'm hoping Moppy 2.0 will make multiple COM ports easier to work with-- also optimistically hoping to have something testable posted this weekend (though I'm not going to hold my breath, holiday weekend and all...)

Lothean commented 6 years ago

@SammyIAm oh, well, late but right, that's the issue!