Home Forums Sparkfun MP3 Shield Library Support Forum cuckoo clock: sparkfun MP3 Player with motors and Servo Motor

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2764
    Anonymous
    Inactive

    I am making a cuckoo clock with arduino UNO which takes time from Time.h. It consists of operation of a Motor which moves fwd and backwards using a H Driver. It also operates a Servo in between. I tried to make it work with Sparkfun MP3 Shield to play music tracks during various phases of movement. For the motor I have used pins not being used by the Sparkfun Shield. However, the project behaves un-predictably with while using MP3 Player. I am using SFEMP3Shield.h by bill porter to drive the Sparkfun MP3 Player.
    Does anyone have experience in such a project, are there any conflicts, should I use a different timer, or a RTC board. Is there any other method of playing music during various movements. I am attaching the sketch I have used. I would be grateful for any assistance.

    #2802

    I suspect an interrupt issue. You may want to configure the SFE MP3 library to run in polled mode, rather than interrupt. By changing USE_MP3_REFILL_MEANS to USE_MP3_Polled in SFEMP3ShieldConfig.h

    #2809
    Anonymous
    Inactive

    Thanks for the guidance. I attempted to carry out the above change in the file, I was unable to decipher as to which line it is to be changed as USE_MP3_REFILL_MEANS  appears at a number of places.  Sorry for my ignorance.

    May I also know as to what will be the implication on the program, possibly two actions cannot be simultaneous.

     

    regards

    #2810

    change line 195 of SFEMP3ShieldConfig.h from

    #define USE_MP3_REFILL_MEANS USE_MP3_INTx

    to

    #define USE_MP3_REFILL_MEANS USE_MP3_Polled

    This changes the driver not to use Interrupts, but rather the main loop() will

    MP3player.available();

    will do the refill. This however, requires the main loop() not to be blocking.

    #2812
    Bill
    Member

    mandeep replied to the email notification instead of posting here. The message:

     

     

    Thanks for your consideration.
    I tried the above configuration as suggested by you.  It does work when the loop is running without any delays.  However, in the loop I have other actions, like the servo motor running, an Op of DC motor which incorporates a delay in the loop.  The music does not play in that case , it is brief and intermittent.  Any suggestions please.
    thanks and regards

    #2813

    Such delays are blocking, until finished preventing the refills of the MP3 from SdCard. It takes time to read the SdCard and it takes time and to service the motors..

    you could try adding the following command of sei(); just after line 1696 http://mpflaga.github.io/Sparkfun-MP3-Player-Shield-Arduino-Library/_s_f_e_m_p3_shield_8cpp_source.html#l01696


    1696 void SFEMP3Shield::refill() {
    1697 sei();
    1698 //Serial.println(F(“filling”));
    1699
    1700 while(digitalRead(MP3_DREQ)){

    #2814

    It was implied, but may not be obvious that change line 195 of SFEMP3ShieldConfig.h was changed back to…
    #define USE_MP3_REFILL_MEANS USE_MP3_INTx
    this should allow the interrupt for the motor timers to interrupt during the SdCard Fill.
    There has been limited success with this. It may cause other issues. Rumor is that it will work.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.