Shop OBEX P1 Docs P2 Docs Learn Events
Visual Studio and Basic Stamp — Parallax Forums

Visual Studio and Basic Stamp

ToonzakaToonzaka Posts: 10
edited 2008-06-05 19:07 in General Discussion
I recently purchased the BASIC Stamp Activity Kit for Windows Portable Devices, which comes with a temperature sensor. I copied the code from the Creating a WPD Driver for a Microcontroller-based Sensor (Off Site)·WPDdriver file from the download on this link. My question is, has anyone else done this example before? Because I cannot get the Visual Basic to work properly for me. I am also getting confussed with·it. What my ultimate goal is, is to design my own driver using the Basic Stamp and temperature sensor to recieve temperatures for me. Does anyone know how to get this working or how to design a driver at all?

Comments

  • SteelSteel Posts: 313
    edited 2008-06-03 19:39
    Which version of Visual Basic are you using?

    If you are using 2005 or later, there is a tool called "Serialport", which has all of the properties there.· You can adjust comport, Baud, Flow control, bit structure.

    And then you can just run

    Dim Sendbyte as byte() = {&HFF, &HFF, &HFF, &HFF}

    Serialport1.write(Sendbyte, 0, 4)

    If you are using an earlier version of VB, I believe that somebody created a Serialport application.· Google 'visual basic serial port' and you should find code to help you out.



    http://www.programmers-corner.com/sourcecode/111



    Shaun
  • ToonzakaToonzaka Posts: 10
    edited 2008-06-03 20:13
    I think I am all messed up... My advisor, who I am working on this for, had me install Visual Studio 2002, but I have Windows Server 2003, and I am also on a computer running Vista. So far all of the tutorials I found have been for Windows Server 2008, and everythign that I have been looking at for reference has been using Windows Server Vista or 2008. I think I am having all these mess ups becuase of the versions being ALL wrong. I did already download Visual Studio 2008 PRO Beta, and have been looking for Windows Server 2008, which I did find. Would any of you suggest reinstalling everything and working with both versions of 2008 on this computer?
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2008-06-03 23:54
    Hi Toonzaka.

    Just to clarify, you said:

    [noparse][[/noparse]quote=Toonzaka"]
    What my ultimate goal is, is to design my own driver using the Basic Stamp and temperature sensor to recieve temperatures for me. Does anyone know how to get this working or how to design a driver at all?


    Is your ultimate goal:
    a) to design a driver?
    b) receive temperatures from the basic stamp activity kit
    c) both?

    My guess is that you are really after b) receive temperatures from the basic stamp activity kit.

    If this is the case, I think you may have gotten caught up in the buzzwords on the Microsoft site.

    Providing that my guess is correct, this is what I suggest:

    Get rid of Windows Server 2003 & 2008, Visual Studio 2002, and Visual Studio 2008 Beta. You don't need them.

    Then, if you need to, start with a fresh install of Vista on your PC (+ security updates, of course), and download & install the Visual Basic 2008 Express Edition. Also install the Parallax PBasic editor for the activity kit.

    After that is done, write a PBasic program that reads the temperature, and sends it to the Debug Terminal of the PBasic editor. At that point, your halfway there.

    Now, with Visual Basic 2008 Express, you can write a program that opens a serial port connection, and reads the value sent by the Stamp. Steel already gave you a good starting point for the program, only his is writing to the port ( Serialport.write() ), you'll want to use Serialport.read().

    Once you get everything working reading the temperature from the Stamp, you can modify your program to do whatever you dream up, like sending an email alert if the temperature goes above a certain value.

    FWIW, I think the Parallax / Microsoft collaboration is good, but sometimes Microsoft throws too much information at you at once. Try the above approach, and you should be able to get things moving.
  • ToonzakaToonzaka Posts: 10
    edited 2008-06-04 13:29
    Hmm, currently I have already taken the approach to get rid of Visual Studio 2008, and the 2003 server. But, you are a little mistaken in my goal, I think... My goal in the final design, is to create a display, something nice and fancy, that will show up on your desktop and take temperature readings from the Basic Stamp. So, I know that I must have the port read but, where exactly will the information be shown at? Because I want it to be relayed to a program that I am running. This is why I need to have Visual Studio to create that program/device that wil be running on the desktop.

    You mentioned Visual Basic Express, I was wondering exactly what is the difference from Visual Studio to this?
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-06-04 13:52
    Hi , Visual Studio is a suite of Microsoft development applications that include C#,Visual Basic, Web Development and SQL Server. The Express versions of those products are free to download but do not include all the features of the versions you have to pay for. Even so the·express versions ·will probably do most of what you want.

    If you want to use the Visual Basic Express edition it is recommended that all previous versions of VB are uninstalled first.

    Hope this helps

    Jeff T.

    PS if you have not done so already check out the following link

    http://forums.parallax.com/showthread.php?p=671804
  • ToonzakaToonzaka Posts: 10
    edited 2008-06-04 14:15
    I have downloaded Visual Studio 2005 trail edition, with Windows Server 2008 just like the tutorial I am going through says at http://msdn.microsoft.com/en-us/library/aa505381.aspx . I am installing them currently as well. A few things I think should also be known about myself in order for everyone to understand better I think.

    I am working for my advisor as a summer learning experience thing to design and create this program using the Basic Stamp and Visual Studio. So writing the temperature sensor program in Basic for the Basic Stamp, then creating my own program to run on the desktop. I am to use C++ to write the code in Visual Studio. Also I am suppose to go off what the WPD whitepaper at http://www.microsoft.com/whdc/device/media/WPD_drv.mspx says. Such as if you download it, you will see on the 3rd or 4th page, two programs that are running on windows desktop. That is my goal for this project, creating something like that but of my own. Also my experience with Visual Studio has been only 3 days working with it, and I only know Java and very very little C. (I still must find out how to write this program in C++). Again I am a student working on this.

    I read through your link Unsoundcode, and also the attached word doc. I was wondering could I use this template to create just a program to gather the temperature reading form the Basic Stamp? Also should I jsut abandon Visual Studio and go ahead and work with Visual Basic Express? And does Visual Basic Express support C++? I know I am asking alot here, but the microsoft board only confusses me more ><;.
  • ToonzakaToonzaka Posts: 10
    edited 2008-06-04 14:29
    Added note: I just talked to my advisor and he said he only wants me using Visual Studio to do this. Now I have been spending sometime reading through your post Jeff, and can I do what is shown there just in Visual Studio? Or is the stuff on the Visual Basic Express only able to be done on Visual Basic Express?
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-06-04 15:14
    Hi, you can create your application with C++ , I use Visual Basic because it is easier for me to understand and I can progress quicker.

    C++ Express can be downloaded here http://www.microsoft.com/express/vc/

    Microsoft have great help features to help you build your applications. You may find some of what I wrote useful when the time comes to communicate your C++ app with a Stamp.

    When you become proficient with C++ Express I am sure you will be capable of creating a very professional looking GUI to accept your temp readings.

    Jeff T.
  • ToonzakaToonzaka Posts: 10
    edited 2008-06-04 15:28
    Thanks for all your help Jeff and Steel. I just have one final question before I disembark on this impossible task, what is the difference between Visual Studio and Visual Basic Express. Because I do not know why my advisor is so set on having me use Visual Studio when it seems like Visual Basic Express is so much easier? I saw how you can create the GUI on your doc File Jeff, and that seems so easy I really want to use that. So I want to bring up a case to him about how Visual Basic Express will be more benifical to use, and easier for me also. Also what language does Visual Basic Express default to? What does it use without the C++ Express install? And if I in the end I have to use Visual Studio, can I still use your template that you used Jeff because that is really easy for me to understand. Easier then the Microsoft tutorial ><;. Thank you for all your help also!
  • ToonzakaToonzaka Posts: 10
    edited 2008-06-04 15:31
    PS. From a beginners stand point / newbie to both of these programs, what would be the easiest to learn and use so I can also use it as an arguement. Like will using Visual Basic Express teach a beginner as myself more to be able to be more proficent in Visual Studio later on. Or are the two programs nothing in the same?

    EDIT::
    I think I just understood something! Does Visual Basic use the Basic Language and Visual C++ use C++? So the difference between Visual Studio and Visual Basic is the languages· that it supports. Such as Visual Studio supports just about all the languages which Visual Basic supports only Basic, and Visual C++ supports C++, so inorder to write it in C++ I would need to dl Visual C++ Express?

    Post Edited (Toonzaka) : 6/4/2008 3:36:55 PM GMT
  • SteelSteel Posts: 313
    edited 2008-06-05 19:07
    Visual Basic is a programming tool. Visual Studio is an 'umbrella' that contains Visual Basic, C++, C#, Java, etc.

    So if you get Visual Studio, Visual Basic will come with it. I think the reason why the instructor wants it in Visual Studio is so that it can be viewed in different ways, and can be used as an 'object' for other projects. Visual Basic only allows you to create a final application (.exe) whereas visual studio allows your application to become an object that can be called from other objects. (So the instructor can make an application in C++ that runs your Visualbasic application and other students applications that are written in C or basic)

    Generally for serialport reading, I do the following (Granted, any of this can be changed):
    add a listbox to a windows form

    add a timer (From the toolbox) to the windows form.
    set the timer interval to 1mS.
    Set the timer enabled to true.
    --The above will cause a timer 'tick' every one mS while the application is running...and you can add code under that tick.

    Add a Serialport (from the toolbox) to the windows form.
    Set the baudrate to the correct baud of the BS2.
    Set the Portname to the correct comport that talks to the BS2.

    Double-click on the timer or create a sub-routine in your code

    ''The following loop will run every 1mS. It will check to see if there is any data in the serialport, and if there is data, it will add it to the listbox on the screen. If there is no data, it will just end the routine

    Dim RecievedString as string = ""

    Do while Serialport1.bytestoread > 1
    dim temp as string = "" ''This is just a temp value
    temp = Hex(Serialport1.readbyte()).tostring) ''Save the first byte in hex form as the string
    if temp.length = 1 then temp = "0" + temp ''If the byte is 0 through F, it will print as 00 through OF
    RecievedString += temp + " " ''The loop will create a string of recieved bytes
    Loop
    listbox1.items.add(RecievedString) ''Display the recieved bytes as a 'line' in a listbox
Sign In or Register to comment.