+ Reply to Thread
Results 1 to 10 of 10

Thread: 18F4550 USB to visual Basic 2010 ADC project

  1. #1

    Default 18F4550 USB to visual Basic 2010 ADC project

    Hi all

    Thanks to Joe Hanley for putting up the VB buttons to control the 18F4550 with VB. I have evolved this and use it now to control 10 ports on the 18F4550, works great for switching stuff on and off remotely as I can log into my PC from work and operate stuff at home!.

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




    Further to that, I have done it the other way... 18f4550 to USB VB2010 analogue data back into the PC displayed in a text box on the PC within the VB2010 program.

    All the files are here for the project, the VB2010, the 18F4550 proton files, and the .exe files.

    I have a major problem now though.. If anyone can help I would be grateful. No one I know seems to know both ends ie. the 18f4550 and then the VB2010 end. The problem I have is that I cannot figure out how to get more than two characters to display in VB2010, and the display only goes from 48 to 57 strangely... I have no idea where to go now. if I put a two line display on my 18F4550 I can see the analogue voltage fine and can scale it as much as I like... I can get 65500 resolution too... but how do I display this on the PC under VB2010 ... Thanks if anyone can help...Ashley
    Attached Files Attached Files
    M1AEJ (MIET)


  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Licensed User captainslarty's Avatar
    Join Date
    Sep 2006
    Location
    A Marina in Portugal
    Posts
    3,064


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    Ash !
    REALLY WELL DONE !!!

    Sorry I aint got time to look into the minor display issue in more detail at the moment, but maybe another day, I thankyou though for taking a concept idea and spending all the hard work and time developing it.
    I am sure you will get there.

    GREAT WORK !.
    Joe
    Civilisation is the limitless mutiplication of unecessary necessities ... (Mark Twain)

  4. #3
    Super Moderator wastrix's Avatar
    Join Date
    May 2008
    Location
    Sydney, Australia
    Posts
    2,555


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    I have looked at your code and you are trying to do two different things in the 4550 and the VB. You have four labels in your VB program, but only take one measurement in the PIC. I'm not sure how you are expecting that to work.

    Anyway, your issue is primarily in the PIC program. You take a reading, divide it by 7000 (why?) and then use str$ to make an ASCII string representation of your calculated value.

    Let me give an example of what your program does. Say the Adin reading is 20000. x/7000 = 2.86 (2dp). Str$ converts this into four bytes {50,46,56,54} (numbers sound familiar?), this is transmitted to the PC, which displays each of those numbers in a separate label.

    What I would recommend that you do, is for example, something more like:
    USBBuffer[0] = Adin 1
    USBBuffer[1] = Adin 2
    USBBuffer[2] = Adin 3
    USBBuffer[3] = Adin 4
    USBOut 1, USBBuffer, USBBufferSizeTX, DoUSBOut
    The PC application will display the 0-255 value. If you want to do any scaling, convert to volts, whatever I recommend you do that on the PC, not the PIC.
    "If you have an important point to make, don't try to be subtle or clever. Use a pile driver."
    - Winston Churchill
    If you want to contact me, please email me, don't PM me.

  5. #4


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    Quote Originally Posted by wastrix View Post
    I have looked at your code and you are trying to do two different things in the 4550 and the VB. You have four labels in your VB program, but only take one measurement in the PIC. I'm not sure how you are expecting that to work.

    Anyway, your issue is primarily in the PIC program. You take a reading, divide it by 7000 (why?) and then use str$ to make an ASCII string representation of your calculated value.

    Let me give an example of what your program does. Say the Adin reading is 20000. x/7000 = 2.86 (2dp). Str$ converts this into four bytes {50,46,56,54} (numbers sound familiar?), this is transmitted to the PC, which displays each of those numbers in a separate label.

    What I would recommend that you do, is for example, something more like:
    USBBuffer[0] = Adin 1
    USBBuffer[1] = Adin 2
    USBBuffer[2] = Adin 3
    USBBuffer[3] = Adin 4
    USBOut 1, USBBuffer, USBBufferSizeTX, DoUSBOut
    The PC application will display the 0-255 value. If you want to do any scaling, convert to volts, whatever I recommend you do that on the PC, not the PIC.
    Thanks Wastrix, will give it a go this evening. The reason that I scale the Adin on the 18F4550 is how it normally displays on my LCD display on the 18F4550. I have a resistor divider on the A/D input and this lets me read 0- 24V scaled from that to 5V for the A/D input. I will however scale it on the PC and I think thats a better way to go about it. Cheers , Ash
    M1AEJ (MIET)

  6. #5


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    Hi again

    Well, I tried the advice you gave and all I can get is "0" or "128" flashing rapidly when I turn the pot on the 18F4550. The display makes no sense and does not seem to follow the pot. I tried scaling the digits in VB2010 and the same thing happens but with several decimal places then the last few digits flashing all the characters from 0 to 128.

    Ash
    M1AEJ (MIET)

  7. #6
    Super Moderator wastrix's Avatar
    Join Date
    May 2008
    Location
    Sydney, Australia
    Posts
    2,555


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    Yes, sorry, my example assumed an 8-bit A/D conversion. Set Adin_res = 8, rather than 10 (this will right justify the results, before you were only getting the two LSBs shifted left by 6). Also, my example uses AN:1,2,3,4, which correspond to inputs PORTA:1,2,3,5, so make sure you also set TRISA correctly or adjust the firmware to suit your hardware.

    I have now tested this in the sim and it works fine.
    "If you have an important point to make, don't try to be subtle or clever. Use a pile driver."
    - Winston Churchill
    If you want to contact me, please email me, don't PM me.

  8. #7
    Super Moderator wastrix's Avatar
    Join Date
    May 2008
    Location
    Sydney, Australia
    Posts
    2,555


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    P.S. if you want higher resolution, you will need to put the Adin into a word variable, then split it into two bytes, then join the bytes back into a word on the PC end. For example

    (on PIC side)
    MyWord = Adin 1
    Buffer[0] = MyWord.HighByte
    Buffer[1] = MyWord.LowByte

    (on VB side)
    Reading = (Buffer(0) << 8) + Buffer(1)
    "If you have an important point to make, don't try to be subtle or clever. Use a pile driver."
    - Winston Churchill
    If you want to contact me, please email me, don't PM me.

  9. #8


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    Thank you thank you thank you.... I have been battling with that for so long and now I can monitor my solar installation remotely. yeehaah.. Regards
    Ashley
    M1AEJ (MIET)

  10. #9


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    ashley ; Thank you for sharing your code with us

  11. #10
    Licensed User captainslarty's Avatar
    Join Date
    Sep 2006
    Location
    A Marina in Portugal
    Posts
    3,064


    Default Re: 18F4550 USB to visual Basic 2010 ADC project

    Quote Originally Posted by graski View Post
    ashley ; Thank you for sharing your code with us
    Hi Graski, please consider registering as a licensed user -
    Joe
    Civilisation is the limitless mutiplication of unecessary necessities ... (Mark Twain)

+ Reply to Thread

Similar Threads

  1. Beginning Visual Basic
    By Phil in forum Data Sheets and Utilities
    Replies: 22
    Last Post: 12th August 2009, 15:49
  2. About Visual Basic
    By hassawfaa in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 25th August 2008, 13:14
  3. EasyHID and Visual Basic.NET
    By CPW1992 in forum The Lounge
    Replies: 4
    Last Post: 6th June 2007, 01:22
  4. A Visual Basic interface to the IDE API
    By johngb in forum Mecanique - IDE
    Replies: 11
    Last Post: 18th December 2004, 23:59
  5. Using the API in Visual Basic
    By johngb in forum Mecanique - IDE
    Replies: 2
    Last Post: 1st December 2004, 19:07

Members who have read this thread since 13th May 2012, 20:40 : 6

Actions :  (Set Date)  (Clear Date)

You do not have permission to view the list of names.

Posting Permissions

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