Embarking on a new project - Page 1
Forum section: electronics / projects

author: Tony R
author_rank: Regular Contributor
timestamp: January 20, 2013, 05:44:27 am
content: So i am looking at starting a new project; however, this project is not one that is typical of this forum, and i would like your help.This forum is well known for the electronic projects that people are doing, however I wish to take a step back.I have learned the value of custom engineering tools to help debug and automate testing. Which is what I would like to start. Here is what i have so far...I intend to write a c# application using the NI Visa library to control equipment such as my Rigol DS1052E, however using this library am not limited to just this scope. My plans are to create a single application that will be able to load a profile (probably in the form of an XML file) of the device you wish to control with the VISA command sets.By doing this I hope to be able control a verity of devices to set parameters and retrieve data which can then been compared with values that are known good values, and to be able to log everything that is going on.The only product that I can find similar to this is LabView.So here is my question: Does anyone have any words of wisdom, ideas, questions, comments, or concerns over what I am about to do?

author: Bored@Work
author_rank: Super Contributor
timestamp: January 20, 2013, 01:54:41 pm
content: OK, concerns:First, XML profileI have seen too many of these, in many circumstances, which badly failed. The typical root cause of the failure is that programmers believe that using a declarative style of descriptive meta data input would allow them to declare anything they need to declare to make "it" magically work in all circumstances. Kind of "lets build a system 'learning' from metadata so it'll figure out to do anything we need, just by be given the right metadata".In the middle of the project they start to discover they actually need a kind of scripting language, with basic programming constructs like a loop and conditions. Then they start to make up XML elements resembling those constructs, and this is where it gets ugly. The syntax and semantics of XML are just not good for making a scripting language (well, XML is not good for much at all, but that isn't the point here). Or a dataflow language, or any programming language.This can happen with other data definition languages, too, but it typically happens with XML, because XML is much hyped for everything, but doesn't deliver.What you probably need is a domain-specific language (DSL). Maybe derived from visual programming with dataflow programming elements (see LabView). Or maybe just a scripting language with proper (object-oriented?) representations of instruments, their functions, and their data I/O.If you can hold your horses, I think it'll really pay off if you spend time thinking about, studying and designing your DSL upfront, instead of hacking up some XML.A second, minor thing. The market on windows is pretty much dominated by LabView. Then there is stuff like Agilent's VEE (Visual Engineering Environment). And then some more amateurish players with tools supporting a few devices only. I don't think you'll find a market for your software on Windows.And a third, big thing: Testing. NI has cultivated relations to instrument manufacturers since years. They can get their stuff verified with almost every relevant instrument on the market, for every release, if they want. Manufacturers voluntarily write and ship VIs with their instruments. NI has a driver library (of not allways great quality) with contributions from big vendors for boatloads of instruments.So how do you want to test every of your releases? Against the ten, 20, 50, 100 instruments you own? What, you don't own that 200 k$ instrument "everyone" in a particular sector of the industry uses? Ups, how do you want to test against it? And the people having these instruments don't have any problem to pay a little bit extra for LabView with almost certainty that it'll work. They won't take the time to learn your DSL or XML, write code for their instrument and donate it to you. And even if they would, how would you ensure their code doesn't break with the next release of your software?

author: Tony R
author_rank: Regular Contributor
timestamp: January 20, 2013, 04:43:25 pm
content: @Bored@Work:Everything you said is very relevant but one thing you seem to think is that I plan to sell this software, I don't, I plan to keep it to myself and give it to whomever wants to use it. I am not going after the big guys. LabView is a great package and I do not intend to really compete with them. Heck I'm using their VISA library. The system is not a "learning system," I have no delusion for that to be the case.If I was planning on marketing my idea, I know better then to talk about it here...Next, I will offer the software without any expectation of support, if it works for the user, great! If the user comes to me with a good idea, great ill do it.The XML file will only hold the VISA commands, which is just ASCII text. I also plan to make an XML builder to help assemble these files so anyone with the programming manual for the device can get started. The commands are grouped up into categories, root keywords, sub keywords, etc. This is in no way a script that is to be ran, this is simply a list of compatible commands for that device.I do plan on this running scripts, but the software will have a script generator built into it which will allow the user to select a command from the device profile and tell it when to run.The idea of this is that the user will have to do very little of actually scripting, this should reduce the learning curve below what it is for LabView.

author: nctnico
author_rank: Super Contributor
timestamp: January 20, 2013, 04:46:27 pm
content: I'd like to suggest to look into Lua. The problem with just listing commands is that in many case you need to wait for an answer. So that gets kind of script-ish quickly.

author: Bored@Work
author_rank: Super Contributor
timestamp: January 20, 2013, 05:38:21 pm
content: So it is again one of those questions where the inquirerer doesn't want to hear anything he doesn't like. So what's the point asking the questions in public? If you think you know how to do it, just do it and don't waste people's time.

author: Tony R
author_rank: Regular Contributor
timestamp: January 20, 2013, 06:27:13 pm
content: Quote from: Bored@Work on January 20, 2013, 05:38:21 pmExcuse me for defending and offering more of an explanation. I am open to public opinions, but i hope that you understand that you may not always be right, and that others have different opinions. Although I value your opinion I feel you may not quite understand the whole project scope, you in your comment assumed that I would be selling my software, This is something for ME. furthermore, it is not about the end goal, it is about the journey, I hope you have not lost sight of that in your hobbies.Your response was not constructive, and it is true, I don't like it. If everyone had thrown up their arms of what they wanted to do saying "its been done before" we would not have a lot of the great products we have now.Quote from: nctnico on January 20, 2013, 04:46:27 pmGood point; however, I have never heard of Lua. How would this language be better then C#? Also does Lua allow for an easy development of a GUI? after all I already am fluent in C# and the VISA library I am using integrates flawlessly with C#. So what will this language offer me that C# cannot?You also make a good point as to the waiting for an answer, something I had not thought of until you brought it up. What I think I can do is open a new thread that will request a response and wait for it and then return it to the main thread, thus not holding up the main process. so then I can also control other equipment while waiting for a response.As for the script-ish part, to be honest that is kind of what I'm going for, but I do want high performance out of it as well. and I also want to remove the user from having to get down and write code.

author: nctnico
author_rank: Super Contributor
timestamp: January 20, 2013, 07:48:02 pm
content: Lua is a platform independant just-in-time-compiled script language. I have never used it myself so far but some very smart people I'm sometimes lucky to work with use it to quickly create user interfaces to embedded Linux systems. Another place where you find Lua is online games (like Roblox) to allow people to write event handlers for things they built. Even my 11 year old son can write bits of Lua. It is that simple :-)More info can be found here:http://www.lua.org/about.htmledit: it would be nice if your software didn't depend on C#. C# is about the least portable programming language of all.

author: Tony R
author_rank: Regular Contributor
timestamp: January 21, 2013, 05:59:19 am
content: I have looked into this Lua thing, and it seems like a good language for what it is but it seems to me that it is kind of python-ish. I have done some python development and I don't think that is the kind of tool that would be beneficial for this. C# can be compiled to run on Linux, but the libraries I am using are windows only, so that removes the idea of cross platform, which was never in my original plan.I will look into this more, it does appear as if it could be useful for other applications.

author: ElektroQuark
author_rank: Unknown
timestamp: January 21, 2013, 08:24:40 am
content: Using wxWidgets for programming, Windows, OSX and Linux users will be very happy.

author: Harvs
author_rank: Super Contributor
timestamp: January 21, 2013, 09:41:56 am
content: Obviously you've got an idea you think is going to work pretty well, so if you want feedback, make a prototype version of it and let us have a play with it.My fear is, every time I've needed to automate something, it's been easier just to write it in C# than try and deal with someone else's software. Keeping in mind, most people that design electronic stuff (even at hobby level) know how to write C, and probably to a lesser degree C++. So for most people, pulling up visual studio C# and writing a small windows form application to do what they need is quite quick. For example the little app that I wrote to log a battery discharge with my prototype eLoad probably took an hour from start to finish, given it only uses ascii commands over a serial port and it's got very little error handling.But you never know until people try it out in anger. If you recon you've got a great idea (and particularly if it's for yourself), just do it. E.g. my eLoad wouldn't suit most peoples taste (i.e. you can buy a nice one off the shelf <$1000), but that hasn't stopped me from building it and continuing to develop it to suit a niche application.

author: Tony R
author_rank: Regular Contributor
timestamp: January 21, 2013, 04:16:08 pm
content: Harvs: how did you get those graphs in there? is that a 3rd party package? or the charts built into the visual studio?ps: thank you for actually taking the time and understand what i was trying to do.

author: Harvs
author_rank: Super Contributor
timestamp: January 21, 2013, 11:47:24 pm
content: I'm using Visual Studio Express 2010 C#, and in the form designer, in the toolbox, they're under the "Data" section.They are a bit limited. e.g. I really want a chart with dual Y-axis, so I could put voltage, current and power all on the one plot. I'm guessing there's plenty of third party packages that can do that, but I haven't spent the time to look yet.If you find a nice free chart package can you let me know.Cheers

author: Tony R
author_rank: Regular Contributor
timestamp: January 22, 2013, 12:34:50 am
content: Quote from: Harvs on January 21, 2013, 11:47:24 pmThere are several comeical packages that i have found NI Measurement Studio, Chart FX come to mind off hand.

author: free_electron
author_rank: Super Contributor
timestamp: January 22, 2013, 01:16:35 am
content: That stuff already exists.For instrument control Its called Command Expert from Agilent. It's free (gratis, zeropaid).http://www.home.agilent.com/en/pd-2036130-pn-E2300/command-expert-11?&cc=US&lc=eng( I helped develop that thing by the way )you can plunk that in matlab, excel , any visual studio language , labview or whatever. interactively set up your machines , test and replay. you can store and entire test sequence inside an excel file. if you need to re-run simlpy click the button and Command Expert goes off and does it all again.as for plotting: Zedgraph.I also have a homebrew system that does all this instrumentation. Instruments are defined as classes with overloads.Dim MyDMM as new HP34401 ("::GPIB0:17")Dim MySupply as new Xantrex330 (":;GPIB0:12",Channel1)dim datapoints as new datastructuredatapoints.columns = 3datapoints.header(0) = "voltage"datapoints.header(1) = "current"datapoints.header(2) = "Dmmresult"mydmm.measure = voltsdcmysupply.currentlimit = 0.5for x = 0 to 10 step 0.1mysupply.voltage = xdatapoints.addrow (mysupply.voltage,mysupply.current,mydmm.reading)next xgraph.plot (datapoints)sub errorhandler() handles mysupply.overcurrentconditionmysupply.output = disabledbreak ("vincent@blah.com","Overcurrent ripped","Overcurrent tripped at "&timedate) ' this sends email and stops program.end subdone.If someone steals my 34401 and i have a keithley laying around i simply pull MyDMM from the keithley class. the classes wrap all low level crap for the user.i don't care if a machine sits on usb , gpib or even lan. The moment you pull the instance the path is passed and done.I use visual basic express. Laugh all you wanthere is the advantages :- not a compiled language. i can 'break' fiddle with parameters , even move the execution pointer and continue. if the program locks in the middle of a loop i can stall , alter the flow in the interactive window and hit continue... no data lost.- not case sensitive- not whitespace sensitive like python- no stupid semicolonsand for end of lines or curly bracket crap like all 'c' derivatives.- just as fast as any other NET language- free. express version is gratis.- any 6 year old can read and understand a basic program. it's almost plain englishif the above program breaks i get an email. when i arrive at my bench i correct the problem in the interactive console and the click Ok and it continues running.I have 'classes' of fatalism. Some errors are , mark and continue, others ( excessive power draw for example in an unattended test ) shut down power supplies and wait. i don't want to arrive finding the lab a smoldering crater....i have routines to do boundary checkingfor exampleIf OutsideWindow(minimum,maximum,mydmm.reading) then RaiseEvent OutOfRangeif OverLimit(maximum,myddm.reding then raiseevent Overcurrentand so on...i can set 'severity' for each of these events.this system has been in use for at least 15 years and started as VB 3.0 program. It's now Net 2010.I even have 'user interfaces'. Custom controls that look adn feel like a multimeter / powersupply / scope etc. you just drag them into view from the toolbar and assign the instrument at startup.dim mydmm as new hp34410("::USB:VID0314:PID0212:SN:034AY3245f")Dmm1Panel.assignto(Mydmm)done. if i click 'run i have a full blown multimeter on screen that i can control with the mouse. not a single line of code needed (from the user perspective) i have panels for scopes, function generators, spectrum analysers, supplies , meters , and more. Drag and drop.the base framework you can download form the internet. It's called Vision6. I describe it in detail in my book about using Visual basic to do automation. It has heavily evolved since then ( that book is 10 years old ). Vision 6 is for VB6.0 and uses my own GPIB driver. the new version is VISA based and has tons of extra libraries.One of these days i need to 'filter' it and see if i can release it.. there are a few things in there that i would need to remove for a 'public domain' release.

author: Tony R
author_rank: Regular Contributor
timestamp: January 22, 2013, 01:50:43 am
content: free_electron:I will have to take a look at this package, i am still interested in creating my own however, but perhaps i can get some ideas from this.

author: free_electron
author_rank: Super Contributor
timestamp: January 22, 2013, 02:19:41 am
content: Before you embark on such a project you need ot have a good understanding of test equipment, what machines can and cannot do, and what are the annoying problems that come back over and over . Like arriving at a bench and wanting to run program... but what the hell are the addresses of all these machines ?worst case scenario you spend half an hour reprogramming the addresses of the machines or adapting your code to the changes. Or your code is written for a particular machine but it is not available. the 34401 is in use but there is a keithley 2002 available . it is a perfectly usable machine but the 'guts' are different including the commands.... you need to shield the user from that.Or the script expects the machine to be connected voer usb , well guess what... it ain't on this particular setup its connected through LXI ...You cannot start rewiring the entire bench and reprogramming all machines or go on a hunt for a particular machine because your system cannot adapt.The system i have doesn't care . A multimeter is a multimeter independent from who makes it (within reason. if you request 61/2 digits from a 41/2 digit system i give you a nice prompt : can;t do this...) . it also doesn't care where it sits (gpib , lxi , vxi , mxi , usb , serial or even a printerport )i also have a button that probes anything connected to the computer and shows you report of all connected machines, their capbilities , addresses .. the whole shebang. if the machine has capabiltiy for display control i even take control of the display and deisplay a custom text identifyin the machines.likeCode:DIm Myvoltmeter as new hp34401("::GPIB0:12","VOLTMETER")dim myCurrentMeter as new hp34401("::GPIB0:13:,"CURRENT METER")Identifythe 'identify' command takes control over all machines and sends the specified text during init to their displays. it then pops upa box and waits for the user to click continue.so you look t the bench and you imediately seed a 34401 that say 'VOLTMETER' on its display and another that says 'CURRENT METER' on its display. no guessing who is who. Wire it up and you know the thing will work right. The moment you click continue i release the displays and readings are resumed. for machines tat have not the capabiltiy of displaying custom text i make the REMOTE indicator blink. the popup box says : VOLTMETER and makes that machines REMOTE indicator blink.click next and it moves to the next machine. and so on. any machine that has remote control ahs such an indicater, wheteher an LED or an indicator on its display.before you dive into this kind of development : get yourself a few instruments and play with them. see what can and cannot be done. find the problematic areas and then SOLVE those problems once and for all.

author: Tony R
author_rank: Regular Contributor
timestamp: January 22, 2013, 03:47:49 am
content: free_electron:Thank you for the helpful input. I have taken a look at your application, and it is nice and seems rather stable.However, it is not quite what I want, but I'm sure i can get a lot of useful ideas from your application, thank you for sharing it.

author: Harvs
author_rank: Super Contributor
timestamp: January 22, 2013, 10:11:33 am
content: Quote from: Tony R on January 22, 2013, 12:34:50 amYeah I was thinking more along the lines of free (or low cost.) I'm not about to spend $700 - $1300 (Chart FX) on a package to draw graphs for one off personal projects. It's just no where near worth it.

author: enz
author_rank: Regular Contributor
timestamp: January 22, 2013, 10:22:09 am
content: Quote from: Harvs on January 22, 2013, 10:11:33 amIf a change to the Qt-Framework (http://qt-project.org/) is an option, then there is a nice Qt-AddOn named Qwt (http://qwt.sourceforge.net/) that i use quite often.Of course, with Qt i think you loose compatibility to any .NET environment or whatever.Martin

author: Tony R
author_rank: Regular Contributor
timestamp: January 22, 2013, 01:11:40 pm
content: Quote from: Harvs on January 22, 2013, 10:11:33 amYeah, i know what you mean and i have not found one worthwhile as of yet.