-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
L298N Support #7
Comments
100% yes! I will for sure be adding copious comments to the code, and maybe a little more overview on the wiki (though I tend to prefer code comments over separate documents since it involves less cross referencing). This next week is especially busy for me so I won't get a lot of time until later in the month, but I'll leave this issue open to remind me. For the short term, a couple highlights of what's different from the previous version:
For the L298N modifications, you'll probably looking mostly at the MoppyInstruments section (from my understanding of how they work, which is, admittedly, very brief). I'd recommend basically copying |
Thanks, I'll wait for the comments! I learned a lot since I made my first Moppy personal modification! You're going to see me alot here (and maybe in pull requests?) ;) |
Great! One of my main goals for 2.0 is to make it a lot easier for me to pull contributions to the library. I just pushed some updates to add some additional comments to the Arduino code, let me know if those help out (and what might be missing that would help you figure out what you need in order to make changes). |
Comments do help a lot, but I'm still trying to figure out how to determine if a step must be done. (like, the condition, not just toggling a pin state) |
Yeah, the mapper thing's going to solve an awful lot of requests / problems! 😄 The step thing has gotten a little complex, but I'll see if I can't provide some additional insight (some of this you'll no doubt already know, but in case it's helpful to others-- I'll probably just copy this into the documentation on the wiki): The frequency with which the floppy drive moves its head equates to the frequency of the note you hear. So for the note A2 the head takes steps at 110Hz. Because we're using loops and counters to time the steps we need to get the inverse frequency, or period, for the note. Again for A2 this is 0.0090909 seconds or about 9091 microseconds between steps. This is the number stored in the We could just do an endless loop and call Since the The floppy drive head takes a step on the falling edge of the signal sent to it (that is, when the voltage of the Step pin drops from 5v to 0v). In order to take a second step, the pin needs to be brought back up to 5v again before we can create another falling edge. For the best signal clarity, we want to keep these rising and falling edges as far apart as we can. Calling Actually tracking the state of each drive is just normal loops and counters after the math above is done. When a NoteOn event comes in, we put the value from Apologies if that was a bit verbose, but better extra documentation that not enough. :P * The resolution affects the accuracy of the notes being played. For A2 = 110Hz, we actually end up playing 109.65Hz. It gets worse at higher frequencies; an A4 = 440Hz comes out at 446.4Hz. Still closer to A than A#, but the next step down with 40 microsecond resolution is 431Hz which is even worse. Higher resolution would improve note accuracy but runs the risk of overlapping interrupts or not enough cycles for serial processing. |
Finally, I managed to understand the code! This seems very clear to me now, I'm gonna come up with a modification soon, and I'll make it in a way that does not add any library for the L298N. Thanks a lot again, it was very helpful :) |
Hey,
Can you take a look at my (probably badly made) code and tell me if there's anything wrong that could create issues with Moppy ? |
I took a quick look (I'm not super familiar with L298Ns so I'll just have to trust that those parts are fine :P ), and it looks generally good. To address your two questions first:
with
And ideally instead of replacing it outright, you could add the two L298N lines commented out below the FloppyDrive lines. Basically, the "default" for the code base will be the FloppyDrives and it'll be up to the end user to comment/uncomment the appropriate lines there to configure for their instrument.
Generally looks awesome though! As soon as I get around to fixing the FloppDrive namespace issue and you get a chance to test on your hardware we can merge it into mainline :) |
I'll make these changes as soon as I can. Thanks for the advices! I also plan on making a completely different Floppy instrument: One Arduino per channel, and the velocity of the note would change the amount of drive that play the note. Would that be possible with the current Java code ? |
The Java code would need to start sending velocity information along with the note information in the MoppyMessages (there'd need to be another byte). Not too hard to do, but would need to be done. I'll add an issue for it. |
Hey, I'm working on a modification of the L298N code which will reduce the amount of bridges that can be connected on the Arduino, but allows more motors to be supported; |
I meant to fix the namespace thing this weekend but got distracted by Cities: Skylines 😉 Just about to see if I can't figure out what's up with the channel 1 only thing, but gotta learn a bit about the L298 (and have some food). |
Hmm, I couldn't see anything that looked like it would cause issues for not-channel 1 so it might be an issue on the controller app side (either in the mapper configuration or with the program itself). Also, in my experience most people are looking for ways to add more motors and more floppy drives rather than less :P Power does always end up being a problem though because no one wants to provide a separate power supply for the drives (which isn't even that hard!) If you still can't get the channel 1 bit working after fixing the namespaces, maybe post a screenshot of the controller app configuration and I'll see if anything looks amiss. |
Code is done, is working, and I submitted it! |
All merged! I added a limiter to the FloppyDrives code, but those higher notes will be really helpful for anyone using stepper motors. Congrats on being the first Moppy2 pull! (Closing this thread as being specific to adding L298N support, but feel free to open a new one for discussion or other questions) |
Hello!
I'd like to contribute and create code for "L298N" H bridges to be compatible but there's no resources to help me... (understanding the arduino code mostly)
Do you plan on adding some ?
The text was updated successfully, but these errors were encountered: