Magnus Lindhe

Default value for the Language property in WPF applications

Most WPF controls you will use are derived from FrameworkElement and use the Language property to format values according to the corresponding culture. By setting the default value for this property you get consistent formatting for all controls in your application.

Read more


Host station port number is expressed using a hexadecimal number

Just a quick reminder to my self in case I make this mistake in the future. The configuration of the built-in ethernet port open settings in GX Developer IEC requires port numbers to be expressed in hex.

This can be confusing if the configured port number only use digits between 0 and 9 like my current configuration. I managed to get confused by this even though the dialog explicitly states that you need to use hexadecimal numbers for the port configuration.

Built-in ethernet port open settings

If you take a quick look at it and try to send a request to port 1392 you will not succeed:

client.Open("192.168.0.1", 1392);
client.ReadWords("D0", 1); 

The correct code also needs to use the hexadecimal number:

client.Open("192.168.0.1", 0x1392);

Or use the correct decimal number:

client.Open("192.168.0.1", 5010);

Read more


Two cases of WhenAnyValue

WhenAnyValue is a method on ReactiveObject that can turn INotifyPropertyChanged.PropertyChanged events into an IObservable.

var layerNotes = this
      .WhenAnyValue(vm => vm.LayerViewModel)
      .Select(vm => vm.Notes)
      .ToProperty(this, vm => vm.Notes);

The code above will actually only push property changes through when the LayerViewModel property is changed. Not when its Notes property changes.

The correct way is to use the complete property chain in the call to WhenAnyValue like the following code:

var layerNotes = this
      .WhenAnyValue(vm => vm.LayerViewModel.Notes)          
      .ToProperty(this, vm => vm.Notes);

The code above will push property changes containing the content of the LayerViewModel.Notes every time the LayerViewModel property changes or its Notes property changes.

Read more


Configure file registers in QCPU using GX IEC Developer

If you get the error code 0x4031 when using MC Protocol to communicate with a QCPU it means that you are trying to read or write to a device address that is out of range. You might as, I did, forgot to setup the file registers in GX IEC Developer.

Q Parameter Setting

Read more


Content before and after tabs using Dragablz

The TabablzControl in Dragablz is capable of displaying content before and after the tab headers in a simple way. Use the HeaderPrefixContent and HeaderSuffixContent properties on TabablzControl. Use HeaderPrefixContentTemplate and HeaderSuffixContentTemplate respectively to provide a template to your content in case it is something else than XAML.

<dragablz:TabablzControl HeaderSuffixContent="After">
    <TextBlock Text="Tab 1"/>
    <TextBlock Text="Tab 2"/>

    <dragablz:TabablzControl.HeaderPrefixContent>
       <TextBlock>Before</TextBlock>
    </dragablz:TabablzControl.HeaderPrefixContent>        

    <dragablz:TabablzControl.HeaderSuffixContentTemplate>
      <DataTemplate>
         <TextBlock Text="{Binding}" ToolTip="You can easily insert content here using HeaderSuffixContent"/>
      </DataTemplate>
    </dragablz:TabablzControl.HeaderSuffixContentTemplate>       

</dragablz:TabablzControl>

Read more


Reboot Mitsubishi QCPU PLC after editing built in ethernet port open settings

Just a quick reminder that you need to reboot your Mitsubishi QCPU PLC after you have edited and downloaded the ethernet port open settings.

Ethernet Diagnostics

Read more


Display link icon for hyperlink in Google Sheets

Google Sheets can display hyperlinks in cells but sometimes you do not want to see the whole hyperlink in the cell. Why not display a nice icon instead? Let me explain how to do it.

Link icon instead of text url

The following formula insert a icon that is hyperlinked to an issue on GitLab. The cell A17 should contain the issue number on GitLab. If A17 is blank the icon will not be displayed.

=IF(ISBLANK(A17);;HYPERLINK(CONCAT("https://gitlab.com/gitlab-org/omnibus-gitlab/issues/";A17);IMAGE("https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-link.svg")))

I use the link icon from the foundicons library hosted on cdnjs.

Read more


Multiple CPU Configuration errors

I am writing a client API in C# for the MELSEC Communication Protocol and wanted to perform a communication test to a PLC. The PLC system I had available was a two CPU system and I used GX IEC Developer to create a simple test program. Since it was a simple communication test to see if the client API was reading and writing devices correctly I was not interested in the second CPU at all.

However, I could not get the PLC program running because of a CPU LAY ERROR. This can be fixed by configuring the correct number of CPU in the system. I then received a MULTI CPU DOWN error which seemed to occur because the default setting is to share memory between multiple CPU. When this setting was removed I got the program running and could proceed with the communication test.

Multiple CPU settings in GX IEC Developer

  • Make sure the correct "No. of CPU" is specified.
  • Make sure the "Host CPU number" is specified
  • Make sure that "Use multiple CPU high speed transmission" is unchecked.

Hopefully this post will be of use to me or somebody else in the future.

Read more


Install Mitsubishi Easysocket USB Drivers on Windows 8

After installing GX Works 2 1.501X on my Windows 8 development laptop I found out that I was not able to communicate with the PLC through the USB cable as usual. After some troubleshooting I found out that the Mitsubishi Easysocket USB drivers has not been installed properly:

Mitsubishi Easysocker USB Driver not installed correctly on Windows 8

This issue can easily be fixed by updating the drivers. Just follow these steps:

  1. Open Device Manager
  2. Locate the USB driver named "MELSEC" as depicted in the image above
  3. Right click on the driver and select "Update Driver Software" from the context menu.
  4. Click on "Browse my computer for dirver software"
  5. Browse to the installation directory of Easysocket and select the sub folder "USBDrivers". My location was "C:\Program Files (x86)\MELSOFT\Easysocket\USBDrivers" but it could depend on where GX Works2 was installed.
  6. Click "Install" when Device Manager identifies the driver as "Easysocket USB Drivers" from Mitsubishi Electric Corporation.

"Easysocket USB Drivers" from Mitsubishi Electric Corporation

Device Manager should be able to find the driver and update it successfully. When the installation is done the driver should appear with the name "MITSUBISHI Easysocket Driver" like this in Device Manager:

Working installation of "Easysocket USB Drivers"

Read more


One way of cancelling commands using ReactiveUI

I was looking for a way to cancel a ReactiveCommand<T> in ReactiveUI but could not find any good official documentation on this. Instead I came up on Gluck's solution on StackOverflow (surprise!).

Read more



Google