Author Topic: Master-slave DACs  (Read 42644 times)

Sonny

  • Guest
Master-slave DACs
« on: May 27, 2005, 11:34:38 AM »
Hi,
i'm working on a project where I am using the D/A outputs to control 4 variable valves (I chose the D/A outputs over the PWM outputs because the valves are controlled by a 0-5V voltage).

I am buying another T100MD-888 to use in a master-slave configuration so that I then have 4 D/A outputs.  However, I can not figure out, from the manuals, how to send instructions from the master to the slave, specifically instructions that pertain to the D/A outputs.  I would like to learn about those before purchasing the 2nd PLC.

Also, is it possible to divide my program between both PLCs?  In that way, I can divide my program into 2 separate files, and do certain functions on each?  As in, when the master runs into code that it does not contain, it activates the slave(somehow), and then the slave runs through its program?  It would definitely make my program easier to manage.

Thanks

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Master-slave DACs
« Reply #1 on: May 27, 2005, 11:59:11 AM »
You can link up the two PLCs' RS485 bus. Then you can let the master write a value for the DAC to the slave using the NETCMD$ output. There are two ways of doing it:

1) If your slave PLC has firmware version r47 or above (new PLCs  now carry firmware r49), you can use the "@nnWAnnccxxxx" host link command to directly set the DAC on the slave without the slave program doing anything. See page 4-15 in your T100MD+ User's Manual (blue color cover) for description of this command.

2) If your firmware version is older than f47 which means it does not support the "WA  host link command. In that case, then the master will have to write to the slave PLC's data memory DM . The slave PLC will have a function that regularly checks the value of the DM and update the DM value to the DAC using the SETDAC command. i.e. in this case the slave PLC needs to handle the SETDAC command. However, this approach has the advantage that master/slave communication can be accomplished using READMODBUS/WRITEMODBUS command which is slightly simpler to use.

The "RemoteIO-Mseries.PC5" sample program in your TRiLOGI samples folder gives you the example of master-slave communication using NETCMD$.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Sonny

  • Guest
Re:Master-slave DACs
« Reply #2 on: May 27, 2005, 12:34:04 PM »
The T100MD888 that I have now has older firmware, however, the slave would be the new one that I purchase.  I'm assuming that then, I could use the WA host link command?

Also, if I were to use this method, what does the response mean? I mean, if I'm sending something to a D/A output, I shouldn't expect a response, right?

I'd be using the slave for the D/A outputs, as well as to control 3 ON/OFF valves (through digital outputs).  Will the sending of instructions to the slave result in any timing delays?  Or will the master execute its instructions as normal even when it sends information to the slave.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Master-slave DACs
« Reply #3 on: May 27, 2005, 12:37:56 PM »
Yes, the newer PLC you purchase should carry the new firmware. The master can be older firmware since the PLC always support the NETCMD$ command.

The response string from the all the host link commands are listed in the User's Manual. Please refer to the manual for details. Normally you don't have to do anything about the response string if it is a write commnad. The NECMD$ takes care of FCS and slave ID verification before returning the string to you so you can assume that the returned response should be correct unless there are multiple PLC of the same slave ID on the same RS485 network, then the response may be erroneous.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Sonny

  • Guest
Re:Master-slave DACs
« Reply #4 on: May 31, 2005, 06:54:51 AM »
In looking through the manual for my PLC, I was wondering if it was possible to use the following command to write to the DAC:

WVS0Cxxxxxx*

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Master-slave DACs
« Reply #5 on: May 31, 2005, 11:10:16 AM »
No, that will not work. The PLC CPU will not be aware that it needs to update the DAC hardware with the new value even if it accepts the WVS command.  Only the newer PLC with firmware r47 and above will react to the WA command to set the DAC accordingly.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Sonny

  • Guest
Re:Master-slave DACs
« Reply #6 on: June 08, 2005, 06:41:16 AM »
Well, I just got my 2nd T100MD888 in the mail, and in looking through the instructions for setting the D/A output, I got confused.

It says that the format is:

WAnncc(16^3)(16^2)(16^1)(16^0)...(16^1)(16^0)*

where
nn=starting analog channel #(01-02h)
cc=channel count

what does that mean? is a channel count like a timer or something? There's only 2 analog channels, so I'm assuming nn would be 01 or 02

Then it says that you enter the DAC output data for 1st channel and then DAC output data for subsequent data.  I don't understand that either.  I'm assuming the first 4 numbers would be the 0-4096 number.  But what about the next few numbers?

Thanks

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Master-slave DACs
« Reply #7 on: June 08, 2005, 09:42:53 AM »
The channel count allows you to write to one or more DAC in a single NETCMD command. If you are writing to only a single DAC, then put 01 and only 4 digit of hex value

E.g, to write to DAC #1 and 2,

  DAC1  =  1000  decimal, or  03E8 in hex
  DAC2 =   2000  decimal, or  07D0 in hex

and assuming your slave PLC has ID=05

Then run:
   A$ = NETCMD$(3, "@05WA010203E807D0")

That will write 03E8 to DAC 1 and 07D0 to DAC 2.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Sonny

  • Guest
Re:Master-slave DACs
« Reply #8 on: June 09, 2005, 07:16:05 AM »
the communication is going well, the problem I am having is that there is always a little bit of error in the value of the D/A output on the slave.  For example, if I input 4095 (4096 does not work for some reason), I get 4.95V instead of 4.99 or 5.00V.  This small drift occurs for any value I try to input (instead of 3.70 i get 3.67, etc.).  I calibrated the outputs on the slave by turning the potentiometer, but now it cannot turn any farther and I'm at a loss as to why there is this small difference.

Is there supposed to be a slight loss of accuracy when you send something to the slave?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Master-slave DACs
« Reply #9 on: June 09, 2005, 12:40:30 PM »
You should calibrate for the analog reference voltage (AVcc) to +5V by using a voltmeter to measure the analog reference voltage pin while you turn the potentiometer.  (Of course the calibration for the slave analog is to be performed at the slave PLC, not at the master).

The highest DAC value you can set for an 8-bit DAC is 255 out of full scale of 256.  For the M-series PLC it was normalized to 12-bit so the maximum possible value for DAT is 4080 out of full scale of 4096. So if your reference voltage is +5V the maximum output voltage from DAC is:

    4080/4096 * 5.00V = 4.98V.

Did you connect the DAC output to any low impedance load?  The loading factor can cause the DAC output to drop. You are supposed to connect only to high impedance load or use a buffering opAmp to buffer the DAC outputs.  Try to measure the voltage before the DAC is connected to the load.

A better way to measure is when DAC is set to 2048 and you should get about 2.50V +/- linearity and quantization error.



« Last Edit: June 09, 2005, 12:43:39 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Sonny

  • Guest
Re:Master-slave DACs
« Reply #10 on: June 15, 2005, 12:10:28 PM »
small, off-topic question here:

If I want to update my PLC from my house, how does it work?  Do I need TLServer over there too?  Or is having it connected to my computer at work enough?

Thanks

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Master-slave DACs
« Reply #11 on: June 16, 2005, 01:02:28 PM »
To connect to the PLC there are two means:

1) Connect the PLC to a PC running TLServer or connect it to an Xserver.  I assume either the PC or the XServer would be accessible via the Internet. If you use a router for your network then you have to configure the network such that the TLServer or XServer can be accessed from the public internet address (usually by means of "Port Forwarding" method). You now can use your home computer's TRiLOGI software to access the PLC via the Internet.

2)  Connect the PLC to a MODEM and use your home PC's modem to connect to the PLC. In this case, Both TRiLOGI and TLServer should be running on your home computer. TLServer is the one that will dial the PC's modem to connect to the remote modem.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Sonny

  • Guest
Re:Master-slave DACs
« Reply #12 on: June 20, 2005, 12:48:30 PM »
You should calibrate for the analog reference voltage (AVcc) to +5V by using a voltmeter to measure the analog reference voltage pin while you turn the potentiometer.  (Of course the calibration for the slave analog is to be performed at the slave PLC, not at the master).

The highest DAC value you can set for an 8-bit DAC is 255 out of full scale of 256.  For the M-series PLC it was normalized to 12-bit so the maximum possible value for DAT is 4080 out of full scale of 4096. So if your reference voltage is +5V the maximum output voltage from DAC is:

    4080/4096 * 5.00V = 4.98V.

Did you connect the DAC output to any low impedance load?  The loading factor can cause the DAC output to drop. You are supposed to connect only to high impedance load or use a buffering opAmp to buffer the DAC outputs.  Try to measure the voltage before the DAC is connected to the load.

A better way to measure is when DAC is set to 2048 and you should get about 2.50V +/- linearity and quantization error.






When I calibrated the reference, it goes up to 4.99V, which I guess is ok.  But on the other PLC, I can go over 5V for the reference, and when I do that, the DAC is more accurate (it goes up to 5V, and gives exactly 2.50 V when I input 2048, when the reference is 5.03V).

So, when I input 2048, I get 2.48V, and when I input 4095, I get 4.96V on the new PLC.

Sonny

  • Guest
Re:Master-slave DACs
« Reply #13 on: June 28, 2005, 10:42:32 AM »
I have another problem.  On my PLC, I want it display the user interface in both English and French.  However, when I wrote in special characters (?...) they come out as weird characters on the PLC LCD (? comes out as the exponent -1).  How can I do this?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Master-slave DACs
« Reply #14 on: June 28, 2005, 01:53:29 PM »
The LCDs support standard ASCII text only and a limited number of special characters. You need to check the character maps for LCD420 which can be found in the LCD full manual. A scanned copy of the character map is as follow:



The LCD will not be able display beyond these predefined character set unless you want to create your own character using the special LCD command (pretty messy way and you are pretty much on your own if you want to take that route).
« Last Edit: June 28, 2005, 01:53:58 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS