What syntax does labview use when communicating - vb.net

I'm using the same code that is still working for a new version of equipment the company the bought.
I can't communicate with the equipment in vb in visual studio (the language of the last code I wrote). But I can make a simple code in LabVIEW to see if the equipment is communicating and it is.
So, my question is what code is labview sending to the equipment?
The only thing I see from the LabVIEW GUI is *IDN?\n
Is that the same as what I writing?
mySerialport.WriteLine("*idn?" + Chr(10))

*IDN?\n
is not the same as :
mySerialport.WriteLine("*idn?" + Chr(10))
The former is capitalized while the later is not and it may cause an issue depending on the instrument.
You are using the serial port, so the most important thing to consider is the baud rate. It is possible that the later model equipment your company purchased has a different baud rate to the one that was used previously.
If you want to see exactly the data that LabVIEW is sending, you can use NI IO Trace or a non NI serial port monitor such as listed here

The question isn’t what language LabVIEW uses. LabVIEW is a programming environment with library APIs to speak to lots of hardware and the ability for anyone to write code to speak to even more hardware. The question is “what language does the HARDWARE speak?” To answer that, you’d post what kind of hardware it is and probably go to the manufacturer’s website for a spec sheet.
“*IDN?/n” looks like a GPIB command, which is just a framework serial protocol. You’d need the spec sheet of the hardware to know the particular commands that your hardware understands.
PS: LabVIEW doesn’t have a GUI showing anything about hardware communication. You have an application written in LabVIEW that has a GUI that is displaying information. You can edit the program to print out more info if you want, just like you could in VB. Complaining about the “LabVIEW GUI” in this case is equivalent to complaining about the Visual Studio GUI when the problem is with the program you’ve written in VS!

"The only thing I see from the labview GUI is *IDN?/n"
That sounds more like you are using the VISA Test Panel in MAX (Measurement and Automation eXplorer). It is related to LabVIEW in that it is also a tool developed by National Instruments (NI). But it does not sound like you have actually touched LabVIEW itself.
As was already stated, *IDN?\n is a typical command that an instrument that follows the SCPI messaging standard. On a Windows system, that is usually the same as "*idn?" + Chr(13) + Chr(10).

As SeanJ pointed out *IDN?\n is not the same as "idn?". Further, make sure that space character in your calling method is visible. Sometimes machines require you to manually type "\r\n" for complete carriage return.

Related

Modern language IDE similar to QBasic?

I'm trying to find a modern environment similar to what I found great about QBasic but making up for the flaws. The purpose of this is to code with my 6 year old son.
I'm looking for an IDE that uses a modern language, has the ability to draw graphics and play audio, and doesn't force the User to jump around much between coding and running their application.
In QBasic you had basically two modes: Edit and Run. There were no third party libraries required for creating graphics or generating Audio tones (that I remember). You never had more than one "window" opened at a time.
Is there a modern day equivalent IDE which uses a modern language that provides what I'm looking for?
I don't want him to have to jump around between various windows, try to wrap his mind around window toolkits, understand the command line, or use OOP just to get started. My end goal is to create simple graphical games with him -- not printing text out to the console.
(Preferably cross platform or useable on Mac OSX since that's what we have at the house. Preferably Python based since that's my language of choice.)
QBasic is a great option. You can purchase an old PC from a thrift store and run QBasic on it. There is the option of QB64 which can run on both Mac and Windows. Hope this is helpful.
I'd suggest QB64, almost 100% compatible with QBasic/QuickBasic but runs on Windows.
You could maybe try Small Basic, it aimed to recreate the ease-of-use and educational purposes of the old BASIC languages build into home computers from the 1980s
The Small Basic project was initiated following this article on Salon:
Why Johnny can’t code (David Brin, 2006)

C two platform compiling

I want to run some C code targeted to run on a unique PIC micro based hardware setup in a PC windows environment as well. The objective is to emulate multiple instances of the hardware without the actual hardware. I expect to have to write the code upfront to account for this and to create low level functions in C or C# that emulate each of the PIC functions.
Does anyone know an environment that can support this?
What you're looking for is a microcontroller simulator. The simulator will run on the PC and execute the PIC code. In order to e.g. generate interrupts / simulate serial data / whatever you'll need to either configure the simulator settings or write a few custom function.
Your target code (for the PIC itself) shouldn't need to be aware of what environment it's running on.
Here's a few links, but you're best off searching for some variant of "PIC microcontroller simulator" or "microchip PIC simulator".
http://sourceforge.net/projects/gpsim/
http://sourceforge.net/projects/picsim/
I'm not sure that this question is about an instruction simulator. It seems to me that it is simply about the technique called "dual targeting". I've asked a similar question on StackOverflow before, please see: Prototyping and simulating embedded software on Windows . Recently, I've also made a blog post about dual targeting and rapid prototyping on Windows here: http://embeddedgurus.com/state-space/2013/04/dual-targeting-and-agile-prototyping-of-embedded-software-on-windows/ .
So, while the links should provide the answer to the original question, I'd like to add that the 8-bit PIC is probably no programmable in C++. In fact, it is so baroque that even C compilers for this "architecture" must cut many corners.

Making my own application for my USB MIDI device

I want to try and make my own application for my Novation Nocturn, which is a USB DJ controller surface. The application software interacts with it to send out MIDI messages to software like Traktor, Ableton and Cubase.
I'm aware of libusb, but that's as far as I've got. I've successfully installed it to interact with my device but stopped there.
I'm after some suitable reading material basically. USB specs, MIDI specs and such. If I'm honest the full USB 2.0 spec looks like it holds loads of stuff I don't need.
Just looking for something interesting to do now that I've finished my degree (Computer Science). My current programming knowledge is C++ and mainly C#.
Could do with some direction on how to get stuck into this task.
edit:
Update to include some info from the Device Manager on the Nocturn.
Hardware IDs:
USB\VID_1235&PID_000A&REV_0009
USB\VID_1235&PID_000A
Compatible IDs:
USB\Class_FF&SubClass_00&Prot_00
USB\Class_FF&SubClass_00
USB\Class_FF
Device Class:
MEDIA
USB MIDI is probably one abstraction layer lower than you want to deal with. I'd suggest finding a good MIDI framework and interacting with the device via MIDI instead.
For C++, Juce is probably the way to go, as you didn't mention a target platform or any other specific requirements.
If you want to go the .NET route, the easiest way to get started is with the C# MIDI Toolkit code:
http://www.codeproject.com/KB/audio-video/MIDIToolkit.aspx
In there, you'll find all the basics for opening an device, reading input, and writing output. Alternatively, NAudio has some MIDI classes, but they are somewhat incomplete.
As you develop, you'll want a reference for the MIDI spec handy.
A tool that you will find invaluable is MIDI-OX. In fact, I suggest that before you start coding, you fire up MIDI-OX and use it to sniff the messages coming from the Novation. It will give you a good idea of what the Novation sends. You can use it in conjunction with MIDI Yoke (a configurable virtual MIDI port) to insert itself between the Novation, and Ableton Live (or whatever software you normally use with your Novation) so you can see all of the messages in normal use.
Done... Kidding, but I've started on this in Python - I personally want linux support. I am teaching myself python, but I only dabble in programming.
You can see basic functionality at https://github.com/dewert/nocturn-linux-midi. The guy who reverse engineered it (i.e. the leap I wouldn't have been able to make myself) doesn't seem to be doing any more with it. His code is at https://github.com/timoahummel/nocturn-game
I am using PyPortMIDI and PyUSB, both of which I believe are wrappers for the C equivalents. I think this is all ok on Windows, but haven't tried.
What is currently on my github is crap, but it is proof-of-concept. I'm working on doing it properly now, with threading and proper configuration options.
The driver for the Nocturn makes it appear to system as a MIDI device, even though it isn't a USB MIDI device at the hardware level. The Automap software works entirely at the MIDI level, receiving MIDI instructions and sending different instructions in response - it is separate from the driver and not neccesary.
Alternatively, look at https://github.com/timoahummel/nocturn-game for an example of talking to it directly over USB from Python. You can probably port this to another language with libusb bindings.
Old thread, but I've just recently started looking into this.
I had a look at the Python application that dewert has written. Interestingly, it turns out that the data that the Nocturn emits is in fact MIDI, although it doesn't register itself as a USB MIDI device.
But looking at the actual data coming from the device, it actually emits control change messages (0xB0 controller value) for everything. Also the control commands that are sent to it are also control change messages, albeit only the data bytes, as the Nocturn seems to support MIDI running status (i.e. when sending multiple control change messages, it is not necessary to repeat the data byte).
Indeed, the looking at the magical initialization data it is actually just a bunch of control changes: it starts with 0xb0 and from there on the data comes in twos. For instance the last two bytes in the init string are 0x7f 0x00 which simply turn off the LED for the rightmost forward button. (There is something subtle happening as a result of the initialization being sent though, as the Nocturn sometimes emits some messages which appear to be some form of timeout events, and that behavior changes depending on whether the initialization string has been sent or not.)
Using MIDI-like messages makes sense, as Novation would be well aware of the MIDI protocol, so it would be easiest for them to use it for the communication even if the device is not strictly a MIDI device.
Note though that the incrementors just send the values 1 or 127, i.e. +1 or -1 step, so even with some trivial mapping software it's not really useful as it is. (Actually, if turned quickly, one can get 3 or 125 for instance, with the 125 corresponding to -3.) The only controller which sends a continuous value is the slider, which emits an 8 bit value when moved.
I suppose you'll want to know about USB classes in general and USB MIDI class in particular. The latter is the best what you can hope for in case you don't posess documentation for some proprietary protocol (whether it's used there instead).

How to program hardware? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am an adept Visual Basic programmer. I wish to learn about how people program hardware. For example I have seen people create an LED watches, boxes etc. How do you achieve this? Can it be done using VB or Java? I have some experience in reading C, C++ code. I am only aware of IO in the C and C++ language.
Probably you are looking for a programmable microcontroller. If you have experience in C/C++/Java, checkout Arduino. Its chip is programmed using a C like language. This "How tos" page might help you get started. There are also some good books that will help you move forward:
Programming Interactivity.
Making Things Move DIY Mechanisms for Inventors, Hobbyists, and Artists
Wiring is a platform similar to Arduino.
Also have a look at the Forth programming language. There are lot of interesting "tiny
computers" that you can program with this rather unusual language. Here is a partial list:
Forth Inc
Greenarrays
Zilog Z8
PIC18Fxx2
Two famous Forth books:
Starting Forth
Thinking Forth (A classic in Software Engineering literature.)
how people program hardware
If by 'hardware' you mean a standalone device (an embedded system), then the process involves cross-compilation. Code for the device is written in some (high-level) language on a host PC, compiled, and converted to a form suitable for downloading onto the target device.
A cross-compiler generates executable code for a platform other than the one it is running on -- for example, an AVR cross-compiler will generate code for the AVR microcontroller, but the compiler runs on a PC. Universally, assembly and C are used, and to some extent C++, Java and Ada.
If by 'hardware' you mean some device connected to the PC via some port (serial, parallel, USB), then the programing involves interaction through that port, possibly needing a device driver as well.
Can it be done using VB or Java?
I'm not sure about VB (perhaps there are VB compilers for WinCE and its ilk). Java is used on more complex/larger embedded systems (eg. mobile phones), mainly to develop user applications for the device.
create an LED watches, boxes etc. How do you achieve this?
If you're interested in developing something like a LED watch, you need to learn how to program a microcontroller. At the least, you need two components: the microcontroller and some hardware which loads programs onto it (a programer). You may invest on a development board, or build one yourself. Naturally, you will also need the cross-compiler, and the sotware that interacts with the programer so that it can load code.
I'm partial to AVR, so I'd suggest that. Other options include PIC, some variant of 8051, PSoC1 and TI's MSP devices.
The AVR tool-chain is bundled in WinAVR, and it includes avr-gcc (cross-compiler frontend), avrdude (software that interacts with the programer hardware) and a C library (avr-libc) + a bunch of useful tools. Programing hardware can be as simple as DAPA/bsd to USB based ones (AVRISP, USBasp, Usbprog) etc.
Or, if your PC still has a parallel port, you can try to control say a set of LEDs using an application written in VB. Check http://www.lvr.com/parport.htm for details.
I would recommend starting out with something like an arduino, which is a good place to get started with programming close to the hardware. It's a prototyping board with some built-in leds and other things, depending on which model you get. You can use C/C++, or any other language which can be cross-compiled to a format which is compatible with the target hardware (ATMega microcontroller I believe on the arduino).
Check out: http://www.google.com/search?client=ubuntu&channel=fs&q=arduino&ie=utf-8&oe=utf-8
If you just want to connect something to the computer serial/parallel port and 'talk' to it, you can use most languages. In Visual Basic you'll need a dll to achieve this. Java may be able to do it too.
If you want to program a microcontroler chip, you'd best learn C, because this is the language used to program most of them, although some of them accept basic, java, processing and C++.
There are a number of basic stamps you can use to get your feet wet. parallax for example made their business on basic based embedded systems. If you want to move forward at that programming level you really need to learn C for the most coverage, and I highly recommend assembler as well, at least a few different instruction sets.
You might be interested in Gadgeteer. I got to play with a kit a few weeks ago, and it's amazing fun. You can't currently do VB, but you can do C# and VB is coming very soon.

why don't more programming languages have builtin interfaces to the window manager?

Programming is at the heart about automating tasks on a computer.
Presumably those tasks would normally be done manually by a human.
Humans use the computer through the keyboard, mouse, and interaction with the console or the window manager. But very few languages have built in functions that provide an interface to these basic computing objects.
A notable exception is autohotkey, an open source language on windows, providing builtin functions that allow the following simple tasks:
* Get Pixel Information
* Get mouse position
* Keyboard macros
* Simulate key strokes
* Simulate mouse click
* Window management
See examples on rosettacode.
There have been various attempts on linux, many of which were stopped without explanation.
One is the inactive tcl library: android. Search google code for android, lang:tcl
I write web server code. No human being interacts with the code. It's simply a lot of complex plug-ins to Apache.
"Humans use the computer through the keyboard, mouse, and interaction with the console or the window manager. "
This is completely false in my case. The "user" sends requests through HTTP. No keyboard, no mouse, no console, no window manager.
The user may be using some kind of fancy GUI, but it doesn't matter to me or my software. All I see are HTTP GET and POST requests. Pure text.
"But very few languages have built in functions that provide an interface to these basic computing objects."
Correct. I have no use for keyboard, mouse, console or window manager.
All personal computing platforms have libraries that will do this.
The problem is that that would require standardizing user interactions over all systems. Java tried this, without a great deal of success. There have been other libraries with more or less success, Qt probably being the most promising one to date.
It's certainly possible to write a language for a single platform that will include all the UI fundamentals. It's also possible to fake it with a GUI and a library. However, there's good reason to want a language that is usable on any major platform, whether or not there's a GUI.
I doubt the premise is true. Java can do all that, except maybe "window management" since I do not know what is meant by this.
I'd be surprised if you can't do it with c#.
If there are many languages that can't do this, I'd guess it is because it is difficult to do it without tying the language to the operating system.
First of all, I think you're asking why the programming languages' standard libraries don't have built-in interfaces to the window manager. The language itself and its libraries are quite distinct.
One big reason is portability. If there's too many specific functions in a programming language's libraries, it will be harder to port it to other systems. For example, I/O, math functions, strings, various data structures and related algorithms, are all generic and can be made to work on virtually any computer.
But things like the window manager, GUI, etc., they are much more specific to certain platforms which is why they are not included in the standard libraries. This is what makes C/C++ so portable.
Tasks performed by computers without any human interface device interaction outnumber those directly actuated by a human by an enormous factor.
Programming languages tries (or at least is currently trying) to be independent with the platform. Example in .net, you have to reference some Win32 api to do some of the stuffs you specified above. Getting it built-in the core programming language model, .net will become too coupled with the OS, thus, creating its Mono counterpart will be too tedious.
Regarding keystrokes, macros and some stuffs, the simplest way I'm doing it right now is true vbscript or in powershell :)