Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteris
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.
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.
C:\Program Files\Arduino\hardware\tools\avr\bin\avr-objcopy.exe" -I ihex [sketchname].ino.hex -O binary [sketchname].ino.bin