Shop OBEX P1 Docs P2 Docs Learn Events
Need to combine Basic Stamp and Microsoft Access — Parallax Forums

Need to combine Basic Stamp and Microsoft Access

Karl MatlackKarl Matlack Posts: 5
edited 2007-06-20 21:08 in BASIC Stamp
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

Comments

  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2007-06-16 10:36
    Unless Access can send its data via the serial port, which I'm not sure if·it can - but I doubt it, you will need to write an interface program in Visual Basic or something that can send Access data to the serial port so that the Basic Stamp can read it. From their you can read and write to the serial port with the Access data·using the Basic Stamps PBASIC language.
  • Karl MatlackKarl Matlack Posts: 5
    edited 2007-06-16 10:41
    Access has a visual basic editor that it works with somewhat but I am not totally sure how. When you create a form button it creates a little code in visual basic that tells the button what to do.
  • FranklinFranklin Posts: 4,747
    edited 2007-06-16 15:36
    Check to see if the underlying code for the button can send text out the serial port. If so you could make this work. try www.tek-tips.com they have forums on access and vb.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Karl MatlackKarl Matlack Posts: 5
    edited 2007-06-16 16:04
    The underlaying code is blank I can type anything that will work with visual basic into it. Accually I only have to be able to send a power signal out on the serial port if you can tell me how to do that.

    I am very new to code and very lost.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-06-16 18:26
    The BS2 sits in the Board Of Education (BOE) and communicates with the PC over the serial port. If you haven't GOT a serial port, a USB to Serial adapter can be used, which looks to Access as if it WAS a 'native' serial port.

    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.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2007-06-18 13:32
    You might want to consider using Visual Basic Express Edition, freely available from Microsoft.

    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.
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-06-19 17:17
    The VBA in Access is quite powerful and the forms include a form timer event all you have to do is include mscomm as you would in visual basic.
    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
  • Karl MatlackKarl Matlack Posts: 5
    edited 2007-06-20 19:31
    I am very new at VBA and code and do not know what I am doing at all really. I would like to learn more but so far I have not caught on. What I need to do is have a button on a Access form that I already have created send a "1" over the usb/serial adapter to my basic stamp. What code would I need. Can anyone help please!

    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?
  • Tom WalkerTom Walker Posts: 509
    edited 2007-06-20 20:16
    Karl,
    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...
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-06-20 20:22
    The following example is for 2400 baud/8 bits which makes communication easier between Windows and a stamp. The BS2 code can use debugin to listen for the data.

    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:
    • Add your button call it Command1(default)
    • Add the ActiveX MS Communication Control (Click on More Controls)- call it MSComm1(default)
    • Right Click on the Command1 button and select properties
    • Under the property sheet select events
    • Select Event Procedure for the onclick event
    • Click on the edit button next to·Event Procedure (looks like this [noparse][[/noparse]...])
    • in the VB Editor add the following under the Command1_Click event


    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
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-06-20 21:08
    The USB Issue

    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
Sign In or Register to comment.