Controlling a stirrer with RS232

Hello Arduino Community!

I am currently working on a project that allows me to control a stirrer using a RS232 port, and I based my project on: RS232 to TTL converter for weighing scale not working [SOLVED] - #114 by AnshumanFauzdar. So the scheme is the following:

Arduino WiFi Rev. 2>TTL to RS232 module>RS232 from the stirrer

Connection

The code I adapted to my project which uses a CAT R100 CL stirrer with the manual available at: https://www.cat-ing.de/cat-ing/produkte/Bedienungsanleitungen%20stand%2005-07-19/Ruehrer/Instruction%20manual%20R100C%20-%20R100CL%20-%20R100CT.pdf.

So, clearly I am doing something terribly wrong because it does not work. Is there any suggestions on how to bring my little but lovely project to life??

Thank you all!
Juan

...but didn't post

Read the forum guidelines to see how to properly post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Hey @jdserrano655 Please post your code and hardware schematic and if possible also attach picture showing RS232 to TTL converter connections and any other microcontroller connection you might be using.

Which arduino? You may try to include some serial prints to the serial monitor to help debug your program.

Check your serial bitrate to ensure the devices are matched

No, no it doesn’t, or you prolly wouldn’t be here asking for help…

When you post your code, tell us what it’s doing that it shouldn’t, or not doing that it should.

That would be helpful to us.

a7

Try ramping up to speed.
Also check viscosity.
You may need a longer ramp time

Thank you so much to all of you for joining. As you can see that was indeed my first post, so here you can find the following setup:

With the following code:

//Copy from: https://forum.arduino.cc/t/rs232-to-ttl-converter-for-weighing-scale-not-working-solved/567570/114

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX <------< Use the pins you want

void setup()
{
  // Open serial communications and wait for port to open
  Serial.begin(1200);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(1200);
}

void loop()
{
  while (mySerial.available())
  {
    Serial.write(mySerial.read()); 
  }
}

Baud rate of the stirrer is 1200 by default.

RS232 has a few hardware handshake pins. I have had to make cables to connect PCs to printers back in the day and IIRC, every one was different. You may need to tie CTS or RTS or DTR (or whatever the others are) high or low to persuade the scale to talk - check the manual.

Can you talk to it from a PC?

Do you have a common ground connection?

Not seeing it in you drawing.

Also do you mean to be reading and writing to just one serial port?

What are you hoping your simple example test will do?

a7

@wildbill I have not tried that. Yes, there is supposed to be a program provided by the company, but I believe that was provided 10 years ago in CD's that I don't have.

In the manual the pins are specified but which one of the following should those be?

grafik

Yes, I connected both GND 5 pins from the RS232 ports , and the GND from the TTL side of the module at the GND of Arduino.

Here is a picture so it's easier to visualize:

General

TTL to RS232 module

Arduino

RS232 ports

I'm hoping to be able to speak to the stirrer to make a stirring protocol of 4 steps, but first I need to know if the stirrer is receiving and transmiting data. Then, I would be able to write a simple code to speak to it using the commands from the manual:

THX. Actually a single line in the schematic would have done, but it is apparent that the modules you use are making the true good ground connection.

I have booked an appointment with the eye doctor. That is to say I looked again at your code.

What you are doing, I think, is "listening" to the stirrer. It may not say anything until poked.

I am with @wildbill, the easiest way to confirm that your device is there and reachable is to use a serial communication program on your PC.

I use CoolTerm, but the key will be any serial comms program with the ability to send any arbitrary characters. Most can, but you may need to send actual low ASCII characters, which a few make hard or cannot.

Your chart of commands doesn't say woh the "command codes" are formed. Perhaps more is said in the document. The commands might be single characters or larger formatted sequences with a command code embedded in them.

Use CoolTerm or another of your choice to send commands to the stirrer and examine its repsonse, if any.

Start with RTY, which looks like a good poke to give it so it talks.

The beauty of using CoolTerm is that you are not messing around with an Arduino program at the same time, less to wonder about. CoolTerm works.

And you can experiment with comms parameters all day long without a single recompile, upload and debug cycle.

Ffrom the docs so far, it doesn't look like you'll need extra handshaking. But keep it in mind. Most of the things I talk to with serial in the modern age (oxymoron alert!) are perfectly happy with three wires, TX, RX and GND. CoolTerm is or can be adjusted to use only these three lines, but it will also allow you to test any theories about extra control signals.

So… does the document go into any detail about the format and coding of command characters or sequences?

a7

starting at page 17 is shows the typical connections and discusses the communication.

your simple schematic shows crossing the TX/RX, but for the 9 pin, the manual shows it different. Page 18

[It's how cables may be made and the cable connection to the chip]

OK, I see the link to the document.

I don't think you need the extra control lines.

The commands seem to be all in readable ASCII and literal, so try sending

1RTY1

followed by a carriage return and see what you get back.

Serial.write("1RTY1"); Serial.write(13);

Then start listening and echoing anything you get back, like your code is doing now.

This is simple enough to just do with the Arduino if you are certain about getting the comms parameters correct - they are spelt out clearly in that doument.

I'd still use CoolTerm, but you do you.

a7

Yes! you are right. I already set them as shown at page 17, but still not getting signal back.

Ok, I implemented the code:

//Copy from: https://forum.arduino.cc/t/rs232-to-ttl-converter-for-weighing-scale-not-working-solved/567570/114

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1); // RX, TX <------< Use the pins you want

void setup()
{
  // Open serial communications and wait for port to open
  Serial.begin(1200);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(1200);
  // asks for Read Type Information of unit
  Serial.write("1RTY1"); Serial.write(13);
}

void loop()
{
    while (mySerial.available())
    {
     
      Serial.write(mySerial.read());   // You can also use: Serial.print((char)mySerial.read());
      delayMicroseconds(200);
    }
}

And I'm getting nothing back:

I tried the format as suggested in the manual (1,RTY,1) but also nothing back. Although I tried as well with the stirrer in operation (in case that would get it to talk), still got no response.

Btw I will download CoolTerm because it's indeed pretty annoying having to compile/upload every change to Arduino.

Why is mySerial sharing pins 0 and 1 now?

I was confused by seeing the 1RTY1 on your serial monitor.

You did have

SoftwareSerial mySerial(2, 3);

originally, and I think this are the pins to use and you should be sending to mySerial.

And that’s my fault, for that is what I wrote.

So sry for causing a possible waste of time.

Do get CoolTerm, but try

  • place mySerial back on 2, 3
  • put a delay(1000); before you
  • send the 1RTY1 (13) to mySerial…

The delay is superstitious, it can’t hurt.

Also, you can try retrying by hitting the reset button on the Arduino, or closing and open the serial monitor window rather than just getting going from scratch by the upload process.

The commas I don’t think enter into it, but that is worth trying.

Again, I apologize for my sloppy previous response.

a7

It was my bad, I set the wrong pins for mySerial. I now implemented your corrections:

//Copy from: https://forum.arduino.cc/t/rs232-to-ttl-converter-for-weighing-scale-not-working-solved/567570/114

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX <------< Use the pins you want

void setup()
{
  // Open serial communications and wait for port to open
  Serial.begin(1200);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(1200);
  delay(1000);
  // asks for Read Type Information of unit
  Serial.write("1RTY1"); Serial.write(13);
}

void loop()
{
    while (mySerial.available())
    {
      Serial.write(mySerial.read());   // You can also use: Serial.print((char)mySerial.read());
      delayMicroseconds(200);
    }
}

But I'm still getting the 1RTY1 back on the serial monitor:

Maybe I'm overlooking something in the code.

No, this should be sent to the stirrer, which is on mySerial.

 mySerial.write("1RTY1"); mySerial.write(13);

Easy to miss, but I did get it more right:

  • send the 1RTY1 (13) to mySerial…

And just now I see

PARAMETERLIST:1 to 6 parameters separated by commas

Yikes,

so try

 mySerial.write("1,RTY,1"); mySerial.write(13);

Sorry gain, tots missed that when I carefully studied breezed through the document.

a7