Visual Studio and Basic Stamp
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
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
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.
You mentioned Visual Basic Express, I was wondering exactly what is the difference from Visual Studio to this?
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
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 ><;.
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.
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
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