Jump to content

Recommended Posts

I've downloaded and have messing around with the Unitronics ComDriver. I've managed to be able to read and write MI, MB, etc. The only problem I'm having is being able to write or change the value of the inputs. I can read them using OperandTypes.Input, but can not write.

I was thinking that it acts the same way as the MB, that any value over 0 will give you a 1 but it won't change. I then tried to change the MB assigned to the input but since it was connected it also wouldn't let me change the value. Doing some digging I spotted a forcedparams under the Unitronics.ComDriver, but was unsure of what that initially does. I was hopeing it would force the input either on or off like the info mode would do. I was looking at both the VB and C# examples.

Any help would be greatly appreciated.

Link to post
Share on other sites

Forced Params under the Unitronics.ComDriver (I belive that you are talking about the .Net communication driver, not the ActiveX driver) is not for forcing an input (But for forcing some comunication parameters).

Forcing an Input or an Output is possible with the ActiveX DLL, but unfortunatelly, it is not supported out of the box in the .Net communication driver.

You can try using Plc.SendString

where the string is in the format of (As explained in the PCOM: http://www.unitronics.com/Data/Uploads/communication/Unitronics%20PCOM%20Protocol.pdf) :


There CC is the Command Code (SE for Force Output, SD for force Input

Address (4 characters) is the address of the output in HEX

Length is the number of bits to write (2 characters, Number is in Hex)

Values is the values (Also in HEX, but for bits 0 and 1 remain the same)

For example, force input 32 to value 1:


I have not tested the string, but I think it should work.

Link to post
Share on other sites

I've tried using the plc.sendstring and I get 'SD' is a type and cannot be used as an expression. I've tried calling it at in addition to the Imports Unitronics.ComDriver (ex.Imports Unitronics.ComDriver.SD) but that didn't seem to help.

Would it be better to use the C# example as opposed to the VB?

Here's just a small snippet of what I have

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

plc.SendString(SD, 0, 1, 1) { I also tried (SD0000011) but it didn't like that format without the comma's}

End Sub

Link to post
Share on other sites

Send string accepts string and Unit ID, therefore you need to give it a string, meaning:

(assuming the PLC is connected to your PLC with no CANBus in the middle, then the Unit ID is 0)

plc.SendString("SD0000011", 0)

Off course plc.SendString(SD0000011) will not work, because it is missing the Unit ID, and also because SD0000011 is not surrounded with ", then the compiler thinks it is a variable or a class and not a string.

plc.SendString(SD, 0, 1, 1) will not work either because again, the number of arguments is wrong, and in this case SD is a type of a class (the SD class is used for reading and writing files from the SD Card of the PLC, it if has one)

Link to post
Share on other sites

Thanks that worked perfectly. Here's an example of what I'm trying to accomplish. We do a lot of trucks that use either the v130 or v570, and we usually don't get a lot of time to troubleshoot progams. It's usually put the program in the truck as they are testing it and getting ready to ship. Our test rig is a big board of switches and output lights that is a mangled mess to hook up. So I figured I'd write up a vb program that would be a virtual test rig that I can run side by side with visilogic and the plc.


This is the basic setup, and from testing works as planned right now. I plan on adding more funcionality. Overall I want to be able to add a drag and drop inputs and outputs.

Link to post
Share on other sites
  • 4 weeks later...

Just wanted to update with progress.


Program features:

- Ability to save and open files, setup and text

- Outputs update real time from PLC and Input buttons

- LED lights automatically update according to 1 or 0, on or off

- Ultrasonic Slider feature control (Controls tank level, 4-20ma)

I'm planning on adding more inputs to use with expansion modules. Button to open or close another window with a visual of the expansion modules. And the ability to choose which COM port to use. I'm running into a bit of a wall with the COM issue and the Unitronics code. Suggestions are greatly appreciated.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...