- Posts: 399
- Thank you received: 133
Mesa modbus and pktUart
3 years 3 months ago #276179
by persei8
Mesa modbus and pktUart was created by persei8
I can't seem to find a more suitable section for this question so I'll just post it here. For some reason, I am obsessed with getting my 7i96 to control the VFD over modbus using the builtin pktUart component. I have 90% of the code done (in python), including VFD driver, modbus protocol, packet assembly etc. What I am missing is the interface to hostmot2 and pktUart driver. There are examples in the Linuxcnc distro but they're written in C++. Is it possible to get the same functionality as the mesa_modbus component, but with python? Is it simply a matter of creating the HAL pins and reading/writing them? I think if I get this solved, it may be of interest to others as well. Thank you for any guidance.
Jim
Jim
Please Log in or Create an account to join the conversation.
3 years 3 months ago #276204
by rodw
Replied by rodw on topic Mesa modbus and pktUart
with the right bit file, the pktUART is exposed but there are functions that need calling from HAL when the component is installed in the hal file. I think that you need to learn how to code in C.
A better approach might be to attract Andy's attention and work with his shiny new component. I'm sure he'll help as that was his intended use.
A better approach might be to attract Andy's attention and work with his shiny new component. I'm sure he'll help as that was his intended use.
Please Log in or Create an account to join the conversation.
3 years 3 months ago #276276
by persei8
Replied by persei8 on topic Mesa modbus and pktUart
I will try to be more specific. I created a mod file based on mesa_modbus.mod.
Then did:
That worked, it created a vfd_modbus.so in /usr/lib/linuxcnc/modules.
Then in my postgui_hal file:
Start linuxcnc and watch the terminal output:
The instructions at
linuxcnc.org/docs/2.9/html/drivers/mesa_modbus.html
say 7i69 but I assume
that's just a typo. Not sure what to try next.
Jim
Code:
#define MAX_MSG_LEN 16 // may be increased if necessary to max 251
static const hm2_modbus_chan_descriptor_t channels[] = {
/* {TYPE, FUNC, ADDR, COUNT, pin_name} */
{HAL_U32, 3, 0x3003, 1, "voltage"},
{HAL_U32, 3, 0x3004, 1, "current"},
{HAL_U32, 3, 0x3005, 1, "speed"},
{HAL_U32, 3, 0x5000, 1, "faultcode"},
{HAL_U32, 6, 0x2000, 1, "motor"}
};
Code:
sudo modcompile vfd_modbus.mod
Then in my postgui_hal file:
Code:
loadrt vfd_modbus ports=hm2_7i96.0.pktuart.0
addf vfd_modbus servo-thread
Code:
... some stuff
hm2/hm2_7i96.0: created PktUART Interface function hm2_7i96.0.pktuart.0.
... more stuff
hm2/hm2_7i96.0: IO Pin 030 (TB2-16/TB2-17): PktUART Receive Channel #0, pin RX Data (Input)
hm2/hm2_7i96.0: IO Pin 031 (TB2-18/TB2-19): PktUART Transmit Channel #0, pin TX Data (Output)
hm2/hm2_7i96.0: IO Pin 032 (internal): PktUART Transmit Channel #0, pin Drv
...more stuff
HAL: ERROR: function 'vfd_modbus' not found
qtdragon_postgui.hal:19: addf failed
Shutting down and cleaning up LinuxCNC...
that's just a typo. Not sure what to try next.
Jim
Please Log in or Create an account to join the conversation.
- tommylight
-
- Offline
- Moderator
-
3 years 3 months ago #276277
by tommylight
Replied by tommylight on topic Mesa modbus and pktUart
Just a stab in the dark, but try
addf vfd_modbus.0 servo-thread
or
addf vfd-modbus servo-thread
Mind the difference between - and _
addf vfd_modbus.0 servo-thread
or
addf vfd-modbus servo-thread
Mind the difference between - and _
The following user(s) said Thank You: persei8
Please Log in or Create an account to join the conversation.
3 years 3 months ago #276278
by persei8
Replied by persei8 on topic Mesa modbus and pktUart
Addendum
Removed the addf line and then QtDragon started. Using HAL show I could see the function name was actually
called vfd_modbus.00. Re-enabled the addf vfd_modbus.00 servo-thread and the GUI started.
However, under the hm2_7i96 component, there is no mention of a pktuart. I suspect it's supposed to show
all the RX and TX HAL pins.
Removed the addf line and then QtDragon started. Using HAL show I could see the function name was actually
called vfd_modbus.00. Re-enabled the addf vfd_modbus.00 servo-thread and the GUI started.
Code:
Component Pins:
Owner Type Dir Value Name
71 u32 OUT 0x00000000 vfd_modbus.00.current
71 bit OUT FALSE vfd_modbus.00.fault
71 u32 OUT 0x00000000 vfd_modbus.00.faultcode
71 u32 OUT 0x00000000 vfd_modbus.00.last-error
71 u32 IN 0x00000000 vfd_modbus.00.motor
71 u32 OUT 0x00000000 vfd_modbus.00.speed
71 s32 OUT 0 vfd_modbus.00.time
71 u32 OUT 0x00000000 vfd_modbus.00.voltage
all the RX and TX HAL pins.
Please Log in or Create an account to join the conversation.
3 years 3 months ago #276279
by persei8
Replied by persei8 on topic Mesa modbus and pktUart
Ha, you were sending this while I was actually doing it.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
Time to create page: 0.238 seconds