Mesa modbus and pktUart

More
24 Jul 2023 23:01 #276179 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

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

More
25 Jul 2023 06:40 #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.

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

More
26 Jul 2023 01:46 #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.
#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"}
};
Then did:
sudo modcompile vfd_modbus.mod
That worked, it created a vfd_modbus.so in /usr/lib/linuxcnc/modules.
Then in my postgui_hal file:
loadrt vfd_modbus ports=hm2_7i96.0.pktuart.0
addf vfd_modbus servo-thread
Start linuxcnc and watch the terminal output:
... 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...
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

 

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

More
26 Jul 2023 01:57 #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 _
The following user(s) said Thank You: persei8

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

More
26 Jul 2023 02:05 #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.
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
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.

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

More
26 Jul 2023 02:07 #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.

More
26 Jul 2023 02:14 #276280 by tommylight
Replied by tommylight on topic Mesa modbus and pktUart
Yup, but i was waiting a bit to see if you read it, so now i go to bed, past 4AM here.
Enjoy the hunt. :)

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

More
26 Jul 2023 11:38 #276298 by camb0
Replied by camb0 on topic Mesa modbus and pktUart
Just checking if you got this working?

I was tipped off on the VFMOD module by Rod when discussing VFD's and a potential purchase of a BD600 VFD for my spindle. I bought the BD600 got that motor up and running and now it got me wondering can I do this via my MESA 7i96->7i76 setup rather than USB.
A bit of searching got me to here, by the looks of it you're pretty close to having that working for your VFD.

I assume with my setup I would do this off the 7i96 TB2 pins 16-19 which are the RS-422/485 pins. And then once you have the commands (channels? from the C file) in hal you should be able to connect them to the spindle control and other pins as needed for the UI etc (apols still learning).

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

More
26 Jul 2023 14:09 #276306 by andypugh
Replied by andypugh on topic Mesa modbus and pktUart
Have you found the docs?
linuxcnc.org/docs/2.9/html/drivers/mesa_modbus.html

It feels like Persei8 hasn't set up pins to control VFD on/off and fwd/reverse?

I have spent some time looking for the config I used for my test BFD (SKI780) bit it looks like I lost it when I decided not to add it to LinuxCNC.

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

More
27 Jul 2023 01:31 #276341 by persei8
Replied by persei8 on topic Mesa modbus and pktUart
I did find that doc and have read it several times. I did also set a pin to control motor on/off (u32   IN     0x00000000  vfd_modbus.00.motor) but I did miss a pin. Things are beginning to slowly sink in so I have to rearrange some code and then rearrange some wires and will report back what happened.
camb0 - yes, those are the pins to connect to your vfd modbus i/f. You may have to reflash your 7i96 board if it doesn't already have the pktuart enabled. Using the mesa card would be quite handy as it frees up a USB port on the computer.
The following user(s) said Thank You: camb0

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

Time to create page: 0.146 seconds
Powered by Kunena Forum