Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem about 4051 analog switches

Status
Not open for further replies.

metalzse

Newbie level 2
Joined
May 11, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
Hello everyone,

At first, I apologize for my poor English.

I am working with a project, which making an DIY E-Drum Midi-Trigger.

The E-drum pad make a 0~5V pulse signal, when it is hit.
The Signal depend on how hard is it hit.
I use a MCU at89s51, ADC0804, and HCF4051 for a scan-input circuit.


As a test-circuit, I connect the circuit as the fallowing picture
I drew only the part of 8051 and 4051.


At first, I use only 2 Inputs, for a Snare and a Bass drum (Kick).
I use the pin13 as a Snare input and pin14 as a Kick input.
and give the Snare input a sustained 3V signal. For Kick 0V



Here is the part of Code about Scan-input
----------------------------------------------------------
while(1)
{
P0_0 = 0; // pick 4051-pin13 as input
P0_1 = 0;
P0_2 = 0;

ADC(); // ADC convert and read value

Snare_value = ADC_value; // write value to Snare

if(Snare_value > 5) // If there is value in snare, send snare midi siganl
{
Midi_Out_Conv(Snare,Snare_value,0,0,0,0); // send a snare MIDI signal to computer
}

Snare_value = 0; // after send, clear Snare value
ADC_value = 0; // after send, clear AD value.


P0_0 = 1; // pick 4051-pin14 as input
P0_1 = 0;
P0_2 = 0;

ADC(); // ADC convert and read value

Kick_value = ADC_value; // write value to Kick

if(Kick_value > 5) // If there is value in Kick, send Kick midi siganl
{
Midi_Out_Conv(Kick,Kick_value,0,0,0,0); // send a Kick MIDI signal to computer
}

Kick_value = 0; // after send, clear Kick value
ADC_value = 0; // after send, clear AD value.
}
----------------------------------------------------------------------------

In this case, I should get only the Midi signal of Snare
Because the AD Value for Kick should be always 0.

The problem is, that I received both of Kick and Snare signal in my computer. And in a unregular tempo.
Just like this.

The X axis is Time in second.

I am confused from this problem for some weeks.

I hope that, you guys can understand my problem.
What is wrong with this circuit.


Thanks a lot.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,178
Helped
14,199
Reputation
28,657
Reaction score
12,888
Trophy points
1,393
Location
Bochum, Germany
Activity points
279,134
The ADC output code may be above 5 even with zero input voltage, due to noise and offset voltage. You should check the ADC codes obtaines with your circuit before defining the threshold. Apart from this point, I don't know what the ADC() function is doing exactly.
 

metalzse

Newbie level 2
Joined
May 11, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
The ADC output code may be above 5 even with zero input voltage, due to noise and offset voltage. You should check the ADC codes obtaines with your circuit before defining the threshold. Apart from this point, I don't know what the ADC() function is doing exactly.

Vielen Dank FvM,

here is the Code of ADC().
it converts analog voltage and divides 2.
Because the Midi output value is between 0 and 127.
------------------------------------------
void ADC(void)
{
ADC_Convert();
ADC_Read();
}

void ADC_Convert(void)
{
ADC_CS = 0;
ADC_WR = 0;

ADC_WR = 1;
ADC_CS = 1;
Delay_50us(3);
}

void ADC_Read(void)
{
ADC_CS = 0;
ADC_RD = 0;

ADC_Value = P2;
ADC_Value = ADC_Value / 2;

ADC_RD = 1;
ADC_CS = 1;
}
--------------------------------------------------

And i don't think,that the problem is due to the noise or offset voltage during AD convert.
The output program of Midi signal, "Midi_Out_Conv(Snare,Snare_value,0,0,0,0)", outputs not only the type(Snare or Kick) also the level.

If the noise or offset voltage is the reason of wrong signal, the Kick signal should be smal.
But the level of Midi output of Snare and Kick,which I received in computer, is the same.

So....I think there is another faults.

Trotzdem danke ich dir für deine Hilfe.
Schönen Tag noch.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top