Wednesday, January 16, 2008

First program for BF537 STAMP board

BF537 STAMP board is possible to buy from Digi-Key. That is a nice board with a plenty of possibilities to create a handy functionality. I just recently got one as well. My board has newer version of software that could be found on companion CD which is dated as 2005 release, but everything could be downloaded from support web site. This wiki style site looks fresh and written for creative people, check remark about documentation.


Today’s laptops or PC are quite powerful devices and capable to run multiple OS at same time by using virtualizing software. This allows of choosing Linux as development platform even if main platform is Windows XP. Check my older post on how to install SUSE 10 on Virtual PC. One of advantage of this approach is to have less hardware on a desk and more time for development.

The STAMP board is a part of the Blackfin/uClinux open source project, and the good thing that schematics for the board available as well. Board could be accessed through serial cable by using terminal window. It has an Ethernet interface, six general-purpose LEDs and four general purpose push-buttons available for quick start hardware control programming.

To be ready for development is necessary to verify number of tools to be installed on development platform. Full list of applications could be found on support site and one of them is gcc compiler. These applications are part of a standard SUSE 10 distribution. Next in a list is latest blackfin-toolchain-07r1.1-3.i386.rpm package from Blackfin support site. Double clicking an RPM file will bring up a graphical front end for installing RPM's. Under SuSE Linux 10 this front-end is provided through YaST2.



After installing the Blackfin tool chain the environment variable PATH must be modified to include the directory where the Blackfin tool chain is installed. It could be done in File Browser by selecting File->Open In Terminal and typing next command line:

export PATH=$PATH:/opt/uClinux/bfin-uclinux/bin:/opt/uClinux/bfin-linux-uclibc/bin

At this point everything is ready for a hello world application:

#include <stdio.h>

int main() {
      printf("Hello, World\n");
      return 0;
}

Next command line will compile this file:

bfin-uclinux-gcc -Wl,-elf2flt hello.c -o hello

The output executable is 'hello' file in flat format, also it creates a file “hello.gdb” which is used for debugging. Check my next post for details on how to run this program on BF537 board.

Wednesday, January 9, 2008

SUSE Linux Desktop on Virtual PC


Jump from Windows into Linux world right away could be a big challenge. To make this smooth as possible is better to have somewhere Linux environment to play. For this task Virtual PC is a handy tool. Virtual PC 2004 SP1 is a free virtualization suite available for download from Microsoft. It runs on Windows 2000 and XP. Virtual PC 2007 is available for Windows Vista.

First step is to install Virtual PC.

Next step is to grab Linux distribution. Lets go to Novell Downloads and select SUSE Linux Enterprise Desktop 10. It is available as DVD or set of 5 CDs.

"SUSE Linux Enterprise Desktop is the most interoperable Linux desktop available today. It works seamlessly with Novell GroupWise® and Microsoft Exchange collaboration servers, and it will connect to Lotus Notes and IBM* Notes plug-in for Workplace client technology. It is also fully compatible with Microsoft Active Directory* and other networking and directory standards."

Now is possible to create a virtual machine. Following wizard select “Other” as Operating System, adjust RAM to 256 MB, and create a new virtual hard drive.

Then start this virtual machine. Under CD menu select Capture ISO image and browse for SUSE Linux Enterprise Desktop ISO image.

Complete installation procedure and start using Linux SUSE Desktop. As additional optional step I do recommend to change Display settings and use for monitor 1280x1024 and for resolution 1152x864.

Wednesday, December 19, 2007

Windows network utilities

tracert

tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name

Determines the route taken to a destination by sending Internet Control Message Protocol (ICMP) echo packets with varying IP Time-To-Live (TTL) values to the destination.

netstat

netstat [-a] [-e][-n][-s] [-p protocol] [-r] [interval]

Displays protocol statistics and current TCP/IP network connections.

nbtstat

nbtstat [-a RemoteName] [-A IP_address] [-c] [-n] [-R] [-r] [-S] [-s] [interval]
Help troubleshoot NetBIOS name resolution problems. Displays protocol statistics and current TCP/IP connections using NetBIOS over TCP/IP.

ipconfig

ipconfig [/? | /all | /d | /renew [adapter index] | /release [adapter index] ]
Prints out the TCP/IP-related configuration of a host

Thursday, November 15, 2007

Phoenix Contact Seminars

Phoenix Contact Industrial Ethernet, and Industrial Wireless seminars were about hardware and network topology solutions used by Phoenix Contact in many industries including automotive projects.

Industrial Ethernet keynotes:
- Industrial Ethernet devices provide reliability (works in wide range of temperatures, torque and other hazard environments)
- Sales of industrial Ethernet devices increased from 1 million in 2004 to 3 million in 2007, and projected 7 millions in 2009
- Most used protocols are Modbus TCP/IP and Allan Bradley DF1
- Prefer to use managed switches with web based configuration
- Expendable managed switches provide flexibility to replace wire cable with fibre optic
- Spanning Tree protocol is used to remove collisions and allow rearrange network in minimum 20 sec on root switch failure
- Rapid Spanning Tree protocol has decrease this time to 1-2 sec on such failure
- Spanning Tree and Rapid Spanning Tree protocol available in managed switches
- Network topology is crucial in industrial applications (use rings as segments)

Industrial Wireless keynotes:
- If you can run cable - use cable
- Bluetooth required less configuration support over 802.11
- Bluetooth is more secure than 802.11
- Bluetooth is cost effective (cheaper than 802.11)
- Antenna is crucial point in wireless connection
- Consider use of Phoenix services to optimize bandwidth, antenna and overcome noise factors

Industrial Automation keynotes:
- Benefits of IEC 61131 standard
- PC Worx platform to program PLC
- OPC as wide used technology
- HMI and SCADA

Saturday, October 27, 2007

How to improve the focus for a goal

It is very difficult to work constantly on same topic, even if you like what you are doing. You loose your focus over time. This happens most often for a developer in a multitasking environment; where you need to take care of lot of things to succeed.

The best way to trick yourself is to use a mind game. Treat every successful action as goal you score in an imaginary game. High results at the end of the day can be considered as a good accomplishment showing your victory. This will help you to increase attention to details, and help to stay focus in same way as a game player is doing during a game.

If done well it will help you focus for a lot longer. At the end of the day you count successful moves as a positive and moves you failed to do as negative. You then add them up, if the sum if positive then you win, if negative then you lose.

Friday, October 5, 2007

How to Create a Schema.ini File Programmatically

1. Start a new project in Visual Basic 6, and save project to disk
2. Add reference to Microsoft ActiveX Data Objects 2.5 Library
3. Add button to the Form
4. Double click on button and add next code

Private Sub Command1_Click()
   Dim con As New ADODB.Connection
   Dim RS As ADODB.Recordset
   con.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
   "Data Source=" & App.Path & _
   ";Extended Properties=text;"
   con.Execute & _
   "CREATE TABLE [TEST1.CSV] " & _
   "( [Name] TEXT NULL, [MaxVolt] DOUBLE NULL)"
End Sub

6. Run project and click on a button
7. Verify that SCHEMA.INI and TEST1.CSV files were created in project folder
8. Use "DROP TABLE [TEST.CSV]" to delete TEST.CSV from SCHEMA.INI and delete TEST1.CSV file from a disk

Remarks: There is no way to update SCHEMA.INI and TEST1.CSV by using ALTER TABLE sql statement. Even if tables (files) does not contain any data, next statement "ALTER TABLE [TEST.CSV] ADD COLUMN [Name2] TEXT NULL" will raise an error "Operation not supported on a table that contains data".

Tuesday, October 2, 2007

Count number of lines in a project with VBScript

'
' www.pullnews.com
' Save this code as file LineCount.vbs
'

If WScript.Arguments.Count= 0 Then
      MsgBox "Usage instruction:" & vbCrLf & _
      "Set folder as argument, or Drag source folder and drop on vbs file"
      WScript.Quit
End If
nCounter = 0
FolderName = WScript.Arguments(0)
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(FolderName) Then
    WScript.Echo "Invalid folder name"
Else
    CheckSubfolders fso.GetFolder(FolderName)
    WScript.Echo "Number of lines in all files is = " & nCounter
End If
' Subfolder recursion
Sub CheckSubfolders(thisFolder)
    Dim subFolder
    CountLinesInFolder thisFolder
    For Each subFolder In thisFolder.SubFolders
        CheckSubfolders subFolder
    Next
End Sub
Sub CountLinesInFolder(thisFolder)
    Const ForReading = 1
    Dim File, theFile
    For Each File In thisFolder.Files
        Set theFile = fso.OpenTextFile(File.Path, ForReading, False)
        Do While theFile.AtEndOfStream <> True
            theFile.ReadLine
            nCounter = nCounter + 1
        Loop
        theFile.Close
    Next
End Sub