Announcement

Collapse
No announcement yet.

Modbus with Arduino

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts


  • Modbus with Arduino

    I am wanting to control my GS2 drive with an Arduino sending a frequency command to the drive over rs485. The Arduino will have a PID controller. I know the GS2 drive has a PID controller but I kneed more control that I can do with the VFD. I can program basic stuff with the Arduino but I need a little help with this code. I will be including the <ModbusMaster.h> library or if somebody has a better one let me know. Also would like to read the frequency from the dive as I am also planning on connecting a display to the Arduino.

    I would like to know the settings I need to set on the VFD and also some example code that I could copy and past. That is well explained and then I can possibly be able to build it from there.


  • #2
    A couple years a go I did these with a CLICK
    read coil - this library's link still works
    read register - it seems that this library's link is cold
    I have not done much with arduino since then.

    Comment



    • #3
      I've played around with a few modbus libraries recently. I've had the most luck with the one straight from Arduino; It supports acting as the master or slave device and both TCP and RTU.

      Comment



      • #4
        I've had good luck with the SimpleModbusMaster and SimpleModbusSlave library with the DUE (SAM3X8E), but note that it doesn't support the full Modbus protocol Standard (only functions 1,2, 4 and 15). I think it's enough to get started communicating with a GS drive though! Let us know how you make out?

        Comment



        • #5
          Originally posted by TimR View Post
          I've had good luck with the SimpleModbusMaster and SimpleModbusSlave library with the DUE (SAM3X8E), but note that it doesn't support the full Modbus protocol Standard (only functions 1,2, 4 and 15). I think it's enough to get started communicating with a GS drive though! Let us know how you make out?
          That seems to be the same lib (code similarities) that I used for the 'read register' reference in post 2 of this thread. Thanks for locating it in its 'new' place!

          Comment



          • #6
            OK I have the communication part working however I cant seem to send the right data as I keep getting the CE03 error on the drive.

            I am using modbusMaster as my library

            This is the write command I use

            node.writeSingleRegister(0x91A,55); //Write the frequency to the drive

            0x091a is the address for, 9.26 serial comm speed reference, and 55 the frequency

            also tried writing 01 and 00 to 0x91B to turn the drive on and off

            nothing works, just get the CE03 error

            Error CE03 = illegal data value - the data value received in the command message is not available for the AC drive.


            Comment



            • #7
              Have you tried 550 for the frequency? There is an implied decimal place. So a 55 would of been 5.5 hz.

              Comment



              • #8
                I was able to grab an Arduino MKRZERO and RS485 shield and get it talking to a GS1 drive using the attached code. I read the firmware version register to double check comms and then wrote to the Serial Comm Speed register (0x91A) and set it to 5.5Hz.

                One hiccup I had was my drive wasn't configured to Serial: 8 data bits, no parity, 1 stop bit. This is what the Arduino will default to for it's RTU comms.
                Attached Files

                Comment



                • #9
                  https://www.arduino.cc/en/Serial.Begin

                  The Serial library can be configured with multiple options.
                  Select how you want/need it.

                  Comment



                  • #10
                    Ok, I was able to get it to work. I needed to have P3.00 and P4.00 of the drive set to RS485 commands, after that the errors went away. I attached a copy of my code. I am not a programmer so I am sure you will find some things not right. But its working for me.


                    Now my next challenge is read from the drive.
                    Attached Files

                    Comment



                    • #11
                      Originally posted by Ben7230 View Post
                      Ok, I was able to get it to work. I needed to have P3.00 and P4.00 of the drive set to RS485 commands, after that the errors went away. I attached a copy of my code. I am not a programmer so I am sure you will find some things not right. But its working for me.


                      Now my next challenge is read from the drive.
                      All that code and not a single delay() to be found. Nice.

                      Comment

                      Working...
                      X