Welcome, Guest
Messages posted to this category need to be reviewed by the moderator before it gets posted.
  • Page:
  • 1
  • 2

TOPIC: Need Python Code Example for SMIEngine

Re: Need Python Code Example for SMIEngine 4 years 6 months ago #1767

  • csearcy
  • csearcy's Avatar
  • OFFLINE
  • Moderator
  • Posts: 463
  • Thank you received: 79
  • Karma: 23
Great! Please let us know how it goes.
The administrator has disabled public write access.

Re: Need Python Code Example for SMIEngine 4 years 6 months ago #1768

  • stephenmoore
  • stephenmoore's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 1
  • Karma: 0
This works just fine with the Kvaser CAN interface...

import comtypes.client as cc

def main():

    """
    CAN communications.
    """
    smiHost = cc.CreateObject('SMIEngine.SMIHost')
    cc.GetModule('IntegMotorInterface.dll')
    import comtypes.gen.INTEGMOTORINTERFACELib as commLib
    smiCom = smiHost.QueryInterface(commLib.ISMIComm)
    smiCom.InitCANOpen(3)
    smiCom.BaudRate = 125000
    smiCom.OpenPort('CANopen')
    findMotor = smiCom.DetectCANOpenMotors(5, 0)
    print('Found motors = ', findMotor)
    numMotor = smiCom.NoOfMotors
    smiCom.DefaultMotor = numMotor
    print('Number of motor = ', numMotor)
    cmd = 'RSP2'
    print('Sending SMI command = ' + cmd)    
    response = smiCom.GetResponseOf(cmd)
    print('Motor response = ' + response)
    
            

if __name__ == "__main__":
    main()

Thank you for your help. My Python HMI was completely re-usable with the CAN interface. This really streamlines our development.

Regards,

sm
The administrator has disabled public write access.
The following user(s) said Thank You: csearcy

Re: Need Python Code Example for SMIEngine 3 years 9 months ago #2205

I have tried this and it works.
I have a query to how to send the commands from python to the SMI interface. Now i am writing directly to the com port .
The administrator has disabled public write access.

Need Python Code Example for SMIEngine 1 year 1 month ago #2314

  • pedro6
  • pedro6's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
Yes it is really neede
The administrator has disabled public write access.

Need Python Code Example for SMIEngine 1 year 1 week ago #2328

  • stephenmoore
  • stephenmoore's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 1
  • Karma: 0
I am not sure I understand your problem. Are you trying to use the serial port or the CANbus port with the Kvaser adaptrer?

It should be possible to just send animatics commands over the interface.

e.g.
"""
Using comtypes to access Animatics Smart Motor library
"""
import comtypes.client as cc

smiHost = cc.CreateObject('SMIEngine.SMIHost')
cc.GetModule('IntegMotorInterface.dll')
import comtypes.gen.INTEGMOTORINTERFACELib as commLib
smiCom = smiHost.QueryInterface(commLib.ISMIComm)
smiCom.InitCANOpen(3)
smiCom.BaudRate = 125000
smiCom.OpenPort('CANopen')
##        findMotor = smiCom.DetectCANOpenMotors(5, 0)
##        print('Found motors = ', findMotor)
##        numMotor = smiCom.NoOfMotors
##        print('Motor number = ', numMotor)
numMotor = 1
smiCom.DefaultMotor = numMotor       
command = 'RUN'
response = smiCom.GetResponseOf(command)
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.141 seconds
Powered by Kunena Forum