LiveJournal Tags:
Arduino,
Modbus,
Modbus RTU,
HMI,
C-more,
Automation Direct,
Touch screens,
PLC,
Automation,
Machine Controls,
How-to,
RS232 to TTL,
Duemilanove
Using an Arduino to collect information from an array of sensors is an economical alternative to using a PLC when the data collection is not critical. In this post I will explain the basics of connecting the hardware of an Arduino to a C-More touch panel from Automation direct. I will then show a basic setting to allow MODBUS communication to work between the two devices.
Hardware you will need:
C-more touch screen:
http://www.automationdirect.com/adc/Shopping/Catalog/Operator_Interfaces/C-more_Touch_Panels/C-more_Touch_Panels_(all_sizes)/EA7-S6M-R
C-more Comm cable:
http://www.automationdirect.com/adc/Shopping/Catalog/Operator_Interfaces/C-more_Touch_Panels/C-more_Touch_Panel_Programming_Software_-a-_Cables/EA-2CBL
Arduino, in this case I used a Duemilanove:
http://www.nkcelectronics.com/arduino-duemilanove.html
RS232 to TTL converter:
http://www.nkcelectronics.com/RS232-to-TTL-converter-board-DTE-with-Male-DB9-33V-to-5V_p_369.html
Parts to make a rj12 to db9 connection. I actually used a serial cable cut in half and spliced into a RJ45 jack. You may want to consider a part like this:
http://www.buy.com/retail/product.asp?sku=229955393&listingid=209691315
Software you will need:
C-more programming software:
http://www.automationdirect.com/adc/Shopping/Catalog/Operator_Interfaces/C-more_Touch_Panels/C-more_Touch_Panel_Programming_Software_-a-_Cables/EA-PGMSW
The Arduino IDE, I used version 1.01. At the time of writing this 1.03 is available.
http://code.google.com/p/arduino/downloads/list
The MODBUS library that I got to work with the C-more.
http://code.google.com/p/arduino-modbus-slave/downloads/detail?name=MODBUS.zip&can=2&q
=
*note this library does not work with Arduino IDE prior to the 1.00 release.
Setting up the hardware.
Create the connector to convert the db9 connection to the RJ12 connection.
http://media.nkcelectronics.com/downloads/rs232ttl_DTE_v1.1.pdf
DB9 connections required are pin 2, 3,and 5. Pin 7 and 8 will not be used.
To make the RJ45 jack as I did connect make these connections.
DB9 — RJ45
Pin 2 – B4
Pin 3 – B5
Pin 5 – B2
When plugging in the RJ12 to the RJ45, be sure to center the plug in the jack.
( of course you can create your own DB9 to DB15 cable instead )

http://www.automationdirect.com/static/specs/cmorecables.pdf
DB9 |–| DB15
Pin 2 – Pin 3
Pin 3 – Pin 2
Pin 5 – Pin 5
Connecting the Arduino with the RS232 to TTL DTE board
Place jumpers on the RTS and CTS connections at the top of the board. 
Then make these following connections:
Arduino |—| DTE
5V – VCC
Gnd – GND
Digital pin 0 – RX (Use a jumper wire or place a switch in the middle of this connection.)
Digital pin 1 – TX
Do not connect the RTS or CTS pins from the board to anything.
Configure the Software.
For the Arduino:
Place the MOBUS library into the Arduino IDE library. See this for more information on how to do that:
http://arduino.cc/en/Guide/Libraries
You can also copy the MODBUSslave example into the example folder.
Launch the Arduino IDE.
Open the MODBUSslave example. ( from the example menu or by navigating to it in the MODBUS library folder.
Now connect to your board. Remove the jumper to the RX pin. ( or turn off the switch if you used one) This will allow the computer to communicate with the Arduino. If you forget to do this, the DTE board will interfere with the upload of the sketch.
Upload the Example to the board.
Once complete, reconnect RX to D0.
C-more setup.
In the C-more software, Start a new project for the panel you have.
Go to Setup -> Panel Manager
On the com port, select the DEV001. Now would be a good time to rename this to ARDUINO.
Set PLC Protocol to Modicon Modbus RTU
Select direct connection
Set PLC SLAVE number to 1.
Baud Rate 9600
Parity None
Stop bit 1
Control RTS No
Require CTS No
Select RS 485 No
Byte Order High Byte, Low Byte
Word Order Low Word, High Word
Character Order in register Char1, Char2
Registers per Message 32
Coils per message 64
Register Write Function Code 06
Coil Write Function Code 05
Time out 30
Poll time 3
Click ok.
Let’s place a Numeric Display on the screen,
In the Data Display tag open the tag database to create a new tag.
Click on Add

Select ARDUINO for the device name, Give the tag a name like ReadOnlyRandom.
Set it to Unsigned INT 16
Select memory type 3
Enter an address of 1
Click ADD, Select the new tag Click OK. (notice that the PLC address is shown as 30001)
Click OK again to assign the tag to the display.
Save and send the project to the C-more.
Test it!
Connect the C-more to the Arduino using the com cable.
You should see LEDs on the DTE board flicker and a random number updating on the C-more screen. Congratulations, you have gotten past the biggest hurdle to getting a C-more to talk to an Arduino.
If you do not see this, check that you have RX and Digital pin 0 connected. Also try swapping the RX and TX connections.
Writing to an Arduino
Ok so now you can read from an Arduino, but how about writing to it.
Continuing with the example, let’s add a Numeric Entry in the same fashion as we did with the Numeric Display.
But this time when you add the new tag, Name it WriteableNumber with a memory type of 4 and an address of 9.

Save and transfer the project to the screen.
You should now see a 9 in the new entry.
Change the 9 to a different number. Now you have written to the Arduino.
To make use the register in the Arduino, update the example to use regBank.get(40009).
So in this post I covered how to setup the hardware to between a C-more touch screen HMI, and an Arduino. I also showed how to load the MODBUS library and example onto the Arduino. Lastly I showed how to configure the settings on the C-more to make use of the MODBUS RTU protocol in conjunction with the supported features of the Arduino.
The MODBUS library I used is not the only one available on the web, but it is the first one I got to work with a C-more.
Remember, when you are uploading to the Arduino, you must remove the RX connection.
In the next post, I will share a derived library that takes advantage of SoftSerial. This will allow You to connect the DTE board to Pins 2 and 3 instead of 0 and 1. There by allowing you to upload to the Arduino while remaining connected to the C-more.
Lastly I will share some methods to make it easy to read and write discrete bits using whole registers, instead of coils.
Please let me know what you think of this post. I welcome questions and feedback.
Resources:
http://code.google.com/p/arduino-modbus-slave/downloads/detail?name=MODBUS.zip&can=2&q
=
http://www.nkcelectronics.com/RS232-to-TTL-converter-board-DTE-with-Male-DB9-33V-to-5V_p_369.html
http://arduino.cc/en/
http://en.wikipedia.org/wiki/Modbus
http://www.automationdirect.com/static/specs/cmorecables.pdf
http://media.nkcelectronics.com/downloads/rs232ttl_DTE_v1.1.pdf
http://forum.automationdirect.com
This will likely be the final post I share about Windows Embedded Compact 7. I have moved off of the team, but the work will go on. As the title shows, the installer can be updated to build 2817 (released last week).
I encourage you to look for updates and post questions or comments to this blog moving forward:
http://blogs.msdn.com/b/icumove/ (Official Install Blog)
Thank you
Kyle
Windows Embedded Compact 7 has been updated with build 2816. This is the 13th update released. This update includes a major upgrade to Windows Embedded Silverlight Tools.
You can update Windows Embedded Silverlight Tools independent of Windows Embedded Compact 7, but it is generally recommended to allow Windows Embedded Compact 7 handle the upgrade for you. Simply let WEDU notify of you of the update, or launch the WindowsEmbeddedCompact7.exe installer from Add / Remove programs and select update.
XP users may encounter an error while installing updates at Install level 9 (Update 8). The issue is resolved by updating to Install level 10 (Update 9). This update was released with the March build 7.0.2812.

If you ever find your self in a situation where you are unsure of the state of you machine, you can uninstall the program with the command line.
Here are the steps to uninstall the whole program:
·Acquire the latest version of WindowsEmbeddedCompact7.exe. At this time the version is 2811.
*note {The Evaluation version program will work for this uninstall procedure, and can be downloaded from Microsoft.com.}
·Place the file on the system where the user can access it. For example c:\2811
·Open the Command Prompt with Administrative rights.
·Run WindowsEmbeddedCompact7.exe with the uninstall and quiet parameters. For example “c:\2811\WindowsembeddedCompact7.exe” –uninstall –quiet
·This will run WindowsEmbeddedCompact7.exe in the “Background”. To view the progress of the program use TaskManager. Under the Processes tad, two WindowsEmbeddedCompact7.exe Image names will be listed when the uninstall is taking place.
·When the WindowsEmbeddedCompact7.exe Image names are no longer present in the list of processes, the uninstall should be complete.
·To confirm that the uninstall finished successfully open the Add and Remove programs from the Control panel. Windows Embedded Compact 7 Should not be listed.
·Windows Embedded Silverlight Tools will remain in the Currently installed programs list.
·Uninstall Windows Embedded Silverlight Tools at this time.
Offline Layout

Offline Layout is a new feature that has been released with the latest update of Windows Embedded Compact 7 and Windows Embedded Silverlight Tools. This feature can create a reusable layout of all the content a user would need to install, modify, or repair the software. The big advantage of this feature is that the update patches will only need to be downloaded once. Now, when patches need to be acquired, the layout folder can be used as the source.
Overview:
1. Select the options you want to add to your offline layout.
2. Select “Yes, create an offline layout.”
3. Allow offline layout to be created.
Quick tips:
· Have the original install DVD’s close by. It is quicker to use the DVD’s as a source rather than downloading. Note not all options are available for download.
· When updating and performing the offline layout only the options currently installed will be saved to the offline layout folder.
· Offline layout will only add files to the layout folder. It will never delete files from the folder.
· The folder can be shared to enable network access and the folder content can be copied anywhere.
· Uninstalling the software will not remove the offline layout folder or its content.
For more details read section below:
So how does one perform an offline layout? It is very simple. If you are installing for the first time or modifying a current install you will see a new screen titled “Install Offline Layout”. See Below:

By default, offline layout is not selected. Select “Yes, create an offline layout” to enable offline layout.

When “Yes, create an offline layout.” is selected, new controls appear on the screen. The location of where the layout folder will be created and an additional check box are displayed. This check box can be unchecked to allow only the creation of the offline layout folder without installing the product. In this case any currently installed options will not be modified. For this demonstration, I’ll leave the check box checked and click next.
The “Ready to Proceed” screen will appear, and a new icon may be displayed.

In this scenario, Platform Builder is being modified to the update 3 level, so the Update 6 patch is being removed. Update 3 is already applied to Platform builder, so only the offline layout action is performed on that package. ARMv5 is also being installed, hence the installation of Architecture Common updates.
This floppy disk icon is displayed when a package is planned to be saved to the offline layout folder, and no other action is being taken with the package.

Packages that are being installed or modified will also be saved in the offline layout folder.
The estimated size of the offline layout is displayed and added to the total disk space required.
· Tip: at this point it is a good idea to have your original install media handy.
· If your system has AutoRun enabled a second instance of the installer may start. Close it down if it does.

Once the acquire phase has completed the offline layout action will begin. The packages will be saved and the modify phase will begin. Once all modifying is complete the “Finished” screen will display.

The location of the offline layout folder is displayed as a link. Click on this link to open the offline layout folder.

The layout folder will contain the packages required for installing the options that have been selected. This includes any updates that the options may have. Performing a Full install with Offline layout will result in a layout folder like the shown below.

I have found that the quickest and easiest process is to update your current install to 7.0.2810 (Update7) without performing the Layout action. Then drop the Windows Embedded Compact 7 DVD into the drive and proceed to perform layout only action on all of the options you may ever want to install. From here on forward only new update folders will need to be acquired.
Links to more information:
http://blogs.msdn.com/b/icumove/ (Official Install Blog)
Posted in
Modifying,
Updates,
Windows Embedded Compact 7,
Windows Embedded Developer Updates,
Windows Embedded Silverlight ToolsTags:
%temp%,
Laying out offline,
layout folder,
Modify,
Modify Windows Embedded Compact 7,
Offline Layout,
updating windows embedded compact 7,
WCE7,
WEDU,
windows embedded CE7,
windows Embedded compact 7,
Windows Embedded Developer Update,
WindowsEmbeddedDeveloperUpdate
There are several ways to determine your Windows Embedded Compact 7 install level.
For the typical developer the easiest method is to launch the WindowsEmbeddedCompact7.exe to the Modify screen. Here at the top left section the screen Current Install Level will be displayed under Found Version.
![clip_image002[4] clip_image002[4]](http://krakllc.files.wordpress.com/2011/12/clip_image0024_thumb.jpg?w=370&h=56)
For those who would rather use a log file entry to determine the install level, you can search near the end of the last WindowsEmbeddedCompact7.00**.log in the user temp directory.
![clip_image003[5] clip_image003[5]](http://krakllc.files.wordpress.com/2011/12/clip_image0035_thumb.png?w=370&h=218)
![clip_image004[5] clip_image004[5]](http://krakllc.files.wordpress.com/2011/12/clip_image0045_thumb.png?w=370&h=15)
The third method is for more advanced users.
Warning: Changes made to the Windows Registry may affect the operations of the computer. Making a backup of the registry is highly recommended. Use Registry Editor, or other methods to access the registry at your own risk. For more information about the Windows Registry please go to:
http://support.microsoft.com/kb/136393
http://support.microsoft.com/kb/256986
As of version 7.0.2807.0, (October 2011 Update ), the value of the InstalledLevel is stored in the registry.
Registry Editor can be used search for the value of InstalledLevel. Regedit.exe can be used on the cmdline or with the GUI.
For 32 bit machines:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{A4FF3FC0-A8B3-47c2-8627-CE1D2988D0D8}]
For 64 bit machines:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{A4FF3FC0-A8B3-47c2-8627-CE1D2988D0D8}]

The RegRead method is also able to programmatically retrieve the value of InstalledLevel.
More information about that method can be found here:
http://msdn.microsoft.com/en-us/library/x05fawxd.aspx

Updates are available for Windows Embedded Compact 7. These updates include changes for DCHP, MSFLASH, and NETIO. There are also changes to the installer software. There are two features added to the software that most people will never see, but will appreciate if they do. Sleep is now blocked by the software when content is being acquired or when an action is performed on an option. This will not over write the system’s power settings. Some updates can take a considerable amount of time to download, and to be applied. This feature prevents the system from going to an idle state where Sleep, Stand by, or Hibernate can take effect.
Of course there are still times when the system can enter into Sleep, Stand by, Hibernate, or even Shutdown while the software is running. To address the issue of having to uninstall everything in the event of an interruption to the software progress, a resume feature has been added. Previously the software was able to recognize that the state of the installation was compromised and an uninstall action would be performed to return the machine to a clean state. This can be annoying and costly in terms of time. The resume feature will keep track of the progress of the software. In the event of an interruption, such as a power loss, the software will store the current state. When the user logs in again the installer software is launched and will attempt to resume the action it was taking prior to the interruption. In the event of a reboot or power loss, the software will launch automatically when the user logs in.
One bug fix that is worth noting is the behavior of the download all check box and Shared Source. A user can select to download all of their content. Shared Source cannot be downloaded. Previously if a user with a retail version of the software wanted to install an option like Platform Builder and Shared Source but did not have Disk 1 in their DVD drive, they would be prompted for source. The user could select to download all the content. The software would proceed to download all of the content until it reached Shared Source. The user would not be able to uncheck the Download All check box, and would have to cancel the out of the software. Now the user can uncheck the Download All check box, and browse to the location of Shared Source.
Please let me know if you have a questions or comments.
Kyle
Links for more information:
http://blogs.msdn.com/b/icumove/ (Official Install Blog)
Friday, 10-14-2011, Update 3 was released for Windows Embedded Compact 7. This is a very useful release that includes updates and fixes for Platform Builder, and Compact Test Kit. This is a larger download for each architecture than the previous updates. A lot of hard work was done to make the update as small in size as possible. You will see a Service update, an Update 3, and an Update 3.1 package get downloaded. Most of the the files that require an update could be delta patched. Which means the file will be edited in place. This greatly reduces the size of the package that handles that part of the update. Files that could not be edited on disk, are replaced with a whole file. The number files that required this was relatively low, which helped to the keep the size of the update lower.
Files will now be backed up if they have been edited. Users who have edited files to suit their needs will appreciate this feature. When updating, the user’s work is now safe. The edited file will be backed up to a sub-folder in Wince700 folder named Backup.
This post is a condensed version a post wrote and had published at
http://blogs.msdn.com/b/icumove/archive/2011/08/12/troubleshooting-red-x-s-in-the-compact-7-installation.aspx
So please go to the above link for more detailed information on trouble shooting, or to ask a question about this topic.
Here is a clip of the post that is focused on finding the log files that Windows Embedded Compact 7 creates. These log files are in the user profile temp folder, of the user who ran the software. The easiest way to get to that folder is to click on Start and Select Run.

In the text window type %temp%, click Ok.

That will open your temp folder and you should see the log files listed.

All four of log files shown were created by the software. When some prerequisites are not found, an entry like the highlighted one here will explain why you are having a problem.

The snippet above is an entry showing that Visual Studios 2008 could not be found on the computer.
When Visual Studios 2008 is found at the proper version, an entry like this can be found in the log. 
If you are having issues, please visit this link:
http://blogs.msdn.com/b/icumove/archive/2011/08/12/troubleshooting-red-x-s-in-the-compact-7-installation.aspx
(Official Install Blog, Trouble Shooting post)
I have few posts lined up. Once I have them finished, I will be publishing them. Please check the site for updates in the next few weeks.
Kyle
Links for more information:
http://blogs.msdn.com/b/icumove/ (Official Install Blog)
Next Page »