This wasn't supposed to work....

Started by karbomusic, December 16, 2014, 11:21:59 PM

Previous topic - Next topic

karbomusic

But it did...

It's the most novel of ideas and I'm sure it's very old news to everyone but me, but I'd been meaning to toy around and see just how good/bad the result would be. So, I fired up my laptop, pushed some simple code over to the Arduino Nano, made a half-baked LDR and gave it a go. It worked better than I expected though to be so simple...




GibsonGM

Sounds good...what are you using as a vactrol?  The LED is just an indicator, right?  I've done this with a 555 but with much less satisfying results!

I'm curious....why'd you think it shouldn't work?
  • SUPPORTER
MXR Dist +, TS9/808, Easyvibe, Big Muff Pi, Blues Breaker, Guv'nor.  MOSFace, MOS Boost,  BJT boosts - LPB-2, buffers, Phuncgnosis, FF, Orange Sunshine & others, Bazz Fuss, Tonemender, Little Gem, Orange Squeezer, Ruby Tuby, filters, octaves, trems...

deadastronaut

https://www.youtube.com/user/100roberthenry
https://deadastronaut.wixsite.com/effects

chasm reverb/tremshifter/faze filter/abductor II delay/timestream reverb/dreamtime delay/skinwalker hi gain dist/black triangle OD/ nano drums/space patrol fuzz//

karbomusic

Quote from: GibsonGM on December 17, 2014, 08:04:05 AM
Sounds good...what are you using as a vactrol?  The LED is just an indicator, right?  I've done this with a 555 but with much less satisfying results!

It's in the top-left, the led on the Arduino is just an indicator, I can remove that by using a different pin but wasn't thinking about that at the time I made the video.

Quote
I'm curious....why'd you think it shouldn't work?

Because I don't really know how tremolos work other than "there must be a virtual person turning the volume knob up and down really fast".  :icon_redface: So, from a caveman perspective, I tried to replicate that but really didn't expect it to work due to ignorance. It had clicks at first but I smoothed it and got rid of those by strapping a 10uF across the LED leads.

karbomusic

Quote from: deadastronaut on December 17, 2014, 08:55:08 AM
IT'S ALIVE.... ;D

good old leds.. 8)

It lives.  :icon_mrgreen: I figured I'd start with LEDs. Next up is to play with the code and explore the caveats which was somewhat the point of the exercise. Even if it stays this simple, it'll end up in a pedal with the USB connector exposed so I can tweak the code post build. Good fun, it's just more pedal crack.

lapsteelman

Very cool! 
I've been playing around with the Arduinos a bit lately myself because my son is into them. Do you mind sharing the code  you used for the LFO? It seems to have a nice smooth change. (The one's I have tried were all very choppy)
I can tell the one knob controls the speed, but what does the other knob do? It doesn't seem to be a depth control.

karbomusic

#6
Quote from: lapsteelman on December 17, 2014, 10:18:50 AM
Very cool!  
I've been playing around with the Arduinos a bit lately myself because my son is into them. Do you mind sharing the code  you used for the LFO? It seems to have a nice smooth change. (The one's I have tried were all very choppy)
I can tell the one knob controls the speed, but what does the other knob do? It doesn't seem to be a depth control.

Embarrassingly, the code is literally similar to the sample code that reads a POT and sets the LED speed. That's why I thought it was "too easy", no assembly just straight up code in the main loop. I was prepared to dig in and write more complex code but I don't have to (yet):

Quote

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
 // declare the ledPin as an OUTPUT:
 pinMode(ledPin, OUTPUT);
}

void loop() {
 // read the value from the sensor:
 sensorValue = analogRead(sensorPin);
 // turn the ledPin on
 digitalWrite(ledPin, HIGH);
 // stop the program for <sensorValue> milliseconds:
 delay(sensorValue);
 // turn the ledPin off:
 digitalWrite(ledPin, LOW);
 // stop the program for for <sensorValue> milliseconds:
 delay(sensorValue);
}

I'm sure it'll go south and require more ingenious work once it goes beyond simple POC but hey, it works good enough for a simple LFO.

For the red knob it is in series with the photo resistor in order to reduce it's effect of shunting the signal to ground which essentially makes it a depth control. Being much more of a coder than an electronics guy, I've been wanting to combine the two for quite some time and just now getting around to it.

GGBB

Awesome! This might be a dumb question (I am a programmer but I know nothing about arduino yet) but is there a reason you used the nano vs. say the uno or due? I'm thinking about getting into this but I'm not sure what board to start with.
  • SUPPORTER

karbomusic

#8
Quote from: GGBB on December 17, 2014, 11:05:31 AM
Awesome! This might be a dumb question (I am a programmer but I know nothing about arduino yet) but is there a reason you used the nano vs. say the uno or due? I'm thinking about getting into this but I'm not sure what board to start with.

Nope, the only reason I chose the Nano was size (it's tiny), something I could fit in a pedal. I have a couple Nano's and maybe a Micro (I forget). These have a 32k limit if I remember. However, if you are also a programmer like me, you'll love it, too simple and loads of fun in general. Just download the Arduino IDE and start sending code over to it via USB/COM port.

Edit: There is also the "Teensy" board which I hear is really great, just haven't been down that road yet.

anotherjim

Nice.

I suppose Nano is more breadboard friendly -  like a big IC - saves all the header pin jumper wires  the bigger ones need which are geared more towards working with a Shield.

Have been coding a bit myself lately (after a long time), but for a little 8pin Atmel Tiny85. I learned to code ages ago using assembly language. I just can't get my head around any "C" like languages - too old to learn. Just for kicks, and maybe it will actually be useful, it will be an 8bit 512 stage BBD type delay using the on-board ADC and PWM out. Using all the RAM in the chip so no stack available, which you don't need for simple prog's written in assembler. Like a BBD, delay will depend on external clock, which keeps the code simple.


deafbutpicky

#10
Now I got an idea for a Christmas gift for me :)

I'm not into arduino so forgive me this question:
why did you choose integers for the variables? Wouldn't float make a smoother response?

Also, using digital and speaks of caveman style gave me a good laugh, imagining a couple fur hanged dudes
around the bonfire discussing the latest tiger catching algorithms in grunt language ;)

@anotherjim

I worked with assembler twice and it made me feel like making handshakes with every single bit in person...
coming from a guy feeling at home with OOP.

karbomusic

Quote from: anotherjim on December 17, 2014, 11:41:06 AM
Nice.
I learned to code ages ago using assembly language.


I'm pretty sure you can drop back to assembly with these. Not sure if there is an _asm{} inline ability or similar. I'm almost sure I saw examples of assembly using more complex code that actually takes audio as input (think digital delay). Maybe Digital Larry knows? I'm sure I've seen similar in the digital subforum, maybe, I think.   ???

karbomusic

#12
Quote from: deafbutpicky on December 17, 2014, 11:53:41 AM
Now I got an idea for a Christmas gift for me :)

I'm not into arduino so forgive me this question:
why did you choose integers for the variables? Wouldn't float make a smoother response?

Simply because I assumed it wouldn't work or there would be large hurdles to overcome, thusly this was literally the first test to see what would happen. It's only 20 minutes in, I hooked it up and proverbially hit go. Still need to go back and beat it up to find the limits. It's literally acting like a square wave since I'm only turning the LED on/off. The ramp is the "play" in the analog chain, LED ramp time and so on.

QuoteAlso, using digital and speaks of caveman style gave me a good laugh, imagining a couple fur hanged dudes
around the bonfire discussing the latest tiger catching algorithms in grunt language ;)

LOL! I can see them drawing the schematic in the sand with a stick.

Quote
@anotherjim

I worked with assembler twice and it made me feel like making handshakes with every single bit in person...
coming from a guy feeling at home with OOP.

Hehe, I agree, I have to debug decompiled assembly as part of my day job, nothing like 50 gazillion instructions to go through one at a time.  :icon_eek:

deadastronaut

you guys lost me at arduino....

this prog stuff looks like fun, but waaaaaaay over my head... :-\   (the only progamming i ever did was atari (copied from a book to make a screen flash  ::))

what are the actual possibilities and advantages of using these arduino dooby things, especially for audio stuff?..just curious. :)
https://www.youtube.com/user/100roberthenry
https://deadastronaut.wixsite.com/effects

chasm reverb/tremshifter/faze filter/abductor II delay/timestream reverb/dreamtime delay/skinwalker hi gain dist/black triangle OD/ nano drums/space patrol fuzz//

GibsonGM

Quote from: karbomusic on December 17, 2014, 10:07:51 AM
Quote from: GibsonGM on December 17, 2014, 08:04:05 AM
Sounds good...what are you using as a vactrol?  The LED is just an indicator, right?  I've done this with a 555 but with much less satisfying results!

It's in the top-left, the led on the Arduino is just an indicator, I can remove that by using a different pin but wasn't thinking about that at the time I made the video.

Quote
I'm curious....why'd you think it shouldn't work?

Because I don't really know how tremolos work other than "there must be a virtual person turning the volume knob up and down really fast".  :icon_redface: So, from a caveman perspective, I tried to replicate that but really didn't expect it to work due to ignorance. It had clicks at first but I smoothed it and got rid of those by strapping a 10uF across the LED leads.



Awesome, you reverse-engineered a trem based on audio experience rather than electronic :)

I play with the Arduino (Uno) now, just for grins. You can some neat things with them for sure.   Maybe something could be expanded on here, using PWM or something?

Currently, mine is connected to a temp. sensor to flash an ultra-bright LED to wake me when my house gets too cold...reminding me to go stoke up the wood fire!!   There are a lot of uses for them, for interfacing with sensors and more. 

What else can you think up?  >;)
  • SUPPORTER
MXR Dist +, TS9/808, Easyvibe, Big Muff Pi, Blues Breaker, Guv'nor.  MOSFace, MOS Boost,  BJT boosts - LPB-2, buffers, Phuncgnosis, FF, Orange Sunshine & others, Bazz Fuss, Tonemender, Little Gem, Orange Squeezer, Ruby Tuby, filters, octaves, trems...

anotherjim

Ok.
MCU chip in the Arduino has certainly got plenty of audio uses.
Usually, it just gets used for control.

It has a analog to digital converter to read pots.
Digital inputs to read switches
Digital outputs to turn things on & off
PWM outputs to generate control voltages or LFO wave generation/
Serial data port that can be used as a midi interface.

Speeding things up for handling digital audio means some special instructions to change the default rate of the PWM and AtoD.

For handling audio, The AtoD can be pushed to run as high as 76Khz for 8 bit audio (a 1Mhz converter clock and it takes 13 clocks to complete a conversion). Given 12Khz is about as low as you could go for guitar (6Khz bandwidth), that means about 6:1 sweep depth for a modulation type effect. This is not as good a range as a BBD. But it will allow shorter delays than a PT2399.
It's actually a 10 bit converter in the chip, but the lower 2 bits loose accuracy with a converter clock over 200Khz. It's easier to forget them and use 8bit.

Headroom depends on the Aref (analog reference) pin, which can be as high as the chips + supply (usually 5volt, but some Arduino versions are 3.3volt) - so better than a BBD chip. I found if input gets above Vref, the converter locks up and it all has to be powered down to get it back.

The Arduino has several analog input channels, but only one converter. If working it for audio, it's unlikely to be free to read any other channels.

For playback,  PWM out can be used instead of a DAC (basic Arduino has no dedicated DAC).
The chip has a fast PWM mode which can run up to 16Mhz. Using an 8 bit counter, a PWM cycle "sample rate" will be 16Mhz/256=62.5Khz. This runs continually.
The PWM uses an 8bit compare register. The value loaded into this register represents the analog voltage to output. The pulse output from the chip is turned into a smooth DC with a simple r/c low pass filter that you supply (it's not on-board). A value of 0 loaded into the compare register gives 0volt, 255 loaded gives 5volt (if that's the chip supply), 128 loaded  gives 2.5volt (from a 50% pulse width waveform) ....
A value read from the AtoD converter or saved to RAM or written into the program as part of a Data segment, can be loaded directly to the PWM and be heard as well as straight 8bit PCM will allow.

As with a BBD, you would need low pass filtering to remove clock noise and prevent aliasing (unless you want aliasing!). The effective sample rate the filtering need to works for is the rate that the AtoD and PWM are read/updated, not the clocking rate of the converters.

RAM is a bit short in an Arduino, you usually get 2KB, some of which will be used by the program to store variables and keep track of where it's up to. It's probably safe to say 3/4 of this will be free to store samples, but your program can find out when running. Overwriting RAM that the program is using will probably crash it. The Arduino Mega2560 has a huge 8KB!

Program memory is usually more than enough. There's also a little EEPROM memory which doesn't get much use unless to store settings when powered down. It's too slow for sample storage unless it's copied to RAM and run there.

You can add external stuff - memory, converters etc. Normally these will have to use a serial interface. Arduino language supports it.


karbomusic

Quote from: GibsonGM on December 18, 2014, 07:15:07 AM

What else can you think up?  >;)

There is no telling.  :icon_lol:



^70+ sensors and other Arduino parts.

karbomusic

QuoteOk.
MCU chip in the Arduino has certainly got plenty of audio uses.
Usually, it just gets used for control.

That's basically what I surmised. I wanted to exhaust the control use side first. Seems like it could be a lot of fun. It's a $15.00 USD board so this isn't something one would typically replace a $2.00 chip with but for my own pedals, it's a bit of a geek fest. One of those sensors above is a distance sensor which I've previously made work outside of audio, I should mount it facing up and make an invisible wah pedal.  :icon_eek:

anotherjim

#18
Get an Arduino board with a socket for 28pin DIP Mega328 chip. You can then program it as an Arduino, then take the chip out and put it in your own board with a 5volt reg, 16Mhz xtal and a reset. Blank 328's cost about £3 in the uk, but you can also get them with the Arduino bootloader already programmed - I expect there are cheaper supplies.

You can run an Arduino sketch that turns it into a programmer, so you can flash the bootloader into blank chips yourself. It's also possible to run sketches in smaller (cheaper) chips.
http://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CCwQFjAB&url=http%3A%2F%2Fhighlowtech.org%2F%3Fp%3D1695&ei=mPuSVOGEK-yv7Aafm4DoDg&usg=AFQjCNGY28axK_4LEK6jn9zwGtncOygvyQ&bvm=bv.82001339,d.ZGU&cad=rja

If the program would work just as well with the chip clock lower at 8Mhz, and isn't time accuracy critical, you can set the chip to run on an internal 8Mhz r/c oscillator. The Tiny85 can run at 16Mhz on the internal.

Quote from: karbomusic on December 18, 2014, 10:31:05 AM

That's basically what I surmised. I wanted to exhaust the control use side first. Seems like it could be a lot of fun. It's a $15.00 USD board so this isn't something one would typically replace a $2.00 chip with but for my own pedals, it's a bit of a geek fest. One of those sensors above is a distance sensor which I've previously made work outside of audio, I should mount it facing up and make an invisible wah pedal.  :icon_eek:

You put that under a trampoline and do a Nils Lofgren wah solo...
https://www.youtube.com/watch?feature=player_detailpage&v=su959eEFnnA


karbomusic

All great info, thanks Jim. I saw a fellow last night who did the same thing (328 + digital switches + digital pots) and inserted it into a guitar to dynamically change the pickups, their phase and a bunch of other stuff...

http://oprahsfavoritedeathmetal.blogspot.com/2014/09/anubis-guitar-preamp.html