A few questions after receiving the Board of Activity (update with support)
ftguy2016
Posts: 26
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.
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
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
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.
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;
}
}
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.
http://www.efx-tek.com/php/smf/index.php?topic=1454.0
http://www.efx-tek.com/php/smf/index.php?topic=2085.0
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 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
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....
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.
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.
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.
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.
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.
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.
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.
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.
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.
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):
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
Thank you everybody for help and directions, I can now start moving on other part of my project.
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);
}
}
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