markfickett / arduinomorse

Morse for Arduino, with Non-Blocking Sending
48 stars 17 forks source link

attiny compatibility #11

Closed ryder2012 closed 4 years ago

ryder2012 commented 4 years ago

hi there, i've been trying to use your code added into my own which just uses case wants to control various sequences, when i load all this up to my arduino uno it all runs perfectly and does exactly what its meant to.

however, when its loaded up into an attiny45, my code all runs however the morse code aspect does not. re-assigning the pins to the chips oututs are all okay, its just there seems to be an issue with your library and the chip.

do you have any ideas?

barry-ha commented 4 years ago

You'll want to look closer at ATtiny compatibility. I've never used one but here's a Stack Overflow article that seems helpful. https://electronics.stackexchange.com/questions/80292/what-cant-the-attiny-do-that-the-arduino-can It does mention that ATtiny doesn't have a full hardware-multiply implementation for factors other than 2. I notice in this "morse.cpp" that at least one function calls on floating-point multiply in MorseSender::setWPM(). Might be more spots; that's the first one I noticed. Good luck, Barry

ryder2012 commented 4 years ago

ah crap, this is bad news for the project i have going on right now. i'll have to find a chip thats small enough and can handle the library

barry-ha commented 4 years ago

Or you can modify morse.cpp to work around the hardware-multiply problems, if that's actually the sticking point. For "setWPM()" routine you might consider pre-computing the few resulting values you need and drop support of the general case of any WPM. By the way, I've had good luck with substituting PJRC Teensy 3.2 for the Arduino Mega. Fully compatible replacement (except only 1 hardware serial port instead of 4) and pretty small. https://www.pjrc.com/store/index.html

ryder2012 commented 4 years ago

i have absolutely no idea how to do any of that haha. never realised how complicated non blocking morse is to be honest.

barry-ha commented 4 years ago

You don't know how to recognize a floating point math operation and try to work around it? I sincerely wish you the best of luck with the rest of your project. Anyway, as far as I can tell, the underlying issue in this problem report is with the ATTiny45 and not the ArduinoMorse library. I'm not an expert; I've only built two Arduino projects and haven't strayed from the Arduino/Adafruit ecosystem. If you can come up with a code fix then let us know, thanks!

ryder2012 commented 4 years ago

With respect no, I'm not a mathematician and still learning code. It's quite rude to make a remark like that.

On Sat, 16 Nov 2019, 14:17 Barry Hansen, notifications@github.com wrote:

You don't know how to recognize a floating point math operation and try to work around it? I sincerely wish you the best of luck with the rest of your project. Anyway, as far as I can tell, the underlying issue in this problem report is with the ATTiny45 and not the ArduinoMorse library. I'm not an expert; I've only built two Arduino projects and haven't strayed from the Arduino/Adafruit ecosystem. If you can come up with a code fix then let us know, thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markfickett/arduinomorse/issues/11?email_source=notifications&email_token=ANYZMPRUI6PH7H62DQPILD3QT76HDA5CNFSM4JNSOKM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEHSQPI#issuecomment-554641469, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYZMPVHKETBTCZSQSRMOYLQT76HDANCNFSM4JNSOKMQ .

barry-ha commented 4 years ago

My apologies. No offense was intended. I do wish you success on your project.

markfickett commented 4 years ago

Hi @ryder2012 , did you ever have luck with this? Some notes in case / for posterity:

I did actually use the morse library myself with an ATTiny85, blinking an LED: https://github.com/markfickett/lipostorage . (It sounds like the 85 just has twice the memory v. the 45, so I'd expect it to translate.)

If you're finding that the ATTiny is too limited, you may be interested in using a bare ATMega328, which is at least smaller than the big Arduino board, though still 28 pins to the ATTiny's 8. I collected links to the resources I tend to use here: https://github.com/markfickett/spinner#bare-atmega-programming . And as @barry-ha pointed out, the Teensy is a good small Arduino alternative.