Skip to content

Instantly share code, notes, and snippets.

View nikvoronin's full-sized avatar
:octocat:
await git status

Nikolai Voronin nikvoronin

:octocat:
await git status
View GitHub Profile
@nikvoronin
nikvoronin / Tc3_CurrentConfig.cs
Last active January 3, 2021 21:55
Changes online value of the Scaling Factor Numerator through the CurrentConfig.xml in TwinCAT 3.1
using System;
using System.Linq;
using System.Xml.Linq;
namespace Tc3_CurrentConfig
{
public class CurrentConfig
{
const string CURRENTCONFIG_PATH = @"C:\TwinCAT\3.1\Boot\CurrentConfig.xml";
@nikvoronin
nikvoronin / AxisParameter.AxisEncoderScalingNumerator.xml
Created June 29, 2020 13:22
NC: ChangeParameter 400100010023 / MC_WriteParameterPersistent / AxisParameter.AxisEncoderScalingNumerator
<InitCmd runtimeadded="true">
<key>Init34\NC: ChangeParameter 400100010023</key>
<port>500</port>
<iGrp>16385</iGrp>
<iOffs>65571</iOffs>
<data>011764cbf275493f</data>
<message>Initialization of boot parameter failed (MC_WriteParameterPersistent)</message>
</InitCmd>
<?xml version="1.0" encoding="UTF-8"?>
<TcBootProject>
<Drivers>
<Driver>
<Type>1</Type>
<ServiceName>TCIO</ServiceName>
</Driver>
<Driver>
<Type>1</Type>
<ServiceName>TCPLC</ServiceName>
PROGRAM MAIN
VAR
{attribute 'TcNcAxis' := 'Axis 1'}
ax1: AXIS_REF;
START: BOOL;
McWriteParameterPersistent: MC_WriteParameterPersistent;
END_VAR
McWriteParameterPersistent(
Axis := ax1,
@nikvoronin
nikvoronin / UsbWebmailNotifier.cs
Created July 4, 2020 21:42
Old stuff USB Webmail Notifier #LibUsbDotNet
using LibUsbDotNet.LibUsb;
using LibUsbDotNet.Main;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace UsbWebmailNotifier
{
class Program
@nikvoronin
nikvoronin / Tc3_CustomFileLoad.cs
Last active January 3, 2021 21:53
Custom FB_FileLoad to compare with original one and performance measurement
PROGRAM MAIN
VAR_INPUT
pReadBuf: PVOID;
sPathName: STRING;
END_VAR
VAR
START: BOOL;
READ_AT_ONCE: UDINT := 65536;
Open: FB_FileOpen;
@nikvoronin
nikvoronin / Tc3_FileLoadTest.cs
Last active January 3, 2021 21:53
Testing of the TwinCAT3 POU FB_FileLoad from Tc2_System
PROGRAM MAIN
VAR
START: BOOL;
FileLoad: FB_FileLoad;
bigBuf: ARRAY[0..35000000] OF BYTE;
timeCounter: UDINT;
GetRouterStatusInfo: FB_GetRouterStatusInfo;
RouterStatusInfo: ST_TcRouterStatusInfo;
@nikvoronin
nikvoronin / TcBsd_ReadWriteDevRandom.cs
Last active January 3, 2021 21:53
TC/BSD: Read /dev/urandom by regular file POUs then write result to the file situated at the remote PLC
PROGRAM MAIN
VAR
state: INT;
buf: byte;
tmpStr: STRING;
hDev, hResFile: UINT;
RUN: BOOL;
Open: FB_FileOpen := (ePath := PATH_GENERIC);
PROGRAM MAIN
VAR
END_VAR
VAR CONSTANT
END_VAR
Click to expand (дальше) →
PROGRAM MAIN
VAR
Bang: BitBang;
Bul : BOOL;
Bite: BYTE;
Ind : INT;
LastTime: UDINT;
i, state: LINT;
END_VAR