Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello there
I for some time trying to operate the buzzer with the M300 command. But it does not work, I just hear a short beep.
The buzzer is connected to pin 66 of the Arduino, is an analog pin then a buzzer sounds digitally. I think the problem comes from.
Someone would make it how to work right?
Hi - on Da vinci 2.0 actually the M300 commands generate a set of "tic" or "tac" following the M300 commands but not the clear sound like others printers neither clear beep when using the test sketch on pin 66.
I have tried to check the code but I am too newbie to find a solution so I am also interrested on some lead to fix it
Thanks in advance

First time post here, but I've had my Davinci for about 4 weeks and moved it over to Repetier with help and documentation from this forum. I also noticed that the M300 command wasn't working and I was a bit bummed out. ( I was hoping to G-code the "Charge!!!" bugle call to signal that the heaters are hot and the print is starting.

After a bit of code diving, I got my buzzer working. I had to modify the HAL.cpp file slightly, but I can now push tones to the buzzer. I am not sure if this is the "correct" thing to do to get this to work, but it does get the buzzer working on my Davinci.

Original code fragment from HAL.cpp:
// IRQ handler for tone generator
    static bool     toggle;


    WRITE(tone_pin, toggle);
    toggle = !toggle;

Modified HAL.cpp:
// IRQ handler for tone generator
    static bool toggle;

    //WRITE(tone_pin, toggle);
    WRITE(BEEPER_PIN, toggle);
    toggle = !toggle;

Someone, correct me here (I'm not a C/C++ coder), but it appears that this is an timer based interrupt vector that is setup by the tone() function in HAL.h. The tone() function attempts to pass the uint8_t value of 'pin' to 'tone_pin'. This value doesn't seem to get sent over to the BEEPER_TIMER_VECTOR() IRQ handler. If the commented //Com::print(tone_pin) line is uncommented and the serial port in the Arduino IDE is opened, then you can see the IRQ handler run, and the pin value is 0 (zero). I haven't figured out how to pass the correct tone_pin value back to BEEPER_TIMER_VECTOR(), so I just used the BEEPER_PIN value that is already all over the code (maps to pin 66, if I remember correctly).

Anyways, Thanks to the folks here for your help getting me into the 3D print world! I hope this information helps you out.


PS - command tested with was M300 S440 P5000 (beep at 440Hz for 5 seconds)

PPS - Code fragment from HAL.h that sets up the Interrupt timer (you can see the tone_pin assignment here):
static inline void tone(uint8_t pin,int frequency) {
        // set up timer counter 1 channel 0 to generate interrupts for
        // toggling output pin.  
        tone_pin = pin;
        // set interrupt to lowest possible priority
        NVIC_SetPriority((IRQn_Type)BEEPER_TIMER_IRQ, NVIC_EncodePriority(4, 6, 3));
                     TC_CMR_TCCLKS_TIMER_CLOCK4);  // TIMER_CLOCK4 -> 128 divisor
        uint32_t rc = VARIANT_MCK / 128 / frequency;
        TC_SetRA(BEEPER_TIMER, BEEPER_TIMER_CHANNEL, rc/2);                     // 50% duty cycle
Excellent catch, it is working

Got my Da vinci 2 having sound back,

Thanks a lot,

Thank you very much
I tried many things but in the end it was just this little problem.
Is that the problem was only on the Da Vinci is the repetier firmware for Arduino Due that a problem? Otherwise it should be reported

If you want, I made special modifications to the Da Vinci

If I have not offered to BGM is that I do not think he wants to change the code to send its changes to the official branch.
Most of the changes I'm doing is at the display, everything works normally

Forum Jump:

Users browsing this thread: 1 Guest(s)