can you change it to both CR+LF just in case?
Changed it. Still nothing happens
I will try to see if my MAX232 is fried
I have to leave the laboratory now
can you change it to both CR+LF just in case?
Changed it. Still nothing happens
I will try to see if my MAX232 is fried
I have to leave the laboratory now
you'll have to explain how you wired / powered your RS232 board
My mistake, I misread Rodrigo's post and thought he was talking to the laser over terminal at that speed.
no worries
Another test you could try would be to see if the Arduino and MAX232 can talk to your terminal program.
see if the Arduino and MAX232 can talk to your terminal program.
tested it now. There is no communication between the arduino and the terminal emulation program. I am starting to feel that the MAX232 is fried
it always has the D1 pin lighted up when it is on. other pins are always OFF.
you'll have to explain how you wired / powered your RS232 board
the connections are:
MAX232 -----to----- Arduino Mega (cable colour)
RX -----------------------TX1 (yellow)
TX ----------------------- RX1 (orange)
VCC -----------------------5V (red)
GND-----------------------GND (brown)
From the photo, it almost looks like power is plugged into 3V3.
It's hard to know which way round RX/TX should go when there are so many components along the way that may switch them.
it almost looks like power is plugged into 3V3.
I know, I am sorry for the quality. I assure you it is on 5V
I do not understand your last statement, can you rephrase it pls?
You know of course that Arduino RX should go to PC TX and vice versa.
However, does the MAX232 take care of that? Does the RS232 to USB cable do it? Do they both do it and cancel each other out - it's difficult to know unless you can put a meter on it.
that sounds about right
can you try this code
#define laserSerial Serial1
void setup() {
Serial.begin(115200);
laserSerial.begin(57600);
delay(1000); // in case a bit of time is needed on laser side
laserSerial.print(F("RFV\r"));
}
void loop() {
if (laserSerial.available())
Serial.write(laserSerial.read());
}
can't be simpler to test... (Serial monitor open @ 115200 bauds)
I will test that code tomorrow with the laser.
I tested it now with the arduino connected to the terminal emulation program and there is no communication. Tomorrow I will buy a new MAX232 to see if the problem is from the component.
you might want to try with Serial2 or Serial3 in case that port of your Arduino is not working well
So I have been testing several changes to the code and most of them do not work.
What kind of worked was the code I posted bellow. With this code I can recieve communications from the laser, but I cannot send any instructions.
Also one thing that does not make any theoretical sense is the fact that the code only works when the wiring is setted up as bellow:
MAX232 -------------------------------- Arduino Mega
RX------------------------------------------ RX1 (pin 19) ****
TX------------------------------------------ TX1 (pin 18) ****
GND--------------------------------------- GND
VCC---------------------------------------- 5V
**** as you can see RX is connected to RX1 and TX to TX1, and before it was RX to TX1 and TX to RX1.
Could this MAX232 be different from others, and the labeling is related to the arduino connections?
#include <Arduino.h>
#define laserSerial Serial1
const size_t messageMaxSize = 50;
char incomingMessage[messageMaxSize + 1]; // +1 for trailing '\0'
boolean getAnswer(const char endMarker = '\r')
{
static size_t index = 0;
boolean messageComplete = false;
int incomingByte = laserSerial.read();
if (incomingByte != -1)
{
if (incomingByte == endMarker)
{ // do not store the end marker
incomingMessage[index] = '\0';
messageComplete = true;
index = 0;
}
else
{
incomingMessage[index++] = (char)incomingByte;
incomingMessage[index] = '\0';
if (index >= messageMaxSize)
index = messageMaxSize - 1; // don't overflow
}
}
return messageComplete;
}
void setup()
{
Serial.begin(115200);
laserSerial.begin(57600);
Serial.println(F("Ensure Serial monitor's line ending is set to CR"));
Serial.println(F("Ready to send commands"));
}
void loop()
{
// send what we type in
while (Serial.available())
laserSerial.write(Serial.read());
delay(1000);
// listen for an answer
while (getAnswer())
{
Serial.print(F("Laser answered ["));
Serial.print(incomingMessage);
Serial.println(("]"));
}
delay(1000);
}
Don't worry about the wiring mystery. RX must go to TX at the ends, but you have several components connecting laser to Arduino. Any one of them can be crossing them for you.
I suggest that you try J-M-L's simplest code. If you're getting stuff back from the laser that would be a good test that you can send.
if communication seems to go that way, it's possible that the labels on the adaptors are reversed in terms of meaning. Keep it the way it seems to work and test with my simple code indeed
I got an osciloscope and measured the wave comming out of the Arduino Mega TX1 pin.
So I coded the pin to always transmit the same character and compared the wave to the ASCII binary.
The wave form is correct, but the Voltage seems very low, it is 0.5V max. Shouldn't this Voltage be 5V?
It should indeed be 5V. I would suspect that your Oscilloscope setup for Y is set incorrectly. What do you see if you attach the probe to the 5V pin?
Yes, the Y is set for 0.5V so I can see the right shape of the wave. If I set it up for 5V the wave amplitude is too small.
What do you see if you attach the probe to the 5V pin?
If i connect GND and 5V to the osciloscope the Arduino shuts down
If i connect TX and GND to the osciloscope, or TX and 5V to the osciloscope the wave is the same for both cases.
The same happens for TX1 and TX2 of the arduino