It's my first post in here and my second day with an Arduino 09. I bought it to work on an edrum project. I managed to setup the piezos, add the Arduino code to send serial data and coded an VB application using MSComm to recieve the data (from USB, I don't have MIDI interface). It's working pretty well, but I'm getting some interruptions in serial communication (I guess) every 30s, 1min. It lasts about 3 seconds and in that period nothing can be sent. As it is supposed to be an e-drum, I can't allow this to happen.
The red led (L) blinks when I get this problem, but I'm new to this and have no idea on what is causing this issue.
Do you guys have any idea on what can be causing this problem?
I'm using a baud rate of 57600 both in my arduino code and VB application. Is it too much for the chip to handle?
The setup I'm using is almost the same as described in the link above. I'm using the resistor in parallel with the piezo but I don't have the 5v diode. This might be an issue (the piezo generating too much voltage, freezing/crashing the processor)?
I'm not sure either how is the best way to send serial data. I'm just sending each byte of the MIDI message this way, with a comma at the end so I can break each message in case I read the buffer and there is more than one message there:
@westfw:
Good idea. I'm at work now, but I'll try that when I get home.
@gbulmer:
The piezo speaker is the only (with the 1M resistor) piece of electronic connected to the Arduino, but I don't recall seeing the red led blinking when it is "idle" (when I'm not sending serial data). I have to confirm that.
PS.: Is there a way to quote a message? I couldn't find the "quote" button.
I did the tests. My arduino is indeed resetting (I've added a serial print at setup()). I now I know the problem, but how can I identify what is causing it to reset?
I did the tests. My arduino is indeed resetting (I've added a serial print at setup()). I now I know the problem, but how can I identify what is causing it to reset?
If your serial program disconnects from the serial port, and then re-connects, it will trigger an auto-reset depending on how your serial library/etc. handles it.
You're not exiting your program, or re-creating your serial object at some point, are you?
If your serial program disconnects from the serial port, and then re-connects, it will trigger an auto-reset depending on how your serial library/etc. handles it.
You're not exiting your program, or re-creating your serial object at some point, are you?
!c
Hi drone. Thanks for the reply.
My VB program is not disconnecting/reconnecting to the serial port. Just in case, I did some tests, not using the serial port at all in my arduino code (only the analog input from the piezo and pin 13 led to detect the hits). It still reboots. I'm not 100% sure of this, but it seems to be resetting when I hit the piezo a bit hard.
I'm connecting the piezo to the pin like shown in this picture, except for the 5.1v zener:
Is the lack of the zener might be causing the issue?
I don't have any technical information about the piezo because the guy who sold it to me didn't know either (I bought it "the way it is", without any case or stamp like the radioshack ones).
I have driven several different piezo's, with many dozens of people without any problems, ever. Folks like to swap a piezo for an LED.
I am always amazed that there aren't any problems.
I'd expect of a back-EMF spike to cause a problem (it's a crystal, it deforms with electricity applied, it should generate an opposite voltage when it 'relaxes'). I'd use a zener like that schematic, or Schottky diodes to ground and Vcc.
I almost always have a current limiting resistor between a pin and anything it's driving. Try 1K in this case.
The zener is a good approach if that doesn't work.
For the piezo input, the 1M resistor is to bleed off the voltage generated by the piezo when it is struck. The 5.1v zener diode is there to insure any large voltages don't make it into the Arduino and blow it out.
I probably should add the zener like described in the article, but I've looked at a the "Knock Sensor" example in the Arduino website and there is no diode in there to protect the circuit, only the resistor (which I'm already using). That's why I'm wondering if it's the lack of the diode that is causing my issue or not.
Thanks for your time guys, I really appreciate it.
Please, connect a zener across the piezo (or use Schottky diodes if you have some). A zener is only a few cents.
I'll see if I can get one tomorrow. I just ask for a 5v zener/diode? Sorry about this dumb questions, but my knowledge in electronics is high school stuff (and I saw that more than 8 years ago...)
Also...
The Arduino is being reset when there is nothing else connected except the piezo speaker and LEDs.
Sorry, I didn't understand. What this a question? There's no led connected to my Arduino, only the piezo with a 1M resistor in parallel with it. It seems to reset when I hit hard. When it's "idle" (no piezo action), it doesn't reset IIRC.