Page 5 of 10 FirstFirst ... 2345678 ... LastLast
Results 49 to 60 of 110

Thread: PIC based DRO

  1. #49
    Registered
    Join Date
    Feb 2010
    Location
    USA
    Posts
    14
    Downloads
    0
    Uploads
    0
    Yes they are Chinese output, confirmed with my 100mhz digital USB storage scope, although I have yet to translate the data stream.

    I have both an 18 inch and a 24 inch and I got them on Ebay recently from seller 800watt.

    These are big an heavy calipers, well worth the money, even though they are inexpensive.

    By the way I checked my cheap Habor Freight 4 and 6 inch calipers and they are +ve gnd.


  2. #50
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    Yes they are Chinese output, confirmed with my 100mhz digital USB storage scope, although I have yet to translate the data stream.
    Great. Keep us informed on your progress and let me know if I can help with modifying the PIC code.

    ...from seller 800watt.
    He's got some nice bits there. (It's a pity it's so expensive to ship heavy goods over to the UK)
    Bill


  3. #51
    Registered
    Join Date
    Feb 2010
    Location
    USA
    Posts
    14
    Downloads
    0
    Uploads
    0
    Bill,

    I am stuck because I can't access the dll from vb6, I know that the answer is simple:

    Here is the VB6 code I am testing:
    PHP Code:
    Public Declare Function MPUSBGetDeviceCount Lib "mpusbapi.dll" Alias "_MPUSBGetDeviceCount" (ByVal pVID_PID As String) As Long

    Global count As Long

    Sub OpenMPUSBDevice
    ()
         
    count MPUSBGetDeviceCount("vid_04d8&pid_003f" Null)  ''ERROR here with Error 49 Bad DLL calling convention
    End Sub 
    Here is what I believe is the C code from the source files for mpusbapi.dll:
    PHP Code:
    DWORD MPUSBGetDeviceCount(PCHAR pVID_PID)
    {
        
    DWORD count;        // Number of USB device with matching VID & PID
        
    count 0;          // Initialization
        
    for(int i 0MAX_NUM_MPUSB_DEVi++)
        {
            if(
    MPUSBGetDeviceLink(i,pVID_PID,NULL,NULL,NULL) == MPUSB_SUCCESS)
                
    count++;
        }
    //end for
        
    return count;
    }
    //end MPUSBGetDeviceCount 
    The DLL routine returns a DWORD which I think is VB6 Long and the argument is PCHAR which I think is a Null terminated string so I added the Null in calling it.

    I've tried it many different ways with no luck-- always ' Error 49 Bad DLL calling convention'.

    Have you got any thoughts on this?

    I have attached the Dll if you want to quickly try this.

    Thanks,
    Dale
    Attached Files Attached Files


  4. #52
    Registered
    Join Date
    Jun 2008
    Location
    Canada
    Posts
    91
    Downloads
    0
    Uploads
    0
    Do a google code search for mpusbapi lang:basic and you will find an example of basic program using this function
    page link it gives is no longer valid but all the code is there.

    http://google.com/codesearch?q=mpusb...%3Abasic&hl=en

    George


  • #53
    Registered
    Join Date
    Feb 2010
    Location
    USA
    Posts
    14
    Downloads
    0
    Uploads
    0
    Thanks George, never seen that code search before, very useful.

    I have already seen that code, it is coded for VB.net (or whatever Microsoft named VB6 successor). Not compatible with VB6, they shouldn't even have had the right to call it VB in my opinion, code is not very convertible.

    I copied the code it used to declare and call MPUSBGetDeviceCount and it got the same error, I went digging and found the C code in the dll and tried to fix the problem with the Null and Long.

    Dale


  • #54
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    If memory serves, the ByVal statement should pass a null terminated string to the dll so you shouldn't need to add the termination.

    A quick google threw up others having the same problem with the microchip dll (suggesting that it doesn't use standard calling conventions - i.e. not VB compatible)

    Might be worth chasing Microchip ???
    Bill


  • #55
    Registered
    Join Date
    Feb 2010
    Location
    USA
    Posts
    14
    Downloads
    0
    Uploads
    0
    Bill,

    Didn't work without Null either, good to know Byval sends it.

    I already have a Microchip ticket open on this but haven't had a response yet.

    I hope I can use VB6. I never went to VB.net, it was just too different and a money grab. Someday I'll just learn C.

    Thanks,
    Dale


  • #56
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    I hope I can use VB6. I never went to VB.net, it was just too different and a money grab. Someday I'll just learn C.
    Snap !

    I tried VB.net as a beta - it was like starting all over again, NOTHING worked !

    A friend suggest C# but ... I think my programming days are over (or at least the days of learning a new language are) , I don't get anything out of it any more
    Bill


  • #57
    Registered
    Join Date
    Feb 2010
    Location
    USA
    Posts
    14
    Downloads
    0
    Uploads
    0

    Smile

    Bill,

    Well that was interesting, I can now send and receive data to the 18F87J50 demo board with a simple VB6 program.

    The template like code was generated by EasyHID and it uses mcHID.dll.

    I just set the VendorID, ProductID, BufferInSize, BufferOutSize.

    Then I wrote a little code to toggle the LEDs (on the pic board) every time there is a state change of a switch on the pic board. Read and write accomplished.

    Attached is the VB6 project and the dll if anyone wants to 'look' at it.

    To run it you need PIC18F87J50 FS USB PIM demo board with 'USB Device - HID - Simple Custom Demo - C18 - PIC18F87J50 PIM.hex' loaded

    Now I just have to mesh your 12F675 asm code into the C++ workspace that Microchip uses for the USB pic's. I hope that is not too hard.

    Cheers
    Dale
    Attached Files Attached Files


  • #58
    Registered
    Join Date
    Feb 2010
    Location
    USA
    Posts
    14
    Downloads
    0
    Uploads
    0
    Bill,

    Well I now am able to modify the C code, build, load and run a hex file. I spent a lot of time trying to consolidate all the necessary .c and .h files into the project directory but eventually gave up. In all there are about 16 files loaded or included, wow.

    Anyway, I can very easily call an asm function from C or insert asm code inline in C (with a little syntax changing). So I am ready to dive in.

    First, I am not sure how not having a +ve gnd on the caliper changes the input signal components. I don't think it does. Would I just use the LED/3.3k components you used?

    In your code below it says you are setting the reference voltage to 0.75v but I can't figure out how that is. The B'10100011' sets VRR to low range and VR3:VR0 to 0011 or decimal 3. Doesn't that make the ref voltage = (3/24)*5 = 0.625? I'm not tying to be picky, I just want to be sure that I understand assembly/binary/.... because I am so rusty at it.

    Anyway, wish me luck!!

    Dale

    Code:
    ;initialise comparator etc
    ;
    VInit	BSF	status,RP0	;select bank 1		
    	movlw	B'10100011' 	;set Vref ~ 0.75v, Vdd = 5v;(24/5)* 0.75 
    	movwf	VRCON


  • #59
    Registered
    Join Date
    Aug 2008
    Location
    UK
    Posts
    561
    Downloads
    0
    Uploads
    0
    Hi Dale, your progress is impressive

    I'll check the ref value code tomorrow. However, your scale works at 3v from the 2032 cell, so you'll want to set the comparetor threshold higher any way. Similarly, you may need to use 3v zeners (or perhaps green leds) to limit the voltage out of the pic (if the pic runs at 3v, not 5v, you could dispence with the doiodes altogether)
    Bill


  • #60
    Registered
    Join Date
    Feb 2010
    Location
    USA
    Posts
    14
    Downloads
    0
    Uploads
    0
    Yep, I wish I had a 3V signal level, then I would just have TTL input levels and use digital I/O ports on the Pic.

    Not to be, even though the battery is 3v, the output signal is only 1.5v.

    One of the main things I need to do is get rid of the battery and get the 10 microamps I need to power the caliper form the USB. I was just going to use a 3V zener to power it with a 100 uF cap on it.

    I will run the Pic on 5v from the USB.

    Now this is a stupid question, why can't I just put the data lines to the comparator thru 10k resistors and forget the diodes?

    Thanks,
    Dale

    P.S. I spoke too soon on how easy it was to add asm to C18. When I actually try it I get syntax error at _asm. Supposedly you just put ams between _asm and _endasm, oh well, more grief (3 hours so far on this one). The more I look at the C code the more I might try just doing it.


  • Page 5 of 10 FirstFirst ... 2345678 ... LastLast

    Similar Threads

    1. Is water based
      By CNCadmin in forum Safety Zone
      Replies: 44
      Last Post: 10-15-2010, 03:27 PM
    2. Need help with CNC UK based
      By ciscoe in forum Europe Club House
      Replies: 1
      Last Post: 07-21-2008, 07:03 AM
    3. Convert to PC based
      By Arcticfox46 in forum CNC Wood Router Project Log
      Replies: 4
      Last Post: 08-10-2007, 09:05 AM
    4. Used CMM based DIY router?
      By biomed_eng in forum DIY CNC Router Table Machines
      Replies: 1
      Last Post: 10-16-2006, 09:52 PM
    5. dos based cnc software
      By flyingmike in forum Computers and Networking
      Replies: 14
      Last Post: 11-25-2005, 02:29 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.