Author Topic: Serial communication  (Read 13574 times)

StefanA

  • Newbie
  • *
  • Posts: 29
  • I'm a llama!
    • View Profile
Serial communication
« on: June 13, 2013, 09:48:19 AM »
Hi,
I have a small and cheap MCU with a Rs232 interface which I have some plans to use building a wireless sensor. Is it possible to make the MCU communicate with a Nano-10 using a RS232 to 485 converter? I have done some "sucessful" tests with a PC and hyperterminal together with a Nano, but connecting the MCU with the Nano-PLC maybe isn't the same thing?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial communication
« Reply #1 on: June 13, 2013, 09:51:48 PM »
Nano-10 has an RS485 interface and that is not directly compatible with RS232. You will need a converter (e.g. Auto485) to convert the signal from RS485 to RS232.

You can also use a FMD PLC which has built-in RS232.

Our PLC can send and receive data via RS232 or RS485 port, no problem. The issue is what can your micro do with the data it receive. You can program your small micro to send some ASCII data out of the serial port when something happen and the Nano-10 or FMD PLC can happily receive these characters and work on them according to your program.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

StefanA

  • Newbie
  • *
  • Posts: 29
  • I'm a llama!
    • View Profile
Re:Serial communication
« Reply #2 on: June 16, 2013, 07:42:42 AM »
Ok, I have a Rs232 to 485 converter  which I used together with a PC and Hyperterminal to send ASCII data to my Nano. I also tested to send character strings from the MCU to my PC.

 I have not been able to send data from the MCU to the Nano using the same converter plugged into the MCU development board.

Any idea why this isn't working when they both can communicate with my PC.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial communication
« Reply #3 on: June 16, 2013, 08:35:57 AM »
If they are the same baud rate, then what your MCU sent to Nano is likely to have been received. But in your Nano-10 program did you check for incoming data using INPUT$(1)? The incoming data has to be terminated with CR in order for INPUT$(1) to receive. The following routine can be used:
    Clk:1.0s              F1
|---||----------------{dCusF}

Inside F1

A$ = INPUT$(1)
IF LEN(A$) <> 0
    B$ = A$            ' save the incoming data
ENDIF

What you sent to Nano-10 from your MCU should appear on B$ if all goes well. Remember to terminate what you sent from MCU to Nano-10 with a CR character.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

StefanA

  • Newbie
  • *
  • Posts: 29
  • I'm a llama!
    • View Profile
Re:Serial communication
« Reply #4 on: June 17, 2013, 10:27:54 AM »
The baud rate and other parameters are the same.

The manual to the MCU states that the PRINT command (which I trying to use) attaches a new-line character to the transmission. Is a new-line character the same as carriage return? It sounds a bit similar.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial communication
« Reply #5 on: June 17, 2013, 08:09:24 PM »
Yes, the PRINT #n command appends a CR (ASCII 13) to the end of the string.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS