Go Down

Topic: Serial communication problem [solved] (Read 584 times) previous topic - next topic

Tactic

Oct 28, 2013, 05:18 pm Last Edit: Aug 22, 2014, 12:56 pm by Tactic Reason: 1
Hey,

I have some problems with serial communication on my Arduino Nano 3. I try to drive a motor over a Faulhaber motion controller via Rx and Tx. I connected Tx of the Arduino over a level converter (MAX232) to Rx of the motion controller and similar to that Rx to Tx. This is my sketch:


Code: [Select]
void setup(){
 Serial.begin(9600);
}
void loop(){
 delay(10000);
 Serial.print("en");
Serial.print("v1000");
 delay(1000);
 Serial.print("v0");
 Serial.print("di");
 delay(2000);
}



The delay in the beginning is for uploadind new sketches (I had some problems uploading while the Arduino was using Rx and Tx). If I start the sketch, nothing happens. But I'm quite sure I connected everything alright because the serial monitor shows that the Arduino is executing the sketch. Motion controller can't be broken because if I drive it with a Motion Manager from the computer it works fine. I really don't know what to do now. Can anybody help me? I'm really desperate because I try to fix the problem for a week and can't find any solution.


groundfungus

I don't know abut the Nano, but can you set up a software serial port to the motor controller?  I don't see how it could work if you have both the Serial Monitor and motor controller attached to the same port.

Tactic

I don't know if I got your question. My computer is connected to the Arduino via MiniUsb and the Serial Monitor reads data through that.
By the way, I read Arduino data out with a Terminal directly connected to Rx and Tx of the motion controller and it says the same like the serial monitor. So that's pretty strange because it shows that data arrives at the controller.

Robin2

I think you will need to give a lot more information.

What is a Faulhaber motion controller? Can you post a link to its datasheet? how does it work? how have you connected it to your Nano?

What is Motion Manager? How does the motion controller connect to the PC when it works that way? What does the PC send?

Why do you need a level converter? Is a level converter needed when it is controlled directly by the PC?

...R

macegr

Please note that the mini-USB port is connected to an FTDI converter, which has RX and TX pins connected to the Arduino's RX and TX pins. So when you attempt to use the Arduino USB serial monitor along with something else on the RX and TX pins, you'll see conflicts. It's absolutely no surprise that code download would be a problem with the motor controller also attached to those pins.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

Tactic

Quote
I think you will need to give a lot more information.

What is a Faulhaber motion controller? Can you post a link to its datasheet? how does it work? how have you connected it to your Nano?

What is Motion Manager? How does the motion controller connect to the PC when it works that way? What does the PC send?

Why do you need a level converter? Is a level converter needed when it is controlled directly by the PC?

...R


http://www.faulhaber.com/manuals/sites/en/steuerungen/mcdc_3003_p_cf.html
http://www.faulhaber.com/n171156/i672617.html

Here are some manuals and a datasheet for the motion controller (MCDC 3003).
I've already used these controllers with an AVR and it only worked by connecting a USB-to-RS232-bus between +5V/Ground and Rx/Tx. Apparently there was a level converter in this bus.
Motion manager is a program by Faulhaber. If I connect Tx,Rx and Ground of USB-to-RS232 from my computer to the corresponding pins of the motion controller (also Rx, Tx and Ground), I can type commands like "v500" and the motor moves. So: no, no extra level converter.
Using my Arduino it doesn't work either without a level converter. I'm pretty sure I need it.

Robin2

Ok, it looks like the level converter is required. But you haven't provided a diagram of how you have the whole thing connected to the Nano.

And you say you can send commands like "V500" but the code you have posted doesn't do that.

Presumably you have checked with the Serial Monitor that the Nano is producing the correct commands.

Does the Faulhaber require or object to carriage-return line-feed?

...R


holmes4

Look up RS232 you can not drive the RS232 interface directly from serial. You need an RS232 to TTL converter. That's not the same as a level converter.

Mark

Tactic

Quote
Look up RS232 you can not drive the RS232 interface directly from serial. You need an RS232 to TTL converter. That's not the same as a level converter.


As I said,I earlier used an avr with a usb-to-rs232 bus and it worked. No level converter. I recently tried the same with the Arduino and it didn't work.

PeterH

As well as the serial speed, you need to check what start/stop and parity bits are expected by the controller. If the Arduino is transmitting with any of those settings wrong then the controller would discard it as invalid input.
I only provide help via the forum - please do not contact me for private consultancy.

Tactic

Do you know how to change these settings?

PeterH

Some of them can be set when you open the Serial port.
I only provide help via the forum - please do not contact me for private consultancy.

nmsneves

Hey Tactic, did you do any progress on this?

recently I had a chance to test a motor from the same manufacturer Faulhaber, and I tested them with Motion Manager,
but I did not try to connect to Arduino (yet).
surely it will require the use of a circuit like the MAX232, and also the use of the SoftwareSerial library.

Tactic

#14
Aug 22, 2014, 12:51 pm Last Edit: Aug 22, 2014, 12:54 pm by Tactic Reason: 1
Hi,

thanks for all your replies and advices. The problem turned out to be the carriage return and line feed. So eventually a simple change to Serial.println instead of Serial.print solved everything. The motion controller needs this new line after every command to perform them correctly.

A MAX232 as a level converter is also necessary.

So this was the working sketch:



Code: [Select]
void setup(){
 Serial.begin(9600);
}
void loop(){
 Serial.println("en");
Serial.println("v1000");
 delay(1000);
 Serial.println("v0");
 Serial.println("di");
 delay(2000);
}



Special thanks to Robin2 who already mentioned the possible problem in the beginning  :)

Go Up