[solved] Encoder problem and other "scratch box" issues

Hi everyone,

I am trying to build rasteris scratch controller(http://www.midibox.org/forum/index.php/topic,11167.0.html) (I’m amazed by it, respect!) I’m using the first c code he posted (can’t use the other new one because of my PIC18F452). I’m almost done and

I just build my encoder with a dual IR photodiode and an IR LED but the only MIDI output (after the one upload request in the beginning that shows that my PIC is up and running) I get is

“CC Bank Select Value: 64”

"CC Bank Select Value: 0 " 

“CC Bank Select Value: 64”

"CC Bank Select Value: 0 "

…when I let the encoder wheel (the one rasteri has avaliable to download in his thread) spin through my encoder.

So in Traktor I can only spin in one direction.

I guess its a problem with the quadrature but I don’t know what possibly could be wrong with my encoder, I took a picture of it maybe it can help to find the problem.

http://foto.arcor-online.net/palb/alben/45/749645/1280_6331653336346461.jpg

Here is the link to rasteris wiki to show how my module is build: http://www.midibox.org/dokuwiki/scratchcontroller

I attached the code I am using right now too(thanks for sharing all this rasteri!). I hope this is all the information you guys need.

Thanks for your time,

Simon

[main.c](< base_url >/applications/core/interface/file/attachment.php?id=4284)

Bank select is the crossfader. Are you sure you have the photodiodes in pins 3 and 4?

You had better ground pin2 as well, that could be causing it.

You were right, I connected pin 2 to ground and the Bank Select disappears. Now I don’t get any midi signal. I thought about it and I forgot to ask if the encoder even sends a signal without a crossfader? Because I don’t have one connected right now  ::slight_smile:

Hi everyone,

All right so I tested a little bit more and I noticed that the voltage at both pins (3 & 4) from 0V when its “off”(the IR LED is covered) only goes up to 0.02V when its “on”. Is that even enough for the PIC to notice a change and send data? I accedently connected the 5V in of the photodiode with one of the out pins and I got midi signals like:

"CC Modulation Wheel value: 63

CC Modulation Wheel value: 64

CC Modulation Wheel value: 65

…"

I don’t get these just with the encoder wheel though (maybe the low voltage difference from on and off?).

Thanks, Simon

The voltage should go up a lot more than that, in my case low is 1.5v and high is 4v.

I don’t really know what the problem could be. Try it in a bunch of different test circuits and stuff - e.g. maybe it wants ground instead of 5v at its common pin (i.e. stick it in the bottom half of the voltage divider), maybe it wants a different resistor value, etc. It’s weird though, it looks IDENTICAL to the one I’m using…

EDIT: Also check the LED is working and wired up properly

The LED is working, I checked it with my digicam. I think the photodoide is not compatible with the 10k resistors, I don’t have a clue though which other value I could take. ::slight_smile:

Try it with some other value resistors in a circuit on its own - 500, 1k, 50k, 100k, etc. Try connecting it the other way round (with the common pin to ground and the resistors going to +5v). Or try another photodiode (if you’re anything like me you have dozens of old mice lying around).

Just try stuff! That’s what I did :stuck_out_tongue:

I just built a fairly lofi version - printed out 12cm diameter gap thingie (180 evenly spaced gaps), put that between two CDs (removed the metal coating first ;)) and used it with an LED and ptohodiode from an old logitech mouse. Works like a charm. Since I don’t have any hardware lying around that I could use to build it into a box, I just stuck the screw that’s holding the CDs into a drill :slight_smile: Now I can fast forward songs. I can only get the “old” version without the touch sensor to work though. The new one (the Pins 4+5 version) doesn’t output anything. I’ll have to find out why - this is really fun without it though, too ;D

I dunno why the new version isn’t working, maybe the voltage reference is not suitable for your photodiodes?

Grab the newest (0.025) version of the code, it lets you adjust the voltage reference at the top of the source (COMPARATOR_THRESHOLD). Maybe try setting it to 0x07?

If you just can’t get pins 4/5 working at all, the new version also lets you revert to the old ADC behaviour (i.e. using pins 3/4) but still use the touch sensor. Uncomment the line that says #define USE_ADC_ENCODER. (you can also change the threshold for that should you so desire)

Check the other thread http://www.midibox.org/forum/index.php/topic,11167.msg97390.html#msg97390 for the new code

I dunno why the new version isn’t working, maybe the voltage reference is not suitable for your photodiodes?

IIRC we looked at it in channel and I had him test the voltages and that’s exactly what it was.

stryd_one is partially correct. I used the mouse wheel in the first version and the voltags were in a 0.7…3.2V range. With the printed out wheel I get 0.7V and 4.2V so I guess that’s not the problem. I’ll try the new code and let you know what the results are! Thanks rasteri this thing is fun ;D

0.7…3.2V range. With the printed out wheel I get 0.7V and 4.2V

Threshold’s been 0.75V so far, so you’re only *just* going below that, assuming your multimeter is very accurate (bad assumption ehehe)

Actually it’s 0.75 * 5v, the comments in the code are misleading.

Heheh just a bit different :wink: I guess I shoulda read the datasheet!

Well the old voltages were too low to cross your high threshold, but it should be OK now ?

By the way, my problem was solved with taking a new photodiode today. It already works with the little encoder wheel in the mouse but I didn’t get it to work with the printed encoder wheel. I guess its not printed dark enough or something.

Thanks guys,

Simon

I was afraid mine wouldn’t be dark enough, so I printed the whole thing twice :slight_smile: That way I can layer them and get it to be darker and by rotating the discs against each other I can also change the gap width.

The problem with mine was that the gabs where not wide enough so I scratched them a little wider, it works now but I’ll try to print it again with  bigger gabs.

Since there wasn’t a pdf or anything I just did some math, which seems to have been sorta correct. Rasteri used a disv about the size of a CD I think so the diameter was ~12cm, and he mentioned a number of gaps. So I calculated the width of his gaps from that info, and made my gaps the same width. That way I would have needed ~173 gaps. So I upped that to 180 to make it easier to draw - done. The gaps are evenly spaced (black bars are the same width as the transparent ones) which seems to work nicely.

I used the pdf rasteri had in his thread. Which programm did you use to draw it ?

There’s a double-res encoder wheel here : http://www.midibox.org/forum/index.php/topic,11167.msg97570.html#msg97570

Inkscape is great for drawing this stuff.

I have a bunch more wheels of different sizes + resolutions, just went to a print shop one day and printed out loads. I really need to make a website to hold all these files and stuff. Or get wiki upload access…