Sound sensor DB and DBA

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc

Moderators: roger, 99jonathan, imaqine

Sound sensor DB and DBA

Postby ruperty » Sun May 29, 2011 1:07 pm

The mindstorms site says that the sound sensor measures DB and DBA, but when I read both types I get exactly the same value. Is this as expected ?

I am using the SoundSensor class in pc api and setting setDBA to true and false.

Rupert
Regards,
Rupert
ruperty
Novice
 
Posts: 31
Joined: Sun Oct 14, 2007 11:21 am

Re: Sound sensor DB and DBA

Postby gloomyandy » Sun May 29, 2011 1:48 pm

Hi,
What sort of test are you using to check the output of the sensor, are you using a constant volume as the test signal? Can you try the same test on the NXT (rather than with the PC API), which firmware are you using? What version of leJOS? It looks to me like the NXT code should be setting the hardware mode correctly...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3012
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Sound sensor DB and DBA

Postby ruperty » Sun May 29, 2011 2:04 pm

Here's my test code, and output. I am not using any test signal; background noise. In the last section the values are all high and about same for DB and DBA. What am I doing wrong? I am on version leJOS NXJ 0.85 beta, with lejos firmware.


Code: Select all
       
                SensorPort sp = SensorPort.S3;
                SoundSensor sound = new SoundSensor(sp, true);
                int db = 0,
                 dba = 0;
                sound.setDBA(false);
                for (int i = 0; i < 20; i++) {
                    db = sound.readValue();
                    System.out.println(System.currentTimeMillis() + " DB " + db);
                }
                sound.setDBA(true);
                for (int i = 0; i < 20; i++) {
                    dba = sound.readValue();
                    System.out.println(System.currentTimeMillis() + " DBA " + dba);
                }
                for (int i = 0; i < 20; i++) {
                    sound.setDBA(false);
                    db = sound.readValue();
                    sound.setDBA(true);
                    dba = sound.readValue();
                    System.out.println(System.currentTimeMillis() + " DB " + db + " DBA " + dba);
                }



1306677386293 DB 93
1306677386322 DB 87
1306677386353 DB 91
1306677386428 DB 81
1306677386503 DB 23
1306677386572 DB 8
1306677386649 DB 4
1306677386718 DB 4
1306677386764 DB 5
1306677386816 DB 4
1306677386870 DB 4
1306677386922 DB 4
1306677386950 DB 3
1306677386996 DB 3
1306677387072 DB 3
1306677387139 DB 4
1306677387215 DB 4
1306677387293 DB 4
1306677387342 DB 4
1306677387392 DB 4
1306677387483 DBA 79
1306677387533 DBA 89
1306677387563 DBA 84
1306677387617 DBA 48
1306677387697 DBA 14
1306677387763 DBA 6
1306677387835 DBA 4
1306677387905 DBA 3
1306677387974 DBA 3
1306677388027 DBA 3
1306677388058 DBA 3
1306677388108 DBA 3
1306677388138 DBA 3
1306677388168 DBA 3
1306677388199 DBA 3
1306677388252 DBA 3
1306677388283 DBA 3
1306677388374 DBA 3
1306677388447 DBA 3
1306677388518 DBA 3
1306677388759 DB 91 DBA 91
1306677389039 DB 89 DBA 92
1306677389313 DB 91 DBA 89
1306677389525 DB 91 DBA 91
1306677389845 DB 92 DBA 91
1306677390034 DB 91 DBA 90
1306677390274 DB 87 DBA 91
1306677390549 DB 91 DBA 93
1306677390759 DB 93 DBA 90
1306677391040 DB 85 DBA 93
1306677391279 DB 92 DBA 92
1306677391475 DB 89 DBA 92
1306677391770 DB 89 DBA 93
1306677391984 DB 89 DBA 91
1306677392245 DB 88 DBA 93
1306677392505 DB 92 DBA 93
1306677392725 DB 87 DBA 92
1306677393053 DB 92 DBA 87
1306677393240 DB 90 DBA 89
1306677393473 DB 90 DBA 92
Regards,
Rupert
ruperty
Novice
 
Posts: 31
Joined: Sun Oct 14, 2007 11:21 am

Re: Sound sensor DB and DBA

Postby gloomyandy » Sun May 29, 2011 3:16 pm

I don't think you can switch between the modes quickly like that and expect to see any difference in the sensor readings. Remember that this is an analogue sensor and these are only sampled every 3ms or so (so for 3ms after you change mode you may be seeing the previous reading), also remember that the actual electronics will take some time to adjust when the mode is changed...

Looking at the output from your tests and assuming that the noise level was constant throughout it seems that when you change the mode the sensor will produce a high reading for a while before it settles. This would explain the high readings going to low for the first two sets of outputs and the constantly high reading when you keep switching the mode...

So what is it that you are actually trying to do? Why do you need to switch modes likes this?

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3012
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Sound sensor DB and DBA

Postby ruperty » Sun May 29, 2011 3:42 pm

Well, I was thinking of controlling the NXT speed and turning by sounds volume and frequency, respectively, e.g. from a musical instrument.

Though re-reading it is not actually frequency that is provided by DBA, but volume in a frequency range.

Are there more sophisticated sound sensors available that provide frequency/pitch as well as loudness?
Regards,
Rupert
ruperty
Novice
 
Posts: 31
Joined: Sun Oct 14, 2007 11:21 am

Re: Sound sensor DB and DBA

Postby gloomyandy » Sun May 29, 2011 3:47 pm

Hi,
I don't know of any sensor for the NXT that will do that, the actual sensing would have to be done in the sensor (frequency analysis etc.) as the sample rate either analogue or i2c is simply too low to allow the NXT to do any of that... You might be able to build your own using a microcontroller, or possibly hook the mike up to the PC (since you seem to be using the PC anyway), and get the input there...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3012
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff