it should work if you have for example two adapters of the same manufacturer
then you get USB0 and USB1 for example which then lead to com1 and com2 in CODESYYS, but if you have two different like for example
USB0 should be your com1 and tty2 your com2:
I would give the following a try:
Use the settings as done in my description,
then make a symlink under Linux to the next serial Interface. (in that example from tty2 to USB1)
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have tested 2 serial adapters, connected on the same time. They are from different manufacturer, but I still get USB0 and USB1 on Raspberry.
I made nothing more than described in Edwin’s description:
But there is another question:
For example:
-we have 2 adapters connected.
-first one on Raspberry USB socket 1 and second one on Raspberry USB socket 2.
-first one will be ttyUSB0, which is COM1 in Codesys, second one is ttyUSB1, which is COM2 in Codesys.
-if we disconnect first adapter or it has a fault, the second one will become ttyUSB0 - COM1 in Codesys, which is wrong.
How can we fix specific USB/serial adapter to specific COM in Codesys, that first adapter will always be COM1 and second one will always be COM2?
Best regards,
Zdenko.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
please google for udev rules raspberry pi,
guess this should show you, how you could link a specific device to always the same device
maybe links like: http://superuser.com/questions/536478/h ... -addresses
could help on this issue.
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to use your project "SerialComWithVisu.project" with one USB to serial cable but It doesn't work.
My Codesys release is V3.5 SP5 patch 2 and on Raspberry it's 2.0.1.0
I have the error ERROR_UNKNOW.--> I set :
udiPort:= 0,
udiBaudrate:= 9600,
paParity:= COM.PARITY.NONE,
sbStopBits:= COM.STOPBIT.ONESTOPBIT,
udiByteSize := 8 );
I tested my connection directly from the Raspberry with Minicom (thru dev/ttyUSB0) and it was working perfectly (emission & reception).
my baudrate is 9600bds.
I checked on the CODESYScontrol.cfg but the [SYSCOM] § doesn't exist !!!
Do you have an idea about what's wrong ?
Thank you for your help
Christian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I modified the file CODESYSControl.cfg (I have just understood that I had to do the modification on the Raspberry side, sorry...).
Now, it's done.
I added 0 to ttyUSB to have ttyUSB0 but it doesn't work anymore (I tested again with minicom & it was working on ttyUSB0 !)
on a window side (in Codesys) I tested
- udiPort:= 0, and
- udiPort:= 1,
without success, I have the same ERROR_UNKNOW !
Do you have another suggestion or idea where the issue comes from ?
thank you
Christian,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i have problems to read from COM in Codesys.
I modified the Project from this thread. I´ve connected a PILZ PNOZmulti with USB to the Raspberry. The USB-Serial Converter works with an FTDI chip. The comWrite send the hex string i want to the PILZ. When i use the Terminal with:
stty -F /dev/ttyUSB0 192000
stty -F /dev/ttyUSB0 raw
cat /dev/ttyUSB0 | od -tx1
the right answer comes back in hex. But i can´t get codesys to recognise it. The ReadBuffer is always empty. Whether i use a timer after the comWrite or not.
Any suggestions?
Best regards,
Daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello. I am having the same problem as the one you seemed to be having. I am getting a read response from my motor controller, but the readBuffer within Codesys is always empty. What did you do to fix your problem?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
could you attach /etc/CODESYSControl.cfg to this post or at least check if your entry for your SerialCom
device is in. (This is what you need to add manually)
in your case it is:
[SysCom]Linux.Devicefile=/dev/ttyUSB
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Edwin Schwellinger hat geschrieben:
Hi,
more Details... which error an where do you see the error ?
Could you use AMA0 in the console in Linux?
BR
Edwin
Good afternoon. I can't attach a screenshot at this topic, have some error;
I use handmade converter on ST485 and npn transistors wich switch direction of USART transmission data. In Raspbian I'm configuring only this - sudo nano /etc/CODESYSControl.cfg
Linux.Devicefile=/dev/ttyAMA
portnum := COM.SysCom.SYS_COMPORT1;
I have configured after
Master device modbus config in Codesys: 9600, 8E1;
Settings in slave device: adress#1, 9600, 8E1
When I login via Codesys, mastes device is run ok (green circle near Master device in Codesys), but slave not response and i have an erron "Bus is not run";
Auto reconection on bus enabled;
How can I check UART in Linux console? And what I must configure in Raspbian for working USART?
BR. Osman
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Edwin Schwellinger hat geschrieben:
Hi Osman,
use a terminal and the following: (sure in your case you need a USB-RS485 converter on Windows to test )
BR
Edwin
I conect USB-RS485 converter on Win PC and raspberry...
ttyAMA0 does not transfere the data;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone I've solved problem. Problem was in electronic circuit on ST485. I've deleted one transistor and connected PIN4 to the GND. On Raspberry I did this:
cp /boot/cmdline.txt /boot/cmdline.bak
cp /etc/inittab /etc/inittab.bak
Next: sudo nano /boot/cmdline.txt
delete this string "console=ttyAMA0,115200" и "kgdboc=ttyAMA0,115200"
Next: sudo nano /etc/inittab
and change string: T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 to #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Thank you very much for help!
BR
Osman.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-09-16
Originally created by: OW_RPi
Hi,
I have an USB-Serial-Adapter and followed Edwin's instructions but when I listen to the port (cat /dev/ttyUSB0) there is no response
(sending data via sencond terminal).
Any idea what I do wrong?
Best regards,
Oleg
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
it should work if you have for example two adapters of the same manufacturer
then you get USB0 and USB1 for example which then lead to com1 and com2 in CODESYYS, but if you have two different like for example
USB0 should be your com1 and tty2 your com2:
I would give the following a try:
Use the settings as done in my description,
then make a symlink under Linux to the next serial Interface. (in that example from tty2 to USB1)
BR
Edwin
Hello,
I have tested 2 serial adapters, connected on the same time. They are from different manufacturer, but I still get USB0 and USB1 on Raspberry.
I made nothing more than described in Edwin’s description:
And it works on COM1 and COM2 in Codesys.
But there is another question:
For example:
-we have 2 adapters connected.
-first one on Raspberry USB socket 1 and second one on Raspberry USB socket 2.
-first one will be ttyUSB0, which is COM1 in Codesys, second one is ttyUSB1, which is COM2 in Codesys.
-if we disconnect first adapter or it has a fault, the second one will become ttyUSB0 - COM1 in Codesys, which is wrong.
How can we fix specific USB/serial adapter to specific COM in Codesys, that first adapter will always be COM1 and second one will always be COM2?
Best regards,
Zdenko.
Hi Zdenko,
please google for udev rules raspberry pi,
guess this should show you, how you could link a specific device to always the same device
maybe links like:
http://superuser.com/questions/536478/h ... -addresses
could help on this issue.
BR
Edwin
Hi Edwin,
Thank you very much. I will try this asap.
Best regards,
Zdenko.
Hello Edwin,
I tried to use your project "SerialComWithVisu.project" with one USB to serial cable but It doesn't work.
My Codesys release is V3.5 SP5 patch 2 and on Raspberry it's 2.0.1.0
I have the error ERROR_UNKNOW.--> I set :
udiPort:= 0,
udiBaudrate:= 9600,
paParity:= COM.PARITY.NONE,
sbStopBits:= COM.STOPBIT.ONESTOPBIT,
udiByteSize := 8 );
I tested my connection directly from the Raspberry with Minicom (thru dev/ttyUSB0) and it was working perfectly (emission & reception).
my baudrate is 9600bds.
I checked on the CODESYScontrol.cfg but the [SYSCOM] § doesn't exist !!!
Do you have an idea about what's wrong ?
Thank you for your help
Christian
Hi,
you need to add the comport device depending on your used connection ( USB / TTY / whatever )
in /etc/CODESYSControl.cfg please add manually
[SysCom]Linux.Devicefile=/dev/ttyUSB
according to your used interface /ttyAMS .... /tty ...
Regards
Edwin
Hello Edwin,
Thank you for your prompt answer.
I modified the file CODESYSControl.cfg (I have just understood that I had to do the modification on the Raspberry side, sorry...).
Now, it's done.
I added 0 to ttyUSB to have ttyUSB0 but it doesn't work anymore (I tested again with minicom & it was working on ttyUSB0 !)
on a window side (in Codesys) I tested
- udiPort:= 0, and
- udiPort:= 1,
without success, I have the same ERROR_UNKNOW !
Do you have another suggestion or idea where the issue comes from ?
thank you
Christian,
Hi Christian,
if your serial port is ttyUSB0
your config fileCODESYSControl.cfg should be without the '0'
[SysCom]Linux.Devicefile=/dev/ttyUSB
that's it.
Regards
Edwin
Hi Edwin,
thank you for your patience, now it works very well.
thank you again,
Hi,
I managed to fix COM port numbers COM1-COM4 to USB sockets on Raspberry Pi B+ .
This is the procedure:
-sudo nano /etc/CODESYSControl.cfg
Add this:
-sudo nano /etc/udev/rules.d/serial-symlinks.rules
Add this:
-Reboot
That's it!
Best regards,
Zdenko.
Hi,
How can I get Error status bit for Modbus_COM_1?
Best regards,
Zdenko
Sorry, posted in other topic...
l viewtopic.php?f=21&t=5986&p=12004#p12004 l
BR
Osman
Hello,
i have problems to read from COM in Codesys.
I modified the Project from this thread. I´ve connected a PILZ PNOZmulti with USB to the Raspberry. The USB-Serial Converter works with an FTDI chip. The comWrite send the hex string i want to the PILZ. When i use the Terminal with:
stty -F /dev/ttyUSB0 192000
stty -F /dev/ttyUSB0 raw
cat /dev/ttyUSB0 | od -tx1
the right answer comes back in hex. But i can´t get codesys to recognise it. The ReadBuffer is always empty. Whether i use a timer after the comWrite or not.
Any suggestions?
Best regards,
Daniel
Hello. I am having the same problem as the one you seemed to be having. I am getting a read response from my motor controller, but the readBuffer within Codesys is always empty. What did you do to fix your problem?
Thanks
Hi nosi,
could you attach /etc/CODESYSControl.cfg to this post or at least check if your entry for your SerialCom
device is in. (This is what you need to add manually)
in your case it is:
[SysCom]Linux.Devicefile=/dev/ttyUSB
BR
Edwin
Hello Edwin,
thank you for answering. I checked the .cfg . But i added the lines manually before.
I found the problem. Somehow another programm cut the connection.
Best Regards,
Daniel
Hi everyone! How to configure the RAspberry UART port in Linux?
I did only this:
sudo nano /etc/CODESYSControl.cfg
[SysCom]
Linux.Devicefile=/dev/ttyAMA
portnum := COM.SysCom.SYS_COMPORT1;
But have an error;
Hi,
more details... which error an where do you see the error ?
Could you use AMA0 in the console in Linux?
BR
Edwin
Good afternoon. I can't attach a screenshot at this topic, have some error;
I use handmade converter on ST485 and npn transistors wich switch direction of USART transmission data. In Raspbian I'm configuring only this - sudo nano /etc/CODESYSControl.cfg
Linux.Devicefile=/dev/ttyAMA
portnum := COM.SysCom.SYS_COMPORT1;
I have configured after
Master device modbus config in Codesys: 9600, 8E1;
Settings in slave device: adress#1, 9600, 8E1
When I login via Codesys, mastes device is run ok (green circle near Master device in Codesys), but slave not response and i have an erron "Bus is not run";
Auto reconection on bus enabled;
How can I check UART in Linux console? And what I must configure in Raspbian for working USART?
BR. Osman
Hi Osman,
use a terminal and the following: (sure in your case you need a USB-RS485 converter on Windows to test )
l viewtopic.php?f=21&t=5699#p10300 l
next step could be - use the serial example and a terminal.
Last step is use modbus with your device
BR
Edwin
I conect USB-RS485 converter on Win PC and raspberry...
ttyAMA0 does not transfere the data;
Hi everyone I've solved problem. Problem was in electronic circuit on ST485. I've deleted one transistor and connected PIN4 to the GND. On Raspberry I did this:
cp /boot/cmdline.txt /boot/cmdline.bak
cp /etc/inittab /etc/inittab.bak
Next: sudo nano /boot/cmdline.txt
delete this string "console=ttyAMA0,115200" и "kgdboc=ttyAMA0,115200"
Next: sudo nano /etc/inittab
and change string: T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 to #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Thank you very much for help!
BR
Osman.
Originally created by: OW_RPi
Hi,
I have an USB-Serial-Adapter and followed Edwin's instructions but when I listen to the port (cat /dev/ttyUSB0) there is no response
(sending data via sencond terminal).
Any idea what I do wrong?
Best regards,
Oleg
Hi Oleg,
you need to show the /etc/CODESYSControl.cfg
BR
Edwin
Originally created by: OW_RPi
Hello Edwin,
thank you for your support!
Best regards,
Oleg
Last line of dmesg:
[ 1399.272505] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
Last few lines of CODESYSControl.cfg:
[CmpCodeMeter]
InitLicenseFile.0=3SLicense.wbb
[SysEthernet]
Linux.ProtocolFilter=3
[SysCom]
Linux.Devicefile=/dev/ttyUSB
portnum := COM.SysCom.SYS_COMPORT1;