Viewport DDE or DLL data or .NET object
henry99
Posts: 67
Is it possible to get the data to stream out of Viewport via DDE or a DLL call or .Net object?
The best would be a .NET object which can be imported into Matlab or C# or VB easily.
I would imagine the following format would be ideal:
Object.GetVariableNames -> List of Strings
Object.GetVariableValue("VariableName") -> Double Array
Object.SetVariableValue("VariableName") -> Double Array
Object.Connect(speed)
Object.Disconnect(speed)
Then data sharing can be much easier to implement.
I could write this myself but why bother if someone better than me like Hanna can do it quickly? [noparse]:)[/noparse]
Also how does Viewport handle arrays?
The best would be a .NET object which can be imported into Matlab or C# or VB easily.
I would imagine the following format would be ideal:
Object.GetVariableNames -> List of Strings
Object.GetVariableValue("VariableName") -> Double Array
Object.SetVariableValue("VariableName") -> Double Array
Object.Connect(speed)
Object.Disconnect(speed)
Then data sharing can be much easier to implement.
I could write this myself but why bother if someone better than me like Hanna can do it quickly? [noparse]:)[/noparse]
Also how does Viewport handle arrays?
Comments
Object.DataChangedEvent
with the following support properties:
Object.ChangedEvent("VariableName",Threshold)
Object.ChangedEventEnable("VariableName")
Object.ChangedEventDisable("VariableName")
That would be the bomb because then I could use drop the object into my C# program and write a few callbacks when the data changed. Otherwise I guess I could just poll it in a timer .net component but the response would not be as good.
do you think callbacks would always be faster? I mean flag/semaphore then burst might be fast too.
Just curious, even though you'd like this in viewport, have you messed around with propellent.dll ?
Hanno,
if you happen to read this, I'd like to second henry's very good suggestions - this would open up some very interesting instrumentation and applications independent of viewport addons.·
cheers,
Howard
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (CounterRotatingProps) : 7/1/2009 8:23:12 PM GMT
If you check a flag, you'd need to setup a timer object with an expiry and that would bog things down.
I'm not that familiar with semaphores.
I think callbacks are much more intuitive also. For example, when the data changes past the threshold, the callback is triggered and I do some processing. Like if the voltage changes or the encoder value changes,
The fastest solution would probably be DMA like on the NI PCI cards but I hardly use it because of the added complexity. The key is to make it as easy as possible. A limited selection of methods and variables to get data in and out is better than 100 functions people will never use.
The code will be easy to write, you have one cog that sends out serial at the max speed and you can use the serial .net object from the .NET library to translate it to callbacks/update variables etc.
Again I'm sort of lazy and would rather pay someone $100 for an off the shelf product than spend time designing it myself.
Currently, I often have my matlab or c# program read in and parse serial data. However, this is definitely not as nice as a packaged .Net component that takes care of all those details that I take short cuts around.
It'd be very nice to add some basic data compression to get the fastest data stream over the USB as possible.
I'd be willing to donate my time to the open source project if someone was willing to write the prop ASM (which I haven't learned yet as I just use spin).
Great inspiration Howard and excellent architecture Henry. This makes lots of sense and will make it into ViewPort soon- exactly as Henry has specified. I just have to finish up something that is so exciting I stayed up till 3am last night- will be out soon and rock your world!
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
Once I have a fast way to get data into Matlab or C#, there will be a lot of cool applications for sure! I would totally throw away most of my NI data cards.
The matlab image processing functions are much more advanced. Also you can write CUDA applications for faster processing.
You can buy an Asus EEE 900 netbook with Windows and Atom 1.6ghz processor for $150 on sale as the PC!
Hanno: I hope it comes as an easy to use .Net component like the .Net Serial component!
Make the event:
Object.DataChangedEvent
with the following support properties:
Object.ChangedEvent("VariableName",Threshold)
where Threshold>0 means the event is enabled, otherwise it is disabled (no need for enable/disable methods)
Object.ChangedVariables(List of Strings with names of variables that have changed so that you don't need to read all the variables in)
Also modify or overload:
Object.GetVariableValue("VariableName") -> Double Array + Long Integer Timestamp (always good to know what time the sample was at)
Yes, do it as a .NET serial component by all means --- they're easy across all the languages.
> CUDA
Very interesting, henry, CUDA in many ways is like the opposite end of the spectrum of dev. platforms on micros. (Hard to imagine a Propeller running more than 8 "threads" much less 12,000!) I like CUDA a lot --- if I wasn't stuck on a boring set of projects right now, I'd be codin' cuda ;0
cheers
-Howard
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I tried Jacket from Accelereyes for matlab and you only need very minimal changes.
Most of my data acquistion needs are pretty simple and it's much easier to write advanced algorithms in matlab than prop asm so can't wait for the .NET component [noparse]:)[/noparse]
Yes, CUDA is awesome- and already built into a prototype of a ViewPort feature. See my google tech talk for details- basically I integrated the Nvidia PhysX physics simulation package with ViewPort. The idea is that people can model their robots and environments within the simulated world, controlled by spin running on the propeller, all managed by ViewPort. It's like a "dreamworld"- the spin program gets sensor readings from the simulated world and controls actuators that act on the simulated world. Then, when everything works, you just replace the simulated sensors/actuators with real ones and you're robot is set! It's working- just have to get time to productize it..
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
I think someone also wrote a OCX wrapper (yuk!) for the propellent dll, but I've not tried it. (Because it would probably hang.)
[noparse][[/noparse]EDIT - Hanno, you're a genius ! ]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Honestly I don't know what I'd be streaming that much data besides video or audio (which is much easier using a usb webcam or audio card).
Pairing with those low cost netbooks is great. For 150 you get a tiny notebook with a battery to power the prop from the usb port and can do all the processing.
I've also used the the Intel D945GCLF2D mini-ITX Atom 2x1.6Ghz to great success which is < $100.
Yes, low cost netbooks are awesome with the Propeller- particularly with ViewPort.
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
Maybe it would require special purpose drivers/code but it certainly seems possible without any special PC mods.
Data packets should be time stamped with the counter clk count from the propeller then transferred asynch to the PC.
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
As a teaser, to continually get the current value of a spin variable called "temperature" into your excel spreadsheet you just need to type this into a cell:
"=viewport|getvalue!temperature"
Isn't that beautiful?
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
You da man!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
Thanks for your updates.
Sorry for the delay as I've been traveling.
DDE might work ok but I think the .NET component is still the way to go.
Since the FTDI chip just emulates a serial port and the serial output commands are already easily communicated in C#, VB, Matlab, etc, making the interface easy to use for programmers is def the way to go.
Hanno: let me know if you need any clarifications for my suggestions
If you really want to program in .net, check out ViewPort's developer's kit: http://mydancebot.com/viewport/dkhelp.php
Once the DDE communication is set up, it should be easy to use that to integrate into pretty much anything.
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
A dde client by contrast is trivial. To get the live value of a spin variable into excel just type this into a cell:
"=viewport|getvalue!temperature"
Do this for whatever variables you want to calculate/graph!
Coming soon....
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
I'm sure quite a bit of work went into Viewport, I'm not doubting that and that's why I didn't want to tackle writing a .Net component myself.
However, again a drop in .Net component makes it much better to use and if one isn't available, I can just use the drop in microsoft .Net serial port and use standard serial comm to send data back and forth.
Hanno, maybe you would consider writing the .net component and selling it as a different product when you have the chance. Certainly you already worked out the communication protocol and data transfer so that's the hard part.
Working on it!
Next release will have a built-in DDE server, a sample Excel spreadsheet which shows how to do engine performance tuning, a VB.net sample client, and a C# sample project.
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
DDE is just fine for data transfers - Dynamic Data Exchange is, after all, what we are talking about.
C# or VB wrappers add little, if any, utility. Your idea to post some example code is all that the average person needs.
Great Job! Say hey to the folks...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH
I used to know how to use DDE in C++ but I have no idea how to do it in now and I don't think it's event driven so you need to parse individually DDE messages.
Often times you want to update the display when the variable changes.
How are you going to know when the variable changes? In C# with a .Net control, you just write the callback function.
In DDE I'm pretty sure you need poll for a DDE event or write a special DDE callback and parse it then stick all your code into the one massive callback.
Polling works fine in single thread programs but not for windows.
Without callback support, I'd just stick with the included free microsoft .Net serial component.
Maybe I should write it myself [noparse]:)[/noparse]
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
Variables that you can read/write/advise/trigger include the video and io arrays, as well as the configuration strings. I've included support for both synchronous read/write, as well as the "advise" event based callback feature for read/write. Here's some Visual Basic code that works for Excel macros- I'll post a C#.net example later.
Am I missing anything?
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
Looks good!
I'd be very interested to see the C#/Matlab example. Can you increase that refresh rate to more than 10Hz reliably? Matlab in particular will be cool to do a lot of hardcore math easily and send back to the prop.
Also, I saw a demo of your Viewport controlling a DC motor + optical encoder using a PID loop. What motor driver did you use for it? I'm trying to find something that is as much plug and play as possible.
I use the LMD18200, beware that the minimum voltage is 12V, otherwise it's perfect.
Hanno
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
This looks terrific, and will serve our needs perfectly. Is the data in the longer arrays/vectors buffered? If a request for data is received while VP is reading data from the Conduit, will it receive a 'pure' snapshot of the data as recieved in one transfer from the prop, or will it be an overlay of some old/some new results?
Do you sleep?
Cheers!
Paul Rowntree
PS : WHen would you expect to post this version?
Cheers!