Shop OBEX P1 Docs P2 Docs Learn Events
Getting Basic Stamp and Macromedia Flash to talk to each other — Parallax Forums

Getting Basic Stamp and Macromedia Flash to talk to each other

Paul HooverPaul Hoover Posts: 15
edited 2007-03-07 19:57 in BASIC Stamp
I'm trying to get a Basic Stamp accelerometer to talk to Flash to prototype some ideas.· What I've found out so far is that I can get Basic Stamp to talk to a debug window, and I need to get Flash to connect to some socket server that I probrably need to set up.· Other than that, I don't know where to start.· Anyone done this before or know how?

Paul

Comments

  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-11-07 02:04
    You will probably need to find a way to create a serial port connection in Flash.

    You might want to check on Adobe's Flash forum to see if anybody has instructions for doing so.
  • Roger PiersonRoger Pierson Posts: 62
    edited 2006-11-07 15:07
    If you program in Visual Basic there is probably a flash object you could add to your VB project. Then you could us the MScomm control to talk to the Stamp via RS232, and your code could manipulate the flash object accordingly.

    I don't know for sure that you can integrate flash into a VB app, but I would be very surprised if you couldn't, since VB interfaces with just about everthing.

    -Roger

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger Pierson
    Senior Electronics Technicain
    DTI Assoicates
  • Paul HooverPaul Hoover Posts: 15
    edited 2006-11-07 15:35
    I'll try to get one of the dev's on my team to write something up for me. Hopefully I can get it to work. Does anyone else have other ideas or experience?
  • KB3JJGKB3JJG Posts: 95
    edited 2006-11-07 17:13
  • Paul HooverPaul Hoover Posts: 15
    edited 2006-11-07 17:50
    Thanks! I'll try it out and post how it went.
  • tj60647tj60647 Posts: 18
    edited 2006-11-08 06:30
    The problem I ran into with the Barragan bit was "The microcontroller serial port settings should be 19200 Bauds, N, 8, 1", the BS2 works well at 9600.··So I wrote·something that offers a couple of baud options on the serial port settings, and I actually·have a student using it to interface a basic stamp [noparse][[/noparse]reading accelerometer data] to Flash.· But if you are not constrained by the baud rate the Barragan piece should work well.
  • Paul HooverPaul Hoover Posts: 15
    edited 2006-11-08 21:28
    Great! Would you be willing to share your code that offeres a couple of baud options?
  • tj60647tj60647 Posts: 18
    edited 2006-11-09 04:02
    Not the code quite yet but the application for a bit.· [noparse][[/noparse]see attached CONNECT.zip]

    Instructions:

    For use with at least a BS2 and a PC with .NET 2.0 [noparse][[/noparse]you can open the *.swf file in Internet Explorer if you do not have Flash installed].

    1.· Program BS2 with serialIO_simple.bs2
    2.· Launch Socket2SerialServer.exe...if you get a warning it is because we are opening a socket, not doing anything nasty.
    3.· Press the help button and follow the directions [noparse][[/noparse]the default settings should be fine].
    4.· Launch CONNECT.swf
    5.· Press the connect button.
    6.· Press reset on the BS2 and you should see a stream of [noparse][[/noparse]ascii] numbers appear in the Rx box.
    7.· Use this framework for further development.· Note the function handleIncoming(messageObj) in CONNECT.fla. This is where you'll do most of the work.

    8.· Sorry, but the socket2serial.server application will only work until December 15, 2006.· And if you close the socket connection you will likely need to restart the application.· Ocassionally the thread doesn't die, I'm working on that bit.· Kill it in task manager.
  • Paul HooverPaul Hoover Posts: 15
    edited 2006-11-09 18:15
    Amazing. Thanks.
  • Paul HooverPaul Hoover Posts: 15
    edited 2006-11-13 23:21
    I've got this running and it worked great doing a simple button press. When I pressed I got a 01, and when I released and got a 00 in Flash by using Socket2SerialServer.exe and CONNECT.fla. I tried hooking up an accelerometer and am gettting hex values (A4, A3, etc.). I assume this is because the values that are being passed are larger than 99. Does anyone know how to pass 4-digit numbers (3700, 2499, etc) through the serial port? Or maybe I could convert the number on the other side.
  • tj60647tj60647 Posts: 18
    edited 2006-11-15 19:42
    You should review the documentation on the serout command in the manual, it covers how to send multiple bytes.
  • Paul HooverPaul Hoover Posts: 15
    edited 2006-11-27 23:58
    I got this working great.· I decided to just send either 1, 2, 3 or 4 depending on the motion detection i am doing in the stamp.· No problem.· tj60647, any chance i could get a version of your serial connector that wouldn't time out· in december?· I would be willing to pay if that would help.
  • tj60647tj60647 Posts: 18
    edited 2006-11-30 02:10
    Another way to send a 4 digit decimal value would be to send it as a string and parse it out on the Flash side, although it isn't quite as efficient as sending byte values.

    On the Stamp side...

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    loopCount VAR word

    FOR loopCount = 0 TO 1024

    SEROUT 16, 84, [noparse][[/noparse]DEC4 loopCount] '9600 baud through proto board serial connection

    PAUSE 250

    NEXT

    END

    And on the Flash side [noparse][[/noparse]in the posted code]

    // received message handler
    function handleIncoming(messageObj) {
    trace(messageObj.toString());
    _root.Rx += messageObj.toString();
    var inValue:Number = parseInt(messageObj);//this is where we parse out the value
    }
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-11-30 02:18
    Here is another good article that shows some basics:
    http://www.hcilab.org/documents/ProjectThesis002-IntegratingSensorDataintoFlashMX2004.pdf

    Roger- I've worked with the VB.Net Flash Object, and it only can't really interact with the flash movie, only do stuff like pause, play, stop, change movie, and stuff outside of it. It isn't good for interacting with the movie, and feeding it data and such.
    -ACfishing

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.
    ·
  • SYSY Posts: 11
    edited 2006-12-01 21:23
    I have bought the Parallax USB2SER Development Tool from Parallax but I'm using a MAC. I can't seem to even recognize my port let alone retrieve the info from the basic stamp. I checked my code using a PC and hyperTerminal and everything seems to be in order but when I hook it up to the mac I can't recognize any of my ports. I have tried using Terminal and looked online for documentation but everything I have found so far refers to PC. My end goal is similar to Paul's - getting the basic stamp to communicate with Flash.
    Has anyone solved this problem before?
    Thanks.
    Sharon.
  • A.C. fishingA.C. fishing Posts: 262
    edited 2006-12-01 23:08
    It depends how familiar you are with the ActionScript language. I think any errors are almost definitely ActionScript Errors, and not on the Basic Stamp side.
    -ACfishing

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Somebody said...
    -Never Underestimate the power of human stupidity.


    Post Edited (A.C. fishing) : 12/1/2006 11:15:44 PM GMT
  • tj60647tj60647 Posts: 18
    edited 2006-12-04 20:02
    Sharon,

    The USB2SER uses the FTDI chips [noparse][[/noparse]see the documentation on the device]. The FTDI driver that you install when using this device creates a virtual com port [noparse][[/noparse]VCP] when the USB2SER is plugged in.

    Have you installed the drivers for the Mac?

    The Parallax page for the drivers [noparse][[/noparse]http://www.parallax.com/html_pages/downloads/software/ftdi_drivers.asp] list that the directions are for Windows NT/2000/XP only.
    However, you may be able to get the VCP Mac drivers from [noparse][[/noparse]http://www.ftdichip.com/Drivers/VCP.htm].

    Flash [noparse][[/noparse]Actionscript] doesn't currently have the capacity to access any serial ports directly, so you need something to bridge between the VCP and Flash. What I have developed does this via sockets on Windows, but not Mac. I'm sure someone out there has either a Java or Mac implementation.

    One workaround may be to connect to the socket remotely. Connect the BS to a PC, run a socket server, and connect to the socket using the IP address and port number.

    Good luck!
  • SYSY Posts: 11
    edited 2006-12-06 19:31
    If and when I figure this out I promise to let you know. Thanks for everything.
    Sharon.
  • tj60647tj60647 Posts: 18
    edited 2007-03-01 20:23
    I have had several requests for an updated version of the socket2serial.server application I posted last fall.· I haven't changed much, but it is currently being used for some demo development so I suspect as things heat up this semester more work will be done.

    If you are using Flash V8 you will need to adjust the security settings to allow the swf included to communicate with the localhost.· Or, you can just run the fla in the flash IDE.· [noparse][[/noparse]Or, you can communicate with the socket server from a remote location via IP + socket address]

    Instructions:

    For use with at least a BS2 and a PC with .NET 2.0 [noparse][[/noparse]you can open the *.swf file in Internet Explorer if you do not have Flash installed].

    1.· Program BS2 with serialIO_simple.bs2
    2.· Launch Socket2SerialServer.exe...if you get a warning it is because we are opening a socket, not doing anything nasty.
    3.· Press the help button and follow the directions [noparse][[/noparse]the default settings should be fine].
    4.· Launch CONNECT.swf
    5.· Press the connect button.
    6.· Press reset on the BS2 and you should see a stream of [noparse][[/noparse]ascii] numbers appear in the Rx box.
    7.· Use this framework for further development.· Note the function handleIncoming(messageObj) in CONNECT.fla. This is where you'll do most of the work.

    8.· Sorry, but the socket2serial.server application will only work until May 15, 2007.· And if you close the socket connection you will likely need to restart the application.· Ocassionally the thread doesn't die, I'm working on that bit.· Kill it in task manager.
  • Paul HooverPaul Hoover Posts: 15
    edited 2007-03-01 21:02
    Sweet. You're a lifesaver. Thanks.
  • SYSY Posts: 11
    edited 2007-03-07 19:57
    Hi guys,

    Just wanted to let you know that I have solved the stamp/Flash communication problem (using a MAC). If anyone needs the help please feel free to email me (syounger@fmnh.org)
    I will post all the info up here in the near future.
    Thanks for everything.
    Sharon.
Sign In or Register to comment.