Building PC Software to interface with device

Hi all,

I guess this would be the best place to write this post - I want to start writing a piece of software to interface with a device I built, using an AVR MCU. I've got for example a lot of chips on the board that can be configured over SPI, amongst other things, and I'd like to be able to change some of these options without reloading bits of source code.

Currently the device is using the Arduino software, but soon i'll be rewriting software without the Arduino libraries, and using Atmel Studio...

I want to write a piece of PC based software, that allows me to connect to the device over USB (and possibly Ethernet on a planned new version of the device) and change a load of parameters stored in RAM, or to tell it to use a different bunch of parameters stored in flash.

I'm not looking to write a fancy piece of software, just a black screen with a list of configuration types that one can navigate using the keyboard, expand a change a few options - I would also like to be able to change the data stored in arrays in real time, i.e. a change made on the PC is instantly rectified on the microcontroller.

So a menu such as the following.

HARDWARE SETUP ->
COMMUNICATION SETUP ->
SOFTWARE SETUP ->

However, the only software I've ever written is embedded software for MCUs using the Arduino environment.

Where do I start in making software for a PC in this way, like I say - I'm not interested in pretty graphics, perhaps some black and white wireframe maps of 2D array data and that's it.

I'll give a better example - one feature of the boards is its ability to sense current draw from it's outputs, and shut those outputs down should current levels rise above a defined value, however - I'd like to be able to adjust these values, by plugging my board into a PC, and quickly changing a value in software, as opposed to reloading an updated source code to the file.

I.e. in a menu, change OUTPUT 1 CURRENT LIMIT, from say 2A to 4A.

Where do I start with this?

Ultimately, I would like in the future to build a touch version for iPad too - but let's focus on PC first...

Many thanks in advance

Parameters should go in EEPROM. Writing to flash is difficult and RAM is lost if the device resets.

On the PC end...first you have to choose a programming language/environment. Some would say do it via a web browser, some would write a standalone app, some would do it on their 'phone via. bluetooth. There's lots of ways to do it and the best choice depends on what sort of programming you're good at. Really it's up to you to decide how to do it.

The "USB" on an Arduino appears as a serial port. You open a serial port on the PC and send bytes to it. On the Arduino you look at incoming data on the serial port and decide what to do with it.

Hi there,

Thanks for your reply.

Writing to RAM isn't a problem in this application, as those parameters that would be adjusted in real time (i.e. during device calibration) once they are set to a satisfactory value, the device would be reset - and the calibration saved permanently into the device and permanently as a calibration file on the PC.

I would rather use flash space, as opposed to EEPROM - in fact, I'm not interested in using EEPROM at all. Writing to flash may be difficult, but that's what I'd like to do. If it makes it any easier, the board I've designed uses an SD card - so data can be stored into certain locations on that card.

Bluetooth and other wireless methods won't be any good in this application, a wired USB / Ethernet connection is what I am using. My first board version dosen't have any Ethernet support, just USB using an FTDI chip to convert between serial and USB.

I would like to develop a standalone piece of software, not do it inside a web browser...and as mentioned above, would need to be able to save and load calibration files to load to boards.

The environment is the advice I'm really looking for here, how to get started if you see :slight_smile:

jtw11:
I would rather use flash space, as opposed to EEPROM - in fact, I'm not interested in using EEPROM at all.

Why not? That's what it's for...

First thing I would do is get it working with "Serial Monitor" in the Arduino IDE. That is, get the messaging working between it and your device. You can pass text into your program by typing in the top box and hitting send. Your program can respond back out.

Once it is behaving the way you want it to, you then move onto the desktop software. At this point there is no change needed by your device, just have your desktop software connect to the com port and behave the same way you did with Serial Monitor.

If you are on Windows I would suggest something like VB.net. You can download a free version of Visual Studio Express which will allow you to do all you need. You can design your page in a WYSIWYG editor, and there is good support for COM in .net.

Best of luck.

Steve

Thanks for the replies!

Regarding EEPROM...

Why not? That's what it's for...

Primarily because of the vast amounts of data I need to store, many tens of large lookup tables - larger than most EEPROMS.

In terms of using the serial monitor, I've got lots of codes working and running where I can input data in the serial monitor and have the controller change values based on that - so the microcontroller side isn't the problem. It's the PC side.

My second edition of this board is unlikely to even use an Atmel MCU...

I'll have a look at Visual Studio - some people have already suggested this to me!

Hello, I would highly recomend Lab View. You can buy the student version from sparkfun for $50. You can build a beautiful user interface in minutes. For example if you would like to change a sample rate. Have the user type in the rate, and press send. Then have your device read the serial port. Update your sample rate variable with this new piece.

The nice thing about Lab View is that information is everywhere. A plug in for arduino has also already been built. Hope this helps!

If you have no experience of writing a program on a PC that communicates with an Arduino I strongly suggest you write a short sketch for the Arduino that simply receives a few bytes (perhaps "helllo") from the Serial monitor and then sends them back to the serial monitor.

Then write a short PC program that takes the place of the serial monitor. When that works (and only then!) start extending the system. If you find that it takes a bit of learning to get the communication to work then ultra simple programs on the PC and Arduino will help the debugging. Basically you need to know what comm port the PC thinks that the Arduino is connected to and use that in your PC program.

Also, get it to work over a USB cable connection (so that the same Arduino sketch works with Serial monitor) before attempting wifi, bluetooth, ethernet etc.

As somebody else said, if you are using Windows (I don't) try VisualBasic or VisualC# . Alternatives might be Python or, my favourite Ruby, especially JRuby which is the easiest version of Ruby to install (especially as Java will already be installed for the Arduino IDE).

...R

You can also check out Processing (http://processing.org/). It uses the same IDE that Arduino uses but the program you compile for runs on the PC instead of the Arduino. This provides you with a simple way to create a graphical user interface you run on your PC which can pull data from the Arduino to display.

In fact there are several examples of how to interface Processing with Arduino via serial interface. In the Arduino IDE, Examples->04.Communication->Graph. This example code has a portion of code you run in the Arduino, then a separate code you cut and paste into Processing.

Some others are
Examples->10.Starterkit->p14TweakTheArduinoLogo
Examples->04.Communication->SerialCallResponse
->SerialCallResponseASCII
->VirtualColorMixer

Writing to flash may be difficult, but that's what I'd like to do. If it makes it any easier, the board I've designed uses an SD card - so data can be stored into certain locations on that card.

So.... Are your lookup array structures declared nul and your intent is to read SD flash at startup to initialize those structures? You seem to be hinting that the lookup data is not static, or at least will need updating and that you wish to do this updates customization outside reprogramming the Arduino.

If my assumption above is true, then the compiler will be unable to keep these lookup structures in flash inside the uC, rather the elements will exist in RAM. IF the array length is fixed to a known maximum, you can likely getaway with the scheme, but if the array length is subject to change then test your code carefully since dynamic memory allocation may cause you future headaches.

Ray