Protobuf protocol buffer .net c# implementation

I’ve red about protocol buffers many month ago, when i was googling about a simple and fast RPC implementation. My attention was attracted by the low transmission bandwidth consumption and the object oriented message system. After a fast analysis I’ve tried to use these open-source products:

  • protobuf-net (Last update Sep 2013, Apache license 2.0)
  • protobuf-remote (c# 1.1, Last update Apr 2011, LGPL)

I  recommend you to start by the example in the Sample  folder (PrimeClient and PrimeServer), there you can see a simple RPC implementation for the math function: bool isPrime(int number) The client query the server in a synchronous and asynchronous way for the desired number.

Note:

I’ve made the test with Visual Studio 2013, you don’t need to install or configure nothing (only dll reference in your project)

Problems found:

I’ve tried to create a my client-server implementation using Socket class, but it doesn’t work for me. I think that the implementation has some bugs, or need an improvement for working with Socket. It works very well using TcpClient and TcpListener classes.


Arduino modbus master/slave communication

Hi, everybody this is the code I use on my application to exchange data between two Arduino Uno r3 using a MAX 485 chip on RS485 network.

Arduino Modbus library download site:
http://code.google.com/p/simple-modbus/

Modbus slave code


#include <SimpleModbusSlave.h>

#define RXPin 0
#define TXPin 1
#define PTTPin 2

enum {

PARAM1,
PARAM2,
PARAM3, // add params as you want, here!
// leave this one
TOTAL_REGS_SIZE
// total number of registers for function 3 and 16 share the same register array

};

unsigned int registers[TOTAL_REGS_SIZE];

void setup() {

// Modbus init
modbus_configure(9600, 2, 2, TOTAL_REGS_SIZE);

}

void loop() {

modbus_update(registers);

}

Modbus master code


#include <SimpleModbusMaster.h>

#define baud 9600
#define timeout 1000
#define polling 250
#define retry_count 10
#define TxEnablePin 8 // Pay attention! Use 3 if you want...

enum {

READ_P,
// leave this one
TOTAL_NO_OF_PACKETS
// total number of registers for function 3 and 16 share the same register array

};

enum {

PARAM1,
PARAM2,
PARAM3, // add params as you want, here!
// leave this one
TOTAL_REGS_SIZE
// total number of registers for function 3 and 16 share the same register array

};

Packet packets[TOTAL_NO_OF_PACKETS];
packetPointer readPacket = &packets[READ_P];

unsigned int slavedata[TOTAL_REGS_SIZE];

void setup()
{

// read 3 registers starting at address 0
readPacket->id = 2;
readPacket->function = READ_HOLDING_REGISTERS;
readPacket->address = 0;
readPacket->no_of_registers = TOTAL_REGS_SIZE;
readPacket->register_array = slavedata;

modbus_configure(baud, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);

}

int loop()
{

unsigned int connection_status = modbus_update(packets);

if (connection_status != TOTAL_NO_OF_PACKETS)
{

// You could re-enable the connection by:
packets[connection_status].connection = true;

}

}


Arduino PLC PCB

Now is possible to connect your Arduino board with industrial equipment. This PCB allows you to get:

  • 4 Optoisolated digital input 12/24VDC
  • 2 0-10V analog output
  • 4 digital output 12/24VDC (you can command relays to get your load work)
  • 2 Temperature input (4€ NTC probes works fine)
  • 1 0-10V analog input
  • Modbus RTU port master/slave

You can buy a professional printed PCB or you can get assembled version on request.


Looking for LCD enclosure production partnership

Hi everybody, we’ve engineered a lcd shield based on Arduino UNO that works as remote control station, communicating to one or many other Arduino over rs485 bus line.

The implementation seems to be roubust and scalable, but the enclosure must be improved.

We are looking for anyone want to produce a professional and low cost enclosure.

For now we are planning to buy 50pcs/year

Note: the lcd shield can also be installed into the wall into a 503 or 504 box.

20131013-084600.jpg

20131013-084606.jpg

20131013-084611.jpg


Working on third party incomplete S7 software

Doing manteinance, debugging and new feature developing on third party software before summer holidays isn’t simple. Big calm and clear targets are required.

In the past, I’ve continued to tell to my self: “this is the last time!” but now, after many years, and many “red code jobs” i start thinking that this part of my job.

Now the plant is shipping to the final customer, good luck!


Arduino at work on HVAC product

Working on heat recovery ventilation automation based on Arduino UNO rev3 board with a custom shield to connect:

  • Two temperature sensor (ntc);
  • A 0..10V analog input
  • Two inverter controlled by PWM 0..5V or 0..10V output
  • Four static 24V relay-ready outputs
  • Modulating valve mounted on a heating coil controlled by a PID
  • Freecooling by-pass damper
  • Anti-freeze damper
  • Modbus RTU on RS485 to communicate with a remote display

Remote display based on Arduino UNO rev3 board wall mounted with:

  • LCD display with 4 arrow keys
  • Two level menu navigation
  • Modbus RTU on RS485 to communicate with the HVAC device

At now we have made 12 plants shipped in Italy, France and Africa

Stay tuned!


Step 7 Axis positioner

EN:

AUTHOR:

Andrea Piovesan
Email: andrea.piovesan at (google mail domain aka = gmail.com)
Web: http://automationcorner.wordpress.com

LICENSE:

GNU Lesser General Public License
Version 3, 29 June 2007

REQUIREMENTS:

Hardware: Any CPU Siemens S7 300, 312, 313, 314, 315, 400, …
IDE: Siemens Simatic STEP 7 Ver. 5.3 or higer
Language: AWL

OPERATION:

This FB works with adjustable time base. Call the function block in the normal scan cycle of the program (making sure that the cycle is faster than the time base) and set the bit “TimebaseOneShoot” with a pulse generator (one pulse
every timebase period) Alternatively you can call this function block into OB35 scheduling such as 100ms task and set the bit “TimebaseOneShoot” with TRUE constant.

Note: Calling this function block into OB35 simplifies the program, but affect the speed of response and the precision.

The positioning is done in three phases:
1. Acceleration (freeride)
2. Deccelerezione (braking)
3. Approach (landing)

The first phase the algorithm accelerates the axis with the maximum possible acceleration indicated by the parameter “aMaxAcceleration”; once reached the maximum speed (parameter “vMaxSpeed”) keeps it until it deceleration.

The deceleration occurs according to the uniformly decelerated motion law until the approach speed specified in the parameter “VLandingSpeed”.

The approach begins when the axis enters the space approach tothe overcoming of the end point.

ERROR CHECK

At the end of the run-up shaft retainer (“vCurrentSpeed” = 0) the algorithm verifies that the Tolerance parameter defined in “XTolleranceSpace” is respected otherwise activates the bit error message “Error” and IN However, the signaling bits of arrival “Landed”

ERROR COMPENSATION

At the end of the approching phase (“vCurrentSpeed” = 0) if the parameter “AutoErrorCompensation” is TRUE, it checks the overshoot positioning. The difference from the point of arrival is stored in the parameter “xForwardErrorComp” if the axis is moved forward and “XBackwardErrorComp” if the axis is moved back to help stop advance on the approach to fit within the limits of possible tolerance.

IT:

AUTHOR:

Andrea Piovesan
Email: andrea.piovesan@gmail.com
Web: http://automationcorner.wordpress.com

LICENSE:

GNU Lesser General Public License
Version 3, 29 June 2007

REQUIREMENTS:

Hardware: Any CPU Siemens S7 300, 312, 313, 314, 315, 400, …
IDE: Siemens Simatic STEP7 ver. 5.3 or higer
Language: AWL

FUNZIONAMENTO:

Questo FB funziona con base tempi impostabile. Chiamare il blocco funzione nel normale ciclo del programma (facendo attenzione che il ciclo sia più veloce della base tempi) ed impostare il bit “TimebaseOneShoot” che comanderà il
ricalcolo delle velocità.
In alternativa è possibile chiamare questo blocco funzione nell’OB35 con schedulazione ad esempio 100ms ed impostare con valore TRUE il bit “TimebaseOneShoot”

Nota: Chiamando il blocco funzione dell’OB35 si semplifica il programma, ma si compromette la velocità di risposta al raggiungimento delle varie soglie di posizione a discapito della precisione di posizionamento.

Il posizionamento avviene in tre fasi:

1. Accelerazione (free-ride)
2. Deccelerezione (braking)
3. Avvicinamento (landing)

La prima fase dura fintanto che l’asse è ad una distanza superiore (rispetto al punto di arrivo) della somma tra spazio di frenatura “xBrakingSpace” e lo spazio di avvicinamento “xLandingSpace”.
L’algoritmo accellera l’asse con la massima accelerazione possibile indicata dal parametro “aMaxAcceleration”
Raggiuna la velocità massima (parametro “vMaxSpeed”) la mantiene fino a che non interviene la deccelerazione.

La deccelerazione avviene secondo la legge del moto uniformemente decelerato fino al reggiungimento della velocità di avvicinamento indicata nel parametro “vLandingSpeed”.

L’avvicinamento inizia quando l’asse entra nello spazio di avvicinamento fino al superamento del punto di arrivo.

ERROR CHECK

Al termine della fase di avvicinamento ad asse fermo (“vCurrentSpeed” = 0) l’algoritmo verifica che la tollerenza definita nel parametro “xTolleranceSpace” sia rispettata altrimenti attiva il bit di segnalazione di errore “Error” e IN OGNI CASO il bit di segnalazione di arrivo “Landed”

ERROR COMPENSATION:

Al termine della fase di avvicinamento ad asse fermo (“vCurrentSpeed” = 0) se il parametro “AutoErrorCompensation” è TRUE, viene verificata la sovraelongazione di posizionamento. La differenza rispetto al punto di arrivo viene memorizzata nel parametro “xForwardErrorComp” se l’asse si muoveva in avanti e “xBackwardErrorComp” se l’asse si muoveva indietro che consentono l’arresto anticipato della fase di avvicinamento in modo da rientrare nei limiti del
possibile nella tolleranza.


Follow

Get every new post delivered to your Inbox.

Join 38 other followers