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

More
19 Sep 2020 22:17 #182790 by rumking
Replied by rumking on topic RS-485 on 5i25+7i76/7i85
Hi guys,
I ordered the 7i74 and wanna try the channel 7 of the 7i74 for half-duplex rs485. I made a simple bitfile for 7i76E+7i74 with UART 1x on channel 7 of the 7i74. It tweaked the InstStride1: integer := 16; of the TopEthernet16HostMot2.vhd aswell, So I had to put all the smart serial away, right?

Mesaflash --readhmid looks ok to me:

readhmid output below
pi@raspberrypi:~ $ mesaflash --device 7i76e --addr 10.10.10.10 --readhmid
Configuration Name: HOSTMOT2

General configuration information:

BoardName : MESA7I76
FPGA Size: 16 KGates
FPGA Pins: 256
Number of IO Ports: 3
Width of one I/O port: 17
Clock Low frequency: 100.0000 MHz
Clock High frequency: 200.0000 MHz
IDROM Type: 3
Instance Stride 0: 4
Instance Stride 1: 16
Register Stride 0: 256
Register Stride 1: 256

Modules in configuration:

Module: DPLL
There are 1 of DPLL in configuration
Version: 0
Registers: 7
BaseAddress: 7000
ClockFrequency: 100.000 MHz
Register Stride: 256 bytes
Instance Stride: 4 bytes

Module: WatchDog
There are 1 of WatchDog in configuration
Version: 0
Registers: 3
BaseAddress: 0C00
ClockFrequency: 100.000 MHz
Register Stride: 256 bytes
Instance Stride: 4 bytes

Module: IOPort
There are 3 of IOPort in configuration
Version: 0
Registers: 5
BaseAddress: 1000
ClockFrequency: 100.000 MHz
Register Stride: 256 bytes
Instance Stride: 4 bytes

Module: StepGen
There are 5 of StepGen in configuration
Version: 2
Registers: 10
BaseAddress: 2000
ClockFrequency: 100.000 MHz
Register Stride: 256 bytes
Instance Stride: 4 bytes

Module: QCount
There are 1 of QCount in configuration
Version: 2
Registers: 5
BaseAddress: 3000
ClockFrequency: 100.000 MHz
Register Stride: 256 bytes
Instance Stride: 4 bytes

Configuration pin-out:

IO Connections for on-card
Pin# I/O Pri. func Sec. func Chan Pin func Pin Dir

TB2 4,5 0 IOPort StepGen 0 Dir/Table2 (Out)
TB2 2,3 1 IOPort StepGen 0 Step/Table1 (Out)
TB2 10,11 2 IOPort StepGen 1 Dir/Table2 (Out)
TB2 8,9 3 IOPort StepGen 1 Step/Table1 (Out)
TB2 16,17 4 IOPort StepGen 2 Dir/Table2 (Out)
TB2 14,15 5 IOPort StepGen 2 Step/Table1 (Out)
TB2 22,23 6 IOPort StepGen 3 Dir/Table2 (Out)
TB2 20,21 7 IOPort StepGen 3 Step/Table1 (Out)
TB3 4,5 8 IOPort StepGen 4 Dir/Table2 (Out)
TB3 2,3 9 IOPort StepGen 4 Step/Table1 (Out)
Internal 10 IOPort None
Internal 11 IOPort None
TB3 18,19 12 IOPort None
TB3 16,17 13 IOPort None
TB3 13,14 14 IOPort QCount 0 Quad-IDX (In)
TB3 10,11 15 IOPort QCount 0 Quad-B (In)
TB3 7,8 16 IOPort QCount 0 Quad-A (In)

IO Connections for P1
Pin# I/O Pri. func Sec. func Chan Pin func Pin Dir

1 17 IOPort None
14 18 IOPort None
2 19 IOPort None
15 20 IOPort None
3 21 IOPort None
16 22 IOPort None
4 23 IOPort None
17 24 IOPort None
5 25 IOPort None
6 26 IOPort None
7 27 IOPort None
8 28 IOPort UARTRX 0 RXData (In)
9 29 IOPort None
10 30 IOPort None
11 31 IOPort None
12 32 IOPort UARTTX 0 TXData (Out)
13 33 IOPort None

IO Connections for P2
Pin# I/O Pri. func Sec. func Chan Pin func Pin Dir

1 34 IOPort None
14 35 IOPort None
2 36 IOPort None
15 37 IOPort None
3 38 IOPort None
16 39 IOPort None
4 40 IOPort None
17 41 IOPort None
5 42 IOPort None
6 43 IOPort None
7 44 IOPort None
8 45 IOPort None
9 46 IOPort None
10 47 IOPort None
11 48 IOPort None
12 49 IOPort None
13 50 IOPort None
readhmid output above

Then, I gladly took the mesa_uart.comp Andy provided and compiled:
pi@raspberrypi:~ $ halcompile mesa_uart.comp
pi@raspberrypi:~ $ halcompile --compile mesa_uart.c
and moved the mesa_uart.so to linuxcnc-master/rtlib/

Then, I wanted to loadrt the mesa_uart component, these are the contents of my hal file:

halfile content below
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS

loadrt hostmot2
loadrt hm2_eth config="num_stepgens=0" board_ip=10.10.10.10
loadrt mesa_uart names="hm2_7i76e.0.uart.0"

addf hm2_7i76e.0.read servo-thread
addf hm2_7i76e.0.write servo-thread

addf motion-command-handler servo-thread
addf motion-controller servo-thread
halfile content above

During linuxcnc startup I get this output:

startup output below
LINUXCNC - 2.9.0~pre0
Machine configuration directory is '/home/pi/linuxcnc/configs/dcell-test'
Machine configuration file is 'dcell-test.ini'
Starting LinuxCNC...
Found file(REL): ./dcell-test.hal
Note: Using POSIX realtime
hm2: loading Mesa HostMot2 driver version 0.15
hm2_eth: loading Mesa AnyIO HostMot2 ethernet driver version 0.2
hm2_eth: 10.10.10.10: INFO: Hardware address (MAC): 00:60:1b:10:45:15
hm2_eth: discovered 7I76E-16
hm2/hm2_7i76e.0: Low Level init 0.15
hm2/hm2_7i76e.0: 51 I/O Pins used:
hm2/hm2_7i76e.0: IO Pin 000 (P1-01): IOPort
hm2/hm2_7i76e.0: IO Pin 001 (P1-14): IOPort
hm2/hm2_7i76e.0: IO Pin 002 (P1-02): IOPort
hm2/hm2_7i76e.0: IO Pin 003 (P1-15): IOPort
hm2/hm2_7i76e.0: IO Pin 004 (P1-03): IOPort
hm2/hm2_7i76e.0: IO Pin 005 (P1-16): IOPort
hm2/hm2_7i76e.0: IO Pin 006 (P1-04): IOPort
hm2/hm2_7i76e.0: IO Pin 007 (P1-17): IOPort
hm2/hm2_7i76e.0: IO Pin 008 (P1-05): IOPort
hm2/hm2_7i76e.0: IO Pin 009 (P1-06): IOPort
hm2/hm2_7i76e.0: IO Pin 010 (P1-07): IOPort
hm2/hm2_7i76e.0: IO Pin 011 (P1-08): IOPort
hm2/hm2_7i76e.0: IO Pin 012 (P1-09): IOPort
hm2/hm2_7i76e.0: IO Pin 013 (P1-10): IOPort
hm2/hm2_7i76e.0: IO Pin 014 (P1-11): Encoder #0, pin Index (Input)
hm2/hm2_7i76e.0: IO Pin 015 (P1-12): Encoder #0, pin B (Input)
hm2/hm2_7i76e.0: IO Pin 016 (P1-13): Encoder #0, pin A (Input)
hm2/hm2_7i76e.0: IO Pin 017 (P2-01): IOPort
hm2/hm2_7i76e.0: IO Pin 018 (P2-14): IOPort
hm2/hm2_7i76e.0: IO Pin 019 (P2-02): IOPort
hm2/hm2_7i76e.0: IO Pin 020 (P2-15): IOPort
hm2/hm2_7i76e.0: IO Pin 021 (P2-03): IOPort
hm2/hm2_7i76e.0: IO Pin 022 (P2-16): IOPort
hm2/hm2_7i76e.0: IO Pin 023 (P2-04): IOPort
hm2/hm2_7i76e.0: IO Pin 024 (P2-17): IOPort
hm2/hm2_7i76e.0: IO Pin 025 (P2-05): IOPort
hm2/hm2_7i76e.0: IO Pin 026 (P2-06): IOPort
hm2/hm2_7i76e.0: IO Pin 027 (P2-07): IOPort
hm2/hm2_7i76e.0: IO Pin 028 (P2-08): IOPort
hm2/hm2_7i76e.0: IO Pin 029 (P2-09): IOPort
hm2/hm2_7i76e.0: IO Pin 030 (P2-10): IOPort
hm2/hm2_7i76e.0: IO Pin 031 (P2-11): IOPort
hm2/hm2_7i76e.0: IO Pin 032 (P2-12): IOPort
hm2/hm2_7i76e.0: IO Pin 033 (P2-13): IOPort
hm2/hm2_7i76e.0: IO Pin 034 (P3-01): IOPort
hm2/hm2_7i76e.0: IO Pin 035 (P3-14): IOPort
hm2/hm2_7i76e.0: IO Pin 036 (P3-02): IOPort
hm2/hm2_7i76e.0: IO Pin 037 (P3-15): IOPort
hm2/hm2_7i76e.0: IO Pin 038 (P3-03): IOPort
hm2/hm2_7i76e.0: IO Pin 039 (P3-16): IOPort
hm2/hm2_7i76e.0: IO Pin 040 (P3-04): IOPort
hm2/hm2_7i76e.0: IO Pin 041 (P3-17): IOPort
hm2/hm2_7i76e.0: IO Pin 042 (P3-05): IOPort
hm2/hm2_7i76e.0: IO Pin 043 (P3-06): IOPort
hm2/hm2_7i76e.0: IO Pin 044 (P3-07): IOPort
hm2/hm2_7i76e.0: IO Pin 045 (P3-08): IOPort
hm2/hm2_7i76e.0: IO Pin 046 (P3-09): IOPort
hm2/hm2_7i76e.0: IO Pin 047 (P3-10): IOPort
hm2/hm2_7i76e.0: IO Pin 048 (P3-11): IOPort
hm2/hm2_7i76e.0: IO Pin 049 (P3-12): IOPort
hm2/hm2_7i76e.0: IO Pin 050 (P3-13): IOPort
hm2/hm2_7i76e.0: registered
hm2: Can not find UART instance hm2_7i76e.0.uart.0.
Found file(REL): ./custom.hal
hm2: Can not find UART instance hm2_7i76e.0.uart.0.
startup output above

The linuxcnc starts and when I open halmeter, the hm2_7i76e.0.uart.0 pins (tx-bytes, tx-data[0..15], etc.) show up, which I do not understand.

Am I loadrt-ing the uart component wrong? Or do you have any suggestions why the uart instance cannot be found?

Thank you guys.

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

More
19 Sep 2020 22:47 #182791 by andypugh
Replied by andypugh on topic RS-485 on 5i25+7i76/7i85
The output would normally declare that the UART existed and give its code name.

It is _possible_ that the message goes straight to dmesg. (when I put the UART hooks in it was all RTAI kernel-mode, uspace wasn't invented)

Though the first thing I would suggest would be to try hm2_7i76.0.uart.0 instead.

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

More
20 Sep 2020 18:48 #182942 by rumking
Replied by rumking on topic RS-485 on 5i25+7i76/7i85
Andy,
thank you for the answer.

I managed to get the UART going without the error message. But the mesa_uart component is not clear to me all the way.

The component is meant to send/receive up to 16B of data each servo-thread cycle, right? If I take a look at the 16 rx-data and 16 tx-data pins, they are all u32 type (4B unsigned integer = 0 to 4294967295).

Does that mean, that each of the pins can carry 4B of data (16*4 = 64B total), or are each of the pins supposed to carry 1B of data (16B total), so each of the pins should not take on value greater than 255?

I really appreciate your help guys.

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

More
20 Sep 2020 20:54 #182959 by andypugh
Replied by andypugh on topic RS-485 on 5i25+7i76/7i85

rumking wrote: Does that mean, that each of the pins can carry 4B of data (16*4 = 64B total), or are each of the pins supposed to carry 1B of data (16B total), so each of the pins should not take on value greater than 255?.


I really can't remember.

The mesa_uart component isn't really intended to be used as-is, it is a sample / starter file to demonstrate the sort of thing that you can do.

The file is meant to be extremely simple, and relatively easy to understand.
github.com/LinuxCNC/linuxcnc/blob/master...ivers/mesa_uart.comp
Though i have just noticed that the comment for send and recieve is identical: copy-paste error.

The input pins are 32-bits but only the lower 8 bits are transmitted.

That probably isn't how you would do it in your own component.

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

More
21 Sep 2020 17:17 #183164 by rumking
Replied by rumking on topic RS-485 on 5i25+7i76/7i85
Andy,
thank you once again.

I created a bitfile with 7i74 filled with UART (8 channels).

I managed to send and receive a bunch of bytes over the uart through channel 0 of the 7i74 (hm2_7i76.0.uart.0). But the issue is that it works just like a loopback (I get received the same bytes I send).

I think that this might be caused by that I tied RX+/TX+ and RX-/TX- together (because I need half duplex rs485). According to 7i74 manual:

RS-485 CAPABLE CHANNEL
Channel 7 of the 7I74 has an output enable and can be used for RS-485 half duplex
type applications. For 2 wire half duplex type RS-485 interfaces, the RX+ and TX+ lines
and the RX- and TX- lines should be tied together at the 7I74.

But when I use the channel 7 (hm2_7i76e.0.uart.7 as it is meant to be used for half-duplex rs485), I do not receive any bytes. I think I should *somehow* operate with the transmit enable pin, but I do not know how.

I also tried terminating the lines with 120ohm resistor without any progress (channel 0 still works as a loopback and channel 7 does not receive any bytes).

Do I miss something?

Or could you point me to a direction, how to operate with the transmit enable pin?

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

More
21 Sep 2020 17:39 #183165 by bevins
Replied by bevins on topic RS-485 on 5i25+7i76/7i85

rumking wrote: Andy,
thank you once again.

I created a bitfile with 7i74 filled with UART (8 channels).

I managed to send and receive a bunch of bytes over the uart through channel 0 of the 7i74 (hm2_7i76.0.uart.0). But the issue is that it works just like a loopback (I get received the same bytes I send).

I think that this might be caused by that I tied RX+/TX+ and RX-/TX- together (because I need half duplex rs485). According to 7i74 manual:

RS-485 CAPABLE CHANNEL
Channel 7 of the 7I74 has an output enable and can be used for RS-485 half duplex
type applications. For 2 wire half duplex type RS-485 interfaces, the RX+ and TX+ lines
and the RX- and TX- lines should be tied together at the 7I74.

But when I use the channel 7 (hm2_7i76e.0.uart.7 as it is meant to be used for half-duplex rs485), I do not receive any bytes. I think I should *somehow* operate with the transmit enable pin, but I do not know how.

I also tried terminating the lines with 120ohm resistor without any progress (channel 0 still works as a loopback and channel 7 does not receive any bytes).

Do I miss something?

Or could you point me to a direction, how to operate with the transmit enable pin?


I dont know about the mesa boards but with RS-485 half duplex, when your done transmitting, its got to revert to receive. You cant receive on a line set to transmit.

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

More
21 Sep 2020 17:52 #183167 by PCW
Replied by PCW on topic RS-485 on 5i25+7i76/7i85
Not sure what the hm2 driver does but typically for 1/2 duplex RS-485 you would set the RXmask so TXData was masked and only data from the remote device was received.

That said, the PktUART is more likely to be supported going forward

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

More
22 Sep 2020 09:05 #183265 by rumking
Replied by rumking on topic RS-485 on 5i25+7i76/7i85
Thank you for the suggestions.

I created a bitfile with 7i74 filled with PktUART.
hm2/hm2_7i76e.0: IO Pin 017 (P2-01): PktUART Receive Channel #0, pin RX Data (Input)
hm2/hm2_7i76e.0: IO Pin 018 (P2-14): PktUART Receive Channel #1, pin RX Data (Input)
hm2/hm2_7i76e.0: IO Pin 019 (P2-02): PktUART Receive Channel #2, pin RX Data (Input)
hm2/hm2_7i76e.0: IO Pin 020 (P2-15): PktUART Receive Channel #3, pin RX Data (Input)
hm2/hm2_7i76e.0: IO Pin 021 (P2-03): PktUART Transmit Channel #0, pin TX Data (Output)
hm2/hm2_7i76e.0: IO Pin 022 (P2-16): PktUART Transmit Channel #1, pin TX Data (Output)
hm2/hm2_7i76e.0: IO Pin 023 (P2-04): PktUART Transmit Channel #2, pin TX Data (Output)
hm2/hm2_7i76e.0: IO Pin 024 (P2-17): PktUART Transmit Channel #3, pin TX Data (Output)
hm2/hm2_7i76e.0: IO Pin 025 (P2-05): PktUART Receive Channel #4, pin RX Data (Input)
hm2/hm2_7i76e.0: IO Pin 026 (P2-06): PktUART Receive Channel #5, pin RX Data (Input)
hm2/hm2_7i76e.0: IO Pin 027 (P2-07): PktUART Receive Channel #6, pin RX Data (Input)
hm2/hm2_7i76e.0: IO Pin 028 (P2-08): PktUART Receive Channel #7, pin RX Data (Input)
hm2/hm2_7i76e.0: IO Pin 029 (P2-09): PktUART Transmit Channel #4, pin TX Data (Output)
hm2/hm2_7i76e.0: IO Pin 030 (P2-10): PktUART Transmit Channel #5, pin TX Data (Output)
hm2/hm2_7i76e.0: IO Pin 031 (P2-11): PktUART Transmit Channel #6, pin TX Data (Output)
hm2/hm2_7i76e.0: IO Pin 032 (P2-12): PktUART Transmit Channel #7, pin TX Data (Output)
hm2/hm2_7i76e.0: IO Pin 033 (P2-13): PktUART Transmit Channel #7, pin Drv Enable (Output)
When I try to loadrt the mesa_uart component now (loadrt mesa_uart names="hm2_7i76e.0.pktuart.0"), I get and error message:

Can not find UART instance hm2_7i76e.0.pktuart.0

I googled a little and I think that I could test the PktUART using the mesa_pktgyro_test component ( linuxcnc.org/docs/2.8/html/man/man9/mesa_pktgyro_test.9.html ). But I could not find the *.comp file anywhere (github, forum, etc.)

Could you provide the file to me, please?

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

More
22 Sep 2020 14:05 #183302 by PCW
Replied by PCW on topic RS-485 on 5i25+7i76/7i85
its here:

src/hal/components/mesa_pktgyro_test.comp

pktuart.c should probably be updated to match the latest firmware that now supports parity
The new firmware should be ok with the existing driver because the parity enable bit is set to 0
(disabled) by the existing driver.

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

More
25 Sep 2020 15:48 #183737 by rumking
Replied by rumking on topic RS-485 on 5i25+7i76/7i85
I was able to start linuxcnc with the pktgyro component loaded, everything seems to be fine. But while the machine is running I am getting an error:

hm2: hm2_7i76e.0.pktuart.0: Overrun error, no stop bit

From what I was able to gather, the error has errno 111 (defined in /src/hal/drivers/mesa-hostmot2/pktuart_errno.h):

#define HM2_PKTUART_RxOverrunError (111) // Overrun error (no stop bit when expected) (sticky), Bit 1

I think it may be caused by wrong bit mask "rtapi_s32 rx_mode" of the hm2_pktuart_setup function ( linuxcnc.org/docs/2.8/html/man/man3/hm2_pktuart_setup.3hm2.html ):

int hm2_pktuart_setup(char *name, int bitrate, rtapi_s32 tx_mode, rtapi_s32 rx_mode, int txclear, int rxclear)

If I am on the right path, bit 1 of the rx_mode bit mask should be the problem. According to the manual:
Bit 1 : Overrun error (no stop bit when expected) (sticky)

I am not sure if I got it right: When the bit 1 of the rx_mode bit mask is set to 1, the stop bit is expected or vice versa?
I also could not find whether the bit 0 of the bit mask is the MSB or LSB.

Thank you guys.

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

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