vDrive: With MDV sound? I wonder.

Nagging hardware related question? Post here!
User avatar
NormanDunbar
Forum Moderator
Posts: 2483
Joined: Tue Dec 14, 2010 9:04 am
Location: Buckie, Scotland
Contact:

Re: vDrive: With MDV sound? I wonder.

Post by NormanDunbar »

Popopo wrote: That's right, as you write. But not always (for every digispark board), in any case, the reset pin affect to this project?
Reset pin is pin1, transformed into GPIO by Digispark GPIO#5, since the project use PB1 and PB4 it doesn't matter actually. Does it?
No, while the code doesn't need the reset pin, you need the reset pin to be available to allow you to reprogram the board normally but it seems this is not the case with the bootloader installed on the Digispark. Unfortunately, that is where the delay of 10 seconds is being caused, by the bootloader looking for new code.

Popopo wrote: I have been programing it with Arduino as ISP, so ISP is enable for me => reset pin is still a reset pin.
Ok, from what you say, it seems that not every Digispark is locked down! This is good and even better, yours sounds like it can be reprogrammed.


bwinkel67 wrote: So that's why I ask what you are doing because if that's what you did and didn't see any difference then I wouldn't bother. If that's the case, why would Stephen's program run on his ATTiny85 board and sound normal and then sound metallic on the Digispark ATTiny board? What's the difference between the two boards?
I suspect that perhaps the clock frequency is higher on the screeching boards, or, the clock divider for the timer being used to generate the PWM "noise" is smaller. The PWM frequency is determined by the clock frequency, the time prescaler which divides the clock frequency and determines how many clock cycles determine a single timer cycle. If the timer is running at full speed, and the clock is 20 MHz, it's possible that the PWM frequency is getting into too high a range, and shoving the audio up a few octaves?

I don't know for certain, I've only ever used Stephen Usher's code and was never able to get a sound out of it as my speaker was buggered!

Also, the board design used by Stephen is not supposed to need a capacitor, it's based on some direct drive sound code.

Popopo wrote: Attiny digitalized sound is played by PWM == SQUARES, not waves, no waves => not nice sound.
Yes indeed, it's definitely not HiFi quality sound, but high end synthesisers often use square waves as a source of their sound, just enhanced by filters and such like.


Ok, further to the above, I've had a look at Stephen's code at https://github.com/stephen-usher/vDrive ... snd-v1.ino. It seems he's enabled the PLL to run the timer at 64 MHz with a divide by 1 prescaler initially, but then this is dropped to a divide by 8, giving a timer frequency of 8 MHz, so the timer will be clocked at 8 MHz. Sound samples will be output at a rate of 8 KHz in "Fast" PWM mode.

I don't know what code the version you are running uses, I wonder if it's similar?


HTH Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
stephen_usher
Super Gold Card
Posts: 544
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: vDrive: With MDV sound? I wonder.

Post by stephen_usher »

NormanDunbar wrote: Fri Jun 06, 2025 7:27 pm Also, the board design used by Stephen is not supposed to need a capacitor, it's based on some direct drive sound code.
Indeed, the code I modified (giving original attribution) uses the pins in push-pull mode so as to double the voltage and give a higher amplitude.


User avatar
bwinkel67
QL Wafer Drive
Posts: 1533
Joined: Thu Oct 03, 2019 2:09 am

Re: vDrive: With MDV sound? I wonder.

Post by bwinkel67 »

stephen_usher wrote: Fri Jun 06, 2025 8:32 pm Indeed, the code I modified (giving original attribution) uses the pins in push-pull mode so as to double the voltage and give a higher amplitude.
I know you don't have a Digispark board, but should I expect your code to work on that as well? Perhaps requiring some tweaks to deal with the clock that Norman suggested. Sorry if my questions seem naive as I've just not done Arduino programming before.


stephen_usher
Super Gold Card
Posts: 544
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: vDrive: With MDV sound? I wonder.

Post by stephen_usher »

bwinkel67 wrote: Fri Jun 06, 2025 9:45 pm I know you don't have a Digispark board, but should I expect your code to work on that as well? Perhaps requiring some tweaks to deal with the clock that Norman suggested. Sorry if my questions seem naive as I've just not done Arduino programming before.
I seem to remember having to go into another tab on either the Arduino system or the TL866 programmer to change a setting but as it's 4 years since I looked at this I can't remember. It could be that this setting can't be altered in the Digispark device. I have no idea.


User avatar
Popopo
Gold Card
Posts: 462
Joined: Wed Apr 07, 2021 10:37 am

Re: vDrive: With MDV sound? I wonder.

Post by Popopo »

Digispark use part of the inner memory to store its bootloader,
How does it affect us? you have some ms less to store a digitalized sound. That is all.

Digispark has published different versions of its bootloader, some bugfixes so on, it is discontinued already, but how it makes easier to program it for people like me (newbies, hobbyists and enthusiasts), there are lot of seller that offer this board. Also libraries to program them from Arduino IDE. The same page of Digispark recommend to don't use old libraries but the AttinyCore libraries.

What else? Fuses, there are some scripts on the Digispark site for MSWindows environments to change fuses and each fuses has a value.
Higher clock should be the best to reproduce sound cause you have more samples to play in 1 second. The problem? the little program space you have in the Attiny, so you need to decrease the clock in order to get at least 1 second (removing also the bootloader) of a sound.

It has the problem to transform this PWM into a sound wave (sine based signal), you need bigger capacitors to make connect all the micro samples in a softly way, because the samples are more separated (clock signal slower). Whatever, it is "easy" to do, but must be done, and it has not been done yet.

My attiny smoked... :) trying to recover it in the surgery room :) why? here is what I suspect: The power consumption.

Attiny85 has 20mA of output in their pins, right?,
we are connecting a speaker of 8 Ohms, feeding them with 5v (by now it is clear).
So... V=R*I => I= V/R = 5/8 = 0.625A ... So What? Are we asking/taking 625mA from a IC that only can deliver safely 20mA ? :) yes, we are. And it doesn't burn cause we use it for short period of times (I guess).
That is why some amplifiers are highly recommended to use here, but by now, no-one implemented it.

And some people don't even use a resistor to limit the current in the output of the pins used.

What could happen? well... for my projects that will not be usable. But for emulating 1 second of a sound for 5 seconds of activity... could be OK, but will damage the IC sooner or later, and since it is connected and feed by the same power line from the QL... probably nothing or perhaps a short, perhaps an opened line.

Very very very probably I am completely wrong because I am inexpert on it, but it is a "for me is working", till the day it is not anymore and burn the Attiny85 because I used it intensively.
It worries me.

I am trying to resurrect my Attiny85 just for gaining experience, but I won't use it. I will use Arduino. The quality will be theoretically lower, actually same or better.
Why?
It has bigger memory => samplers could be bigger => sampling with higher freqs (if my numbers are not wrong)
Clocks are slower than attiny, but since the memory is higher, (I suppose) the digitization of the sound could use higher freqs for sampling and playing (what I have describe above if I am not wrong).
...
And other capabilities that I would like to use in the MicroDrivePico.

Does it make sense?


stephen_usher
Super Gold Card
Posts: 544
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: vDrive: With MDV sound? I wonder.

Post by stephen_usher »

You have to remember that the component either side of the speaker is the ATTiny85, which will limit the current draw due to its line drivers. Putting a capacitor on that line will potentially draw a very large current, however, due to the inrush current, so don't do that. If you want to smooth it you need to use an inductor.

You seem to be tying yourself in knots due to trying to use that Digispark device. Far better a bare ATTiny85 and a TL866 EPROM programmer to program it.

As for the memory, that also could be a problem as I think that the sample was very close to filling the whole memory of the device.


User avatar
Popopo
Gold Card
Posts: 462
Joined: Wed Apr 07, 2021 10:37 am

Re: vDrive: With MDV sound? I wonder.

Post by Popopo »

stephen_usher wrote: Sat Jun 07, 2025 8:13 pm You have to remember that the component either side of the speaker is the ATTiny85, which will limit the current draw due to its line drivers. Putting a capacitor on that line will potentially draw a very large current, however, due to the inrush current, so don't do that. If you want to smooth it you need to use an inductor.

You seem to be tying yourself in knots due to trying to use that Digispark device. Far better a bare ATTiny85 and a TL866 EPROM programmer to program it.

As for the memory, that also could be a problem as I think that the sample was very close to filling the whole memory of the device.
You are right.
I am trying (just for experiments with the limits purpose) to use Digispark device at first try, but I have removed it from it and now trying to convert it into a regular Attiny85 (it is already outside and soldered in an adaptor TH PCB pinned).

I didn't try with TL866 yet, hummm I will check it out how to. Thanks for the tip! :)

About the inductor, the own speaker is one itself. And perhaps that is the reason why sometimes with some speakers it seems to work OK. I couldn't try it yet due it smoked up.

I will use an electronic simulator tomorrow or after-tomorrow to check how the current behave with inductor and a capacitor.


Post Reply