Author Topic: Communication issue between Arduino and RS232  (Read 1016 times)

0 Members and 1 Guest are viewing this topic.

Offline KEIN NEINTopic starter

  • Contributor
  • Posts: 30
Communication issue between Arduino and RS232
« on: October 23, 2024, 10:49:27 pm »
Hello.

I want to read temperature data using the rs232 port on my PC, but first I checked if the MAX232 converter even works properly and I get this error messages after uploading:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x0c
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x0c
I selected the right board (Arduino Uno) and the port COM1, I tried restarting while uploading the cord and nothing happens. Connections are as follows:

Vcc to 5V on Arduino
RXD to TX on Arduino
TXD to RX on Arduino
GND to GND too

Arduino is connected to PC via USB for uploading the code (as I read, uploading via serial typically doesn't work) but also connected to 7.5V supply through the barrel jack, so I can disconnect the USB cable after uploading to transfer data entirely via rs232

What kind I do? Thanks in advance
 

Offline MAS3

  • Contributor
  • Posts: 34
  • Country: nl
Re: Communication issue between Arduino and RS232
« Reply #1 on: October 23, 2024, 11:25:13 pm »
Do you have the serial port as well as the USB port connected to your PC during upload ?
USB connects to serial, so having both connected at the same time isn't a good idea.
The messages you see during the upload attempt, are most likely a time out error.
If you selected COM1 to upload to your Arduino, is COM1 the USB connection, or is it the direct connection to your PC ?

The IDE sends a handshake signal which triggers a necessary reset when connected to the USB port.
If you want to use the direct connection through COM1, there is no reset which will enable the bootloader to accept the oncoming upload.
Therefore, and in that case, you have to handle the reset yourself.
Connect your Arduino, press and hold the reset button on your Arduino.
Tell the IDE to upload the sketch.
Once you see the message in IDE that the upload is starting, immediately release the reset button.
Might take a few retries but that way you should be able to upload your sketch with your direct COM port connection.

If for any reason your upload fails while using the USB connection (without having the same serial connection in use), you can still try this procedure (holding the reset button until upload starts).

If all of the above still fail, you could use another Arduino as programming device.

If i misunderstood which connections are in use at the same time, please tell what is connected at which stage.
 
The following users thanked this post: KEIN NEIN

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13201
Re: Communication issue between Arduino and RS232
« Reply #2 on: October 24, 2024, 12:04:40 am »
Connecting a serial signal source to an Arduino together with the on board USB<=> UART bridge does not work.  They both try to drive the ATmega's RXD pin and invariably cause a conflict so programming fails.   When the USB is disconnected, depending on the board, either the bridge disables its data out or there is a series resistor to manage the level conflict so the external connection to RXD wins, and external serial communication is possible.   

Solution: either disconnect external D0/RXD while programming the Arduino, or use an Arduino with either native USB (e.g. a Leonardo) or more than one serial port so the external serial source doesn't conflict with programming.
 

Offline KEIN NEINTopic starter

  • Contributor
  • Posts: 30
Re: Communication issue between Arduino and RS232
« Reply #3 on: November 01, 2024, 04:30:08 pm »
This is my setup, hope it is shown clear enough, thanks  :)
 

Offline KEIN NEINTopic starter

  • Contributor
  • Posts: 30
Re: Communication issue between Arduino and RS232
« Reply #4 on: November 01, 2024, 04:31:58 pm »
Now I have another problem, windows shows the message: "the device (arduino) malfuctioned and Windows didn't recognize it"
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13201
Re: Communication issue between Arduino and RS232
« Reply #5 on: November 01, 2024, 06:39:56 pm »
So that's a genuine Italian Arduino Uno R3 (at least I *think* its R3)  which means it has an ATmega16U2 or possibly an ATmega8U2 (some older boards) as the USB to serial bridge.  Here's  your board's schematic: https://content.arduino.cc/assets/UNO-TH_Rev3e_sch.pdf (if I've IDed it correctly)
You can see it has 1K resistors between the ATmega328P and the  ATmega16U2 USB to serial bridge, so its unlikely that the conflict with the MAX232 could have blown the ATmega16U2 (that's the QFN32 IC between the USB socket and the RX and TX LEDs).

TROUBLESHOOTING
* The first thing to try is restart your PC.
* If that doesn't help, unplug all leads from the board then try it on a different PC port, with a different USB A to B lead, preferably a nice thick fairly short one you know works on other devices.
* If its still not detected check the board's 5V supply with only the USB connected - if its under 4.5V you've got a problem!
* If low/no 5V - disconnect and try taking the ATmega328P out of its socket, wait five minutes (to give the 500mA polyfuse time to reset) then reconnect the USB.  if the 5V comes up and it now is seen by the PC you've badly blown the ATmega328P (which was shorting the +5V) and need a new one, which you'll need programmed with the Arduino bootloader using another Arduino, or an AVR programmer or buy it pre-programmed.  If the 5V doesn't come up, disconnect and put the ATmega328P back.

At this point, if its still broke, you need an expert - it may well be quicker/cheaper/easier to replace the whole Arduino!

« Last Edit: November 03, 2024, 02:23:55 am by Ian.M »
 
The following users thanked this post: KEIN NEIN

Offline MAS3

  • Contributor
  • Posts: 34
  • Country: nl
Re: Communication issue between Arduino and RS232
« Reply #6 on: November 03, 2024, 12:36:32 am »
Thanks, a picture tells more than a thousand words, and you submitted 2 of them.
The pictures confirm my first suspect, you are using USB connected to your PC, whilst at the same time have a serial to TTL solution connected to pins 0 and 1 and at the other side of that solution connected to the same PC.
Pins 0 and 1 are the same pins on your controller connected to the on board serial to USB solution.
You cannot use these at the same time, use either one of those but not both at one time because that will lead to conflicts as you've found out.
So try again with only the USB cable connected while programming.
So no external power supply (USB's power should be enough for uploading your code) and no MAX232.
Do not use pins 0 and 1 in your code for anything else than serial communications.

If this will not work and your Arduino is still not recognised, try it the other way around:
Disconnect the USB cable, reconnect the MAX232 and the external power supply, and power up.
Point your IDE to the MAX232 at com1.
Press the reset button on your Arduino and hold it.
Start the upload, keeping the button pressed and watch the progress in IDE.
Once you see the IDE telling you the upload actually starts, release the reset button.

I'm not sure you need to cross RX and TX between MAX232 and Arduino so if this still doesn't work, try to change that.

Once you successfully uploaded your code (in whatever way), you can use the MAX232 to connect to your PC or any other device with a com port.
Still do not use the USB cable while he MAX232 is connected to pins 0 and / or 1.
Perhaps you could power your Arduino through a USB wall wart, but that would depend on the make and model of that wall wart.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13201
Re: Communication issue between Arduino and RS232
« Reply #7 on: November 03, 2024, 02:34:30 am »
@MAS3,
 Please explain how connecting an external serial converter to ATmega328P (Arduino)  RX and TX can prevent the ATmega16U2 enumerating as a USB device!   Note my comment above about the 1K protection resistors between the ATmega16U2 and Arduino RX and TX.


However I agree with you that programming the Arduino via USB with RX and TX connected externally to another serial interface cant work.  In fact I have run into this issue myself with a WiFi connected Arduino Uno based robot buggy a few years ago.  To allow it to be programmed via USB I had to add a switch to disconnect the ESP8266 WiFi to serial bridge from Arduino RX and TX.
 

Offline MAS3

  • Contributor
  • Posts: 34
  • Country: nl
Re: Communication issue between Arduino and RS232
« Reply #8 on: November 04, 2024, 12:21:45 am »
I can't explain that.
But this was not the first question and i have to assume (and i know what assumption is) that TS has been trying all kinds of things to solve his problem.
As the 16u2 is a controller itself, it may have suffered and lost it's program.
That device isn't infallible and i've seen similar questions / problems before.

If you cannot use that path, try the alternatives i suggested.
I tried to explain how upload is initiated and how you can try to trick the bootloader to accept the upload without the "remote reset".
 

Offline KEIN NEINTopic starter

  • Contributor
  • Posts: 30
Re: Communication issue between Arduino and RS232
« Reply #9 on: November 10, 2024, 05:33:51 pm »
I restarted my PC and now it works as normal, thanks
 
The following users thanked this post: Ian.M


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf