586,745 active members*
6,252 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 22
  1. #1
    Join Date
    Sep 2006
    Posts
    509

    MODBUS control of VFD

    I'm trying to get control of my GE -Fuji Electric VFD model AF300-E11. It will talk (and listen to) MODBUS so I figured I'd give it a shot at using the MODBUS in EMC2 to control it (versus a 0-10V analog output card and fwd/rev relay)

    1st - has anybody done this for this series of VFD?

    2nd - rather than starting from scratch I'm going to "try" and work from prior examples such as:

    gs2_vfd

    OR

    does somebody have a classic ladder clp file they can share for any MODBUS control that I can look at as an example - I've looked but not found one?

    3rd - this will be strictly an EMC2 effort as I have checked out communications so I know that works...(unlike some cheap VFD's I've been reading about on other threads)

    Unfortunately my programming skills are rather weak - though I do know a bit about MODBUS as I've had to fight through it for work purposes.

    I'll use this thread to publish any positive results I get for the benefit of others with this series of drive (got mine from here Variable Frequency Drive, AC Motor Drives, Pool Pump Motors, Marathon Electric 3 Phase Motor, Teco Westinghouse Distributor

    BTW my initial objective is to have the following controls:
    Spindle stop, on-fwd or on-rev, spindle speed,
    and to read the following:
    Spindle speed
    (pretty basic list...)

    Mike

  2. #2
    Join Date
    Nov 2005
    Posts
    496
    I assume you are using serial modbus?
    here is the basic idea:
    EMC Documentation Wiki: ClassicLadder Ver 7.124
    What version of EMC are you using?
    Its been a while since I used modbus with CL but some are using it.
    Running EMC / CL in a terminal will give much more info while debugging modbus
    Chris M

  3. #3
    Join Date
    Sep 2006
    Posts
    509
    Thanks Chris,

    Yes to be clear I'm using the Serial Modbus (RTU).
    EMC2 is up to date (v 2.4.5 on Ubuntu 10.04)

    ****EDIT - udpate manager was running - its now 2.4.6 if that makes any difference) - ***

    I've had a look at the wiki - unfortunately I'm such a newbie at this it isn't much help - I really need a "worked" example to play with and break to get the hang of it (classic ladder that is) ie somebody has made the connections in classic ladder to their VFD via Modbus.. From there I can usually find my way to rework it for my application (ie my vfd's function codes, registers etc)

    The other option is to hack somebody else's work such as the gs2_vfd.c that is referenced in the manual. Looks like that is the way I may end up going (though I still would like to learn the classic ladder interface)

    Cheers,

    Mike

  4. #4
    Join Date
    Nov 2005
    Posts
    496
    modbus configs are so specialized for each vfd.
    I will look to see if I can find my modbus example for a yaskawa vfd.
    do you have pdf docs for your vfd?
    CL does take a bit to get used to.

  5. #5
    Join Date
    Sep 2006
    Posts
    509
    I do have the pdf for the drive, but not on this machine ( it did take a whole bunch of searching to find it so I hope its still on my other machine). I'll post it here when I go upstairs.

    If you do have an example I would really appreciate it - I'm a bit slow on the programming stuff but I usually get from point a to point b eventually...

    Thanks,

    Mike

  6. #6
    Join Date
    Sep 2006
    Posts
    509

    pdf of the manual is in a zip over here...

    I don't have the manual on my machine but thank goodness I posted it to the zone for safe keeping! (albeit in a place that wasn't where I thought it would be...)

    http://www.cnczone.com/forums/732560-post11.html

    Mike

  7. #7
    Join Date
    Nov 2005
    Posts
    496
    It's not clear to me from docs if 8n1 (8 bit data,no parity,1 stop bit ) serial signals are supported.
    currently CL only supports this.
    Have you connected to this inverter with modbus before?
    Can you check the settings of :
    H31 slave number
    H34 baud rate
    H35 data bits
    H36 parity
    H37 stop bits.

    Boy are the docs written poorly for modbus!

  8. #8
    Join Date
    Sep 2006
    Posts
    509
    Quote Originally Posted by chester88 View Post
    It's not clear to me from docs if 8n1 (8 bit data,no parity,1 stop bit ) serial signals are supported.
    currently CL only supports this.
    Have you connected to this inverter with modbus before?
    Can you check the settings of :
    H31 slave number
    H34 baud rate
    H35 data bits
    H36 parity
    H37 stop bits.

    Boy are the docs written poorly for modbus!
    Hi Chris,

    Boy, I wasn't expecting you to wade through that manual - been there done that! I did connect up briefly with my laptop and a terminal program. I sent the example of an invalid message and got the proper error response message so I left it at that. (page 12-9 of the users guide..) I do have a GE program for configuring the drive via the RS485 so I can use that to prove the communications - but its on my laptop at work (the laptop is a windows machine)

    I just tried a terminal program (moserial) on the linux machine - and I get the same as before:

    send: 01 03 03 31 00 14 14 4E (request 20 bytes of data)
    receive: 01 83 02 C0 F1 (error response)

    Here are the configuration data as it stands now -

    H31 = 1 = slave 1
    H34 = 1 = 9600 baud
    H35 = 0 = 8 data bits
    H36 = 0 = no parity
    H37 = 0 = 2 stop bits

    8n1 is supported I believe - I will test it now by reconfiguring the drive.

    If you have your yaskawa VFD example please post it so I can have a look - it might be the piece that lets my brain put together all the pieces

    Thanks for your help with this!

    Mike

  9. #9
    Join Date
    Sep 2006
    Posts
    509

    8 N 1 not supported..

    Chris

    Turns out you can't set 8n1 - the drive automatically sets the stop bits depending on the parity - no parity is 2 stop bits, even or odd parity is 1 stop bit.

    Does this mean the whole idea of using Classic Ladder is dead in the water?:drowning:

    If so I'll try the other method - hacking up the gs2_vfd.c file I copied from somewhere...

    Mike

  10. #10
    Join Date
    Nov 2005
    Posts
    496
    I check the source code and it is possible to set different values for data, stop bit, and parity. It just hasn't been tested or documented.
    i haven't found my USB drive with the modbus ladder tests on it yet.
    I may just build a little one to suit testing for you to try.
    next thing you need to find out is Linux's serial port address. Are you using a serial port or a usb serial converter?
    Where in Canada are you?

    Chris M

  11. #11
    Join Date
    Sep 2006
    Posts
    509
    The serial port is /dev/ttyS0

    It works throught the moserial program I downloaded moserial - GNOME Live!

    I just haven't tried to actually control it yet as that requires figuring out the CRC to go with the command sent - I'll bring my laptop home tonight as it has my little tool for doing the Modbus stuff (crc calculator) as well as a GE program for configuring the drive via the RS485.

    BTW I'm in Ottawa

  12. #12
    Join Date
    Sep 2006
    Posts
    509
    I was controlling the VFD through the GE configurator software on my laptop last night.

    At the same time I was snooping on the serial port and recording a log file for future refference of the commmands that were being sent.

    Unfortunately the GE software does a lot of monitoring of the drive and is reading continuously so picking out the write commands is a bit tedious. If I get a chance I'll post up some of the commands it sent cause they don't make a lot of sense to me (though I was doing this at midnight so maybe that was the problem).

    From memory an example command started as:

    01 30 31 06 53 .......

    I get the 01 - address 01 but then 30? I can't find anything like this in the manual for a function code?
    31 - lost me here too
    06 53 - From the manual S06 is operation command so 53h = S in Ascii
    Note - i may be reveresing the 06 53 as this is from memory... I'll correct it when I can confirm what I recorded - too many pc's!!!)

    Went back and I can't view the log I recorded as its and unknown format to windows and I need some sort of program to read the log file

    I might get to this tomorrow and do it all live with multiple pc's to try and get as much as I can written down..

    Mike

  13. #13
    Join Date
    Nov 2005
    Posts
    496
    Are you comfortable with classicladder, HAL, and the command line?

    I have a CL test program.

    based on what I understood from manual:
    s05 sets the command frequency.
    s = 08H, 05 = 05H = 0805H subtract 1 = 0804H = 2052 in decimal
    the range of the frequency is 0.00 to 400.00 in .01 increments
    though you must multiply the speed by 100 before sending it to the VDF
    eg for 40 hz command send 4000 for 62.1 send 620

    so for CL 2053 would be the 'first modbus address'
    the 'type access' would be write regs(s) we want function code 6 so...
    the number of elements would be one (if you ask for more elements then CL automatically uses function code 16)
    the slave number is 1 .

    ok the classicladdert proigram i posted is run from the command line with out EMC at all.
    its called modbus.txt (so the zone will upload it) you must change it to modbus.clp

    open a terminal
    change directory to the place you downloaded the CL program.
    and type halrun

    they type these commands (return after each):
    loadrt classicladder_rt
    loadrt threads
    addf classicladder.0.refresh thread1
    start
    loadusr classicladder --modmaster modbus.clp

    if the VFD is connected and every thing goes well it should start communicating right
    away.The terminal will continuously spit out comments which will help us debug problems.
    on the classicladder section view window click the vars button till you see the bit status window.
    clicking B2 on or off should alternately send the frequency command of 20 or 0 hz respectively.

    click on th config button a window will come up click on modbus comunication.
    there are a lot of options available. one that might come up right away is modbus element offset. I set it to 0 pretty sure thas right but its easy to try both. this is if the communication works but the VFD doesn;t respond properly.

    I mentioned that 8n2 is possible but not documented - i will tell you how its was done.
    I loaded and saved a dummy modbus classiclader file then opened it with a text editor.
    There you can edit the 8n1 to 8n2 then resave then reload with CL and edit as you want.
    after thyat, you can resave the file with CL and the setting will stay the same.
    the only problem is I have never tested 8n2 on CL so don't know for sure it works.
    You could try other combinations that your VFD supports too.

    Lets start with that and see what happens...
    Attached Files Attached Files

  14. #14
    Join Date
    Sep 2006
    Posts
    509
    Quote Originally Posted by chester88 View Post
    Are you comfortable with classicladder, HAL, and the command line?
    Command line and HAL - yes and somewhat - in that order, classicladder I'm a complete newbie but I'll figure it out!

    Quote Originally Posted by chester88 View Post
    based on what I understood from manual:
    s05 sets the command frequency.
    s = 08H, 05 = 05H = 0805H subtract 1 = 0805H = 2052 in decimal
    Thanks - This is what I was missing in the manual (lookup table to command code) and now the messages I was looking at are starting to make sense.

    I'll give the classic ladder a try out tonight and let you know how I make out.

    thanks again.

    Mike

  15. #15
    Join Date
    Sep 2006
    Posts
    509
    I was able to get it to talk using the classic ladder but I couldn't control it. I need to do some more investigating as to why. It doesn't like the command 2052 (exception code 86)

    I tried very briefly a read from 0 and that works (no errors) so the communications are sorted out - I just need to work out what to send. A little slow this week as I came down with a stomach bug....

    Mike

  16. #16
    Join Date
    Sep 2006
    Posts
    509

    Progress...

    I made some good progress tonight but I obviously need to learn classicladder if I'm going to be successful at this...

    Using the modbus.clp file Chris supplied I was able to establish coms with the unit but I was getting errors. Turns out the manual for the VFD sucks even more than I thought! I searched a bit more and found users manuals for later versions that are a little bit better and detail the commands codes in plain English - setting the frequency is S05 - which maps to 1797 (function code S = 07, so 0705h = 1797

    Editing the communications config to use this results in no errors but the drive still does not spin - I can toggle the %B2 variable and see the output change but no response from the motor/drive.

    Next I tried to sent the command function (S06) for forward / reverse but no go

    I'll try again tomorrow night...getting late now

    Mike

  17. #17
    Join Date
    Nov 2005
    Posts
    496
    hmm the manual said to subtract one from the command address try 1796.
    did you try the setting the modbus offset from zero to 1?
    Are these manuals later versions of the same model?
    do they have sample commands?
    i hope you figure this out!
    Chris m

  18. #18
    Join Date
    Sep 2006
    Posts
    509
    Quote Originally Posted by chester88 View Post
    hmm the manual said to subtract one from the command address try 1796.
    did you try the setting the modbus offset from zero to 1?
    Are these manuals later versions of the same model?
    do they have sample commands?
    i hope you figure this out!
    Chris m
    I've tried just about every combination of addresses, offsets, etc.

    I took a break from it for a bit to let some of it sink in...there are too many variables at play that I need to get working.

    i.e. the drive needs to be put in a mode where it can be commanded to spin from the RS485 - appears the GE software does this but I'm missing it somewhere...

    I need to reconnect with my laptop and spy on the communications between the GE software and the drive again...I think last time I was seeing only one side of the conversation and it was the response from the drive - I'll see if I can fix that so I see it all - hopefully it will reveal that last little bit of missing information.

    Mike

  19. #19
    Hi Mike,

    I've written linux modbus drivers for Fuji, Danfoss, PDL, ABB

    It's been a while, but assuming your baud rate, cabling, and parity are all set correctly.

    If you have a function that does write to holding register, mine is called
    int WHR( int address, int data)

    //To start the drive, write 0x8001 to address 1798 // clears faults and sets the start bit (forward that is) reverse would be 0x8002

    WHR(1798,0x8001);


    To set the frequency write frequency*100 to address 1797

    WHR(1797,freq*100); // ie to set 30 hz you would write 3000 to 1797

    To stop the drive, write 0x00 to 1798

    WHR(1798,0x0));

    Hope that helps.

    Regards
    Ray

    EDIT: I'm pretty sure you've already got a handle on this, but be aware that, those addresses are what appears on the line, PLC's and some other software offsets the holding register addresses by 40001...

    EDIT2: It's coming back to me in bits and pieces, but there is another manual, which documents some AUX registers that let you do 8N1, sorry I can't seem to find it at present... I'll look for it over the next few days..

  20. #20
    Join Date
    Sep 2006
    Posts
    509
    Hi Ray,

    If there is anything you can contribute I'd be very appreciative. I'm taking a short break from it to let my head heal from all the thinking I've been doing.

    I'm going to draw up a game plan of how to move forward with this and a checklist of all the different "variables" that need to be correct before the drive will work under Modbus control (ie settings that make operation and frequency commands valid, etc)

    I'm also going to start by reading from the drive all the registers I can and see if they match what I read using the GE software (ie confirm that the address / register I think I'm at is the the one that I get data from)

    BTW the GE software appears to transmit using what I'm guessing is ASCII type Modbus - ie the address 01 is transmitted as 30 31 which are the ASCII characters 0 and 1 in hex...I'm not familiar with this and the manual doesn't say anything about it..

    But it accepts my transmitions that are formatted in RTU Modbus....just doesn't actually do what I ask...

    I'm going to relax and make a few things while it all sinks in...

Page 1 of 2 12

Similar Threads

  1. Modbus to run GS-2 drive?
    By mecheng10 in forum Mach Mill
    Replies: 14
    Last Post: 06-17-2012, 07:01 PM
  2. USB Modbus I/O Using PIC
    By rdhopkins in forum PIC Programing / Design
    Replies: 7
    Last Post: 05-03-2012, 01:23 AM
  3. Mach3 with Hitachi VFD using Modbus
    By swinn in forum Mach Software (ArtSoft software)
    Replies: 2
    Last Post: 11-28-2008, 07:44 PM
  4. EMC2/Modbus......HELP!
    By pauldkeeton in forum LinuxCNC (formerly EMC2)
    Replies: 5
    Last Post: 02-18-2007, 11:47 PM
  5. modbus device
    By Drew in forum Machines running Mach Software
    Replies: 14
    Last Post: 02-11-2007, 08:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •