Need to combine Basic Stamp and Microsoft Access
Karl Matlack
Posts: 5
I need help figuring out how to incorporate my basic stamp with Microsoft Acces database.
I have an Access database to long function I am doing and I have a basic stamp board to send a power signal to a wireless remote to enage a piece of equipment that does four different functions. Now I would just like to clicka button in acces that will allow me to activate the Basic Stamp board. I no nothing about all this code and programing and could use all the help anyone will give me.
Thanks, Karl
I have an Access database to long function I am doing and I have a basic stamp board to send a power signal to a wireless remote to enage a piece of equipment that does four different functions. Now I would just like to clicka button in acces that will allow me to activate the Basic Stamp board. I no nothing about all this code and programing and could use all the help anyone will give me.
Thanks, Karl
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I am very new to code and very lost.
You then program Access to talk (and listen) to the BS2 over the serial port. You can then, when NOT using Access to talk to the BS2, use the Parallax IDE to talk to the BS2, and program it (in PBasic) to listen (and talk) to its side of the serial port.
It sounds like you've got all the pieces you need -- except how to program in Access how to have a button-click send a message over the serial port to the BS2. That's all PC side programming. You could use the MSCOMM control (if you had VB6 Pro). I believe there's a "Native" windows OpenPort command that you can give the "COM1" to "COM3" string to, to open the PC's serial port.
It would be a lot easier to set up the serial communications, and you should still be able to log info to an Access .mdb file.
Here's an example of code:
Private Sub Form_Load()
· Timeout = TOut
· setcap False
· pauseflag = 0
· stopflag = True
· addList "Stopped"
· With MSComm1
···· .Handshaking = 0
···· .RThreshold = 1
···· .RTSEnable = True
···· .Settings = "9600,n,8,1"
···· .SThreshold = 0
···· .EOFEnable = False
·····.PortOpen = True
' Leave all other settings as default values.
· End With
· TimerInterval = 10
· pause (100)
End Sub
and event handling:
Private Sub MSComm1_OnComm()
Dim InBuff As String, rs
'Debug.Print MSComm1.CommEvent
· Select Case MSComm1.CommEvent
·· Case comEvReceive
···· InBuff = MSComm1.Input
···· If InStr(InBuff, "!") > 0 Then setcap True
···· Debug.Print InBuff;
·· Case Is > 8
···· Call addList("ERROR!!!!")
···· setcap True
· End Select
End Sub
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 6/19/2007 5:22:13 PM GMT
I was told that there was a chance this does not work with a USB Serial adapter only a actual serial port.... Is this true possibly?
First - if the USB Serial Adapter drivers have been correctly installed, then, as far as your PC is concerned, the adapter is just another serial port and any "standard" method of writing to a serial port should work.
Second - you need a way to address a serial port. For Visual Basic, this is traditionally accomplished by using the MsComm control. Unfortunately, this control is not included in either the "cheap" versions of VB or as a stock part of VBA. You will have to find a way to access a serial port. There are "free" controls that can accomplish this...Google is your friend.
Third - once you have control to access the serial port, communication typically involves a) setting the appropriate parameters on the control (baud rate, parity, stop bits) and then calling a "send", "write" or "tx" method on the control to output your information.
Finally - once you have gotten something to go between your pc and the Stamp, you just need to attach the output method to a button event in Access.
None of the above is particularly difficult...especially if you take it in steps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
Every time you click the button the character "1" (ASCII 49)·will be sent plus a carraige return. Listen for a string of "1" or·a decimal of 49 at the stamp.
This is about all you need to do that:
Private Sub Command1_Click()
With MSComm1
··········· .CommPort = 1
··········· .Handshaking = 0
··········· .RThreshold = 1
··········· .RTSEnable = True
··········· .Settings = "2400,n,8,1"
··········· .SThreshold = 0
··········· .EOFEnable = False
··········· .PortOpen = True
End With
DoEvents
MSComm1.Output = "1" & vbCr
DoEvents
MSComm1.PortOpen = False
End Sub
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 6/20/2007 9:25:48 PM GMT
The only USB issue I know of is sometimes when your user plugs into a differnet USB port the Comm Port changes with it. So I'd suggest using a textbox that your user can change the port number in this fashion
MSComm1.CommPort = me.text1
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR