Jump to content

AIN Sensibility when multiplexed ...


gabz
 Share

Recommended Posts

Hello, I want to use  a distance sensor as a potentiometer into the AIN

(it is a sharp GP2d120)

It works well when I use a Single potentiometer program (AIN exemple 1) without the AIN module,with the distance sensor directly on the core

But when i Use The multiplexed AIN module with the 32 potentiometers programm, the AIn becomes very sensible to perturbation and when I Supplie my distance sensor with the +5 and 0 of the AIN module, i Sends a lot of midi event, even if i have not plugged in the out of the distance sensor into a multiplexer ...

I don't know what to do, why is the multiplexed more sensible ??? I tried to put capacitors bypass and all it doesn't change anything ...

For exemple, when i load the single potentiometer program, the PIN is not really sensible to perturbations (I can let the entry PIN in the air without having midi random events) but with the 64 potentiometers, I must ground all unused pins ...

WHy ????????

thanks

Link to comment
Share on other sites

This has to do with my sensor

I use ALL the Inputs of my AIN module (32) and the other pins of the J5 are grounded

Before I supply my sensor, all is good, when i supply it, all go shitty ...

I know you can't help me on this, I just would like to know Why when the AIN is not multiplexed it is less sensible to perturbations, maybe I can disable some options to get the same sensibility as when it is in single pot mode ...

You should test : Load the first of the first program exemple (in the download page) AIN exemple 1 : single pot

Do not ground the first PIN, link nothing to it, you 'll see it does not send random events

thanks for the response !

Link to comment
Share on other sites

I didn't find anything in the datasheet about the impedance : http://info.hobbyengineering.com/specs/gp2d120.pdf

I'll try to mesure it at work ...

But, I don't think this is an impedance problem because I tried to solder the sensor directly on the Core with the single pot program, and it worked well ... Or maybe the impedance problem is linked to the multiplexing program ?

When in multiplexed mode, I don't even need to solder the output of the sensor to send random events, just by supplying the sensor (without connecting its output!) with +5 - 0V does perturb the other potentiometers and sends already bad midi events ... So the alimentation is perturbed by the sensor, but only when in multiplexed mode ... strange !!?

Thanks for all the help

Link to comment
Share on other sites

It is an impedance problem, because the 4051 multiplexers have a resistance which need to be added to the impedance of the sensor itself. It's not a software problem!

Maybe a small amplifier helps to improve the output signal

Best Regards, Thorsten.

Link to comment
Share on other sites

Yes I think also this is the fault of the 4051's but, Where to place the resistance and how to determine it ?

I'll test with an operational amplifier, but it's not just the output impedance of the sensor, it's his whole resistance, because when I supply the sensor with VSS et VD it goes shitty (without soldering the output of the sensor to the 4051 !)

So where do you think i should place a resistance ? at the output ? As a Pull up on the supply ?

I'll ask all this to my teachers maybe they 'll have some ideas ...

Thanks a lot TK  8)

Link to comment
Share on other sites

So where do you think i should place a resistance ?

The goal should be to have a low resistance (impedance when we are talking about R/C/L) - than higher the impedance, than higher the jitter. This means, that an additional resistor will worsen the results.

I would suggest to search in the web for this topic, it cannot be explained so easy (maybe somebody else knows some good links?)

Best Regards, Thorsten.

Link to comment
Share on other sites

While the imendance thing might add a bit to your problem, the main issue is probably about the supply voltages:

I tried the GP sensors for a new version of my "Midibox Sofa", connected the sensors directly to J5. I noticed that with one sensor this works quite well, but the more sensors were connected the more unstable the readings get. So I searched for the reason. The data sheet from your link is a compact version, on the Sharp website there´s also a more extensive one that suggests putting an electrolytic cap of around 1000uF directly across the supply pins of the sensor.

The GP apparently draws supply current in short bursts every time it sends out a IR light burst. The "average current" is around 50 mA, that means these bursts probably go up much further. They can either stray in on the data lines of the AIN->Core connections or make the supply voltage of the whole system unstable. The capacitor is kind of a "local"power supply that can provide the current for the short bursts. Higher frequency interference on the power line can be suppressed if you add a normal bypass cap to the electrolytic one, e.g. 100nF or 1uF ceramic.

If the readings are still not stable enough, there are also notes on the net that suggest adding another capacitor that acts as a low pass filter: If you put a ceramic cap between the value output and ground that smoothens out very fast changes. Remember a capacitor is non-conductive for DC voltage and gets more conductive the highter the frequency gets. The lower the cap value, the higher the suppressed frequency gets. So you can experiment with different values there to find a value that makes the output stable enough for your application without making values change too slow.

Hope this helps :)

Seppoman

BTW: I found the GP sensor is a bit slow for musical applications - the measurement takes about 50ms, and that is in fact a really high latency if you e.g. control a pitch value with it. So at the moment I´m developing an ultrasonic range finder solution (AVR based). For short distances one measurement takes no longer than 1-2 ms, so even if you do 5 measurements and do a median filtering over them to smoothen out the values, the latency is still 5 times better than with the Sharp sensors.

Link to comment
Share on other sites

I tried the GP sensors for a new version of my "Midibox Sofa", connected the sensors directly to J5. I noticed that with one sensor this works quite well

exactly the same for me. I didnt try with more sensor (I just need one or Two) but when muxed ... you know my problem

The GP apparently draws supply current in short bursts every time it sends out a IR light burst. The "average current" is around 50 mA, that means these bursts probably go up much further. They can either stray in on the data lines of the AIN->Core connections or make the supply voltage of the whole system unstable. The capacitor is kind of a "local"power supply that can provide the current for the short bursts. Higher frequency interference on the power line can be suppressed if you add a normal bypass cap to the electrolytic one, e.g. 100nF or 1uF ceramic.

very very interesting !!

I looked the supply voltage with an oscilloscope once I have supplied the sensor, the supply voltage has little peaks periodicaly, surely the "bursts" you are talking about

It the same when powering a big amplifier with subwoofer from a 12V battery ...

I'll try this tonight

If the readings are still not stable enough, there are also notes on the net that suggest adding another capacitor that acts as a low pass filter: If you put a ceramic cap between the value output and ground that smoothens out very fast changes. Remember a capacitor is non-conductive for DC voltage and gets more conductive the highter the frequency gets. The lower the cap value, the higher the suppressed frequency gets. So you can experiment with different values there to find a value that makes the output stable enough for your application without making values change too slow.

I tried to make a Low pass filter at the output some days ago, but it doesn't change anything because the supply tension is shitty ...

As you say, this solution is to use only when you've fixed the supply problem

BTW: I found the GP sensor is a bit slow for musical applications - the measurement takes about 50ms, and that is in fact a really high latency if you e.g. control a pitch value with it. So at the moment I´m developing an ultrasonic range finder solution (AVR based). For short distances one measurement takes no longer than 1-2 ms, so even if you do 5 measurements and do a median filtering over them to smoothen out the values, the latency is still 5 times better than with the Sharp sensors.

When i tried the GP on the G5 it was fast enough

What GP do you use ? I'm using the GP2D120, the short distance

The ultrasonic solution is better (my teacher use one) but it's a bit expensive ...

I'll let you know my tests

The goal should be to have a low resistance (impedance when we are talking about R/C/L) - than higher the impedance, than higher the jitter. This means, that an additional resistor will worsen the results.

I would suggest to search in the web for this topic, it cannot be explained so easy (maybe somebody else knows some good links?)

I know what's an impedance and a resistance but why as it to be low ? And from what point of view ? I mean the low resistance is to be viewed between the 4051 input and sensor output or between the 4051 input and the sensor supply ?

I remember of a circuit that simulate a low resistance ... I'll to find it

thanks for all the help  :D ;)

Link to comment
Share on other sites

I tried a 100µF capacitor on the supply, it seems to send less random events !! I think i'm on the good way, tomorrow i'll get a big big capacitor to fix this ...

An other question on the GP2 is this :

Its maximum voltage (for a minimum distance) is 3.5 - 4V

I thought of putting a little Operational Amplifier, but Can I just program (in MUXED mode !) a special PIN of the 4051 to send a 127 value on only 4V (and not 5!) ??

thanks

PS : sorry if itt's not really understandable, I must work a bit my english

Link to comment
Share on other sites

I thought of putting a little Operational Amplifier, but Can I just program (in MUXED mode !) a special PIN of the 4051 to send a 127 value on only 4V (and not 5!) ??

only by programming a scaling routine into the application...

Best Regards, Thorsten.

Link to comment
Share on other sites

When i tried the GP on the G5 it was fast enough

What GP do you use ? I'm using the GP2D120, the short distance

The ultrasonic solution is better (my teacher use one) but it's a bit expensive ...

"Fast enough" depends on what you want to control with it - not on the power of your computer ;) All Sharp sensors have around 50 ms latency, just look at the timing diagram. I also used the short distance version.

Ultrasonic is not necessarily better. I searched for different ready-made solutions quite a long time. The problem is that all affordable ultrasonic range finders are targeted at the DIY robotics market, so they want to achive a maximum sensor range. Usual types have about 4-5 m max. distance, so with the speed of sound you can easily calculate they´ll have to wait quite a long time whether there´s a far away echo coming. Normally they also do multiple measurements to get better readings before putting out a value. In (hobby) robotics, latency is not really important. Typical robots don´t move fast enough that it would make a difference if they detect an obstacle 50 ms earlier or later. There are ultrasonic (or laser-based) distance sensors with good timing in the industry automation market, but I really didn´t want to sell my car to buy six of them for the sofa ;)

But back to your problem:

getting good values from the GP has different problems - the output curve is (kind of) negative logarithmic, starts at around 3V and goes only down to around 0.4V. A major problem is that in the second half of measurable distance, the curve is so flat that you´d need a really good analog and A/D cirquit design to still get a good resolution. I took the pure software approach to get usable values:

1. Look at the data sheet figure - a minimum distance of about 4 cm gives 2.5V output. The sensor can only measure down to 3 cm, so I sacrificed this one cm to get an easy solution. The PIC does 10 bit conversion. 2.5V is half of the maximum value (5V), so I just stripped the highest bit - a 9-bit value remains.

2. Especially with the jitter problems of the GP, the lowest bit is only meaningless crap anyway, so just right-shift the 9-bit value one bit. Now we´ve got an 8 bit value that still contains (most of) the relevant information, but is way easier to deal with.

3. Now comes the tricky part. You need to linearize this distance information. There is some division involved, but divisions consume a lot of processor time on a microcontroller, so the best way is to calculate the result for all possible values and use a lookup table. If the precision has to be really good, you can afterwards setup a measuring experiment, e.g. a ruler lying on the floor in front of a wall. So you can move the GP above the ruler and compare the output value with the real distance and make some corrections to your table.

The programming part was not too hard in my case because the GPs were the only analog controllers. So you can just jump in at the point where MB64 acquires the A/D values and change everything to your needs. If you want to have both GPs and "normal" potentiometers/faders in one box, it gets a bit complicated...

Seppoman

Link to comment
Share on other sites

Hello, I just tried the Capacitor solution (I used a 2220µF capacitor) and it works well well well for the disturbance

Obviously, I used It In muxed mode on the 4051 entries !

It's quite unstable so it always sends midi events, As you said maybe I should use A low pass filter, I tried just one low pass with what I had as resistor and capacitor (without calculing any frenquency cut ...) and, as you will guess, the reactivity of the GP's was a lot more slowed ...

I think this is because of the too low frequency cut of my bad low pass filter, but I don't really think I need one , I explain my  solution :

A choosed The same 4051 entry for A potentiometer AND the GP, and I can switch to each one with a switch ... so when I want to use the GP, I switch to it, and I barely use only It and maybe one other potentiometer (I looked In midi studio, the messages of the potentiometer still arrive thought the GP send continuous data)

And when I don't use the GP, I switch to the potentiometer, so It is more stable ...

I'll try some better value of Frequency cut, but I certify that for What I use the GP (Guitar Effects) the rapidity is really enought (without the low pass filter)

I also thought of ultra sonic sensors, but I wondered if it could be perturbed with sounds (ultra) in a concert or by the environment ??

Now I've got to go through this part :

But back to your problem:

getting good values from the GP has different problems - the output curve is (kind of) negative logarithmic, starts at around 3V and goes only down to around 0.4V. A major problem is that in the second half of measurable distance, the curve is so flat that you´d need a really good analog and A/D cirquit design to still get a good resolution. I took the pure software approach to get usable values:

1. Look at the data sheet figure - a minimum distance of about 4 cm gives 2.5V output. The sensor can only measure down to 3 cm, so I sacrificed this one cm to get an easy solution. The PIC does 10 bit conversion. 2.5V is half of the maximum value (5V), so I just stripped the highest bit - a 9-bit value remains.

2. Especially with the jitter problems of the GP, the lowest bit is only meaningless crap anyway, so just right-shift the 9-bit value one bit. Now we´ve got an 8 bit value that still contains (most of) the relevant information, but is way easier to deal with.

3. Now comes the tricky part. You need to linearize this distance information. There is some division involved, but divisions consume a lot of processor time on a microcontroller, so the best way is to calculate the result for all possible values and use a lookup table. If the precision has to be really good, you can afterwards setup a measuring experiment, e.g. a ruler lying on the floor in front of a wall. So you can move the GP above the ruler and compare the output value with the real distance and make some corrections to your table.

The programming part was not too hard in my case because the GPs were the only analog controllers. So you can just jump in at the point where MB64 acquires the A/D values and change everything to your needs. If you want to have both GPs and "normal" potentiometers/faders in one box, it gets a bit complicated...

thanks a lot for the advices !!

Unfortunately, I'm using It with other potentiometers of the AIN module ... I know a little bit of programming, but I don't know what's a scaling routine ... can somebody Help me on this topic ? Has it got to be modified in the MIOS or in the Midi box program ?

I don't really need to linearize the caracteristic, It's some part of the musical instrument, I can adapt myself to the instrument, but what i really need is the first and second steps you describe, a better resolution of the upper values ...

I don't have got the time to do all this work by now, I will be able to do all this only this summer ... unless I doesn't need too much time ?

Thanks for all I hope it'll help futur people using GP's

Link to comment
Share on other sites

It's quite unstable so it always sends midi events, As you said maybe I should use A low pass filter, I tried just one low pass with what I had as resistor and capacitor (without calculing any frenquency cut ...) and, as you will guess, the reactivity of the GP's was a lot more slowed ...

It´s probably better to leave out the resistor because of the high impedance issue Thorsten pointed out. Impedance consists of "real" resistance and a complex reactance, so adding a resistor in series also makes the total impedance higher. The parallel capacitor acts as kind of a lowpass filter on its own, just don´t use too large values and it will smoothen the output without making things too slow.

A choosed The same 4051 entry for A potentiometer AND the GP, and I can switch to each one with a switch ... so when I want to use the GP, I switch to it, and I barely use only It and maybe one other potentiometer (I looked In midi studio, the messages of the potentiometer still arrive thought the GP send continuous data)

And when I don't use the GP, I switch to the potentiometer, so It is more stable ...

Just don´t expect the potentiometer to react linear and in the same value range, because you´ll have to have this AIN pin adjusted to the GP behaviour. Another solution to lock the value would be to build a simple voltage divider from two resistors to set the value e.g. to 2.5 V.

I also thought of ultra sonic sensors, but I wondered if it could be perturbed with sounds (ultra) in a concert or by the environment ??

Normally there shouldn´t be ultrasonic sounds in the air. Usual us. receivers work at 40 kHz and have a quite narrow band they can pick up. At 40 kHz, most microphones don´t pick up very much, and even a playback from a 96k sound card doesn´t contain 40 kHz signals. The generated 40kHz pulses from the transmitter are quite loud (can go up to 120dB), so the receiver sensitivity doesn´t need to be very high if you only want to measure short distances.

Unfortunately, I'm using It with other potentiometers of the AIN module ... I know a little bit of programming, but I don't know what's a scaling routine ... can somebody Help me on this topic ? Has it got to be modified in the MIOS or in the Midi box program ?

I don't really need to linearize the caracteristic, It's some part of the musical instrument, I can adapt myself to the instrument, but what i really need is the first and second steps you describe, a better resolution of the upper values ...

Scaling just means the routine gets in some values and calculates or looks up some corresponding other value. If you want full 0..127 output from the GP, this is neccessary anyway (because of the GP not going down to 0V). So it doesn´t make much difference if you convert the 255..40 value range (after the first two steps) to 0..127 with or without linearizing the curve. It´s just another conversion table.

The conversion has to be done in the application - MIOS is just used to get the raw 10bit A/D values.

Although the GPs were not suitable for the sofa, I´m still interested to make use of them in a normal MB configuration, so I´ll probably try to write a "driver" for them. So if you get stuck and it´s not too urgent for you, just wait :) It could take several weeks although.

Seppoman

Link to comment
Share on other sites

Regarding the scaling routine: Goule made some experiments with it using C - it's mostly easier to program this in C first, because modifications can be made faster. Once the perfect algorithm has been found, we can help you to port this to assembler in order to allow an integration into MB64

-> http://www.midibox.org/forum/index.php?topic=5270.0

Best Regards, Thorsten.

Link to comment
Share on other sites

Although the GPs were not suitable for the sofa, I´m still interested to make use of them in a normal MB configuration, so I´ll probably try to write a "driver" for them. So if you get stuck and it´s not too urgent for you, just wait Smiley It could take several weeks although.

It's absoluetly not urgent  ;D

I thought of just amplifing the output with a TL081 ... Do you think it would work ? (I doesn't really matters of the curve is not really linear)

thanks

Link to comment
Share on other sites

Hello Gabz,

I suggest you take a look at the thread I wrote on GP2D120 Thorsten pointed out. I think you will find useful information as I posted the C code for gating the flickering from the Sharp sensor (and you also have the scaling instructions if I remember well).

I'm very interrested in this GP thingy : until last week I was just using analog inputs of the core and now I've just added an AINx4, so I think with your electronic knowledge and my software abilities, we could find the ultimate solution for making this baby work for midibox  ;D what do you think ?  8)

> Hello, I just tried the Capacitor solution (I used a 2220µF capacitor) and it works well well well for the disturbance

Wow, I have to try that !!! How exactly do you connect it ? Between analog out of GP and 4051 input ?

By chance : are you french ??  ::) (I am)

Goule

Link to comment
Share on other sites

I am french  8)

but lets keep talking english in this topic

for the capacitor it's really easy : you just have to put It between the +5V and the 0V that you will use to supply The GP

sinon chui ok pour bosser sur une adaptation du GP, lundi je teste l'ampli OP

Ce qu'il faudra savoir pour ta partie programmation : si mon ampli marche, le GP sortira donc une tension max de 5V et une minimum de je sais plus trop combien mais c'est pas 0 quoi. Je peux aussi essayer de décaller la caractéristique pour que ca fasse 0, et la t'aura plus qu'a "linéariser" le truc. CA permetra de mettre aussi un potentiomettre sur la meme pate quand on veut pas laisser le GP

In english : I'll amplify the maximum output of the GP to 5V, but I remember that the minimum value is not 0V, so I will put a little negative offset so it goes to 0V ... do you think it can work ?

thanks for all the participation ! I'll post my circuits

Link to comment
Share on other sites

I'm okay for keeping english language for a while  ;D to have anybody here understand our plans  ;)

The only problem I still have to deal with is flickering because for linearizing & scaling (0-5v) my algorythm already does this quite correctly 8)

The thing is : I'd really like to avoid switching the GP manually on and off so that it's always active. The current version of my "gate" (see the thread) works well but I still havn't tried on an AINx4, it's still connected directly to the core. I will post the entire C code if you want it.

By the way the AOP solution might allow us to perhaps have a better resolution ... tell me as soon as you have results.

I let you my phone number in case you want to get in touch (and speak French  ;D) : 06 16 95 78 08 (olivier)

Goule

http://aerodrink.free.fr

Link to comment
Share on other sites

for the flickering problem as suggested to reduce the resolution to 9bits (I don't know how to do this)

But i'll try the low pass solution, it should be easy, I just hope it will not slow too much the response

I sent you a private message

Link to comment
Share on other sites

Hi,

just wanted to drop in a few comments:

I'm using two GPs with absolutely no problems. I'm using a pure software based filter/amount reducer/gate/scaler combination also posted in the thread goule mentioned without reducing the overall resolution:

http://www.midibox.org/forum/index.php?topic=5270.15

I have to mention, that there's a lot more jittering if there's any other sensor not properly connected; so if you have more than the GPs connected, I'd check also the other AINs. In my case I had some linear soft pots and I've went through signal hell before I realized I have to add another tiny resitor here and there... if there's something wrong on line #2, it might easily disturb lines #1 and #3 (my experice, don't know why...)

I cannot recommend linearizing: it really reduces the resolution of the sensor dramatically. While on the other hand, I can really live with the response time... Waving your hands in the air isn't that precise anyway, for weeping some sounds away it's perfect!

:)

regards,

Michael

Link to comment
Share on other sites

I cannot recommend linearizing: it really reduces the resolution of the sensor dramatically. While on the other hand, I can really live with the response time... Waving your hands in the air isn't that precise anyway, for weeping some sounds away it's perfect!

Smiley

I agree with you, but why linearizing reduce resolution ??  ???

I don't really understand what you are doing with "tiny resistors" ? Where do you place them and for what ?

Do you use a AIN module or do you directly solder on the Core ?

thanks !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...