Shop OBEX P1 Docs P2 Docs Learn Events
A few questions after receiving the Board of Activity (update with support) — Parallax Forums

A few questions after receiving the Board of Activity (update with support)

ftguy2016ftguy2016 Posts: 26
edited 2016-01-27 04:06 in Learn with BlocklyProp
I have installed and tried the board and I have a couple of questions that maybe somebody can answer :

1) Cannot find any DC motors samples despite the readme file stating it should be located in the samples folder ?!? That sample is supposed to show how to drive more than 2 PWM...

2) When I try to compile the wav_player with compiler -oSize, it does not work, (apparently -oSpeed is required) is that normal ?

3) On my board, the wav_player is working but almost once per wa play, it does totally break up for 2 seconds (could be almost anywhere in the music) with the sound looking like some old digitized vocoder and then continues the playback normally, is that a known issue ? Any way to fix it ?

4) It seems that I cannot power the board using USB if there is no drivers installed on a computer which means I cannot use a USB charger to power the board, can this be fixed or is that a limitation of the board ?

Thank you.

Comments

  • edited 2016-01-22 19:43
    Hi ftguy2016,

    1) ...\Documents\SimpleIDE\Learn\Examples\Devices\Motor\DC\Two DC Motors 60 Percent.side

    2) In my experience, -oSize works for applications, but not for the wavplayer library itself. All other Simple Libraries work with -oSize; libwavplayer is the only one that needs to be compiled with -oSpeed. If you have made a copy of the library test harness and are working with that, or if you are working with the original library, it would explain why it needs to be -oSpeed. So, my guess would be that your application would work with -oSize if it started with a copy of ...Documents\SimpleIDE\Learn\Examples\Devices\Audio\Test WAV Volume.side. If it instead started with a copy of the library test harness (not recommended unless you plan to modify the library, and located in ...Documents\SimpleIDE\Learn\Simple Libraries\Audio\libwavplayer\libwavplayer.side), I would expect the -oSpeed to be necessary. In general, start with code from the Examples folder, not the Simple Libraries folder.

    There may be some other issue though, like maybe some non sequential read rate of the particular SD card, or maybe something about the .wav file. If so, please let us know.

    (This may be TMI, in which case, skip to answer 3 below.) When modifying a library, I usually copy code that uses the library (the .side and .c file) from the Examples folder into the My Projects folder. Then, I copy the library folder (starting with lib) from the Simple Libraries folder into the My Projects folder. After that, I open the liblibraryname folder in My Projects, open liblibraryname.side, and then click the bottom-left Show Project Manager button to browse the .h and .c files within the library, modify, recompile, etc.

    Initial test harness code can live in liblibraryname.c, but once I think it's working as intended, I do not use the library test harness for applications. For applications that use the library, I go up a folder level, and open the code I copied from the Examples folder. Since that example code has my modified liblibraryname folder in the same folder with my project (.side + .c files from Examples folder) SimpleIDE will use my modified library instead of the default in the Simple Libraries folder. Reason being, when application code has #include "libraryname.h", SimpleIDE looks in the same folder as the project first. If it finds a modified or custom library there, it uses it. If it doesn't find the library there, it looks for the unmodified default version in the Simple Libraries folder.

    3) I haven't seen this before. Could you contact our support dept, and having them download a copy of your .wav file for testing?

    4) I just tested with a USB battery, and that appears to power an Activity Board. 5 V cell phone chargers also work, so it may have something to do with the way the computer is handling the port sans driver.

    Hope this helps...

    Andy
  • Hi Andy,

    Very helpful.

    1) I located the project, thank you very much.

    2) This is not a big deal actually, I was just curious to know if it was a known issue, I can deal with the oSpeed at this time.

    3) I will do so, it does not happen every time, really time to time on my board, I am also using the adc_init to read voltage in the same time to check the RF remote controller sold on the store connected to an analog-in so could it be connected somehow ?

    4) Indeed strange then, I just cannot have my board to power-up out of any micro-usb charger, only if connected to the PC, and only if detected by windows, an external jack 5 volt seems to power the board thought, just no chance with any USB's one here.



  • Here is a wav file that did capture the bug I am having, the sound is not very good quality but you can definitely heard the frequency weirdness .
  • and here is the code that running, I just need to wait a few minutes and eventually the bug is happening.

    int main()
    {
    int DO = 22, CLK = 23, DI = 24, CS = 25;
    sd_mount(DO, CLK, DI, CS);

    adc_init(21, 20, 19, 18);




    int counter=0;

    while(1)
    {
    pause(50);
    if (wav_playing()==0)
    {
    wav_volume(10);
    wav_play("music1.wav");
    }

    char t=0;

    if(adc_volts(0)>3.0f)
    {
    t =1;
    }

    counter +=1+t;

    if (counter>40000/50)
    {
    wav_stop();
    counter = 0;
    }
    }
  • Unfortunately, I am stuck with that sound issue which make my 49$ board useless :(

    Here is a new sound capture of the bug of the sound output, at 1.5 second, the wav on the sdcard is at 22khz.

    After exchanging couple of emails with the support, they are advising me that it might sounds normal that the driver is playing "that way", I should not expect PC quality (did I ever ask for it ???), that my original 32khz wav file is not "a playing speed supported" by the driver (when their own sample test techloop.wav downloaded from the learn website is at actually @ 32khz). I had to mention that 22khz is also having issues on my board. Sorry but it sounds more like a way to evade/dismiss my problem than anything else. I am not sure how somebody can listen the sample attached and pretends this is "playing normally".

    As a new customer, I am already starting to lose faith on this board of activity with propeller and the ability of the support team to help me. I hope a solution can be find thought. I will also attempt to write my own driver so I can fully asses if I received a defective board with timers or clock going crazy time to time.

    Not very happy customer here.
  • kwinnkwinn Posts: 8,697
    It looks like the problem may be due to aliasing (sampling at a rate close to the frequency of the sound signal). Take a look at the spectrum using Audacity and you will see frequencies above 20KHz. To digitize a signal the highest incoming frequency should be no more than half the sampling frequency, so for a 32KHz sampling rate the highest incoming signal frequency should be 16KHz max.
  • kwinnkwinn Posts: 8,697
    One other thing you can try is to take a clean copy of the music and use Audacity to to change (resample) the sampling frequency to a lower rate and see if that solves the problem.
  • JonnyMac wrote a couple of tutorials for converting wave file to play on the propeller.:

    http://www.efx-tek.com/php/smf/index.php?topic=1454.0

    http://www.efx-tek.com/php/smf/index.php?topic=2085.0
  • That sounds like a granular sound artifact - IE, that there's a relatively small buffer that's being played repeatedly, and whatever is replacing the buffer is failing to do so briefly in the middle, resulting in that "stretched" sound.

    What is your code that stops the wav playback doing? Are you sure when you stop playback that the wav is actually done? Also, you don't wav_stop() before you wav_play() all the time - have you looked at the implementation of wav_play? If you were overlapping them (running more than one at a time) it could cause some really strange artifacts. I'm totally guessing here based on what I hear - I don't know this code, but trying to give you things to look at.
  • I don't think I have any problem with the wav file itself, it does play well, until a hicup occurs,

    I was suspecting some kind of buffer issues, so I have timed the function that is reading the buffer in the wav driver (the 512 bytes buffer fread) and indeed there is a x10 increase when the bug is happening, the fread, like those value (in clock ticks are showing below ) , the code is the wavplayer from the simplelibrary, stock version...I simply have no idea why it does happen, randomly when playing ....

    latest timing, highest timing

    317136 - 509968
    325168 - 509968
    318960 - 509968
    316496 - 509968
    317808 - 509968
    7747568 - 7747568 <=== here
    315888 - 8040048
    323888 - 8040048
    315856 - 8040048
    319088 - 8040048
  • kwinn wrote: »
    One other thing you can try is to take a clean copy of the music and use Audacity to to change (resample) the sampling frequency to a lower rate and see if that solves the problem.

    I already reduced to 22khz, I could try to reduce more like 11khz, I will try again, I could also simply patch the wavplayer to force whatever frequency I want with the same file....but I do knot why reading 512 bytes is freezing the whole board or it seems....

  • JasonDorieJasonDorie Posts: 1,930
    edited 2016-01-28 09:35
    It's possible it's an issue with the SD card itself. I've heard there are issues when writing to them for sure, but it's possible that reading from them could be dodgy too, depending on the card.

    Try doing a quick format of the SD card and then put your file back on it, and make sure there's very little else on the card aside from what you need for your code. How big / how fast is the card? Check to see if the SD driver has any recommendations for sector size or anything - they often do.
  • Hi Jason,

    I already did that, I totally formatted the sdcard (no the slow format but the full one) and there is just 1 file on the sdcard. The sdcard is 2GB and it is the one I bought from the parallax store, it came with the board so I suppose it should work properly.
  • Humm..what else....on the board I had also plugged the RF keys module (bought also on the parallax store) :

    https://www.parallax.com/product/700-10016

    Connected on the 5v , ground, and the 5v output signal connected to 1 of the Analog input ..I am not pushing any button so it should not drain too much current but I will remove it and make another round of test with the breadboard plate fully empty.
  • Well just tested. unfortunately even without the RF module I am still getting the problem, it is really random, sometimes a few seconds after the first play, sometimes I need to way 2 or 3 cycle of the file to be played. I am left now with the only reason that the fread low level function is, on my board, locking for 7,000,000 cycle almost 1/10 of a second for reading 512 bytes. Is the driver built to do so some clean-up routines time to time, freeing huge block of memory or .... Is that something somebody already experimented ?

    I want also to point out that I feel weird that I cannot have my board powered using only a USB charger. My board does require to be detected by my PC in order to power UP, for example, if I boot my PC, and then connect the board, there is no power until the PC ran the drivers detection and identifies the devices. I have multiple smartphone usb chargers and no one can power the board.
  • kwinnkwinn Posts: 8,697
    At the moment the only suggestion I can come up with is to replace the sd card routines with a routine that provides a 512 byte block of data that produces a tone that switches between two frequencies every second or so. That way you have at least isolated the problem to the sd card & software or not.

    For the USB power problem you can plug in one of your usb chargers and measure the voltage and at various points on the board. It may be that a charger cannot supply enough current to drive the board. SW2 has to be in the correct position (same as for Vin to power it up) to enable power. Once that is done you can check the voltages at the locations listed below.

    Both sides of FB2 should measure 5V. If the voltage is lower than 4.75V the charger is not up to powering the board.

    U6 pin 1 should be 5V, and pin 6 should be the same or a few mV less. If pin 5 has 5V and pin 6 is close to 0V check pin 3. It should be close to 0V. If it is near 5V then usb power is not being enabled.
  • Hi Kwiin,

    I think I could that, make a different square wave and hear i the sound is playing flawlessly...but since I timed before and after the fread, I already identified this "call" to be taken 7,000,000 cycles.
    For the USB power problem you can plug in one of your usb chargers and measure the voltage and at various points on the board. It may be that a charger cannot supply enough current to drive the board. SW2 has to be in the correct position (same as for Vin to power it up) to enable power. Once that is done you can check the voltages at the locations listed below.

    I will do that but I hardly believe any of my big tablet chargers is providing enough current. Is the USB on PC not working until drivers installed is a normal behavior ? I cannot power this board when I plug it to another PC.
  • kwinnkwinn Posts: 8,697
    ftguy2016 wrote: »
    Hi Kwiin,

    I think I could that, make a different square wave and hear i the sound is playing flawlessly...but since I timed before and after the fread, I already identified this "call" to be taken 7,000,000 cycles.
    It is possible that the sd card could be the problem. Sometimes a bad part slips by no matter how good your QC is. Could even be the sd driver, so it would not hurt to try another sd card and a freshly downloaded copy of the driver.
    I will do that but I hardly believe any of my big tablet chargers is providing enough current. Is the USB on PC not working until drivers installed is a normal behavior ? I cannot power this board when I plug it to another PC.
    Chargers generally put out a relatively low and well controlled current for charging batteries, particularly LiIon batteries. This may not be the case here, but it's worth checking out. Troubleshooting computer and electronic problems involves finding a lot of things that are not the problem before finding what is the problem.

    Be grateful that this intermittent shows up often enough to have a chance of finding it in a reasonable time frame. Over the years I have had intermittent problems that showed up so rarely that it took many many hours over many months to find.

  • I have no problem to test, so I will swap the sdcard with another one and check where is the current available when I put a USB charger, however I still find strange that no power come from a PC (which does not charge a battery) if the FTDI drivers are not install, it is like the board is waiting a special handshake code before taking the power from the USB which would explain why a charger cannot power it.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2016-01-29 08:38
    I think the USB power issue is because of the FTDI chip. If I'm not mistaken, the FTDI negotiates with the host before supplying power to the rest of the board. Someone else can chime in if I'm wrong. There might be a way to reconfigure that with FTDI's setup / config software.

    It's also worth mentioning that the Propeller chip is *very* deterministic and repeatable in my experience, so the timing issue is very likely something with the SD card, or possibly a bug in the SD driver. It's unfortunate you're having trouble - they're usually very well behaved.
  • Hi JasonDorie,

    Thanks for your input on the USB power, I am quite sure it is like you wrote because no FTDI drivers == No power indeed. I plan to check the sdcard's option tomorrow by using another one which I know is working well on another Arduino project.
  • AribaAriba Posts: 2,682
    I've just tried my Activity Board with a USB Power Adapter, and it did also not work.
    Then I used FT-Prog (from the FTDI Website) and tried some alternative settings.
    My final solution was to disable the Battery Charge Detector and just set the CBUS0 pin to low. Now it works. Here are the steps in case you want to try it (you can restore the old settings if necessary):
    Start FT-Prog then
    DEVICES -> Scan and Parse
    Device Tree:
     USB String Descriptor: uncheck "Auto Generate Serial No."
     Hardware Specific:
       CBUS Signals: C0 = Drive_0 (instead of BCD_Charger#)
    

    Have you tried a Spin Wave-Player? There are many variations of waveplayers in Spin for example: obex.parallax.com/object/254
    I think you find a few more in forum threads, the Obex has not the best ones I think.

    I'd say Sample buffers with 512 bytes are too small, I always found 1kB is the minimum. This can buffer 2 sectors.
    I never worked with the simple-libraries in C, but I think they use the slow SD card access of the C standard librariy. A fast SD card driver like FSRW (Spin) is about 4..5 times faster. I have played also 44.1 kHz 16bit stereo Wave files with it.

    Andy
  • After testing, I can report that the SdCard itself was the issue in my problem. Switching the 2G SdCard I received with the board with another one 1GB size is making the player to behave perfectly as expected without any lag whatsoever so I will see how I could manage to get a replacement for that defective one.

    Thank you everybody for help and directions, I can now start moving on other part of my project.
  • iexpressiexpress Posts: 2
    edited 2016-02-01 04:35
    I've found that uint8_t samples work very good with this.
    basically, I converted audio files to 8-bit unisgned .pcm raw format
    without headers so it's straight binary data.

    Then, i opened the files individually, grabbed 2000 bytes at a time, then scrolled through the uint8_t arrays sending values to the DAC channels.

    The way I had this looped was set for 8-bit 8khz sample rate
    so if you encoded a track down to 8-bit 16khz, it would still sound
    pretty close to normal. I do not like to use unsigned chars, but am used to uint8_t data type, pure binary operations.

    #include "simpletools.h" // Include simple tools

    int DO = 22, CLK = 23, DI = 24, CS = 25; // SD card pins on Propeller HIB //22 23 24 25


    uint8_t data[2000];
    int counter;
    int repeater;
    int loop = 0x00;

    int i = 0x00;

    int main(void){


    sd_mount(DO, CLK, DI, CS); // Mount SD card



    while (1){

    FILE* fp = fopen("00000000.pcm", "rb+");

    for (repeater = 0; repeater < 17600; repeater++){
    fread(&data, 1, 2000, fp);

    for (counter = 0; counter < 1999; counter++){
    for (loop = 0; loop < 1; loop++){
    dac_ctr(27, 0, data[counter]);
    dac_ctr(26, 1, data[counter]);
    //dac_ctr(10, 0, data[counter]);
    //dac_ctr(11, 1, data[counter]);
    }
    }
    }
    fclose(fp);

    fp = fopen("00000001.pcm", "rb+");

    for (repeater = 0; repeater < 17600; repeater++){
    fread(&data, 1, 2000, fp);

    for (counter = 0; counter < 1999; counter++){
    for (loop = 0; loop < 1; loop++){
    dac_ctr(27, 0, data[counter]);
    dac_ctr(26, 1, data[counter]);
    //dac_ctr(10, 0, data[counter]);
    //dac_ctr(11, 1, data[counter]);
    }
    }
    }
    fclose(fp);

    }
    }
  • Sounds like you have a solution, however last year I put together the Halloween Pumpkin Project that plays .wav sound bytes and the suggestion there was to ensure the SD card was formatted for FAT32. I'm not sure if that is the same in this case, but if the card was not formatted as such, there were issues with the play back.

    Also, for future ref, here be a link to a list of sample sound files that could be used to test the set-up, as well as the links to formatting the audio files.

    learn.parallax.com/reference/sound-library

    Cheers,

    Jon
  • Thanks, I am using goldwave for the sound, 16 bits audio unsigned wav file and it works pretty well. Indeed the problem was only the capricious sdcard, now totally fixed with a new one but... I will give a try to the Fat32 once again when I have time.
Sign In or Register to comment.