Sunday, May 19, 2013

More Modbus



The support of Modbus RTU was just added to Artisan (see this previous post), but it is already time to extend its scope based on your requests. This extension of the Modbus support allows Artisan to talk to more device including some build into commercial roasters.


Before we come to the new configurations, let's start with some Modbus theory. Modbus differentiates between Holding Registers and Input Registers. Holding Registers can be used to read and write data to and from a device via the Modbus function 3. This is what Artisan supported initially. But there are also devices that offer readings in read-only Input Registers to be accessed via the kind of outdated Modbus function 4.


Modbus Function 4


For example, the Fuji PXR/PXG 4 & 5 PIDs as well as the ENDA ETC PIDs hold the temperature readings in Input Registers. While the Fuji PIDs were supported before by device specific code, the ENDA PIDs could not be accessed with the initial Modbus support. As you see in the Modbus tab, from now on you can select Modbus Function 4 as well to read values from devices.

Here is how the updated Modbus configuration tab looks now.

Float Registers


So what is this Float tick-box about? I was contacted by the producer of the San Franciscan roaster telling me that a client would like Artisan support in his new roaster. They offered him a build-to-order option with an Modbus-enabled Watlow EZ-Zone PM6 PID. While this PM6 can be accessed via the Modbus function 3, it does return its readings as float values encoded in 2 groups of 2 bytes. Up to that point Artisan could read only 2 byte integer registers. So we added support for float registers. As the Modbus standard is weak on specifying the standard order of those byte groups, we also added an option to switch from the standard big-endian order to the little-endian order. Some PIDs, like the PM6 allow to configure the byte-order on the device. In this case it has to be ensured that Artisan and the device agree on the order.


Registers vs Memory Addresses


Often you read in the documentation of a Modbus device about memory addresses to access data. Those are usually numbers like 31000 or 40001 (known as Modicon notation). Don't get confused! Those are not the register numbers that Artisan expects in its Modbus tab. However, they are related. Holding Registers (function 3, remember?) have address from the range 40001-49999 and Holding Registers (function 4) from the range 30001-39999. So the memory address 31001 has to be specified by its corresponding register number 1001 or sometimes as 1000 (to be accessed via Modbus function 4; no typo here!) in Artisan and the address 40001 as register 1 or sometimes 0 (to be accessed via Modbus function 3; again no typo).


Modbus Cheet Sheet


First you have to ensure that your serial2RS485 adapter is recognized by your PC (choose one that is compatible with your platform and  were the driver supports your specific device. The FTDI drivers only support devices that have their device id registered within the driver!), which needs to have the corresponding driver installed, and can talk to your Modbus devices. Second, you have to enter the corresponding serial connection parameters into Artian's Modbus tab. Third, note down the Modbus slave id from the device configuration.


  • Watlow EZ-Zone PM6 (2 channel PID; built-to-order for The San Franciscan roasters)
    • channel 1: register=360, function=3, float=true
    • channel 2: register=450, function=3, float=true
Note: this device needs to be set to the correct data map (map 2) and its byte order for floats have to correspond to the one configured in Artisan (little vs big-endian)


  • Watlow Series 96 and 97 (1 channel PV + OUT% PID)
    • channel 1 (PV): register=100, function=3, float=false
    • channel 2 (OUT%): register=103, function=3, float=false


  • Fuji PXR/PXG (1 channel PID)
    • channel 1: register=1000, function=4, float=false, divider=1/10 (with MODBUS RTU meter setup)
    • alternatively select the PID/Fuji setup with the separate radio button and popup

 Note: values needs to be divided by 10 using the formula "x/10.0" in the Symb ET/BT tab. Anyhow, Artisan comes with a specific support for the Fuji PIDs that allows also the control of a device by selecting PID in the device settings. 


  • myPCLab (2+1 channel temperature meter)
    • channel 1: register=4, function=3, float=false
    • channel 2: register=5, function=3, float=false
    • ambient temperature: register=6, function=3, float=False

 Note: the myPCLab ignores the slave id (just set to 1) and values needs to be divided by 10 using the formula "x/10.0" in the Symb ET/BT tab


  • ENDA ETC 4420 (one channel PID; build into some Toper roasters)
    • channel 1: register=0, function=4, float=false


  • Autonics TK4S (one channel PID; build into some Proaster roasters)
    • channel 1: register=1000, function=4, float=false

  • APAR AR 200
    • channel 1: register=12, function=4, float=false
    • channel 2: register=13, function=4, float=false


  • Delta DTA / DTB
    • channel 1: register=4699, function=3, float=false, divider=1/10
    • select PID (not meter) with the corresponding radio button and choose DTA/DTB from the popup. The device needs to be configured to communicate MODBUS ASCII with baud 9600, 8 N 1


    • baud rate: 9600 (to be sure you set the same baud rate on E5CC)
    • parity: If you choose "n" then "byte size" will be 8, and "stopbits" will be 2!! If you choose "e", or "o", "byte size" will be 8, and "stopbits" will be 1!! THIS IS UNCHANGEABLE!! E5CC will hide byte size and stopbits selection once you choose Modbus!!
    • slaveId: just set the same as what you set on E5CC
    • register: 8192
    • function: 3
    • divider: 1/10
    • mode: C
    • little-endian: enable
    • type: Serial-RTU



So if you order your The San Franciscan roaster today, ask for the Artisan build-to-order option;)

39 comments:

  1. I'm trying to connect my Proaster with Autonics TK4S PIDS and USB converter. I'm reading the communication manual here:http://products.autonicsonline.com/Asset/tk%20communication%20manual.pdf

    If i read the manual correctly and this blog post correctly, if I wanted to configure artisan to read the Present Value from the PID (i.e. the temp reading), I should set Input values for Input 1& 2 to Slave "1" Register "1001" Function "4" ? The PV address in the manual is listed as 31001.

    ReplyDelete
    Replies
    1. Dear Ian, Please refer my case.
      In my case, I set-out like below;
      Input1: slave(1), register(1000), function(4), float(unchkd)
      Input2: slave(2), register(1000), function(4), float(unchkd)

      Even thought AUTONICS MANUAL speak register(1001), ARTISAN worked on the register(1000). I don't know the reason, but it's a real.

      Hope your success!!

      Delete
  2. Yep, the PV register should be 1001 accessible via function 4 on slave 1. Did that work for you? Seems that the TK4S is a single channel PID. So if you have two of those, just configure input 2 the same as input 1, just using the slave id of that second PID (both PIDs should be assigned different slave ids and connected to the same Modbus wire that is connected via this one modbus2serial converter).

    ReplyDelete
  3. I have found the SOLO 4848 that now comes on some US Roaster's Corp machines works well.

    Note that the documentation for the SOLO is wrong for the PV adddress, it shoud be 4096 rather than 4097. 4097 is the SV address. you also need to load the SL Soft software for the drivers.

    ReplyDelete
  4. Thanks Ricky! Just added that information to the post.

    ReplyDelete
  5. Marko,

    I have seen a number of posts where people running SF roasters with the Watlow and B&B 485 to USB converter cannot get the temps to come up in Artisan. This is my issue. Did I miss some resolution to this issue?

    Thanks,

    Frustrated Sam

    ReplyDelete
  6. Samuel, there is an issue with the B&B modbus2USB converter that is delivered with the SF roaster on the Watlow configuration. While the converter is excellent, it is not supported by the FTDI driver on the Mac OS platform most likely due to a missing license agreements. There should be no issue on Windows. So this is not exactly an Artisan issue. There is a (ugly) way to patch the kernel extension of the FTDI driver to make that converter work (see http://dfusion.com.au/wiki/tiki-index.php?page=Installing+FTDI+USB+Serial+Driver+on+Mac to get an idea). However, a better alternative is to replace the converter by one that comes with Mac support. Generally, the FTDI-based products are more stable also on the Mac than all other alternatives.

    ReplyDelete
    Replies
    1. Marko,

      I have tried the patch to the kernel that you posted elsewhere. I have also tried extensively with my Windows 7 PC. I pulled out the Watlow manual and scoured it for settings that needed changing. I can't get the Watlow, B&B combo to work with either OS. Have other people gotten the Watlow, B&B combo to work on either OS? My next move is to verify the B&B wiring is correct. If that doesn't work I'll look at replacing the B&B. Any suggestions on a converter that works well with Mac OS X?

      Delete
    2. Your combo works for several people on Windows and Mac (after the patch). Did you put your Watlow to register map 2 and Modbus RTU mode? Only suggestion is to look for a (supported!) FTDI-based product.

      Delete
  7. Well. After hours spent troubleshooting, I could not get the Windows setup to work. The Watlow ez zone software would not even talk to the Watlow. On a last ditch effort I connected my Macbook Pro back to the Watlow and low and behold (pun intended) I get the correct ET and BT in Artisan!

    I did rewire the B&B converter. I believe it was wired backwards and I also changed the A- and B+ ports used on the B&B converter. The B&B is a two wire RS-485 unit but it looks like it shares the same box with the four wire RS-485 version. Thus, there are two sets of A and B (Tx and Rx) connections. I'm guessing the A and B ports that were wired are not live ports. Anyways, whatever I did works and the SF6 from San Franciscan works on a Mac OS with the Watlow and B&B converter.

    I'm still puzzled as to why the Watlow and B&B don't work on the Windows Vista OS as Watlow and B&B make it very clear that this is the OS for which they were designed.

    Thanks for the great help Marko!

    ReplyDelete
  8. A big thank you to the entire Artisan Team, your software is truly outstanding! I've finally got Artisan up and running with my Proaster THCR-01 using the supplied serial adaptor and modbus. It even works on my Mac which had the FTDI serial driver I downloaded for the Amprobe TMD-56 thermometer. Thanks to the Proaster owners who posted their settings setup!

    ReplyDelete
  9. buonasera
    Ho problemi con l'installazione del programma "artisan". In pratica , dove dovrebbe leggere la temperatura (ET e BT), esce sempre "0.0" come se la sonda nn funzionasse.
    Come devo fare per configurare per bene il dispositivo "Novus myPClab con Artisan?

    ReplyDelete
    Replies
    1. The myPClab uses an unusual USB2RS485 chip from TI and the vendors driver supports only Windows. Th myPClab won't work on a Mac. On Windows, please first check if the supplied software from the vendor works.

      Delete
    2. Il software myPCLab funziona correttamente

      Delete
    3. Could you please try if v0.7.4 works for you. You can still download this from here: http://code.google.com/p/artisan/downloads/list?can=1&q=&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount

      Please contact me by email to work this out.

      Delete
  10. trying to connect my proaster 1.5 kilo.
    i went through the set up and it gives me an error

    Modbus error : readSingleRegister() [errno 2] No such file or directory: 'COM6'@line 23915

    it doesnt see that it is connected..

    thanks for your help.

    jon

    ReplyDelete
  11. I had to install the driver for the FTDI chip on my Mac again after updating OS versions.

    Here's a good summary for all you out there trying to use an FTDI chip (perhaps a B2B serial to USB converter attached to the Watlow device that San Franciscan uses).

    All I did was install the driver from the FTDI website (http://www.ftdichip.com/Drivers/VCP.htm2) and then edit the info.plist.org file in the system library to include the 44083 product id for the 2W device.

    Below are instructions I lifted from elsewhere that give the more detailed version of events but you can skip most of the terminal work he uses and go straight to editing the plist file.

    Hope this helps someone out there from banging his head against the wall!

    Hi Blake,
    can you let me know what your troubles are. The installation for Artisan was pretty straight forward on the Mac for me. I just followed the instructions on the Artisan page. Here are the key steps:

    Configuration for Mac
    1) Install the latest FTDI VCP driver for Mac OS X (currently v2.2.18) from here http://www.ftdichip.com/Drivers/VCP.htm2)
    2) Convert the ProductID/VendorID shown by the System Profiler in Hex to decimal idProduct and idVendor.
    Open Terminal.app and type (after the # prompt) using the ProductID/VendorID as shown by the System Profiler (without the 0x hex prefix).
    Eg type for the numbers above:
    # dc -e “16i AC33 p 0856 p”
    44083
    2134
    3) Modify the “supported” devices list
    Open “/System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist” with TextEdit and search for an entry for your device.
    The following would be the one for the 485USBTB-4W:
    485USBTB-4W

    CFBundleIdentifier
    com.FTDI.driver.FTDIUSBSerialDriver
    IOClass
    FTDIUSBSerialDriver
    IOProviderClass
    IOUSBInterface
    bConfigurationValue
    1
    bInterfaceNumber
    0
    idProduct
    44084
    idVendor
    2134

    Which is obviously for the 485USBTB-4W device of the same vendor (same vendor id as computed above), however with the product id 44084, not for your product (44083). Now you just have to add a corresponding entry like suggested by that page to get your device being recognized.
    It should look like this:
    485USBTB-2W

    CFBundleIdentifier
    com.FTDI.driver.FTDIUSBSerialDriver
    IOClass
    FTDIUSBSerialDriver
    IOProviderClass
    IOUSBInterface
    bConfigurationValue
    1
    bInterfaceNumber
    0
    idProduct
    44083
    idVendor
    2134

    Save the modified Info.plist to your Desktop
    4) Modify the FTDI driver
    a) Open Terminal.app
    b) Change to the Desktop folder where you saved the modified Info.plist of the FTDI driver
    # cd Desktop
    c) Make a copy of the original configuration file (you will be asked for the admin password)
    # sudo cp /System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist /System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist.org
    d) Install the modified configuration file
    # sudo cp Info.plist /System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents
    # sudo chmod 755 /System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist
    # sudo touch /System/Library/Extensions
    e) Reload the driver
    Just reboot your Mac
    f) Open the Terminal.app again and check if the driver was loaded (connect your device first)
    # kextstat | grep FTDI(this should return something)
    g) Check if the serial ports have finally been allocated (with the device connected!)
    # ls -las /dev | grep -i usb
    (this should list two serial ports one starting with “cu.usbserial-” the other with “tty.usbserial-“

    In Artisan you need to select a ModBus device with the following settings:
    Comm Port: Model 485USBTB-2W
    Baud rate: 9600
    Byte Size: 8
    Parity: N
    StopBits: 1
    Timeout: 1

    Input 1:
    Slave: 1
    Register: 360
    Function: 3
    Float: Checked

    Input 2:
    Slave: 1
    Register: 450
    Function: 3
    Float: Checked

    little-endian: unchecked

    Hope this will help you get it going! For me it worked like a charm.

    Good luck and let me know if it does not work, but let me know what is not working …

    Thomas

    ReplyDelete
  12. This comment has been removed by a blog administrator.

    ReplyDelete
  13. Hello
    Please can you tell me wich pid from Enda works better for controling an roaster. The enda et4420 or the epc 4420. Because Etc4420 does not exist.
    Thank you

    ReplyDelete
  14. Hi Marko. Just managed to pair a Shinko JCS-33A-S/M C5(9600) temperature controller with Artisan software. Shinko writes PV values in register 128, function 3, float false.
    Select Modbus in Device tab, also divider 1/10 in Serial Port Configuration.

    George

    ReplyDelete
    Replies
    1. Thanks George for this. I added your information in the post above.

      Delete
  15. Hey Marko - I've read through everything on your website, but still can figure out how to get Artisan up and running with our SF6. When I enter in the settings under config > serial port as USB Serial Port COM3, Baud 9600, Byte size 8, N11, Input 1: Slave 1 Register 360, Fxn 3, Float Checked; Input 2: Slave 1, Register 450, Function 3, Float Checked, I get:

    Modbus Error: readFloat() no communication with the instrument (no answer) @line 19491

    I'm using the Watlow+Modbus from San Franciscan, and the drivers are all installed. Any ideas?

    ReplyDelete
  16. Hello Marko.
    I have some question about modbus.
    I want to use Artisan for controlling fan and burner but my modbus controller uses 0x10 (16) function to write registers to turn on/off fan and burner. Is there any way to edit modbus command function in Artisan? Or maybe any other way to send hex data to serial port?

    ReplyDelete
  17. Hello Marko.
    I have a question about modbus. I want to control fan and burner via Artisan, but my modbus controller uses function x10 (16) to write into registers to turn on/off fan and burner. I know that "write" command sends 6 function. Is there any way to change sending function into artisan or any other way to send hex to serial port?

    ReplyDelete
    Replies
    1. The write command in Artisan sends MODBUS function 6 (06) if its argument is an Integer and function 16 (0x10) if its argument is a float. So in a event slider MODBUS command you could replace a write(1,100,{}), assuming unitID=1 and registerID=100, by write(1,100,{}.0) or write(1,100,{}/10), depending if you wish to send out values in the range of 0.0-100.0 or 0.0-10.0. Note that the placeholder {} is replaced by the slider value (0-100) multiplied by "Factor" with the offset "Offset".

      Delete
    2. Sadly, but it doesn't help. When i use write(1,9,0.0) Artisan sends data to two registers, 9 and 10 (in my example), but my device has a restriction of one register to be writen with function 16 (0x10) (I know it's stupid but it works that way, using multiple write function with restriction of one register). So i see Artisan sends:

      Mode: RTU
      Address: 1 (Slave)
      Function: 16 (Write Multiple Registers)
      Starting Address: 9
      Number of Registers: 2
      Parsed As:
      Registers 40009-40010:
      Register0: 0
      Register1: 0
      CRC:13253 (OK)

      And device responses:

      Mode: RTU
      Address: 1 (Slave)
      Error Notification
      Function:0x10 (Write Multiple Registers)
      Exception Status: 3
      CRC:3073 (OK)

      But when i use modbus software and send function 16 with 1 register it works great:

      Mode: RTU
      Address: 1 (Slave)
      Function: 16 (Write Multiple Registers)
      Starting Address: 9
      Number of Registers: 1
      Parsed As:
      Registers 40009-40009:
      Register0: 0
      CRC:42697 (OK)

      And device responses:

      Mode: RTU
      Address: 1 (Slave)
      Function: 16 (Write Multiple Registers)
      DATA
      Starting Address: 9
      Quantity Of Registers: 1
      CRC:53707 (OK)

      Any way to set quantity of register in function 16 (0x10) to 1?
      Or, as I said before, i cand send hex data (01 10 00 09 00 01 02 00 00 a6 c9
      ) to device and it works great. Any way to send hex like this from Artisan?

      Delete
    3. Dear Jake, I just added the commands writem(id,register,[v1,..,vn]) and writem(id,register,v) that uses the MODBUS function 16. In case you need a build for testing, contact me via the "Contact Me" form and tell me your operating system.

      Delete
  18. Hi, I am roasting on an SF-25 and having issues connecting to artisan. I recently upgraded from an older MacBook Pro to a new MacBook Air. The issue is that once I plug my usb into the computer and turn on a roast, I receive:

    Modbus Error: readFloat () Exception response@line 29594

    I have checked the following:

    Device Menu
    Meter: Modbus

    Serial Port Config
    Comm Port: USB Serial Cable
    Baud Rate: 9600
    Byte Size: 8
    Parity: N
    Stopbits: 1
    Timeout 1

    Input 1:
    Slave 1
    Register: 450
    Function: 3
    Float: checked

    Input 2:
    Slave 1
    Register: 360
    Function: 3
    Float: checked

    These are the same settings that I had when I was using my old MacBook. And once I downloaded the program and input these settings, it was pretty much plug and play with my old laptop. Does anyone have any advice to troubleshoot this problem? I'll clarify anything I need to to get to the solution.

    Thanks in advance...

    ReplyDelete
    Replies
    1. John, did you install the corresponding serial driver for your setup on the new laptop?

      Delete
    2. I installed the latest FTDI driver for Mac, both third party and the one authorized by Apple.

      Delete
    3. You should only have one FTDI driver installed as otherwise they start to compete. Best the one included in the newer systems (>10.9), so don't install anything if you have a FTDI device. Are you sure that the USB2serial controller has a FTDI chip? If unsure, ask your roaster manufacture.

      Delete
    4. A few updates: 1) I wiped the new laptop, just to have a fresh start without the drivers. 2) I did a little research and found that Mac OS X version 10 or greater doesn't need the addition of FTDI chips. I am also using a SerialComm USB to RS-485/422 Isolate Converter to connect the laptop to the SF-25. I have also reinstalled Artisan, so I am now a blank slate to start figuring out this problem.

      Delete
    5. Could it also be a matter of compatibility? Does Artisan work with the latest Mac OS X (Sierra)?

      Delete
    6. Artisan is build on Sierra. Your Mac is simply not talking to your USB2serial converter. Maybe it is not FTDI-based. So this does not seem to be an Artisan issue. John, I don't think discussing your specific hardware setup issues in comments on this blog is productive. Why not ask an expert nearby or try to get some wisdom from the crowed on the Artisan mailing list or a public coffee roasting forum?

      Delete
  19. John
    I agreee with Marco there's Probably a better forum for submitting your questions. I have a 2014 San Franciscan and recently had Matt send me the new serial to USB converter they are selling. That fixed all of my compatibility issues with Mac OS X.

    ReplyDelete
  20. Hi Marko, Thanks for your software it is great. Just a note for anyone using a Delta DTA / DTB . I had a lot of trouble getting this to work but have it going really well now. The device configuration section PID ... DTA works for reading the PV and setting the SV with no further settings necessary. The trick is to set the mode to ASCII on the DTA / DTB device, with baud 9600, 8 N 1 . Artisan is configured to communicate with the DTA /DTB in ASCII mode.
    One request, could you integrate the slider into the DTA SV control and the P I D settings the registers look correct in the code, but I am no programmer and can't quite see why it isn't working.

    ReplyDelete
    Replies
    1. Thanks Anton for documenting this PID DTA/DTB support thing a little bit. However, this code is quite outdated and this specific PID support might just be removed at one point. As you might know, the generic MODBUS device, if configured properly, can take over all the function, including the SV slider thing and the p-i-d control setting. Just select meter MODBUS as main device tick "Control". The MODBUS tab of the Serial Ports Configuration dialog allows to specify also registers for SV and p-i-d. Would that deliver already what you are looking for?

      Delete