Closed Thread
Page 3 of 3 FirstFirst 123
Results 21 to 30 of 30

Thread: Programming Hardware

  1. #21
    Fullenglish's Avatar
    Fullenglish is offline Newbie
    Join Date
    Dec 2009
    Posts
    17
    Rep Power
    0

    Re: Programming Hardware

    The .dll that i think i need had this:
    Name: DeviceIni, address: 0x10001d80, Relative address: 0x00001d80, Ordinal: 1 (0x1)
    Name: ReadBuffer, address: 0x10001e40, relative address: 0x10001e40, Ordinal: 2 (0x2)
    Name: WriteBuffer, address: 0x10001de0, relative address: 0x10001de0, Ordinal: 3 (0x3)
    Thats all that I could get out of it, any of it useful?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #22
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Programming Hardware

    Um...sort of. Really the only way I can think of is to disassemble the function code and examine the sizes of the arguments and figure out how they're used. Not fun.
    sudo rm -rf /

  4. #23
    Fullenglish's Avatar
    Fullenglish is offline Newbie
    Join Date
    Dec 2009
    Posts
    17
    Rep Power
    0

    Re: Programming Hardware

    Sorry about the delay, been a bit busy as of late.
    What I was wondering, which thinking about it might not be the best idea but...
    what if I where to use the python program which I showed in a laster post, to try and figure out how to use them.....

  5. #24
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Programming Hardware

    Ok, so I'm officially an idiot...I have no idea why I didn't catch this before. Sorry for making you jump through all these hoops.

    I just took another close look at the code and finally figured out where all the trouble was. The relevant code is this:
    Code:
    class MissileDevice:
      INITA     = (85, 83, 66, 67,  0,  0,  4,  0)
      INITB     = (85, 83, 66, 67,  0, 64,  2,  0)
      CMDFILL   = ( 8,  8,
                    0,  0,  0,  0,  0,  0,  0,  0,
                    0,  0,  0,  0,  0,  0,  0,  0,
                    0,  0,  0,  0,  0,  0,  0,  0,
                    0,  0,  0,  0,  0,  0,  0,  0,
                    0,  0,  0,  0,  0,  0,  0,  0,
                    0,  0,  0,  0,  0,  0,  0,  0,
                    0,  0,  0,  0,  0,  0,  0,  0)
      STOP      = ( 0,  0,  0,  0,  0,  0)
      LEFT      = ( 0,  1,  0,  0,  0,  0)
      RIGHT     = ( 0,  0,  1,  0,  0,  0)
      UP        = ( 0,  0,  0,  1,  0,  0)
      DOWN      = ( 0,  0,  0,  0,  1,  0)
      LEFTUP    = ( 0,  1,  0,  1,  0,  0)
      RIGHTUP   = ( 0,  0,  1,  1,  0,  0)
      LEFTDOWN  = ( 0,  1,  0,  0,  1,  0)
      RIGHTDOWN = ( 0,  0,  1,  0,  1,  0)
      FIRE      = ( 0,  0,  0,  0,  0,  1)
    
      def __init__(self, battery):
        try:
          self.dev=UsbDevice(0x1130, 0x0202, battery)
          self.dev.open()
          self.dev.handle.reset()
        except NoMissilesError, e:
          raise NoMissilesError()
    
      def move(self, direction):
        self.dev.handle.controlMsg(0x21, 0x09, self.INITA, 0x02, 0x01)
        self.dev.handle.controlMsg(0x21, 0x09, self.INITB, 0x02, 0x01)
        self.dev.handle.controlMsg(0x21, 0x09, direction+self.CMDFILL, 0x02, 0x01)
    The initialization function here opens a new USB device (a Python library) and passes some parameters to it. I don't know what the 0x1130 and 0x0202 are; probably some flags. You should be able to find the documentation for Python's UsbDevice online. Anyway, if you look at the move() function, you'll see that it sends control messages down the USB device to the rocket launcher. To send a command you need to send the bytes 0x21 0x09 to signal the beginning of a command. Then you send your command (see the declarations above it) and then the command termination bytes 0x02 0x01. So the first two lines of the function would send this byte stream down the USB port:
    Code:
    21 09 55 53 42 43 00 00 04 00 02 01
    21 09 55 53 42 43 00 40 02 00 02 01
    The next command would follow. Now if you notice, each of the simple commands (left, right, up, down, fire) has exactly one byte set to one. This is called one-hot encoding. The left-up signal is just the left and up commands ORed together. Thus the basic fields are, in order,

    0 LEFT RIGHT UP DOWN FIRE

    Setting any of these high (note that the first byte must be set to 0) will cause the launcher to perform the requested action. Setting two high will perform both actions at the same time. Obviously you don't want to set conflicting commands like left and right at the same time, as this would most likely result in physical damage to the motors since they're fighting each other. (If it's one motor it'll probably stick. But don't take that chance.)

    Anyway, you must follow your command with the CMDFILL block. Why I don't know, but that's how it works. So a full command block to turn left would look something like the following:

    (Command initialization in green, command code in red, filler in blue.)
    Code:
    
    21 09 55 53 42 43 00 00 04
    00 02 01 21 09 55 53 42 43
    00 40 02 00 02 01 00 01 00
    00 00 00 02 01 08 08 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    
    Last edited by dargueta; 03-26-2010 at 11:35 AM. Reason: Oops.
    sudo rm -rf /

  6. #25
    Fullenglish's Avatar
    Fullenglish is offline Newbie
    Join Date
    Dec 2009
    Posts
    17
    Rep Power
    0

    Re: Programming Hardware

    Thanks for that info, dargueta, that has really cleared everything up
    But one thing that i'm a bit lost about, on that last command box:

    Code:
    00 01 02 03 04 05 06 07 08
    21 09 55 53 42 43 00 00 04
    00 02 01 21 09 55 53 42 43
    00 40 02 00 02 01 00 01 00
    00 00 00 02 01 08 08 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 
    The first line, has "00 01 02 03 04 05 06 07 08", where did you get this line from?
    Oh, and the 0x1130 and 0x0202, are the vendorID and the ProductID of the USB launcher, I guess there needed so that the program knows which USB device it to talking to.
    And so now that I know how to make the laucher move, how to I write a program in Visual which will send that code down the USB cable, will it use the calls within the .dll that i said in a later post??

    Thanks

  7. #26
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Programming Hardware

    The 0-8 thing was me aligning the columns and then forgetting to take that reference row out. My bad. As far as the USB thing, I found some stuff on Google:

    Visual Basic and USB!!
    Visual Basic USB Control

    Basically all you have to do is write the driver--which you've already done with the stuff I gave you--and then use some WinAPI calls to connect with the USB ports, probably using IO.dll and INPOUT32.dll. (Don't quote me on that.) Do you know how to import functions from a Windows DLL?
    sudo rm -rf /

  8. #27
    Fullenglish's Avatar
    Fullenglish is offline Newbie
    Join Date
    Dec 2009
    Posts
    17
    Rep Power
    0

    Re: Programming Hardware

    isn't it just something like '#Include IO.dll' at the start of the program?

  9. #28
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Programming Hardware

    Noooo. I've got to go in two seconds but I'll edit this post once I have more time. In the meantime, look up the Declare Function directive on Google.
    sudo rm -rf /

  10. #29
    Fullenglish's Avatar
    Fullenglish is offline Newbie
    Join Date
    Dec 2009
    Posts
    17
    Rep Power
    0

    Re: Programming Hardware

    Alright I see what you mean, I have to write:
    Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)

    But one thing that I think i'm missing, is that these declares will connect me to a serial port, which isn't quite what a USB is, (well to my knownledge at least).......So how would i connect to a USB?

  11. #30
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Programming Hardware

    USB actually stands for Universal Serial Bus. So yes, it's a serial port. Anyway, I suggest you look here for some more guidance and information. A little more than halfway down there's some code you could use.
    sudo rm -rf /

Closed Thread
Page 3 of 3 FirstFirst 123

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. Question Regarding Best Hardware Specs For Programming.
    By Poecilotheria in forum Computer Hardware
    Replies: 3
    Last Post: 12-23-2010, 06:52 PM
  2. Programming hardware in Java
    By ThemePark in forum Java Help
    Replies: 3
    Last Post: 01-19-2010, 03:01 AM
  3. General advise on programming languages - WinCE apps - hardware.
    By arcade_007 in forum General Programming
    Replies: 1
    Last Post: 06-15-2009, 05:27 AM
  4. Programming Hardware
    By dingdongsilver in forum General Programming
    Replies: 1
    Last Post: 03-09-2009, 08:58 AM
  5. Hardware
    By kalam88 in forum Computer Hardware
    Replies: 1
    Last Post: 11-10-2008, 07:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts