mitxela.com forum
Welcome. Please log in or register.

Polyphonic on attiny85
lasoaaro Posted: 4 Mar 2022, 03:00 PM
Avatar


Member
Posts: 3
Joined: 4-March 22
Good Morning,

I came across your project the other day and wanted to implement it into a card I was making but I seem to be having a bunch of issues I'm hoping you can help with.

I was able to upload the example .hex file you created but when it plays on my piezo speakers it's extremely quiet. Any background noise will easily drown out the sound and is not loud like in your recorded playback. Curious if you have any ideas why this might be?

The main issue I'm having however is trying to compile an updated .asm file to .hex so I can try with a song that I converted. Could you explain what software you used and the process to compile it? I've tried to use MPLab X but it complains about everything... can't find the at85def.inc file, throws errors about expecting commas, etc...

I was hoping to have this project completed by today but these issues have been major roadblocks and it's looking like I will not be able to complete this in time.

Below is the output from MPLab when I try to build the project...

Error: can't open tn85def.inc for reading: No such file or directory
polyphony.asm:5: Error: expected comma after "amplitude"
polyphony.asm:6: Error: expected comma after "speed"
polyphony.asm:7: Error: expected comma after "tempo"
polyphony.asm:33: Error: garbage at end of line
polyphony.asm:34: Error: garbage at end of line
polyphony.asm:35: Error: even register number required
polyphony.asm:35: Error: `,' required
polyphony.asm:35: Error: garbage at end of line
polyphony.asm:42: Error: constant value required
polyphony.asm:64: Error: garbage at end of line
polyphony.asm:66: Error: junk at end of line, first unrecognized character is `7'
polyphony.asm:117: Error: even register number required
polyphony.asm:117: Error: garbage at end of line
polyphony.asm:122: Error: even register number required
polyphony.asm:122: Error: `,' required
polyphony.asm:122: Error: garbage at end of line
polyphony.asm:126: Error: garbage at end of line
polyphony.asm:127: Error: garbage at end of line
polyphony.asm:128: Error: even register number required
polyphony.asm:128: Error: `,' required
polyphony.asm:128: Error: garbage at end of line
polyphony.asm:201: Error: unknown pseudo-op: `.db'
polyphony.asm:202: Error: unknown pseudo-op: `.db'
polyphony.asm:210: Error: unknown pseudo-op: `.db'
polyphony.asm:211: Error: unknown pseudo-op: `.db'
polyphony.asm:212: Error: unknown pseudo-op: `.db'
polyphony.asm:213: Error: unknown pseudo-op: `.db'
polyphony.asm:214: Error: unknown pseudo-op: `.db'
polyphony.asm:215: Error: unknown pseudo-op: `.db'
polyphony.asm:216: Error: unknown pseudo-op: `.db'
polyphony.asm:217: Error: unknown pseudo-op: `.db'
polyphony.asm:218: Error: unknown pseudo-op: `.db'
polyphony.asm:219: Error: unknown pseudo-op: `.db'
polyphony.asm:220: Error: unknown pseudo-op: `.db'
polyphony.asm:221: Error: unknown pseudo-op: `.db'
polyphony.asm:222: Error: unknown pseudo-op: `.db'
polyphony.asm:223: Error: unknown pseudo-op: `.db'
polyphony.asm:224: Error: unknown pseudo-op: `.db'
polyphony.asm:225: Error: unknown pseudo-op: `.db'
polyphony.asm:226: Error: unknown pseudo-op: `.db'
polyphony.asm:227: Error: unknown pseudo-op: `.db'
polyphony.asm:228: Error: unknown pseudo-op: `.db'
polyphony.asm:229: Error: unknown pseudo-op: `.db'
polyphony.asm:230: Error: unknown pseudo-op: `.db'
polyphony.asm:231: Error: unknown pseudo-op: `.db'
polyphony.asm:232: Error: unknown pseudo-op: `.db'
polyphony.asm:233: Error: unknown pseudo-op: `.db'
polyphony.asm:234: Error: unknown pseudo-op: `.db'
polyphony.asm:235: Error: unknown pseudo-op: `.db'
polyphony.asm:236: Error: unknown pseudo-op: `.db'
polyphony.asm:237: Error: unknown pseudo-op: `.db'
polyphony.asm:238: Error: unknown pseudo-op: `.db'
polyphony.asm:239: Error: unknown pseudo-op: `.db'
polyphony.asm:240: Error: unknown pseudo-op: `.db'
polyphony.asm:241: Error: unknown pseudo-op: `.db'
polyphony.asm:242: Error: unknown pseudo-op: `.db'
polyphony.asm:243: Error: unknown pseudo-op: `.db'
polyphony.asm:244: Error: unknown pseudo-op: `.db'
polyphony.asm:245: Error: unknown pseudo-op: `.db'
polyphony.asm:246: Error: unknown pseudo-op: `.db'
polyphony.asm:247: Error: unknown pseudo-op: `.db'
polyphony.asm:248: Error: unknown pseudo-op: `.db'
polyphony.asm:249: Error: unknown pseudo-op: `.db'
polyphony.asm:250: Error: unknown pseudo-op: `.db'
polyphony.asm:251: Error: unknown pseudo-op: `.db'
polyphony.asm:252: Error: unknown pseudo-op: `.db'
polyphony.asm:253: Error: unknown pseudo-op: `.db'
polyphony.asm:254: Error: unknown pseudo-op: `.db'
polyphony.asm:255: Error: unknown pseudo-op: `.db'
polyphony.asm:256: Error: unknown pseudo-op: `.db'
polyphony.asm:257: Error: unknown pseudo-op: `.db'
polyphony.asm:258: Error: unknown pseudo-op: `.db'
polyphony.asm:259: Error: unknown pseudo-op: `.db'
polyphony.asm:260: Error: unknown pseudo-op: `.db'
polyphony.asm:261: Error: unknown pseudo-op: `.db'
polyphony.asm:262: Error: unknown pseudo-op: `.db'
polyphony.asm:263: Error: unknown pseudo-op: `.db'
polyphony.asm:264: Error: unknown pseudo-op: `.db'
polyphony.asm:265: Error: unknown pseudo-op: `.db'
polyphony.asm:266: Error: unknown pseudo-op: `.db'
polyphony.asm:267: Error: unknown pseudo-op: `.db'
polyphony.asm:268: Error: unknown pseudo-op: `.db'
polyphony.asm:269: Error: unknown pseudo-op: `.db'
polyphony.asm:270: Error: unknown pseudo-op: `.db'
polyphony.asm:271: Error: unknown pseudo-op: `.db'
polyphony.asm:272: Error: unknown pseudo-op: `.db'
polyphony.asm:273: Error: unknown pseudo-op: `.db'
polyphony.asm:274: Error: unknown pseudo-op: `.db'
polyphony.asm:275: Error: unknown pseudo-op: `.db'
polyphony.asm:276: Error: unknown pseudo-op: `.db'
polyphony.asm:277: Error: unknown pseudo-op: `.db'
polyphony.asm:278: Error: unknown pseudo-op: `.db'
polyphony.asm:279: Error: unknown pseudo-op: `.db'
polyphony.asm:280: Error: unknown pseudo-op: `.db'
polyphony.asm:281: Error: unknown pseudo-op: `.db'
polyphony.asm:282: Error: unknown pseudo-op: `.db'
polyphony.asm:283: Error: unknown pseudo-op: `.db'
polyphony.asm:284: Error: unknown pseudo-op: `.db'
polyphony.asm:285: Error: unknown pseudo-op: `.db'
polyphony.asm:286: Error: unknown pseudo-op: `.db'
polyphony.asm:287: Error: unknown pseudo-op: `.db'
polyphony.asm:288: Error: unknown pseudo-op: `.db'
polyphony.asm:289: Error: unknown pseudo-op: `.db'
polyphony.asm:290: Error: unknown pseudo-op: `.db'
polyphony.asm:291: Error: unknown pseudo-op: `.db'
polyphony.asm:292: Error: unknown pseudo-op: `.db'
polyphony.asm:293: Error: unknown pseudo-op: `.db'
polyphony.asm:294: Error: unknown pseudo-op: `.db'
polyphony.asm:295: Error: unknown pseudo-op: `.db'
polyphony.asm:296: Error: unknown pseudo-op: `.db'
polyphony.asm:297: Error: unknown pseudo-op: `.db'
polyphony.asm:298: Error: unknown pseudo-op: `.db'
polyphony.asm:299: Error: unknown pseudo-op: `.db'
polyphony.asm:300: Error: unknown pseudo-op: `.db'
polyphony.asm:301: Error: unknown pseudo-op: `.db'
polyphony.asm:302: Error: unknown pseudo-op: `.db'
polyphony.asm:303: Error: unknown pseudo-op: `.db'
polyphony.asm:304: Error: unknown pseudo-op: `.db'
polyphony.asm:305: Error: unknown pseudo-op: `.db'
polyphony.asm:306: Error: unknown pseudo-op: `.db'
polyphony.asm:307: Error: unknown pseudo-op: `.db'
polyphony.asm:308: Error: unknown pseudo-op: `.db'
polyphony.asm:309: Error: unknown pseudo-op: `.db'
polyphony.asm:310: Error: unknown pseudo-op: `.db'
polyphony.asm:311: Error: unknown pseudo-op: `.db'
polyphony.asm:312: Error: unknown pseudo-op: `.db'
polyphony.asm:313: Error: unknown pseudo-op: `.db'
polyphony.asm:314: Error: unknown pseudo-op: `.db'
polyphony.asm:315: Error: unknown pseudo-op: `.db'
polyphony.asm:316: Error: unknown pseudo-op: `.db'
polyphony.asm:317: Error: unknown pseudo-op: `.db'
polyphony.asm:318: Error: unknown pseudo-op: `.db'
polyphony.asm:319: Error: unknown pseudo-op: `.db'
polyphony.asm:320: Error: unknown pseudo-op: `.db'
polyphony.asm:321: Error: unknown pseudo-op: `.db'
polyphony.asm:322: Error: unknown pseudo-op: `.db'
polyphony.asm:323: Error: unknown pseudo-op: `.db'
polyphony.asm:324: Error: unknown pseudo-op: `.db'
polyphony.asm:325: Error: unknown pseudo-op: `.db'
polyphony.asm:326: Error: unknown pseudo-op: `.db'
polyphony.asm:327: Error: unknown pseudo-op: `.db'
polyphony.asm:328: Error: unknown pseudo-op: `.db'
polyphony.asm:329: Error: unknown pseudo-op: `.db'
polyphony.asm:13: Error: invalid operands (*ABS* and *UND* sections) for `<<'
polyphony.asm:13: Error: invalid operands (*ABS* and *UND* sections) for `<<'
polyphony.asm:16: Error: invalid operands (*ABS* and *UND* sections) for `<<'
polyphony.asm:16: Error: invalid operands (*ABS* and *UND* sections) for `<<'
polyphony.asm:16: Error: invalid operands (*ABS* and *UND* sections) for `<<'
polyphony.asm:23: Error: invalid operands (*ABS* and *UND* sections) for `<<'
polyphony.asm:47: Error: invalid operands (*ABS* and *UND* sections) for `<<'
polyphony.asm:171: Error: invalid operands (*UND* and *ABS* sections) for `/'
polyphony.asm:82: Error: can't resolve `0' {*UND* section} - `amplitude' {*UND* section}
polyphony.asm:82: Error: expression too complex
polyphony.asm:165: Error: invalid operands (*UND* and *ABS* sections) for `/'
polyphony.asm:173: Error: can't resolve `0' {*ABS* section} - `amplitude' {*UND* section}
polyphony.asm:173: Error: expression too complex
make[2]: *** [build/default/production/polyphony_ff7.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
nbproject/Makefile-default.mk:111: recipe for target 'build/default/production/polyphony_ff7.o' failed
make[2]: Leaving directory 'H:/Development/polyphony.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'H:/Development/polyphony.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUILD FAILED (exit value 2, total time: 958ms)


Thank you,

Aaron

-------------
[top]
mit Posted: 4 Mar 2022, 04:07 PM
Avatar
yeah whatever

Admin
Posts: 566
Joined: 4-May 16
Hi,

I've never heard of MPLab X [edit: oh yeah it's the PIC version of AVR studio, I've not used either in years]. To assemble the .asm I use avrasm2. It's a windows .exe file but it runs fine under wine. The .exe file is very small and the only other files you need are the .inc files with the register definitions.

On linux I have a file called /usr/bin/avrasm2 that looks like this:
!/bin/sh
exec wine ~/avrasm/avrasm2.exe -I ~/avrasm "$@"

I originally acquired the files from AVR studio 4 many years ago, but I'm pretty sure some googling will find a way to download them, or failing that I assume the modern versions of AVR studio contain them somewhere if you can dig through all the bloat.

The volume level is a real problem. Even on the first card I made, which had differential square waves at 6V, it was pretty quiet, and the polyphonic version is even quieter. To get it louder you could add a transistor or two. Maybe add a whole load of coin cell batteries, power the attiny off of one of them, but drive the speaker with a handful in series, that ought to get it loud enough.

See also this thread where I made a converter to work with ELM chan's attiny synth: https://mitxela.com/forum/topic/elm-wavetable-melody#1530375858

Last edit by mit at 4 Mar 2022, 04:10 PM

-------------
[top]
lasoaaro Posted: 4 Mar 2022, 05:33 PM
Avatar


Member
Posts: 3
Joined: 4-March 22
Thank you for the speedy reply.

I was able to find a copy of the tn85def.inc file on github. I'm not familiar with using avrasm2, are there any option bits that I need to pass when I'm compiling the file or can I just run it as is? How would I include the .inc file in the compiler?

Sorry for these basic questions, I'm trying to find the answers on Google but can't find the answers I'm looking for.

Thanks again,

Aaron

-------------
[top]
lasoaaro Posted: 4 Mar 2022, 06:00 PM
Avatar


Member
Posts: 3
Joined: 4-March 22
I tried running the .asm through avrasm2 and I was able to get the .hex file which plays fine when I have it connected to 5v, extremely low but I can make it out, but when I switch to a 3v PS I can't hear anything. Unfortunately I don't have a scope to check if there's anything being generated on the pins, but it did upload with no errors so I'm assuming it's running. You mentioned that your projects were quiet, and even quieter when you went polyphonic - were they still audible at like a speaking level, or were they so quiet you needed complete silence in order to hear them? I'm trying to avoid using more components than needed as this will also be embedded in a card, so trying to get by using a single coin cell.

Thanks again,

Aaron

-------------
[top]
mit Posted: 5 Mar 2022, 01:57 AM
Avatar
yeah whatever

Admin
Posts: 566
Joined: 4-May 16
Check it's wired up in differential mode, sticking the piezo between the two GPIO pins, not from one pin to ground.

You can stick two 3V batteries in series to get it a bit louder, the chip is technically rated up to 5.5V but I found it works fine.

The original card I made was only 2-channel polyphony and used a different method which was louder but still pretty quiet. I thought it was fine when I built it on my desk, but when I took it to my friend's birthday do, you could only hear it if you held it up to your ears. I think it's just a property of piezo speakers, they need a fair bit of voltage. You could also try using stiffer card so it resonates a bit more.

There might be a clever way of boosting the sound output but it will almost certainly mean more components. I wonder if you could build a tiny transformer, just two flat coils of wire, with the attiny connected on one side and the piezo on the other. I don't know if you'd need a core for that to work.

Another option is to stick a real speaker on it instead of a piezo, might work better but won't be as flat. The impedance of the speaker will affect how loud it is at the attiny's voltage.

-------------
[top]

Sign in to post a reply.