RS-485 on 5i25+7i76/7i85

More
25 Sep 2020 15:57 #183743 by PCW
Replied by PCW on topic RS-485 on 5i25+7i76/7i85
This is not related to masking, is more like due to a polarity error or
lack of RS-485 biasing to insure an idle line state when not driven.

Please Log in or Create an account to join the conversation.

More
29 Sep 2020 13:41 #184290 by rumking
Replied by rumking on topic RS-485 on 5i25+7i76/7i85
Hi Peter,
thank you for the suggestion. According to this scheme:
www.ni.com/images/support/us/bias.gif

I used 120R terminating resistor and 1k bias resistors (I dont know whether the 1k is not too large...).

Anyway, the error "hm2: hm2_7i76e.0.pktuart.0: Overrun error, no stop bit" went away. But now, I am getting another error message:

hm2: Can not find PktUART instance X�߾<�ߵ�V�.

The weird characters are probably some unicode... I took a screenshot of the error message, here:
pasteboard.co/Jtkulbj.png

In halmeter, the pin hm2_7i76e.0.pktuart.0.rxbytes gives a value of -22. Which indicates an errno 22. However, I cannot find the errno in pktuart_errno.h.

Do you have any idea what is going on?

Please Log in or Create an account to join the conversation.

More
29 Sep 2020 13:51 #184292 by PCW
Replied by PCW on topic RS-485 on 5i25+7i76/7i85
The first error looks like some kind of driver bug
not sure any further errors have any meaning after the first

Please Log in or Create an account to join the conversation.

More
02 Oct 2020 18:49 #184604 by rumking
Replied by rumking on topic RS-485 on 5i25+7i76/7i85
Peter, thank you. The issue really was caused by the driver (my C-programming skills are not that great).

Anyway, I got another error:
hm2_7i76e.0.pktuart.0hm2_eth: ERROR: used llio->read in realtime task (addr=0x6400)
hm2_eth: This causes additional network packets which hurts performance

I think that the issue is caused by the driver also, but I have no clue, what this message means. Could you, please, give me a suggestion?

Please Log in or Create an account to join the conversation.

More
02 Oct 2020 19:40 - 02 Oct 2020 19:42 #184607 by PCW
Replied by PCW on topic RS-485 on 5i25+7i76/7i85
Basically its a structural issue, The HM2 driver was written initially for PCI/PCIE cards
and assumes that random read and writes are inexpensive. Unfortunately this is not
true of HM2 Ethernet. On Ethernet, its expected that only three packets are exchanged every
servo thread invocation. (read-request, read data, write data) Probably what needs to be done
is that the PktUART driver needs to have a state machine so that all access is merged
into these three packets.

For example when a packet data count is read (via the standard read-request/read)
The actual FIFO character data read would have to be deferred to the next servo thread
invocations read-request/read, to avoid doing a random additional read.

I have also considered a firmware/driver change to allow a FIFO readout command
during a read_request
Last edit: 02 Oct 2020 19:42 by PCW.

Please Log in or Create an account to join the conversation.

More
20 Oct 2020 17:02 #186710 by rumking
Replied by rumking on topic RS-485 on 5i25+7i76/7i85
Hi Peter,
thank you for the suggestions.

I managed to send some bytes over the line (it seems - the send function returns the number of bytes sent), but I got an error while read:
hm2/hm2_7i76e.0: error finishing read! iter=6

I have read-request, read, write functions added to the servo thread (however, I am not sure about the order of the functions)
addf hm2_7i76e.0.read servo-thread
addf hm2_7i76e.0.read-request servo-thread
addf hm2_7i76e.0.write servo-thread

My realtime component is named dcell_ascii_test. I run the receive function in a thread with 2s period (to be able to track the rtapi_print_msg - which might not be very clever)
loadrt dcell_ascii_test names="hm2_7i76e.0.pktuart.0"

loadrt threads name1=test1 period1=2000000000
addf hm2_7i76e.0.pktuart.0.receive test1

What I am intending to do inside the hm2_7i76e.0.pktuart.0.receive function is to send a frame of 11B - "!001:SOUT?\r" like this:
rtapi_u16 message_length = 11;
rtapi_u16 message_size[1]={message_length,};
rtapi_u8 num_frames = 1;
unsigned char message[1*11] ={
//! 0 0 1 : S O U T ? \r
0x21, 0x30, 0x30, 0x31, 0x3a, 0x53, 0x4f, 0x55, 0x54, 0x3f, 0x0d
};
retval=hm2_pktuart_send(name, message, &num_frames, message_size);
rtapi_print_msg(0, "PktUART send: sent %d bytes\n", retval);

The slave device should then respond with some bytes of data I want to get:
rtapi_u8 num_frames = 1;
rtapi_u16 max_frame_length = 26;
unsigned char Replyd3[num_frames*max_frame_length];
rtapi_u16 frame_sizes3[26];
rxbytes=hm2_pktuart_read(name, Replyd3, &num_frames, &max_frame_length, frame_sizes3);
rtapi_print_msg(RTAPI_MSG_INFO, "PktUART receive: got %d bytes, %d frames\n", rxbytes, num_frames);

Do you have any idea why I get the error?
hm2/hm2_7i76e.0: error finishing read! iter=6

I am not sure if I can do all this inside the hm2_7i76e.0.pktuart.0.receive function (send a request and expect a response).
I think I should aswell set the line to transmit mode when transmitting and to receive mode when reading. But to be honest, I don't know how to work with the transmit enable pin.

Thank you.

Please Log in or Create an account to join the conversation.

More
20 Oct 2020 18:01 #186717 by PCW
Replied by PCW on topic RS-485 on 5i25+7i76/7i85
You do not need read-request so I would drop that

Because you cannot poll,, the upper layer code must implement a state
machine that does the status polling and determining RX packet sizes by reads
in one servo thread invocation, and the data reads in the next invocation

TXenable is automatic if enabled in the register

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.103 seconds
Powered by Kunena Forum