Audio sensor problems

Oh, and yes, I did a DI update in addition to the GoBox update we’d done earlier.

Good! Indeed it is not a traceback issue, so that’s great news!

I do have a question for you about your Scratch code. Why is there a stop script block? What’s your intent with that block?

The stop script is basically a “quit everything and go home” block. That block will kick you out of the forever loop and end the program. What happens if you remove it?

Cleo

We put that in there just so we could do one time tests of the script. It would run continuously until the sensor threshold of 80 was reached and then stop. So, that way we could see that the last sensor value was indeed over the threshold. We also tried adding a “say 'Value is over 80”’ within the if statement just to make sure there wasn’t a problem there somehow.

I have removed the ‘stop script’ block and it still doesn’t react to the ‘broadcast FORWARD’ block. (I’ve tried removing the ‘wait’ block as well, and still, nothing.

Valid use of the Stop Script block, that. You might not want to keep it once we get everything working, but in the meantime, it’s good.

What happens if you add a Wait block before you loop ? Right after the if block and outside of it?
I would try with wait 0.5 for now and see if it behaves better. I suspect you’re flooding Scratch with too many broadcasts. It does what it can, and it will do them in order. If there are no wait statement, the broadcast sound block gets called faster than Scratch can handle them. So Scratch puts them in a queue, and handles them one by one. Eventually it will get a broadcast forward but quite a bit after it was sent. That might account for why your GoPiGo suddenly lurched forward.

Am I making sense?
Cleo

OK - we’ll try that tonight and let you know how it goes.

Hi all-

I think we’re having the same problem as others with the audio sensor. Going through the steps, we connected the audio sensor and ran the first little “Say sound sensor value” program, and everything was fine. But once we added the Forever lop and the FORWARD and STOP commands, everything froze up. The sound sensor wasn’t even reporting anymore. We switched to one of the older programs - the one that moved the robot backwards and forwards with keyboard commands - and that wouldn’t work either.

We gave up for the night, unplugged everything, and tried again the next day, starting with the Demo just to see if the wheels worked. Everything went fine. So we went the the keyboard controls program. Everything worked fine. And then we tried the sound sensor program again. It started okay, reading and reporting sound levels, but then it got stuck, just reported the same value all the time and never moved. We restarted several times and it was always the same. It’s currently jammed showing a sound value of 113.

When I look at the running code window, the black one with the white code, it reports reading a sound value of 11356, then the next line says something about Trackback, and after that it shows a TypeError: “int” object is not callable.

Any thoughts?

Hi @brianguerrero,
It looks like you might have older software on the raspberry pi. Can you try running the DI update by following the directions here and see if it works for you.

If it still doesn’t work, can you try running the troubleshooting script by following this guide to generate a test log and upload it on the forums.

OK - adding the wait block worked… sort of. Ran the script in a quiet room and had my son make some loud noises right in front of the sensor. The sprite continued to “say” readings that were in the average range of the quiet room (35, 37, 41, 35, 42, 41, etc) even during his loudest moments. I stopped the script, monkeyed with the wait block time and restarted the script. Immediately the robot started to move and the sensor readings were 150, 201, 160, etc despite the fact that the room was silent. It’s like it was responding to the reading from 5 minutes further. We tested this quite a few times and every time the readings didn’t match the sound levels in the room. (Seemed to be behind by at least a minute or two). Any ideas?

This is regarding my issue with the 4th GoPiGo mission (sound sensor). Some folks in the forum have had erratic results even after updating DI software. I did update the DI software. I also updated GoBox. I was able to get GoPiGo to respond to the sound, but when trying to stop it, it won’t respond to the broadcast stop block, I have to go to the scratch startup GUI to press the stop button.

I’ve copied the log.txt from test and troubleshoot procedure:

Check space left

Filesystem Size Used Avail Use% Mounted on
/dev/root 3.6G 2.7G 630M 82% /
devtmpfs 182M 0 182M 0% /dev
tmpfs 186M 0 186M 0% /dev/shm
tmpfs 186M 4.7M 181M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 186M 0 186M 0% /sys/fs/cgroup
/dev/mmcblk0p1 60M 21M 40M 35% /boot
tmpfs 38M 0 38M 0% /run/user/1000

Check for dependencies

python 2.7.9-1 install ok installed
python-pip 1.5.6-5 install ok installed
git 1:2.1.4-2.1+deb8u2 install ok installed
libi2c-dev 3.1.1+svn-2 install ok installed
python-serial 2.6-1.1 install ok installed
python-rpi.gpio 0.6.3~jessie-1 install ok installed
i2c-tools 3.1.1+svn-2 install ok installed
python-smbus 3.1.1+svn-2 install ok installed
arduino 2:1.6.0 install ok installed
minicom 2.7-1 install ok installed
scratch 1.4.0.6~dfsg1-5 install ok installed

wiringPi Found
wiringPi Found
I2C already removed from blacklist
SPI already removed from blacklist

Check for addition in /modules

I2C-dev already there
i2c-bcm2708 already there
spi-dev already there

Hardware revision

gpio version: 2.32
Copyright © 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
Type: Model B+, Revision: 02, Memory: 512MB, Maker: Sony

  • Device tree is enabled.
  • This Raspberry Pi supports user-level GPIO access.
    -> See the man-page for more details
    -> ie. export WIRINGPI_GPIOMEM=1

Check the /dev folder

i2c-1
spidev0.0
spidev0.1
ttyAMA0

USB device status

Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
|__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
|__ Port 3: Dev 4, If 0, Class=Vendor Specific Class, Driver=rtl8192cu, 480M

Checking for Atmega chip

avrdude: Version 5.10, compiled on Jun 18 2012 at 12:38:29
Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright © 2007-2009 Joerg Wunsch

    System wide configuration file is "/etc/avrdude.conf"
    User configuration file is "/root/.avrduderc"
    User configuration file does not exist or is not a regular file, skipping

    Using Port                    : unknown
    Using Programmer              : gpio
    AVR Part                      : ATMEGA328P
    Chip Erase delay              : 9000 us
    PAGEL                         : PD7
    BS2                           : PC2
    RESET disposition             : dedicated
    RETRY pulse                   : SCK
    serial program mode           : yes
    parallel program mode         : yes
    Timeout                       : 200
    StabDelay                     : 100
    CmdexeDelay                   : 25
    SyncLoops                     : 32
    ByteDelay                     : 0
    PollIndex                     : 3
    PollValue                     : 0x53
    Memory Detail                 :

                             Block Poll               Page                       Polled
      Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
      ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
      eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
      flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
      lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
      hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
      efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
      lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
      calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
      signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

    Programmer Type : GPIO
    Description     : Use sysfs interface to bitbang GPIO lines

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f

avrdude done. Thank you.

Checking I2C bus for devices

Checking I2C bus 0

Error: Could not open file /dev/i2c-0' or/dev/i2c/0’: No such file or directory

Checking I2C bus 1

0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00: – -- – -- – 08 – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --

Checking for firmware version and CPU Speed and Voltage

v 1.6
CPU speed: 2
9.86 V

CHECKING ENCODER READINGS
0 0
Both motors moving Forward with LED On
after 5 sec 157 164
Both motors stopped with LED Off
None after stop cmd 164 170
None after 2 more sec 166 170
Both motors moving back with LED On
after 5 sec 337 340
Both motors stopped with LED Off
None after stop cmd 344 345
None after 2 more sec 346 346

CHECKING ENCODER TARGETING

Initial encoder read vals: 0 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 0
Final encoder read vals: 73 75

Initial encoder read vals: 0 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 0
Final encoder read vals: 73 75

Initial encoder read vals: 0 2
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 0
Final encoder read vals: 72 77

Initial encoder read vals: 0 2
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 0
Final encoder read vals: 72 78

Initial encoder read vals: 0 2
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 1
Enc tgt Status: 0
Final encoder read vals: 73 77

Hello @Fujifilm_X-E1

Can you post your Scratch code ? My guess is that you’re looping too quickly on the broadcast command. The sound sensor needs a wait block (0.2 to 0.5 second) to slow it down.

Cleo

I’m on a cell phone so I’ll be brief.
Add a wait block between forever and broadcast sound. Try a value of 0.5 to start