I have an Arduino Uno with a 3g shield and am using a Software Serial port on pin 6, 7 and the usb port for debug. After doing well for days, now my program seems to start over and over again (I see that thanks to a println in the setup function) - I added some code, to be honest.
Any suggestion about possible reasons?
Because you are using pin 6 and 7 with SoftwareSerial, the autoreset on serial connection start does not apply.
It would if you use the "standard" 0 and 1 pin which are connected on the USB.
This kind of bug happens in many cases, normally is HW related (attached hardware use too much current, are you using an external charger or power by usb?) or because you are out of ram. Check if you have enough Available Memory
What code did you add? You say you are experienced in C#, so did you remember to clean your garbage? C/C++ does not have a garbage collector that does that for you.
The Arduino has much less memory then you are probably used to, so if are recursively calling a function intentionally or indirectly you could run out of memory.
If you are using a lot of strings it could also use all of your memory.
Can you divide and conquer to determine specifically what routine is causing the reset?
I would start by commenting out half of the main loop and see if it still resets?
An Arduino will reset when the usb port is reinitialized (read: usb cable replugged), and that could be due to the host computer sleeping, rebooting, or something else such as the whole usb controller restarting because another usb device was plugged in.
Use watchdog timer Solve above issue.And while Debug using Serial monitor keep in mind whenever you start the controller get reinitialize
I had the same problem, and my issue was have 10 sensors on arduino 5v output. I changed 5 of them to a separeted power with a 5v regulator and all works great.
Power regulator might be overheating and it's turning off. Putting a small piece of metal on top of it as a heatsink might fix the problem.
When I had this problem I found out that it had something to do with the Sony software for my phone. Turning the software On my computer solved it, and my Arduino has been happy ever since.
The solution was found here
The culprit in my case was Sony Ericsson software trying to identify if the USB device was a mobile phone. Disabling this cured the problem. The moral of the story is don’t run any software which uses the USB whilst you are doing Arduino development. You can disable the reset function after you’ve finished developing if you want.
Related
My custom board with Atmel SAMD21 microcontroller (same as Arduino MKR Zero) is not making a USB port since yesterday. The board was working fine before that.
Please suggest ways to resolve this issue. What are the possible reasons for such an issue?
Since reset is equivalent to powering the board ON and OFF which has not resolved the issue, can burning the bootloader again help?
Further information:
The board seems fine. It powers ON and OFF in the usual manner.
This problem with the USB port connection happened while I was trying to upload the code.
The USB pin connections on the board have been checked as well as tested with different USB wires.
Appreciate your help.
Solutions to the problem:
External Hardware Reset -- using a reset button (that I externally managed to solder) -- to get into bootloader mode and start the program from the beginning
Burning bootloader again may also work (theoretically) - I have not tried and tested it.
For detailed understanding - follow this post - https://forum.arduino.cc/t/atmel-samd21-microcontroller-not-making-a-usb-port-anymore/882504/5
I've been trying to establish serial (UART) communication between a Raspberry Pi Model B Revision 2.0 (checked the model like described on this page) and Arduino Mega 2560. I made a service on the Pi that writes to UART and then expects a message and a coworker programmed the Arduino with an echo program. While they were communicating, I had trouble receiving data, meaning that it was clustered in 8 byte pieces and I had to introduce a timeout for waiting between them (I was actually as much as available and calling select()for the next cluster but it turned to be 8bytes a cluster, except for maybe the last one. As explained in a question I found on this site, the programmer is the one to take care of the protocol and can not rely that the whole message will be ready to read at once (that is logical).
However, when I just connected Pi's TXD and RXD pins, no matter how much bytes I tried sending, it sends them in one go (I've gone up to a bit more than 256, that's more than enough for my purposes). I also have around 50 milliseconds of duration difference, measured directly from within the program, using gettimeofday() function.
So, could anybody clear things for me:
Why is this happening?
Is this difference in behaviour expected?
Is there a potential problem in either of the devices (if that can even be concluded from the given information).
Of course, any additional information is welcome, in case I forgot asking something that is deemed important.
Why is this happening?
I tried some time back communicating Arduino-Arduino and Arduino-Pi. I faced some problems with UART communication. However, you might want to keep same Baud rate on both the devices. With Pi, you might need to trigger an event if you receive data from Arduino. On the other side, if you code runs longer, then you might lose some data i.e. your Arduino code is running something else while Pi sends data over UART.
Is this difference in behaviour expected?
Yes. Arduino is a microcontroller based device while Pi is microprocessor based (runs on OS)
Is there a potential problem in either of the devices (if that can even be concluded from the given information).
I don't think there could be any hardware problem unless it is not functioning at all.
Also, because of this issues, I switched from UART communication to SPI communication. This solved my problem completely.
I have an Arduino Uno and I am using arduino 1.0.5 IDE. I followed he procedures for bootloading an atmega328P-PU on a breadboard.
I uploaded the ArduinoISP sketch first, made the connections(using the External Oscillator) and then wired it up. Then, I selected the programmer as Arduino as ISP, selected the board as Arduino duemilanove w/ Atmega328P. Then I selected the correct serial port and clicked Burn Bootloader.
I got the following errors:
avrdude.exe: stk500_program_enable(): protocol error, expect=0x14,
resp=0x50avrdude.exe: initialization failed, rc=-1 Double
check connections and try again, or use -F to override
this check.avrdude.exe: stk500_disable(): protocol error, expect=0x14,
resp=0x51
How to solve this issue? Also, can I upload the bootloader directly by using it on the Uno in place of the original chip. If so, how?
to my understanding the error you have indicates a bad reading from the chip. I experienced that with chips that were either dead or not properly connected, especially to power supply.
You may find more detailed information in th tutorial : https://www.arduino.cc/en/Tutorial/ArduinoISP
Especially those things :
Note for Arduino 1.0: you need to make one small change to the
ArduinoISP code. Find the line in the heartbeat() function that says
"delay(40);" and change it to "delay(20);".
Select the items in the
Tools > Board and Serial Port menus that correspond to the board you
are using as the programmer (not the board being programmed).
Instead of arduino built-in boot loader just go through below link and it will be great for uploading boot loader and verifying board status info
I am replying you this because same issue I got long back and it saved me.
One more thing for arduino boot loader: for atmega328 you need to put capacitor between reset and gnd( in case you missed)
For gammon bootloader you don't need it.
Be Innovative.
For reset line you might me using 100nf(thats what stated in documentation )...but sometimes it doesn't work...try something like 4.7uf, 22uf or 47uf or close values
I had a similar problem and the issue was that my programmer was a bit slow, I used the -B flag for avrdude to slow down the bitrate and it started working, I set the -B20 and works like a charm every time, but I use the USBTinyISP programmer, not the stk500 one, so this might not work for you.
In case someone stuck at this as I did and nothing like changing the cap value helped. Make sure you are using your USB-TTL adapter in a 5v mode (obviously for a 5v powered chip). I always used it in a 3.3v mode in order not to accidentally burn my 3.3v chips and it always worked. Until today, I was trying to flash my custom atmega8 board and everything worked with the ISP but I was having a hard time using the bootloader and after half a day searching and trying different stuff the 5v setting to the rescue.
I am using arduino uno r3 board and arduino 1.6.5 on windows 8. When Itried to upload my program on ATMEGA328 microcontroller it is showing:
avrdude:stk500_getsync not in sync:resp=0x87.
help me to solve this error
This boils down to 3 problems usually..
The bootload on the chip is missing (unlikely if you purchased the board from Arduino).
The serial connection between the arduino and the computer is disconnected or interrupted.
You've simply selected the wrong board type or port when programming, and thus the IDE is searching for a signal that the arduino isn't coming back with.
This problem is most likely due to option 3, however it can occur in odd situations especially on the Arduino Micro where the board does all USB comms on chip and can be flooded by main without an appropriate delay to the point it can't communicate with the IDE. However this is just most likely a bad board selection or a bad port selection.
I've tried many things but this worked for me. If you have a working Arduino lying around (in my case Uno) you can use it as an intermediate in-system programmer (ISP).
Follow this guide to first load the ISP sketch into your working Arduino.
Once you are done, for your non-working Arduino, select from the Tools > Programmer menu and choose Arduino as ISP, and set Board and Processor accordingly. To program choose Sketch > Upload using programmer.
Hope this works.
I think the reason that this work is that it will bypass the CH340/FTDI chip, and all those synchronization issue. Given that that is your problem.
I am currently working on a system (home projects - finally got the time yay!) and i am wondering whether it would be possible to program an arduino from a pic32? the system currently has both and given the pic32 proc has an SD card attached, i figured i could use the platform potentially to program all the other systems if there was new firmware deployed onto the SD card..
just wondered if it was possible? there doesnt seem to be anything online but maybe im googling the wrong thing? i suppose the pic32 would be acting as an ISP?
Thanks in advance..
Chris
sure, why not, it is just spi. I think just out of convenience (of something with spi on it or trivial to bit bang) I use another microcontroller to program my avr (an msp430 or mbed which program easily over usb). avrs docs are pretty good on the protocol. you can use the serial bootloader as well, but that gets into a larger number of combinations of which arduino, what speed the uart is, exactly how and you have to tickle the dtr (reset), seemed like when I was still messing with that each arduino board type was different. Where with the isp interface excluding xmega, there are chip to chip differences as far as the identification number, etc but easier come up with something more generic. And the nice thing about that spi interface is the processor is in reset so you are not relying on there being a bootloader, what version of the bootloader, or a chip with a flash that is for some reason causing a hang, etc. you should generally get the same programming experience independent as to what was programmed before.