Según altos estándares industriales

Busca en nuestro Blog. Encontrarás múltiples aplicaciones, soluciones, ejemplos de código. Navega utilizando la nube de etiquetas o busca utilizando criterios específicos

Upload an sketch to a PLC using Ethernet - Step 2 - Binary File


In this post we will see how to take the binary file from an sketch.ino


Ethernet or 20 I/Os PLC:      Ethernet PLC             20 I/Os PLC     

Industrial Shields boards:   Industrial Shields Boards


First of all we need to know the differences between uploading a code via USB  and uploading via Ethernet. When a code is uploaded into an Arduino board using the USB, Arduino IDE software automatically does its magic and transforms the code sketch.ino into a file.hex which is the one that gets uploaded automatically. If we want to upload a code via Ethernet we need to do it manually. To start with, we do not upload a .hex file as in the USB, now it is a .bin file so the first part is getting this binary file.

It is a different process to get the binary file using Windows than using Linux, so this post will be separated into this 2 parts.

1. Common Part. Modification of a Preference in Arduino IDE software.

On Arduino IDE software go to File -> Preferences. tick in the Show verbose output during: Compilation *optional: Upload (not necessary).


2. Verify your sketch on the Arduino IDE software.


*Take in consideration by the time you want to upload a code using Ethernet it has to be done a Reset to the PLC, if the PLC hasn’t been configured to automatically resets, it will have to be manually (pressing phisically the button of reset). Here it is let the post which explains the code you need to add in order to remote reset. 


3. Windows 

In order to create the binary file we need to know where is located the .hex file. This file is created in a temporary folder. By the time a code is verified having this Compilation tick (in Preferences) we will be able to see the path.

We need to situate into the last lines. After “Linking everything together… ” the next line shows this path. It is not showed in the first photo as it is too large for represented in one photo. In this following photo I have just moved to the right the black windows finding the path of the temporary file. (TIP: search for /Temp/)

By default it should be saved in the temporary folder of the Windows system of your user.

If you go to that directory you will find something like this in the temporary folder:

As you can see I have found my .hex file created after verifying my sketch. 

3.1 Open CMD

This is a terminal to insert commands that the Windows understands, we will use this terminal to send a command that will execute an Arduino IDE tool that will convert the .hex into the .bin. 

If you know how CMD works you need to go to the directory of the .ino.hex file which is the one we have seen from before. This is made using the command cd “$path” as it is shown in the photo.
Once we get into the correct directory we need to use this command to use the Arduino IDE Tool that transforms the .hex into .bin. The path on the first path can be slightly different depending on the language and the architecture of your computer (32bits computers have \Program Files (x86)\).
C:\Program Files\Arduino\hardware\tools\avr\bin\avr-objcopy.exe" -I ihex [sketchname].ino.hex -O binary [sketchname].ino.bin
Here is the result: