ODROID C1+ RS485 framing errors

Moderators: mdrjr, odroid

ODROID C1+ RS485 framing errors

Unread postby martin_p » Wed Dec 28, 2016 12:09 am

We are attemping to use an ODROID C1+ together with an ADM2483 chip to communicate using RS485.

We are using GPIOX.BIT19 and GPIOX.BIT18 to control DE (RTS) and PV on the ADM2483-chip. We have tested the exact same setup with a Raspberry Pi 2 Model B without any problems but when we try the same software with the ODROID we get the following error(s):

Uart 2 Driver: Framing Error while receiving a character

Any suggestions on what could be causing this? Could the choice of GPIO pins be the problem? The schematics seems to indicate that these pins are dedicated for RTS/CTS (as discussed here: viewtopic.php?f=115&t=17279). Could this be a problem for us when when we are using one of these pins for the PV handling of the ADM2483 chip?
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Wed Dec 28, 2016 11:37 am

Did you compile the kernel after modifying the DTS?
Can you check the signal of the RTS/CTS?
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Wed Dec 28, 2016 4:58 pm

We didnt actually follow the approach with modifying the DTS-file. Instead we are using a version of libmodbus which includes support for handling the RTS using a GPIO-pin (https://github.com/stephane/libmodbus/w ... spberry-pi).

We currently doesnt have access to any oscilloscope so unfortunately we cannot monitor the signal that way. But using a USB-RS485 module we have confirmed that the message we sending arrives at the receiver. The problem is since we get that UART error we never seem to get any valid response.
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Wed Dec 28, 2016 7:51 pm

I think RTS/DTS timing issue or wrong baudrate might be a root cause of the framing error.

Since we have no experience of RS485 on our side, you might need to show us a signal capture to solve the issue.
Or it is very worth to try the modified DTS to enable the hardware RTS/CTS handshake.
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Wed Dec 28, 2016 8:27 pm

Sorry for being unclear. We did actually try modifying the DTS-file earlier using the method described in the link above. But without any success so that's why we chose to control the RTS manually using GPIO instead which seems to work fine on a Raspberry Pi.

Both the library and the device that we are communicating with is set to 9600 so it shouldn't be a baudrate issue (this also works on the RPi).

What is still confusing me is the references to RTS/CTS in the schematics. As I mentioned earlier, we are using GPIOX.BIT18 to control the PV (power valid) function of the ADM2483-chip. Could this cause problems for us even if we do not enable the hardware RTS/CTS handshake using the DTS?
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Thu Dec 29, 2016 10:15 am

Do you have a DMM to see the GPIO voltage level?
Can you toggle the level of GPIOX.BIT18 manually?
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Fri Mar 17, 2017 4:42 pm

Sorry for the very late response. We made some further progress regarding this. We have now managed to get communication working using libmodbus on RS-485. But we still have one major problem left.

The UART driver is constantly giving the following error message:

Uart 2 Driver: Framing Error while receiving a character

Is seems that the driver is not satisfied with the way the frames look even though we successfully manage to read relevant data into our application. This error message is produced at a high rate and seems to be causing problems for the syslog which occasionally even crashes (probably) due to the huge amount of faults.

I have found a number of threads on the ODROID forum describing the problem:
http://dev.odroid.com/viewtopic.php?f=1 ... iew=unread
http://dev.odroid.com/viewtopic.php?f=1 ... iew=unread

And all of these seems to have solved their problems using the stty tool. We have tried to disable the configuration of the UART made by libmodbus and instead used the stty tool with a large number of different configurations but still havent found one that removes the error above.

Any ideas on how we can solve this?
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Thu Mar 23, 2017 4:45 pm

Some further debugging shows that the syslog is not the cause of the actual crash. I have attached an image that shows the crash dump.

Any thoughts on how we can prevent this from happening?
Attachments
20170322_164732.jpg
(558.79 KiB) Downloaded 433 times
Last edited by martin_p on Thu Mar 23, 2017 9:03 pm, edited 1 time in total.
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Thu Mar 23, 2017 7:50 pm

Can you post your schematics and test code to test the RS485 functionality/stability with C1/C2 on our side?
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Mon Mar 27, 2017 3:15 pm

Hi!

Thanks for the quick response. We are using a fork of the libmodbus library which can be found here:
https://github.com/dhruvvyas90/libmodbus

This fork allows us to control the RTS using GPIO.

The code example found below basically shows what we are trying to do. The only difference is that we are using modbus_new_rtu instead of modbus_new_tcp.
http://libmodbus.org/docs/v3.1.4/modbus ... sters.html

Operating system:
Linux odroid-jessie 3.10.104 #1 SMP PREEMPT Thu Nov 10 07:56:43 CET 2016 armv7l GNU/Linux

In regards of hardware we are using the ADM2483 circuit for RS485. I have attached an image which shows how the circuit is connected to the ODROID-C1+.

Thanks for helping out in investigating this issue. Please let me know if you need further information!
Attachments
RS485_odroid.jpg
(38.35 KiB) Downloaded 378 times
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Mon Mar 27, 2017 4:39 pm

Thank you for the information.

Let's narrow down the root causes.
What happens if you don't change the communication direction?
When you just received some data from Rx, did you meet the Framing error?
Or only when you switch DE/RE mode dynamically?
Do you have a scope to check the Rx, Tx, DR/RE pins signal?
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Mon Mar 27, 2017 6:57 pm

The RTS/DE pin switching is handled automatically by the library. The direction needs to switched at least one time to be able to first send a request and then receive a response.

We seem to always get the framing error regardless. I tested to remove the dynamics in our program and only send one single request and then receive the response (no further RTS/DE switching after that). It still leads to an error in dmesg:

[ 7534.781808] Uart 0 Driver: Framing Error while receiving a character

Unfortunately we do not have any oscilloscope at the moment which makes the debugging much harder.
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Tue Mar 28, 2017 4:52 am

Do you mean "data sending out form C1+ to end device" has no issue?
Only the receiving has the Framing Error?
The Framing Error occurs only when the baud-rate, stop-bit, or start-bit configuration is not correct.
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Tue Mar 28, 2017 5:20 pm

Yes, it seems so. The device that we are communicating with does not seem to have any problems with the data that is sent out from the C1+.

We have made tests with different baud-rates and also with both 1 and 2 stop-bits but the end result is always the same.

I can confirm that the start-bit sometimes seems to be a problem. We occasionally seem to receive an extra byte of data in the beginning of the message. This was solved by adding an extra byte delay in the library to make sure that we only read the relevant data.

What can we do to modify the start bit configuration of the driver? Can the stty tool be used for that?
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Tue Mar 28, 2017 6:19 pm

The start-bit is not configurable. I meant the broken/missing start-bit by wrong DE/RE control timing could make the Framing error.
Sorry for the confusion caused.

Anyway, It is really hard to know the root cause without an oscilloscope or logic analyzer.
You have to check the baud rate as well as DE/RE timing with the scope.
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Wed Mar 29, 2017 5:33 pm

I understand! I think your theory is valid regarding the timing of the DE/RE control. We will buy an oscilloscope to be able to continue with the debugging. I will let you know as soon as we have some further details to share!
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Wed Mar 29, 2017 8:26 pm

We have now been able to have a closer look at the frames and the timing. I have attached an image that shows the result. The result look pretty much as we expect it do. We have added some extra delays to be able to see start and stop bits clearly. Please have a look and let us know if you need any further images.
Attachments
Skärmavbild 2017-03-29 kl. 13.13.32.png
(170.59 KiB) Downloaded 327 times
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Sat Apr 01, 2017 9:42 am

Thank you for capturing the stream.
Did you see the framing error while receiving 8 bytes?
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Mon Apr 03, 2017 5:29 pm

Yes, we seems to be getting the framing error every time. Even though the frames look as expected.
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Thu Apr 06, 2017 7:59 am

We ordered a couple of RS485 add-on boards.
We will test it by end of next week.
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Thu Apr 06, 2017 7:18 pm

That's great news! Thanks a lot for helping out with this issue. Please let us know if you need any further information.
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Wed Apr 12, 2017 10:09 pm

We have some interesting news regarding this. We switched to an ODROID C2 and the framing errors does not appear anymore.

Instead we get this message in the syslog in huge amounts:
Apr 12 11:29:41 localhost kernel: [ 183.856018] ttyS1 use xtal 24000000 change 57600 to 9600
Apr 12 11:29:41 localhost kernel: [ 183.858228] ttyS1 use xtal 24000000 change 9600 to 9600
Apr 12 11:29:41 localhost kernel: [ 183.859854] ttyS1 use xtal 24000000 change 9600 to 57600

It seems like something is trying to change the baud rate back to 9600 all the time.

Is there any differencies in the hardware or the driver regarding the UART between the C1+ and the C2? We really need to use the C1+ so replacing it with a C2 is not really an option at this stage.
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby odroid » Wed Apr 12, 2017 10:30 pm

I think we can start to test the RS485 communication on C1+ early next week.
We will share our test result with simpler test code soon.
User avatar
odroid
Site Admin
 
Posts: 24371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Thu Apr 13, 2017 12:34 am

We made an dist-upgrade on the C2 and that made the "ttyS1 use xtal" disappear. We will run some long term tests with the C2 to make sure that it doesn't crash.

Must be some difference between the UART-driver for the C1+ and the C2 which causes the framing-errors since the environment is identical otherwise. Please let us now if you have any theories regarding that and how we can move forward with the C1+.
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby neal » Wed Apr 19, 2017 5:06 pm

We have tested under C1+ and C2 each with a module of rs485 which is using sp3485 chip.

RS485.PDF
(154.41 KiB) Downloaded 70 times


In above sch pdf file, U1 is replaced from DS75176B to SP3485 to supply power 3.3v and it is compatible pin to pin.
It is Wiring UART1(TXD1, RXD1), GPIO_87(Header pin 12, To control send and receive) at C1+,
UART1(TXD1, RXD1), GPIO_238(Header pin 12, To control send and receive) at C2.
and we make sample code.

here's how to build the sample code.
1.
Code: Select all
git clone https://github.com/hardkernel/wiringPi

2.
Code: Select all
./wiringPi/build

3.
Code: Select all
gcc -o rs485_test rs485_test.c -lwiringPi -lpthread

4. Master in case of C2 :
Code: Select all
sudo ./rs485_test -d /dev/ttyS1 -b 115200 -p 1 -m 1

4-1. Slave in case of C2 :
Code: Select all
sudo ./rs485_test -d /dev/ttyS1 -b 115200 -p 1 -m 0


As a result, all of kernel jerk out words "Uart Driver: Framing Error while receiving a character" and at the same time,
it seems to be sending and receiving work without any problem.

I think Framing Error cause is that handling of the control pin.
I can't see the Framing Error when I only set slave mode or master mode which means control pin always low or high.
I just guess, there is some noise receive when control pin toggle.
Attachments
rs485_test.c
(7.04 KiB) Downloaded 21 times
neal
 
Posts: 20
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Thu Apr 20, 2017 3:26 pm

Thanks for sharing your results!

We have a a question regarding the tests.

* Did you get the framing errors also on the C2? We are not experiencing any framing errors on the C2 and has not seen any crashes yet with that board.

We agree with your theory about the control pin toggle but the problem is that we cannot see any noise when using our oscilloscope. The driver seems to be giving the framing error regardless of how the frame looks.

Since we are not experiencing any problems on the C2, I think the relevant question now is what the difference is between C1+ and C2 in regards of the UART hardware and the driver.

Could this be a potential issue in the UART driver that the C1+ is using?
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby neal » Thu Apr 20, 2017 6:08 pm

C2 also has framing errors, but kernel code in C2 only hasn't an error message in it.
and I can see some noise at RX line our oscilloscope when control pin toggled at the moment.
The noise voltage amplitude is 200mV roughly.

In my opinion, I just think that issue is not the UART driver.
neal
 
Posts: 20
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Wed Apr 26, 2017 2:43 pm

How can you determine that you have framing errors if the driver does not report them?

Could you please show us an image with the control pin noise that you see with your oscilloscope? We are not able to see any noise with our oscilloscope.

We have been running the C2 now for about 2 weeks without any crashes at all so regardless of framing errors or not it seems that it is only the C1+ that has the crash issue (which is our main problem).
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby neal » Fri May 19, 2017 5:32 pm

Added debug message into kernel code and build again under the C2.

I haven't seen the framing errors after changed from SP3485 to DS75176B and not place R5(pull up) and R6(pull down) using a 5V power supply(HEADER PIN Number 2 - 5.0V) like the attached schematic under the C1+.
but, C2 have frame error displayed with occasional. It is decreased than before.

What voltage does your RS485 trans chip supply?
Have you supplied 5V to ADM2483 chip and tested?
neal
 
Posts: 20
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english

Re: ODROID C1+ RS485 framing errors

Unread postby martin_p » Wed Jun 07, 2017 11:51 pm

Thanks for your reply!

That sounds like interesting results. Unfortunately we are stuck with the ADM2483-chip so we need to get it working with that chip. Do you have any ADM2483-chip to test with?

Please see the attached picture for the schematic.
Attachments
ADM2483.jpg
ADM2483.jpg (53.16 KiB) Viewed 790 times
martin_p
 
Posts: 17
Joined: Tue Dec 27, 2016 11:45 pm
languages_spoken: english
ODROIDs: C1+

Re: ODROID C1+ RS485 framing errors

Unread postby neal » Thu Jun 08, 2017 12:25 pm

Sorry for having no ADM2483-chip.

Can you change and test VDD1(Logical Side) power supply to +5V from +3V3 with isolated VDD2?
As I above written by.
but, I'm not sure it solves the problem.
neal
 
Posts: 20
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: english


Return to Issues

Who is online

Users browsing this forum: No registered users and 2 guests