RS232, Working correctly from PC but not from Arduino. dont know why.

Hi All,

I posted here a few weeks ago and got some helpful replies which progressed my project quite a bit but now I'm stumbling again.

I have : An Arduino Nano
A TTL to RS232 Converter
A peltier effect controller (with RS232 input)

What I want to do is send serial commands from the Arduino to the peltier effect controller so that I can control it by sending new temperature set points to it.

I have the manual for the peltier effect controller which describes the format for serial messages. Using this I connected the controller to a PC using a USB to RS232 converter. On the PC I then opened a terminal program and sent the command I wanted. The peltier effect controller responded and the set point changed successfully.

I then tried connecting the Arduino using the TTL to RS232 converter and sending the exact same message but I got neither a reply or any change in set point on the controller.

To test the TTL to RS232 converter I connected the Arduino to the PC (different PC than I was programming with) using: Arduino -> TTL to RS232 -> RS232 to USB. Opening the terminal program on the PC I could see the serial commands coming in correctly so nothing was wrong with what I was sending.

I then thought that I might have a grounding problem so I disconnected the Arduino from the USB of the other PC I was using to program it and connected a separate 5V power supply and it still didn't work.

Finally, I got a scope out and compared the signal being sent out of the PC using the terminal program to the signal being sent out of the Arduino; Both look identical.

I'm now out of ideas so would be very appreciative of any of yours

Cheers

Steve

Just another thing. Supposing the Arduino receive correct answer but it doesn't able to process correctly.

Yep, that could well be the case, but I haven’t got round to receiving yet, just sending, trying not to run before I can walk.

void setup() {
    Serial.begin(115200);
}

void loop() {
Serial.println("$R0=30.5");
}

That’s how complicated the program is at the moment. that $R0=30.5 command is the exact same command that I tested working from the PC.

::slight_smile:

Your loop is sending command again and again....
You have to add some condition and also read the answer from Serial. Next, to do something with the answer.
Start with the simple code like this:

void setup() {
    Serial.begin(115200);
    Serial.println("$R0=30.5"); // send the command just once after reset
}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

  // read a character
    byte c = Serial.read();

// decide what to do else
  }
}

The examples in Serial Input Basics should be useful for receiving a response from your peltier controller.

Using a Mega (or Leonardo or Micro) so you can have a separate hardware serial port for the peltier controller would make development and debugging much easier.

...R

Yes, another serial port would be useful or use the SoftwareSerial lib.

Thanks Guys.

Yes I do actually have more code ready to deploy for when I get this part ready. My reading code is very similar to the code posted as adapted from the link you posted. At the moment though that part of the project is unimportant as I'm separately measuring the temperature of the peltier controller so I'm just looking for a change in temperature from the peltier controller in response to my sending of the set point command.

megamef:
Yes I do actually have more code ready to deploy for when I get this part ready. My reading code is very similar to the code posted as adapted from the link you posted. At the moment though that part of the project is unimportant as I'm separately measuring the temperature of the peltier controller so I'm just looking for a change in temperature from the peltier controller in response to my sending of the set point command.

Does all that mean that you now have it working?

...R

No, I haven’t got it working. I’ve just simulated the parsing bit of code using the Arduino serial monitor but still nothing from my peltier controller. To keep things simple for the purposes of debugging just the transmitting part I’ve put the receiving part to the side for now.

megamef:
No, I haven’t got it working. I’ve just simulated the parsing bit of code using the Arduino serial monitor but still nothing from my peltier controller. To keep things simple for the purposes of debugging just the transmitting part I’ve put the receiving part to the side for now.

Like Reply #6, that does not convey anything that I can help with.

…R

I'd love to provide info that you could help with but I don't know what the problem is myself. I'm trying to present the problem as simply as I can and make sure I've done my diligence before posting here, that's why I explained that I'm only trying to send serial data and not worry about receiving it at this stage.

I don't think you have posted a link to the datasheet for the Peltier controller - that should be the first step.
For example I have no idea whether it makes sense to send data without listening for a response. And using the link I gave you in Reply #4 there should be no problem listening for a response.

When you make changes to your code and try something new you should post the latest code and tell us what it actually does and what you want it to do differently.

It is also a good idea to include a specific question in a post.

...R