Shop OBEX P1 Docs P2 Docs Learn Events
question for constructing a simple GUI using visual basic with stamp — Parallax Forums

question for constructing a simple GUI using visual basic with stamp

ArchiverArchiver Posts: 46,084
edited 2003-07-21 16:07 in General Discussion
I'm currently doing a project which require a simple GUI which can
count the number of item when the basic stamp input the signal .
My idea is let the basic stamp input either 1 or 0 to the computer .
If the computer receive the 1 as one pulse,it will count in the
counter .If it is zero,the computer will not count it in the counter .

But i'm lack of knowledge of input receiving the signal using
computer with visual basic .Someone told me about referring to the
article in nuts & volts about the data exchange using visual basic
and stamp .But when i look through it ,i found that it is too hard
for me to understand and it doesn't need so much for my project .
Since my project only let the computer receive a signal like 1 or 0
while the article show me about the serial in and serial out data
tranfer ,i couldn't understand and modify it to suit my need .

So ,can someone help me about the programming for receiving such
single bit signal from basic stamp to computer ?thanks for your help .

By the way ,when i see the article,it first mention about the flow
control .Is it needed for this case which only a bit of signal is
used for transfer?thanks.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 14:12
    There was a post a couple of days ago which mentioned microGUI, it is a
    great program where you add the different meters or leds or screens that

    your project calls for and the stamp communicates with the program
    through a
    serial interface. You can get the program here:
    www.rhombusinc.com/uGUI.chm

    -Mike

    Original Message
    From: kaijiun83 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=UGxlyplzfIcmALJoJ6pcPLH3urkCYwsLZHLRt7Epsgzni8uUslSXTUhZHAc4b0whj53Kp_RaQFIbmMWOr8U]kaijiun83@y...[/url
    Sent: Tuesday, July 15, 2003 8:28 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] question for constructing a simple GUI using
    visual basic with stamp

    I'm currently doing a project which require a simple GUI which can
    count the number of item when the basic stamp input the signal .
    My idea is let the basic stamp input either 1 or 0 to the computer .
    If the computer receive the 1 as one pulse,it will count in the
    counter .If it is zero,the computer will not count it in the counter .

    But i'm lack of knowledge of input receiving the signal using
    computer with visual basic .Someone told me about referring to the
    article in nuts & volts about the data exchange using visual basic
    and stamp .But when i look through it ,i found that it is too hard
    for me to understand and it doesn't need so much for my project .
    Since my project only let the computer receive a signal like 1 or 0
    while the article show me about the serial in and serial out data
    tranfer ,i couldn't understand and modify it to suit my need .

    So ,can someone help me about the programming for receiving such
    single bit signal from basic stamp to computer ?thanks for your help .

    By the way ,when i see the article,it first mention about the flow
    control .Is it needed for this case which only a bit of signal is
    used for transfer?thanks.




    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 14:29
    Unfortunately, the PC is not very good at
    reading a 'signal'. It was designed to run
    spreadsheets and word processors, drive
    printers, etc.

    The BS2 IS very good at reading 'signals'.
    So what you want is an interface between the
    PC and the BS2 so they can tell each other
    stuff.

    And you have that -- it's the BS2's built-in
    serial port. Since you are building 'a simple
    GUI', I assume you are using Visual Basic on
    the PC side. Since you are using Visual Basic,
    you can easily interface with the BS2's serial
    port.

    So: BS2:
    ' ******** BS2 SIDE **************************
    DataPin VAR IN1
    MyData VAR BYTE

    SerPin CON 16
    SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    ' From BASIC Stamp Prog Man, 2.0c,
    ' Page 297
    MAIN:
    MyData = DataPin ' Read the data state on the pin
    SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    PAUSE 100 ' Wait (in mS) a while for the next reading
    GOTO MAIN ' And loop.

    END
    ' ****** END OF BS2 SIDE ************************

    Now, VB Side:
    Well, that's a little more complicated for a 'complete'
    solution. I'll work on it and download the finished
    product in a few days. For now, you should know:
    1. You need to check Project, Component,
    "Microsoft Comm Control ..". This will put the
    serial port component in your toolkit.

    2. you need to drag one of these to the form.

    3. You need to put a text box on the form, for
    the bytes to be displayed in.

    4. On 'FormLoad', you can open the port.
    MSComm1.DTREnable = FALSE ' Don't reset the BS2
    MSComm1.Port = 1 ' Use COM1: port
    MSComm1.Open = 1 ' Open the port

    5. Make an MSComm1_OnCom event handler.
    MyValue = MSComm1.Input
    textbox.text = MyValue



    --- In basicstamps@yahoogroups.com, "kaijiun83" <kaijiun83@y...>
    wrote:
    > I'm currently doing a project which require a simple GUI which can
    > count the number of item when the basic stamp input the signal .
    > My idea is let the basic stamp input either 1 or 0 to the computer .
    > If the computer receive the 1 as one pulse,it will count in the
    > counter .If it is zero,the computer will not count it in the
    counter .
    >
    > But i'm lack of knowledge of input receiving the signal using
    > computer with visual basic .Someone told me about referring to the
    > article in nuts & volts about the data exchange using visual basic
    > and stamp .But when i look through it ,i found that it is too hard
    > for me to understand and it doesn't need so much for my project .
    > Since my project only let the computer receive a signal like 1 or 0
    > while the article show me about the serial in and serial out data
    > tranfer ,i couldn't understand and modify it to suit my need .
    >
    > So ,can someone help me about the programming for receiving such
    > single bit signal from basic stamp to computer ?thanks for your
    help .
    >
    > By the way ,when i see the article,it first mention about the flow
    > control .Is it needed for this case which only a bit of signal is
    > used for transfer?thanks.
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 15:12
    Doesn't the Microgui use the bs2's serial port also?? What is the
    difference between using the Microgui program and using Qbasic?

    Bill

    Original Message
    From: Allan Lane [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=h7VzYb0RPmEA_9oxrAHogUqKE4OM2TG0usTOLOvxubnHY9MKN5OpFfV4UtmMtjivPoBMwWUyFHIx37MkKZnDjlFGeg]allan.lane@h...[/url
    Sent: Wednesday, July 16, 2003 9:29 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp


    Unfortunately, the PC is not very good at
    reading a 'signal'. It was designed to run
    spreadsheets and word processors, drive
    printers, etc.

    The BS2 IS very good at reading 'signals'.
    So what you want is an interface between the
    PC and the BS2 so they can tell each other
    stuff.

    And you have that -- it's the BS2's built-in
    serial port. Since you are building 'a simple
    GUI', I assume you are using Visual Basic on
    the PC side. Since you are using Visual Basic,
    you can easily interface with the BS2's serial
    port.

    So: BS2:
    ' ******** BS2 SIDE **************************
    DataPin VAR IN1
    MyData VAR BYTE

    SerPin CON 16
    SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    ' From BASIC Stamp Prog Man, 2.0c,
    ' Page 297
    MAIN:
    MyData = DataPin ' Read the data state on the pin
    SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    PAUSE 100 ' Wait (in mS) a while for the next reading
    GOTO MAIN ' And loop.

    END
    ' ****** END OF BS2 SIDE ************************

    Now, VB Side:
    Well, that's a little more complicated for a 'complete'
    solution. I'll work on it and download the finished
    product in a few days. For now, you should know:
    1. You need to check Project, Component,
    "Microsoft Comm Control ..". This will put the
    serial port component in your toolkit.

    2. you need to drag one of these to the form.

    3. You need to put a text box on the form, for
    the bytes to be displayed in.

    4. On 'FormLoad', you can open the port.
    MSComm1.DTREnable = FALSE ' Don't reset the BS2
    MSComm1.Port = 1 ' Use COM1: port
    MSComm1.Open = 1 ' Open the port

    5. Make an MSComm1_OnCom event handler.
    MyValue = MSComm1.Input
    textbox.text = MyValue



    --- In basicstamps@yahoogroups.com, "kaijiun83" <kaijiun83@y...>
    wrote:
    > I'm currently doing a project which require a simple GUI which can
    > count the number of item when the basic stamp input the signal .
    > My idea is let the basic stamp input either 1 or 0 to the computer .
    > If the computer receive the 1 as one pulse,it will count in the
    > counter .If it is zero,the computer will not count it in the
    counter .
    >
    > But i'm lack of knowledge of input receiving the signal using
    > computer with visual basic .Someone told me about referring to the
    > article in nuts & volts about the data exchange using visual basic
    > and stamp .But when i look through it ,i found that it is too hard
    > for me to understand and it doesn't need so much for my project .
    > Since my project only let the computer receive a signal like 1 or 0
    > while the article show me about the serial in and serial out data
    > tranfer ,i couldn't understand and modify it to suit my need .
    >
    > So ,can someone help me about the programming for receiving such
    > single bit signal from basic stamp to computer ?thanks for your
    help .
    >
    > By the way ,when i see the article,it first mention about the flow
    > control .Is it needed for this case which only a bit of signal is
    > used for transfer?thanks.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 16:17
    You don't have to write any VB code that's all. It is way easier to use.

    Original Message
    From: Bill Katakis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=rtfcoIsB-6Ov-egFTUTeD8a0EegyVepvIt1MrR9Afy5tr7jtaSBIQuBOa3TlGXByGSQDB5J5vTkmS0uN]bkatakis@a...[/url
    Sent: Wednesday, July 16, 2003 9:12 AM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI
    using visual basic with stamp

    Doesn't the Microgui use the bs2's serial port also?? What is the
    difference between using the Microgui program and using Qbasic?

    Bill

    Original Message
    From: Allan Lane [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=AeM5l4Iag68lu4k4fZ-Ny3QccOLmmfkXZ4ANAFa5I8IxZC-oZvxJvy8ObDyYW0ybjolbyGcPMiZsvU7BrZ1I_Xw9Hlc9]allan.lane@h...[/url
    Sent: Wednesday, July 16, 2003 9:29 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp


    Unfortunately, the PC is not very good at
    reading a 'signal'. It was designed to run
    spreadsheets and word processors, drive
    printers, etc.

    The BS2 IS very good at reading 'signals'.
    So what you want is an interface between the
    PC and the BS2 so they can tell each other
    stuff.

    And you have that -- it's the BS2's built-in
    serial port. Since you are building 'a simple
    GUI', I assume you are using Visual Basic on
    the PC side. Since you are using Visual Basic,
    you can easily interface with the BS2's serial
    port.

    So: BS2:
    ' ******** BS2 SIDE **************************
    DataPin VAR IN1
    MyData VAR BYTE

    SerPin CON 16
    SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    ' From BASIC Stamp Prog Man, 2.0c,
    ' Page 297
    MAIN:
    MyData = DataPin ' Read the data state on the pin
    SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    PAUSE 100 ' Wait (in mS) a while for the next reading
    GOTO MAIN ' And loop.

    END
    ' ****** END OF BS2 SIDE ************************

    Now, VB Side:
    Well, that's a little more complicated for a 'complete'
    solution. I'll work on it and download the finished
    product in a few days. For now, you should know:
    1. You need to check Project, Component,
    "Microsoft Comm Control ..". This will put the
    serial port component in your toolkit.

    2. you need to drag one of these to the form.

    3. You need to put a text box on the form, for
    the bytes to be displayed in.

    4. On 'FormLoad', you can open the port.
    MSComm1.DTREnable = FALSE ' Don't reset the BS2
    MSComm1.Port = 1 ' Use COM1: port
    MSComm1.Open = 1 ' Open the port

    5. Make an MSComm1_OnCom event handler.
    MyValue = MSComm1.Input
    textbox.text = MyValue



    --- In basicstamps@yahoogroups.com, "kaijiun83" <kaijiun83@y...>
    wrote:
    > I'm currently doing a project which require a simple GUI which can
    > count the number of item when the basic stamp input the signal .
    > My idea is let the basic stamp input either 1 or 0 to the computer .
    > If the computer receive the 1 as one pulse,it will count in the
    > counter .If it is zero,the computer will not count it in the
    counter .
    >
    > But i'm lack of knowledge of input receiving the signal using
    > computer with visual basic .Someone told me about referring to the
    > article in nuts & volts about the data exchange using visual basic
    > and stamp .But when i look through it ,i found that it is too hard
    > for me to understand and it doesn't need so much for my project .
    > Since my project only let the computer receive a signal like 1 or 0
    > while the article show me about the serial in and serial out data
    > tranfer ,i couldn't understand and modify it to suit my need .
    >
    > So ,can someone help me about the programming for receiving such
    > single bit signal from basic stamp to computer ?thanks for your
    help .
    >
    > By the way ,when i see the article,it first mention about the flow
    > control .Is it needed for this case which only a bit of signal is
    > used for transfer?thanks.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/





    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 16:22
    How would the MicroGui program respond to Parallax's PWMpal? How would you
    measure a pwm signal from PWMpal with the microgui? Could that be done via
    the normal connection. I'm looking for a way to verify (with software) that
    pwm is being generated.

    Original Message
    From: Mike Dillon [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=J0BLauDhe78O6pAEcxaTkJ6ZzVw7hrqQ9KDFDoGZlvVaZtLj9y0l_ekXussjIY2li08-EEBNZuS--wgAUqo]laxboy687@e...[/url
    Sent: Wednesday, July 16, 2003 11:18 AM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI
    using visual basic with stamp


    You don't have to write any VB code that's all. It is way easier to use.

    Original Message
    From: Bill Katakis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=R5pAIOucquuDQmM5gMFxZm9bHji7GHbkJtRyd72tVErJw-6vTK4E2d6LhB-vxHw-Xa-AOJhDkbsjwnNd]bkatakis@a...[/url
    Sent: Wednesday, July 16, 2003 9:12 AM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI
    using visual basic with stamp

    Doesn't the Microgui use the bs2's serial port also?? What is the
    difference between using the Microgui program and using Qbasic?

    Bill

    Original Message
    From: Allan Lane [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=8eVqzRlc8G-cI2g1oiEBkK8zskTn06aLXlx7a-BW-g6v1keoASfVeVXYNqu8Sh7a7QKlXzgHHX0wIw1tfy2cFdc8D3DB]allan.lane@h...[/url
    Sent: Wednesday, July 16, 2003 9:29 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp


    Unfortunately, the PC is not very good at
    reading a 'signal'. It was designed to run
    spreadsheets and word processors, drive
    printers, etc.

    The BS2 IS very good at reading 'signals'.
    So what you want is an interface between the
    PC and the BS2 so they can tell each other
    stuff.

    And you have that -- it's the BS2's built-in
    serial port. Since you are building 'a simple
    GUI', I assume you are using Visual Basic on
    the PC side. Since you are using Visual Basic,
    you can easily interface with the BS2's serial
    port.

    So: BS2:
    ' ******** BS2 SIDE **************************
    DataPin VAR IN1
    MyData VAR BYTE

    SerPin CON 16
    SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    ' From BASIC Stamp Prog Man, 2.0c,
    ' Page 297
    MAIN:
    MyData = DataPin ' Read the data state on the pin
    SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    PAUSE 100 ' Wait (in mS) a while for the next reading
    GOTO MAIN ' And loop.

    END
    ' ****** END OF BS2 SIDE ************************

    Now, VB Side:
    Well, that's a little more complicated for a 'complete'
    solution. I'll work on it and download the finished
    product in a few days. For now, you should know:
    1. You need to check Project, Component,
    "Microsoft Comm Control ..". This will put the
    serial port component in your toolkit.

    2. you need to drag one of these to the form.

    3. You need to put a text box on the form, for
    the bytes to be displayed in.

    4. On 'FormLoad', you can open the port.
    MSComm1.DTREnable = FALSE ' Don't reset the BS2
    MSComm1.Port = 1 ' Use COM1: port
    MSComm1.Open = 1 ' Open the port

    5. Make an MSComm1_OnCom event handler.
    MyValue = MSComm1.Input
    textbox.text = MyValue



    --- In basicstamps@yahoogroups.com, "kaijiun83" <kaijiun83@y...>
    wrote:
    > I'm currently doing a project which require a simple GUI which can
    > count the number of item when the basic stamp input the signal .
    > My idea is let the basic stamp input either 1 or 0 to the computer .
    > If the computer receive the 1 as one pulse,it will count in the
    > counter .If it is zero,the computer will not count it in the
    counter .
    >
    > But i'm lack of knowledge of input receiving the signal using
    > computer with visual basic .Someone told me about referring to the
    > article in nuts & volts about the data exchange using visual basic
    > and stamp .But when i look through it ,i found that it is too hard
    > for me to understand and it doesn't need so much for my project .
    > Since my project only let the computer receive a signal like 1 or 0
    > while the article show me about the serial in and serial out data
    > tranfer ,i couldn't understand and modify it to suit my need .
    >
    > So ,can someone help me about the programming for receiving such
    > single bit signal from basic stamp to computer ?thanks for your
    help .
    >
    > By the way ,when i see the article,it first mention about the flow
    > control .Is it needed for this case which only a bit of signal is
    > used for transfer?thanks.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/





    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/





    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 16:40
    I don't know, but David Lawrence is the guy to ask, maybe he'll chip in.


    Original Message
    From: Bill Katakis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ltJiWNZt-CGju36vC4y5qdFsGwEKd9QUKk079raAnpUp0_BqTzySjvLciLUWSBAHMNyPIpXgHFwZXLmi4p8]bkatakis@a...[/url
    Sent: Wednesday, July 16, 2003 10:23 AM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI
    using visual basic with stamp

    How would the MicroGui program respond to Parallax's PWMpal? How would
    you
    measure a pwm signal from PWMpal with the microgui? Could that be done
    via
    the normal connection. I'm looking for a way to verify (with software)
    that
    pwm is being generated.

    Original Message
    From: Mike Dillon [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ie3kUwZnl6j2S3Kw2p7xPryOhoJSt0EB1zy_cyWvCXFItkZOyLJZI2wAyuHU0lSS1Wi4yE4n6Wet8YsVPCBHy3M]laxboy687@e...[/url
    Sent: Wednesday, July 16, 2003 11:18 AM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI
    using visual basic with stamp


    You don't have to write any VB code that's all. It is way easier to use.

    Original Message
    From: Bill Katakis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ltJiWNZt-CGju36vC4y5qdFsGwEKd9QUKk079raAnpUp0_BqTzySjvLciLUWSBAHMNyPIpXgHFwZXLmi4p8]bkatakis@a...[/url
    Sent: Wednesday, July 16, 2003 9:12 AM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI
    using visual basic with stamp

    Doesn't the Microgui use the bs2's serial port also?? What is the
    difference between using the Microgui program and using Qbasic?

    Bill

    Original Message
    From: Allan Lane [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=cHckMXzroHWhIyNj0tyPQrd4EeGrqnNyeLebBTMLZV-Nijzc-5RTdgzbrmUc7yA5_u2enE1QhiDIIu8_tcDiiP9zShCv]allan.lane@h...[/url
    Sent: Wednesday, July 16, 2003 9:29 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp


    Unfortunately, the PC is not very good at
    reading a 'signal'. It was designed to run
    spreadsheets and word processors, drive
    printers, etc.

    The BS2 IS very good at reading 'signals'.
    So what you want is an interface between the
    PC and the BS2 so they can tell each other
    stuff.

    And you have that -- it's the BS2's built-in
    serial port. Since you are building 'a simple
    GUI', I assume you are using Visual Basic on
    the PC side. Since you are using Visual Basic,
    you can easily interface with the BS2's serial
    port.

    So: BS2:
    ' ******** BS2 SIDE **************************
    DataPin VAR IN1
    MyData VAR BYTE

    SerPin CON 16
    SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    ' From BASIC Stamp Prog Man, 2.0c,
    ' Page 297
    MAIN:
    MyData = DataPin ' Read the data state on the pin
    SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    PAUSE 100 ' Wait (in mS) a while for the next reading
    GOTO MAIN ' And loop.

    END
    ' ****** END OF BS2 SIDE ************************

    Now, VB Side:
    Well, that's a little more complicated for a 'complete'
    solution. I'll work on it and download the finished
    product in a few days. For now, you should know:
    1. You need to check Project, Component,
    "Microsoft Comm Control ..". This will put the
    serial port component in your toolkit.

    2. you need to drag one of these to the form.

    3. You need to put a text box on the form, for
    the bytes to be displayed in.

    4. On 'FormLoad', you can open the port.
    MSComm1.DTREnable = FALSE ' Don't reset the BS2
    MSComm1.Port = 1 ' Use COM1: port
    MSComm1.Open = 1 ' Open the port

    5. Make an MSComm1_OnCom event handler.
    MyValue = MSComm1.Input
    textbox.text = MyValue



    --- In basicstamps@yahoogroups.com, "kaijiun83" <kaijiun83@y...>
    wrote:
    > I'm currently doing a project which require a simple GUI which can
    > count the number of item when the basic stamp input the signal .
    > My idea is let the basic stamp input either 1 or 0 to the computer .
    > If the computer receive the 1 as one pulse,it will count in the
    > counter .If it is zero,the computer will not count it in the
    counter .
    >
    > But i'm lack of knowledge of input receiving the signal using
    > computer with visual basic .Someone told me about referring to the
    > article in nuts & volts about the data exchange using visual basic
    > and stamp .But when i look through it ,i found that it is too hard
    > for me to understand and it doesn't need so much for my project .
    > Since my project only let the computer receive a signal like 1 or 0
    > while the article show me about the serial in and serial out data
    > tranfer ,i couldn't understand and modify it to suit my need .
    >
    > So ,can someone help me about the programming for receiving such
    > single bit signal from basic stamp to computer ?thanks for your
    help .
    >
    > By the way ,when i see the article,it first mention about the flow
    > control .Is it needed for this case which only a bit of signal is
    > used for transfer?thanks.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/





    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/





    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/





    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-16 17:15
    OK, in the 'Files' section, I've added:
    \AlDemo\BS2_VBDemo.zip

    This contains both the BS2 side, and a
    very simple VB project, which implements the
    MSComm control, and uses it to get data from
    the BS2 and display it in a scrolling
    text box on the PC.

    I've also included a readme.txt file of
    instructions how to re-create the VB project
    from scratch.

    I hope you can use this as the starting point
    for more elaborate uses of the BS2 with the
    PC.


    --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    wrote:
    > Unfortunately, the PC is not very good at
    > reading a 'signal'. It was designed to run
    > spreadsheets and word processors, drive
    > printers, etc.
    >
    > The BS2 IS very good at reading 'signals'.
    > So what you want is an interface between the
    > PC and the BS2 so they can tell each other
    > stuff.
    >
    > And you have that -- it's the BS2's built-in
    > serial port. Since you are building 'a simple
    > GUI', I assume you are using Visual Basic on
    > the PC side. Since you are using Visual Basic,
    > you can easily interface with the BS2's serial
    > port.
    >
    > So: BS2:
    > ' ******** BS2 SIDE **************************
    > DataPin VAR IN1
    > MyData VAR BYTE
    >
    > SerPin CON 16
    > SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    > ' From BASIC Stamp Prog Man, 2.0c,
    > ' Page 297
    > MAIN:
    > MyData = DataPin ' Read the data state on the pin
    > SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    > PAUSE 100 ' Wait (in mS) a while for the next reading
    > GOTO MAIN ' And loop.
    >
    > END
    > ' ****** END OF BS2 SIDE ************************
    >
    > Now, VB Side:
    > Well, that's a little more complicated for a 'complete'
    > solution. I'll work on it and download the finished
    > product in a few days. For now, you should know:
    > 1. You need to check Project, Component,
    > "Microsoft Comm Control ..". This will put the
    > serial port component in your toolkit.
    >
    > 2. you need to drag one of these to the form.
    >
    > 3. You need to put a text box on the form, for
    > the bytes to be displayed in.
    >
    > 4. On 'FormLoad', you can open the port.
    > MSComm1.DTREnable = FALSE ' Don't reset the BS2
    > MSComm1.Port = 1 ' Use COM1: port
    > MSComm1.Open = 1 ' Open the port
    >
    > 5. Make an MSComm1_OnCom event handler.
    > MyValue = MSComm1.Input
    > textbox.text = MyValue
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "kaijiun83" <kaijiun83@y...>
    > wrote:
    > > I'm currently doing a project which require a simple GUI which
    can
    > > count the number of item when the basic stamp input the signal .
    > > My idea is let the basic stamp input either 1 or 0 to the
    computer .
    > > If the computer receive the 1 as one pulse,it will count in the
    > > counter .If it is zero,the computer will not count it in the
    > counter .
    > >
    > > But i'm lack of knowledge of input receiving the signal using
    > > computer with visual basic .Someone told me about referring to
    the
    > > article in nuts & volts about the data exchange using visual
    basic
    > > and stamp .But when i look through it ,i found that it is too
    hard
    > > for me to understand and it doesn't need so much for my project .
    > > Since my project only let the computer receive a signal like 1 or
    0
    > > while the article show me about the serial in and serial out data
    > > tranfer ,i couldn't understand and modify it to suit my need .
    > >
    > > So ,can someone help me about the programming for receiving such
    > > single bit signal from basic stamp to computer ?thanks for your
    > help .
    > >
    > > By the way ,when i see the article,it first mention about the
    flow
    > > control .Is it needed for this case which only a bit of signal is
    > > used for transfer?thanks.
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 18:32
    Thanks for helping me .At least i know about the code for the pc to receive the
    data from the stamp .The problem i'm facing now is i can't modifying it to
    become a counter .
    Since i think is just purely programming after the transfering data problem had
    solved ,so i ask my lecturer about letting the text.box display a counter
    instead of display all the number .But my lecturer says that textbox shouldn't
    include the variable for display purpose .and he also don't understand about one
    of the line :
    Text1.Text = Text1.Text & MSComm1.Input
    the & use here seems to be wierd for me .when i learning c++ and java ,& for me
    is a logic function .and my lecturer says that it should be the same for VB also
    .
    So ,can you please explain to me what's happen in this textbox?
    and can i declare variable like this ?(using c++ since i'm not sure for vb later
    i'll try to get it to vb):
    int a=0;
    if ( MSComm1.PortOpen)
    a=a + MSComm1.Inputl
    Text1.Text = Text1.Text +a;

    i know that the syntax is wrong .but i hope you can get my little concept for
    this .thanks again .
    Allan Lane <allan.lane@h...> wrote:
    OK, in the 'Files' section, I've added:
    \AlDemo\BS2_VBDemo.zip

    This contains both the BS2 side, and a
    very simple VB project, which implements the
    MSComm control, and uses it to get data from
    the BS2 and display it in a scrolling
    text box on the PC.

    I've also included a readme.txt file of
    instructions how to re-create the VB project
    from scratch.

    I hope you can use this as the starting point
    for more elaborate uses of the BS2 with the
    PC.


    --- In basicstamps@yahoogroups.com, "Allan Lane"
    wrote:
    > Unfortunately, the PC is not very good at
    > reading a 'signal'. It was designed to run
    > spreadsheets and word processors, drive
    > printers, etc.
    >
    > The BS2 IS very good at reading 'signals'.
    > So what you want is an interface between the
    > PC and the BS2 so they can tell each other
    > stuff.
    >
    > And you have that -- it's the BS2's built-in
    > serial port. Since you are building 'a simple
    > GUI', I assume you are using Visual Basic on
    > the PC side. Since you are using Visual Basic,
    > you can easily interface with the BS2's serial
    > port.
    >
    > So: BS2:
    > ' ******** BS2 SIDE **************************
    > DataPin VAR IN1
    > MyData VAR BYTE
    >
    > SerPin CON 16
    > SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    > ' From BASIC Stamp Prog Man, 2.0c,
    > ' Page 297
    > MAIN:
    > MyData = DataPin ' Read the data state on the pin
    > SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    > PAUSE 100 ' Wait (in mS) a while for the next reading
    > GOTO MAIN ' And loop.
    >
    > END
    > ' ****** END OF BS2 SIDE ************************
    >
    > Now, VB Side:
    > Well, that's a little more complicated for a 'complete'
    > solution. I'll work on it and download the finished
    > product in a few days. For now, you should know:
    > 1. You need to check Project, Component,
    > "Microsoft Comm Control ..". This will put the
    > serial port component in your toolkit.
    >
    > 2. you need to drag one of these to the form.
    >
    > 3. You need to put a text box on the form, for
    > the bytes to be displayed in.
    >
    > 4. On 'FormLoad', you can open the port.
    > MSComm1.DTREnable = FALSE ' Don't reset the BS2
    > MSComm1.Port = 1 ' Use COM1: port
    > MSComm1.Open = 1 ' Open the port
    >
    > 5. Make an MSComm1_OnCom event handler.
    > MyValue = MSComm1.Input
    > textbox.text = MyValue
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "kaijiun83"
    > wrote:
    > > I'm currently doing a project which require a simple GUI which
    can
    > > count the number of item when the basic stamp input the signal .
    > > My idea is let the basic stamp input either 1 or 0 to the
    computer .
    > > If the computer receive the 1 as one pulse,it will count in the
    > > counter .If it is zero,the computer will not count it in the
    > counter .
    > >
    > > But i'm lack of knowledge of input receiving the signal using
    > > computer with visual basic .Someone told me about referring to
    the
    > > article in nuts & volts about the data exchange using visual
    basic
    > > and stamp .But when i look through it ,i found that it is too
    hard
    > > for me to understand and it doesn't need so much for my project .
    > > Since my project only let the computer receive a signal like 1 or
    0
    > > while the article show me about the serial in and serial out data
    > > tranfer ,i couldn't understand and modify it to suit my need .
    > >
    > > So ,can someone help me about the programming for receiving such
    > > single bit signal from basic stamp to computer ?thanks for your
    > help .
    > >
    > > By the way ,when i see the article,it first mention about the
    flow
    > > control .Is it needed for this case which only a bit of signal is
    > > used for transfer?thanks.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and Body of
    the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/




    Do you Yahoo!?
    The New Yahoo! Search - Faster. Easier. Bingo.

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 20:42
    With the current code, the BS2 sends a "1" if it's
    currently a "1", and a "0" if currently a "0". So,
    the following should work:

    Dim OneCounter As Long
    Dim ZeroCounter As Long

    Sub UpdateText()
    Dim MyStr As String
    Dim I As Long
    Dim TestChar As String

    If MSComm1.PortOpen Then
    MyStr = MSComm1.Input
    For I = 1 To Len(MyStr)
    TestChar = Mid$(MyStr, I, 1)
    If TestChar = "1" Then
    OneCounter = OneCounter + 1
    End If
    If TestChar <> "1" Then
    ZeroCounter = ZeroCounter + 1
    End If
    Next I
    End If
    Text1.Text = ZeroCounter & vbCrLf & OneCounter
    End Sub

    Put a call to 'UpdateText' in the Timer1.Timer call,
    and enable the timer at about a 500 mSec rate.

    --- In basicstamps@yahoogroups.com, Cheang Kaijiun <kaijiun83@y...>
    wrote:
    > Thanks for helping me .At least i know about the code for the pc to
    receive the data from the stamp .The problem i'm facing now is i
    can't modifying it to become a counter .
    > Since i think is just purely programming after the transfering data
    problem had solved ,so i ask my lecturer about letting the text.box
    display a counter instead of display all the number .But my lecturer
    says that textbox shouldn't include the variable for display
    purpose .and he also don't understand about one of the line :
    > Text1.Text = Text1.Text & MSComm1.Input
    > the & use here seems to be wierd for me .when i learning c++ and
    java ,& for me is a logic function .and my lecturer says that it
    should be the same for VB also .
    > So ,can you please explain to me what's happen in this textbox?
    > and can i declare variable like this ?(using c++ since i'm not sure
    for vb later i'll try to get it to vb):
    > int a=0;
    > if ( MSComm1.PortOpen)
    > a=a + MSComm1.Inputl
    > Text1.Text = Text1.Text +a;
    >
    > i know that the syntax is wrong .but i hope you can get my little
    concept for this .thanks again .
    > Allan Lane <allan.lane@h...> wrote:
    > OK, in the 'Files' section, I've added:
    > \AlDemo\BS2_VBDemo.zip
    >
    > This contains both the BS2 side, and a
    > very simple VB project, which implements the
    > MSComm control, and uses it to get data from
    > the BS2 and display it in a scrolling
    > text box on the PC.
    >
    > I've also included a readme.txt file of
    > instructions how to re-create the VB project
    > from scratch.
    >
    > I hope you can use this as the starting point
    > for more elaborate uses of the BS2 with the
    > PC.
    >
    >
    > --- In basicstamps@yahoogroups.com, "Allan Lane"
    > wrote:
    > > Unfortunately, the PC is not very good at
    > > reading a 'signal'. It was designed to run
    > > spreadsheets and word processors, drive
    > > printers, etc.
    > >
    > > The BS2 IS very good at reading 'signals'.
    > > So what you want is an interface between the
    > > PC and the BS2 so they can tell each other
    > > stuff.
    > >
    > > And you have that -- it's the BS2's built-in
    > > serial port. Since you are building 'a simple
    > > GUI', I assume you are using Visual Basic on
    > > the PC side. Since you are using Visual Basic,
    > > you can easily interface with the BS2's serial
    > > port.
    > >
    > > So: BS2:
    > > ' ******** BS2 SIDE **************************
    > > DataPin VAR IN1
    > > MyData VAR BYTE
    > >
    > > SerPin CON 16
    > > SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    > > ' From BASIC Stamp Prog Man, 2.0c,
    > > ' Page 297
    > > MAIN:
    > > MyData = DataPin ' Read the data state on the pin
    > > SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    > > PAUSE 100 ' Wait (in mS) a while for the next reading
    > > GOTO MAIN ' And loop.
    > >
    > > END
    > > ' ****** END OF BS2 SIDE ************************
    > >
    > > Now, VB Side:
    > > Well, that's a little more complicated for a 'complete'
    > > solution. I'll work on it and download the finished
    > > product in a few days. For now, you should know:
    > > 1. You need to check Project, Component,
    > > "Microsoft Comm Control ..". This will put the
    > > serial port component in your toolkit.
    > >
    > > 2. you need to drag one of these to the form.
    > >
    > > 3. You need to put a text box on the form, for
    > > the bytes to be displayed in.
    > >
    > > 4. On 'FormLoad', you can open the port.
    > > MSComm1.DTREnable = FALSE ' Don't reset the BS2
    > > MSComm1.Port = 1 ' Use COM1: port
    > > MSComm1.Open = 1 ' Open the port
    > >
    > > 5. Make an MSComm1_OnCom event handler.
    > > MyValue = MSComm1.Input
    > > textbox.text = MyValue
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "kaijiun83"
    > > wrote:
    > > > I'm currently doing a project which require a simple GUI which
    > can
    > > > count the number of item when the basic stamp input the signal .
    > > > My idea is let the basic stamp input either 1 or 0 to the
    > computer .
    > > > If the computer receive the 1 as one pulse,it will count in the
    > > > counter .If it is zero,the computer will not count it in the
    > > counter .
    > > >
    > > > But i'm lack of knowledge of input receiving the signal using
    > > > computer with visual basic .Someone told me about referring to
    > the
    > > > article in nuts & volts about the data exchange using visual
    > basic
    > > > and stamp .But when i look through it ,i found that it is too
    > hard
    > > > for me to understand and it doesn't need so much for my
    project .
    > > > Since my project only let the computer receive a signal like 1
    or
    > 0
    > > > while the article show me about the serial in and serial out
    data
    > > > tranfer ,i couldn't understand and modify it to suit my need .
    > > >
    > > > So ,can someone help me about the programming for receiving
    such
    > > > single bit signal from basic stamp to computer ?thanks for your
    > > help .
    > > >
    > > > By the way ,when i see the article,it first mention about the
    > flow
    > > > control .Is it needed for this case which only a bit of signal
    is
    > > > used for transfer?thanks.
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    >
    > Do you Yahoo!?
    > The New Yahoo! Search - Faster. Easier. Bingo.
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 20:44
    Another answer: In VB, the '&' character is
    for string concatenation -- though you can
    use '+' for the same purpose. VB uses
    'AND' for the 'and' function.

    --- In basicstamps@yahoogroups.com, Cheang Kaijiun <kaijiun83@y...>
    wrote:
    > Thanks for helping me .At least i know about the code for the pc to
    receive the data from the stamp .The problem i'm facing now is i
    can't modifying it to become a counter .
    > Since i think is just purely programming after the transfering data
    problem had solved ,so i ask my lecturer about letting the text.box
    display a counter instead of display all the number .But my lecturer
    says that textbox shouldn't include the variable for display
    purpose .and he also don't understand about one of the line :
    > Text1.Text = Text1.Text & MSComm1.Input
    > the & use here seems to be wierd for me .when i learning c++ and
    java ,& for me is a logic function .and my lecturer says that it
    should be the same for VB also .
    > So ,can you please explain to me what's happen in this textbox?
    > and can i declare variable like this ?(using c++ since i'm not sure
    for vb later i'll try to get it to vb):
    > int a=0;
    > if ( MSComm1.PortOpen)
    > a=a + MSComm1.Inputl
    > Text1.Text = Text1.Text +a;
    >
    > i know that the syntax is wrong .but i hope you can get my little
    concept for this .thanks again .
    > Allan Lane <allan.lane@h...> wrote:
    > OK, in the 'Files' section, I've added:
    > \AlDemo\BS2_VBDemo.zip
    >
    > This contains both the BS2 side, and a
    > very simple VB project, which implements the
    > MSComm control, and uses it to get data from
    > the BS2 and display it in a scrolling
    > text box on the PC.
    >
    > I've also included a readme.txt file of
    > instructions how to re-create the VB project
    > from scratch.
    >
    > I hope you can use this as the starting point
    > for more elaborate uses of the BS2 with the
    > PC.
    >
    >
    > --- In basicstamps@yahoogroups.com, "Allan Lane"
    > wrote:
    > > Unfortunately, the PC is not very good at
    > > reading a 'signal'. It was designed to run
    > > spreadsheets and word processors, drive
    > > printers, etc.
    > >
    > > The BS2 IS very good at reading 'signals'.
    > > So what you want is an interface between the
    > > PC and the BS2 so they can tell each other
    > > stuff.
    > >
    > > And you have that -- it's the BS2's built-in
    > > serial port. Since you are building 'a simple
    > > GUI', I assume you are using Visual Basic on
    > > the PC side. Since you are using Visual Basic,
    > > you can easily interface with the BS2's serial
    > > port.
    > >
    > > So: BS2:
    > > ' ******** BS2 SIDE **************************
    > > DataPin VAR IN1
    > > MyData VAR BYTE
    > >
    > > SerPin CON 16
    > > SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    > > ' From BASIC Stamp Prog Man, 2.0c,
    > > ' Page 297
    > > MAIN:
    > > MyData = DataPin ' Read the data state on the pin
    > > SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    > > PAUSE 100 ' Wait (in mS) a while for the next reading
    > > GOTO MAIN ' And loop.
    > >
    > > END
    > > ' ****** END OF BS2 SIDE ************************
    > >
    > > Now, VB Side:
    > > Well, that's a little more complicated for a 'complete'
    > > solution. I'll work on it and download the finished
    > > product in a few days. For now, you should know:
    > > 1. You need to check Project, Component,
    > > "Microsoft Comm Control ..". This will put the
    > > serial port component in your toolkit.
    > >
    > > 2. you need to drag one of these to the form.
    > >
    > > 3. You need to put a text box on the form, for
    > > the bytes to be displayed in.
    > >
    > > 4. On 'FormLoad', you can open the port.
    > > MSComm1.DTREnable = FALSE ' Don't reset the BS2
    > > MSComm1.Port = 1 ' Use COM1: port
    > > MSComm1.Open = 1 ' Open the port
    > >
    > > 5. Make an MSComm1_OnCom event handler.
    > > MyValue = MSComm1.Input
    > > textbox.text = MyValue
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "kaijiun83"
    > > wrote:
    > > > I'm currently doing a project which require a simple GUI which
    > can
    > > > count the number of item when the basic stamp input the signal .
    > > > My idea is let the basic stamp input either 1 or 0 to the
    > computer .
    > > > If the computer receive the 1 as one pulse,it will count in the
    > > > counter .If it is zero,the computer will not count it in the
    > > counter .
    > > >
    > > > But i'm lack of knowledge of input receiving the signal using
    > > > computer with visual basic .Someone told me about referring to
    > the
    > > > article in nuts & volts about the data exchange using visual
    > basic
    > > > and stamp .But when i look through it ,i found that it is too
    > hard
    > > > for me to understand and it doesn't need so much for my
    project .
    > > > Since my project only let the computer receive a signal like 1
    or
    > 0
    > > > while the article show me about the serial in and serial out
    data
    > > > tranfer ,i couldn't understand and modify it to suit my need .
    > > >
    > > > So ,can someone help me about the programming for receiving
    such
    > > > single bit signal from basic stamp to computer ?thanks for your
    > > help .
    > > >
    > > > By the way ,when i see the article,it first mention about the
    > flow
    > > > control .Is it needed for this case which only a bit of signal
    is
    > > > used for transfer?thanks.
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    >
    > Do you Yahoo!?
    > The New Yahoo! Search - Faster. Easier. Bingo.
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 20:56
    Hi Bill:

    If I understand properly, I would think that all you really need is a CR
    filter to look at the PWM, and read it from the Stamp using its A/D
    statement.

    Optionally you could output that value to microGUI on the PC and Plot it
    along with some other events that may be of interest - see Starter5 project.

    www.rhombusinc.com/microgui.html

    or look at the gifs here for something similar:

    www.rhombusinc.com/ZIPs/Kaijun.zip

    David Lawrence


    Original Message
    From: Mike Dillon <laxboy687@e...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, July 16, 2003 8:40 AM
    Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp


    > I don't know, but David Lawrence is the guy to ask, maybe he'll chip in.
    >
    >
    >
    Original Message
    > From: Bill Katakis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=L-eu2TeJT2FEEcHgCBNIgbOPvNFRSbx-ty96U_4pvnZTWJ8TfLONRMh6l727Dt1ag9BvFDQ__WJanZk]bkatakis@a...[/url
    > Sent: Wednesday, July 16, 2003 10:23 AM
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 20:58
    What Mike says is so true - here is the total code for BS2 and the PC:

    WaitLp:
    '---- Check Pulse
    INLo = INL
    IF INLo.Bit0 = OldPulse THEN WaitLp 'Detect an Edge
    OldPulse = INLo.Bit0 'Record it
    IF OldPulse = 0 THEN WaitLp 'Limit to +ve edges
    Cnt = Cnt + 1 'Else Count

    '---- This is the PC Code
    SEROUT 16,84, [noparse][[/noparse]CmdNumW,CntLo,CntHi] 'And Display
    SERIN 16,84, [noparse][[/noparse]Tmp]

    The above displays the Count on a 5 Digit Numeric display.
    All I had to do at the PC was:
    - New Project
    - Setup
    - Select '1' Numeric Display (Word size)
    - Apply, then Close (Setup screen)
    - Save Project as 'Kaijun.prj'
    DONE !

    It would function totally, completely right there, but I 'chose' to make it
    more appealing to me.
    I did a Right-Click on the Meter Frame to reach the properties, and then:
    - Color Blue for the digits
    - Comma Separator to break up such a long count
    - Right side (of separator) digit count to 3 (for thousands)
    - Labelled the Display 'Kaijun's Count'

    I also re-positioned and reduced the Panel size before saving.

    A small ZIP here has the .Bs2, and .prj (but you need microGUI demo below)
    plus a GIF of what it looks like.

    I then went a step further and added this Bs2 code

    '---- Plot Count
    SEROUT 16,84, [noparse][[/noparse]CmdPlot,CntLo,CntHi]
    SERIN 16,84, [noparse][[/noparse]Tmp]

    to plot the Count as 2 separate Analog Channels. The MS byte is very flat
    and allows good visual judgement of total, whereas the fast slope of the LS
    Channel visually highlights any deviations in rate.

    I could also have added a few digital Channels as in Starter5.prj, to
    identify events in sync with rate changes.

    At the PC I had to hit the Scope Button to make it visible. (There may be a
    need here for a small mod, so that the Scope can optionally be Locked down,
    rather than Debug style floating).

    That GIF is also included in the ZIP - total ZIP is

    (Note, to run without a Pulse input I commented out the 4 lines of BS2 code
    immediately after WaitLp).

    www.rhombusinc.com/ZIPs/Kaijun.zip

    Demo is here - 2.7Megs (including 20+ Ready-to-Run Projects, both .Bs2s and
    .Prjs)

    www.rhombusinc.com/microgui.html

    David Lawrence


    Original Message
    From: Mike Dillon <laxboy687@e...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, July 16, 2003 8:17 AM
    Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp


    > You don't have to write any VB code that's all. It is way easier to use.
    >
    >
    Original Message
    > From: Bill Katakis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=pcUy1ahFPi1HQz-j0cFB_hL_cJ4ffR8-BfUYEyBzRAQpKNuy8MCQ804vi-83ut2fe2p0JiGKohQvbUsQug4]bkatakis@a...[/url
    > Sent: Wednesday, July 16, 2003 9:12 AM
    > To: basicstamps@yahoogroups.com
    > Subject: RE: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI
    > using visual basic with stamp
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 22:33
    If you are looking for a fast & easy solution you may have missed my post
    earlier - or perhaps it is something to do with College and you must create
    your own code - if so, at least see how it would have looked:

    www.rhombusinc.com/ZIPs/Kaijun.zip

    www.rhombusinc.com/microgui.html

    David Lawrence
    Rhombus

    Original Message
    From: Cheang Kaijiun <kaijiun83@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, July 17, 2003 10:32 AM
    Subject: Re: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-18 02:19
    Actually i wanted to see it .But i don't know why i can't access the website you
    give when i copy and paste it to browse it .
    Instead of that ,it goes to other page where tell me that this domain is not
    registered .
    i would like to check it out since i want to know both VB and micro GUI .can you
    check what's the problem behind it?

    David Lawrence <david@r...> wrote:
    If you are looking for a fast & easy solution you may have missed my post
    earlier - or perhaps it is something to do with College and you must create
    your own code - if so, at least see how it would have looked:

    www.rhombusinc.com/ZIPs/Kaijun.zip

    www.rhombusinc.com/microgui.html

    David Lawrence
    Rhombus

    Original Message
    From: Cheang Kaijiun
    To:
    Sent: Thursday, July 17, 2003 10:32 AM
    Subject: Re: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp





    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and Body of
    the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/




    Do you Yahoo!?
    The New Yahoo! Search - Faster. Easier. Bingo.

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-18 06:58
    I am not sure why - just downloaded it myself, unzipped and looked at Gifs
    in PSP, and all OK.

    Anyway I have now put it in the Stamp Files section - just saw notification
    so it has arrived and should work out for you this time.

    David Lawrence
    Rhombus

    Original Message
    From: Cheang Kaijiun <kaijiun83@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, July 17, 2003 6:19 PM
    Subject: Re: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI using
    visual basic with stamp


    > Actually i wanted to see it .But i don't know why i can't access the
    website you give when i copy and paste it to browse it .
    > Instead of that ,it goes to other page where tell me that this domain is
    not registered .
    > i would like to check it out since i want to know both VB and micro GUI
    .can you check what's the problem behind it?
    >
    > David Lawrence <david@r...> wrote:
    > If you are looking for a fast & easy solution you may have missed my post
    > earlier - or perhaps it is something to do with College and you must
    create
    > your own code - if so, at least see how it would have looked:
    >
    > www.rhombusinc.com/ZIPs/Kaijun.zip
    >
    > www.rhombusinc.com/microgui.html
    >
    > David Lawrence
    > Rhombus
    >
    >
    Original Message
    > From: Cheang Kaijiun
    > To:
    > Sent: Thursday, July 17, 2003 10:32 AM
    > Subject: Re: [noparse][[/noparse]basicstamps] Re: question for constructing a simple GUI
    using
    > visual basic with stamp
    >
    >
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    >
    > Do you Yahoo!?
    > The New Yahoo! Search - Faster. Easier. Bingo.
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-21 11:15
    hi,unfortunately,after testing the code ,i still can't get it .i feel that i
    should put them correctly but the output turns out to be nothing or remain the
    same.I put the source code at here .I'm really out of idea to let it become
    counter .tested almost 2-3days for this program..........i give up on it .So
    ,please help me .thanks
    I don't want to use the microGUI because i know my examiner will deduct my mark
    by saying that it is copy and not my work .it is kind of unlucky to have that
    kind of lecturer .So,please help me to correct this source code .thanks for
    everything .


    Private Sub Command1_Click()
    Dim MyObj As Object
    Set MyObj = Command1
    If MSComm1.PortOpen Then
    MyObj.Caption = "Open"
    MSComm1.PortOpen = False
    Else
    MyObj.Caption = "Close"
    MSComm1.PortOpen = True
    Text1.Text = Text1.Text & vbCrLf
    End If

    End Sub
    Private Sub Command2_Click()
    End ' Exit the Program
    End Sub
    Private Sub Form_Load()
    Dim MyVal As Long
    MSComm1.DTREnable = False
    MSComm1.Settings = "9600,n,8,1" ' 9600 baud, No Parity, 8 databits
    MSComm1.CommPort = 2
    MSComm1.RThreshold = 1 ' 0 (default) == NEVER kick off OnComm RX event
    MSComm1.PortOpen = True ' Opens port
    Command1.Caption = "Close"
    Command2.Caption = "Quit"

    End Sub
    Private Sub MSComm1_OnComm()
    ' To use 'OnComm', MUST set the MSComm1.RThreshold
    Text1.Text = Text1.Text & MSComm1.Input
    End Sub
    Private Sub Timer1_Timer()
    If MSComm1.PortOpen Then
    Call UpdateText
    End If
    End Sub
    Sub UpdateText()
    Dim MyStr As String
    Dim I As Long
    Dim TestChar As String

    If MSComm1.PortOpen Then
    MyStr = MSComm1.Input
    For I = 1 To Len(MyStr)
    TestChar = Mid$(MyStr, I, 1)
    If TestChar = "1" Then
    OneCounter = OneCounter + 1
    End If
    If TestChar <> "1" Then
    ZeroCounter = ZeroCounter + 1
    End If
    Next I
    End If
    Text1.Text = vbCrLf & OneCounter
    End Sub

    Allan Lane <allan.lane@h...> wrote:
    With the current code, the BS2 sends a "1" if it's
    currently a "1", and a "0" if currently a "0". So,
    the following should work:

    Dim OneCounter As Long
    Dim ZeroCounter As Long

    Sub UpdateText()
    Dim MyStr As String
    Dim I As Long
    Dim TestChar As String

    If MSComm1.PortOpen Then
    MyStr = MSComm1.Input
    For I = 1 To Len(MyStr)
    TestChar = Mid$(MyStr, I, 1)
    If TestChar = "1" Then
    OneCounter = OneCounter + 1
    End If
    If TestChar <> "1" Then
    ZeroCounter = ZeroCounter + 1
    End If
    Next I
    End If
    Text1.Text = ZeroCounter & vbCrLf & OneCounter
    End Sub

    Put a call to 'UpdateText' in the Timer1.Timer call,
    and enable the timer at about a 500 mSec rate.

    --- In basicstamps@yahoogroups.com, Cheang Kaijiun
    wrote:
    > Thanks for helping me .At least i know about the code for the pc to
    receive the data from the stamp .The problem i'm facing now is i
    can't modifying it to become a counter .
    > Since i think is just purely programming after the transfering data
    problem had solved ,so i ask my lecturer about letting the text.box
    display a counter instead of display all the number .But my lecturer
    says that textbox shouldn't include the variable for display
    purpose .and he also don't understand about one of the line :
    > Text1.Text = Text1.Text & MSComm1.Input
    > the & use here seems to be wierd for me .when i learning c++ and
    java ,& for me is a logic function .and my lecturer says that it
    should be the same for VB also .
    > So ,can you please explain to me what's happen in this textbox?
    > and can i declare variable like this ?(using c++ since i'm not sure
    for vb later i'll try to get it to vb):
    > int a=0;
    > if ( MSComm1.PortOpen)
    > a=a + MSComm1.Inputl
    > Text1.Text = Text1.Text +a;
    >
    > i know that the syntax is wrong .but i hope you can get my little
    concept for this .thanks again .
    > Allan Lane wrote:
    > OK, in the 'Files' section, I've added:
    > \AlDemo\BS2_VBDemo.zip
    >
    > This contains both the BS2 side, and a
    > very simple VB project, which implements the
    > MSComm control, and uses it to get data from
    > the BS2 and display it in a scrolling
    > text box on the PC.
    >
    > I've also included a readme.txt file of
    > instructions how to re-create the VB project
    > from scratch.
    >
    > I hope you can use this as the starting point
    > for more elaborate uses of the BS2 with the
    > PC.
    >
    >
    > --- In basicstamps@yahoogroups.com, "Allan Lane"
    > wrote:
    > > Unfortunately, the PC is not very good at
    > > reading a 'signal'. It was designed to run
    > > spreadsheets and word processors, drive
    > > printers, etc.
    > >
    > > The BS2 IS very good at reading 'signals'.
    > > So what you want is an interface between the
    > > PC and the BS2 so they can tell each other
    > > stuff.
    > >
    > > And you have that -- it's the BS2's built-in
    > > serial port. Since you are building 'a simple
    > > GUI', I assume you are using Visual Basic on
    > > the PC side. Since you are using Visual Basic,
    > > you can easily interface with the BS2's serial
    > > port.
    > >
    > > So: BS2:
    > > ' ******** BS2 SIDE **************************
    > > DataPin VAR IN1
    > > MyData VAR BYTE
    > >
    > > SerPin CON 16
    > > SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    > > ' From BASIC Stamp Prog Man, 2.0c,
    > > ' Page 297
    > > MAIN:
    > > MyData = DataPin ' Read the data state on the pin
    > > SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    > > PAUSE 100 ' Wait (in mS) a while for the next reading
    > > GOTO MAIN ' And loop.
    > >
    > > END
    > > ' ****** END OF BS2 SIDE ************************
    > >
    > > Now, VB Side:
    > > Well, that's a little more complicated for a 'complete'
    > > solution. I'll work on it and download the finished
    > > product in a few days. For now, you should know:
    > > 1. You need to check Project, Component,
    > > "Microsoft Comm Control ..". This will put the
    > > serial port component in your toolkit.
    > >
    > > 2. you need to drag one of these to the form.
    > >
    > > 3. You need to put a text box on the form, for
    > > the bytes to be displayed in.
    > >
    > > 4. On 'FormLoad', you can open the port.
    > > MSComm1.DTREnable = FALSE ' Don't reset the BS2
    > > MSComm1.Port = 1 ' Use COM1: port
    > > MSComm1.Open = 1 ' Open the port
    > >
    > > 5. Make an MSComm1_OnCom event handler.
    > > MyValue = MSComm1.Input
    > > textbox.text = MyValue
    > >
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "kaijiun83"
    > > wrote:
    > > > I'm currently doing a project which require a simple GUI which
    > can
    > > > count the number of item when the basic stamp input the signal .
    > > > My idea is let the basic stamp input either 1 or 0 to the
    > computer .
    > > > If the computer receive the 1 as one pulse,it will count in the
    > > > counter .If it is zero,the computer will not count it in the
    > > counter .
    > > >
    > > > But i'm lack of knowledge of input receiving the signal using
    > > > computer with visual basic .Someone told me about referring to
    > the
    > > > article in nuts & volts about the data exchange using visual
    > basic
    > > > and stamp .But when i look through it ,i found that it is too
    > hard
    > > > for me to understand and it doesn't need so much for my
    project .
    > > > Since my project only let the computer receive a signal like 1
    or
    > 0
    > > > while the article show me about the serial in and serial out
    data
    > > > tranfer ,i couldn't understand and modify it to suit my need .
    > > >
    > > > So ,can someone help me about the programming for receiving
    such
    > > > single bit signal from basic stamp to computer ?thanks for your
    > > help .
    > > >
    > > > By the way ,when i see the article,it first mention about the
    > flow
    > > > control .Is it needed for this case which only a bit of signal
    is
    > > > used for transfer?thanks.
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    >
    > Do you Yahoo!?
    > The New Yahoo! Search - Faster. Easier. Bingo.
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and Body of
    the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/




    Do you Yahoo!?
    The New Yahoo! Search - Faster. Easier. Bingo.

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-21 15:28
    At the PC you are looking for ASCII "0" and "1" (Dec 48 & 49 or $30 & $31)

    The BS2 code you were given does not generate "0" and "1"

    David Lawrence
    www.rhombus-tek.com/microgui.html


    hi,unfortunately,after testing the code ,i still can't get it .i feel that
    i should put them correctly but the output turns out to be nothing or
    remain the same.I put the source code at here .I'm really out of idea to
    let it become counter .tested almost 2-3days for this program..........i
    give up on it .So ,please help me .thanks

    > > > So: BS2:
    > > > ' ******** BS2 SIDE **************************
    > > > DataPin VAR IN1
    > > > MyData VAR BYTE
    > > >
    > > > SerPin CON 16
    > > > SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    > > > ' From BASIC Stamp Prog Man, 2.0c,
    > > > ' Page 297
    > > > MAIN:
    > > > MyData = DataPin ' Read the data state on the pin
    > > > SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    > > > PAUSE 100 ' Wait (in mS) a while for the next reading
    > > > GOTO MAIN ' And loop.
    > > >
    > > > END
    > > > ' ****** END OF BS2 SIDE ************************
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-21 16:04
    The origiginal code (which you included in
    your post) uses the '_OnComm' event to
    transfer the data to the Text Box.

    Instead, you should use a 'Timer'.
    Call the 'UpdateText()' routine from
    the 'Timer' routine.

    --- In basicstamps@yahoogroups.com, Cheang Kaijiun <kaijiun83@y...>
    wrote:
    > hi,unfortunately,after testing the code ,i still can't get it .i
    feel that i should put them correctly but the output turns out to be
    nothing or remain the same.I put the source code at here .I'm really
    out of idea to let it become counter .tested almost 2-3days for this
    program..........i give up on it .So ,please help me .thanks
    > I don't want to use the microGUI because i know my examiner will
    deduct my mark by saying that it is copy and not my work .it is kind
    of unlucky to have that kind of lecturer .So,please help me to
    correct this source code .thanks for everything .
    >
    >
    > Private Sub Command1_Click()
    > Dim MyObj As Object
    > Set MyObj = Command1
    > If MSComm1.PortOpen Then
    > MyObj.Caption = "Open"
    > MSComm1.PortOpen = False
    > Else
    > MyObj.Caption = "Close"
    > MSComm1.PortOpen = True
    > Text1.Text = Text1.Text & vbCrLf
    > End If
    >
    > End Sub
    > Private Sub Command2_Click()
    > End ' Exit the Program
    > End Sub
    > Private Sub Form_Load()
    > Dim MyVal As Long
    > MSComm1.DTREnable = False
    > MSComm1.Settings = "9600,n,8,1" ' 9600 baud, No Parity, 8
    databits
    > MSComm1.CommPort = 2
    > MSComm1.RThreshold = 1 ' 0 (default) == NEVER kick off OnComm
    RX event
    > MSComm1.PortOpen = True ' Opens port
    > Command1.Caption = "Close"
    > Command2.Caption = "Quit"
    >
    > End Sub
    > Private Sub MSComm1_OnComm()
    > ' To use 'OnComm', MUST set the MSComm1.RThreshold
    > Text1.Text = Text1.Text & MSComm1.Input
    > End Sub
    > Private Sub Timer1_Timer()
    > If MSComm1.PortOpen Then
    > Call UpdateText
    > End If
    > End Sub
    > Sub UpdateText()
    > Dim MyStr As String
    > Dim I As Long
    > Dim TestChar As String
    >
    > If MSComm1.PortOpen Then
    > MyStr = MSComm1.Input
    > For I = 1 To Len(MyStr)
    > TestChar = Mid$(MyStr, I, 1)
    > If TestChar = "1" Then
    > OneCounter = OneCounter + 1
    > End If
    > If TestChar <> "1" Then
    > ZeroCounter = ZeroCounter + 1
    > End If
    > Next I
    > End If
    > Text1.Text = vbCrLf & OneCounter
    > End Sub
    >
    > Allan Lane <allan.lane@h...> wrote:
    > With the current code, the BS2 sends a "1" if it's
    > currently a "1", and a "0" if currently a "0". So,
    > the following should work:
    >
    > Dim OneCounter As Long
    > Dim ZeroCounter As Long
    >
    > Sub UpdateText()
    > Dim MyStr As String
    > Dim I As Long
    > Dim TestChar As String
    >
    > If MSComm1.PortOpen Then
    > MyStr = MSComm1.Input
    > For I = 1 To Len(MyStr)
    > TestChar = Mid$(MyStr, I, 1)
    > If TestChar = "1" Then
    > OneCounter = OneCounter + 1
    > End If
    > If TestChar <> "1" Then
    > ZeroCounter = ZeroCounter + 1
    > End If
    > Next I
    > End If
    > Text1.Text = ZeroCounter & vbCrLf & OneCounter
    > End Sub
    >
    > Put a call to 'UpdateText' in the Timer1.Timer call,
    > and enable the timer at about a 500 mSec rate.
    >
    > --- In basicstamps@yahoogroups.com, Cheang Kaijiun
    > wrote:
    > > Thanks for helping me .At least i know about the code for the pc
    to
    > receive the data from the stamp .The problem i'm facing now is i
    > can't modifying it to become a counter .
    > > Since i think is just purely programming after the transfering
    data
    > problem had solved ,so i ask my lecturer about letting the text.box
    > display a counter instead of display all the number .But my
    lecturer
    > says that textbox shouldn't include the variable for display
    > purpose .and he also don't understand about one of the line :
    > > Text1.Text = Text1.Text & MSComm1.Input
    > > the & use here seems to be wierd for me .when i learning c++ and
    > java ,& for me is a logic function .and my lecturer says that it
    > should be the same for VB also .
    > > So ,can you please explain to me what's happen in this textbox?
    > > and can i declare variable like this ?(using c++ since i'm not
    sure
    > for vb later i'll try to get it to vb):
    > > int a=0;
    > > if ( MSComm1.PortOpen)
    > > a=a + MSComm1.Inputl
    > > Text1.Text = Text1.Text +a;
    > >
    > > i know that the syntax is wrong .but i hope you can get my little
    > concept for this .thanks again .
    > > Allan Lane wrote:
    > > OK, in the 'Files' section, I've added:
    > > \AlDemo\BS2_VBDemo.zip
    > >
    > > This contains both the BS2 side, and a
    > > very simple VB project, which implements the
    > > MSComm control, and uses it to get data from
    > > the BS2 and display it in a scrolling
    > > text box on the PC.
    > >
    > > I've also included a readme.txt file of
    > > instructions how to re-create the VB project
    > > from scratch.
    > >
    > > I hope you can use this as the starting point
    > > for more elaborate uses of the BS2 with the
    > > PC.
    > >
    > >
    > > --- In basicstamps@yahoogroups.com, "Allan Lane"
    > > wrote:
    > > > Unfortunately, the PC is not very good at
    > > > reading a 'signal'. It was designed to run
    > > > spreadsheets and word processors, drive
    > > > printers, etc.
    > > >
    > > > The BS2 IS very good at reading 'signals'.
    > > > So what you want is an interface between the
    > > > PC and the BS2 so they can tell each other
    > > > stuff.
    > > >
    > > > And you have that -- it's the BS2's built-in
    > > > serial port. Since you are building 'a simple
    > > > GUI', I assume you are using Visual Basic on
    > > > the PC side. Since you are using Visual Basic,
    > > > you can easily interface with the BS2's serial
    > > > port.
    > > >
    > > > So: BS2:
    > > > ' ******** BS2 SIDE **************************
    > > > DataPin VAR IN1
    > > > MyData VAR BYTE
    > > >
    > > > SerPin CON 16
    > > > SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    > > > ' From BASIC Stamp Prog Man, 2.0c,
    > > > ' Page 297
    > > > MAIN:
    > > > MyData = DataPin ' Read the data state on the pin
    > > > SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    > > > PAUSE 100 ' Wait (in mS) a while for the next reading
    > > > GOTO MAIN ' And loop.
    > > >
    > > > END
    > > > ' ****** END OF BS2 SIDE ************************
    > > >
    > > > Now, VB Side:
    > > > Well, that's a little more complicated for a 'complete'
    > > > solution. I'll work on it and download the finished
    > > > product in a few days. For now, you should know:
    > > > 1. You need to check Project, Component,
    > > > "Microsoft Comm Control ..". This will put the
    > > > serial port component in your toolkit.
    > > >
    > > > 2. you need to drag one of these to the form.
    > > >
    > > > 3. You need to put a text box on the form, for
    > > > the bytes to be displayed in.
    > > >
    > > > 4. On 'FormLoad', you can open the port.
    > > > MSComm1.DTREnable = FALSE ' Don't reset the BS2
    > > > MSComm1.Port = 1 ' Use COM1: port
    > > > MSComm1.Open = 1 ' Open the port
    > > >
    > > > 5. Make an MSComm1_OnCom event handler.
    > > > MyValue = MSComm1.Input
    > > > textbox.text = MyValue
    > > >
    > > >
    > > >
    > > > --- In basicstamps@yahoogroups.com, "kaijiun83"
    > > > wrote:
    > > > > I'm currently doing a project which require a simple GUI
    which
    > > can
    > > > > count the number of item when the basic stamp input the
    signal .
    > > > > My idea is let the basic stamp input either 1 or 0 to the
    > > computer .
    > > > > If the computer receive the 1 as one pulse,it will count in
    the
    > > > > counter .If it is zero,the computer will not count it in the
    > > > counter .
    > > > >
    > > > > But i'm lack of knowledge of input receiving the signal using
    > > > > computer with visual basic .Someone told me about referring
    to
    > > the
    > > > > article in nuts & volts about the data exchange using visual
    > > basic
    > > > > and stamp .But when i look through it ,i found that it is too
    > > hard
    > > > > for me to understand and it doesn't need so much for my
    > project .
    > > > > Since my project only let the computer receive a signal like
    1
    > or
    > > 0
    > > > > while the article show me about the serial in and serial out
    > data
    > > > > tranfer ,i couldn't understand and modify it to suit my need .
    > > > >
    > > > > So ,can someone help me about the programming for receiving
    > such
    > > > > single bit signal from basic stamp to computer ?thanks for
    your
    > > > help .
    > > > >
    > > > > By the way ,when i see the article,it first mention about the
    > > flow
    > > > > control .Is it needed for this case which only a bit of
    signal
    > is
    > > > > used for transfer?thanks.
    > >
    > >
    > > To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > > from the same email address that you subscribed. Text in the
    > Subject and Body of the message will be ignored.
    > >
    > >
    > > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    > >
    > >
    > >
    > >
    > >
    > > Do you Yahoo!?
    > > The New Yahoo! Search - Faster. Easier. Bingo.
    > >
    > > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    >
    > Do you Yahoo!?
    > The New Yahoo! Search - Faster. Easier. Bingo.
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-21 16:07
    Yes, the line
    SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    SHOULD BE:
    SEROUT SerPin, SerBaud, [noparse][[/noparse]DEC MyData] ' Send to PC
    ' The 'DEC' modifier sends out the decimal
    ' equivalent. Without it, you get CHR(0) or
    ' CHR(1). With it, you get "0" or "1".
    ' (in other words, the STRING "0")
    ' The VB side expects the STRING "0".

    > > > >
    > > > >

    --- In basicstamps@yahoogroups.com, "David Lawrence" <david@r...>
    wrote:
    > At the PC you are looking for ASCII "0" and "1" (Dec 48 & 49 or $30
    & $31)
    >
    > The BS2 code you were given does not generate "0" and "1"
    >
    > David Lawrence
    > www.rhombus-tek.com/microgui.html
    >
    >
    > hi,unfortunately,after testing the code ,i still can't get it .i
    feel that
    > i should put them correctly but the output turns out to be nothing
    or
    > remain the same.I put the source code at here .I'm really out of
    idea to
    > let it become counter .tested almost 2-3days for this
    program..........i
    > give up on it .So ,please help me .thanks
    >
    > > > > So: BS2:
    > > > > ' ******** BS2 SIDE **************************
    > > > > DataPin VAR IN1
    > > > > MyData VAR BYTE
    > > > >
    > > > > SerPin CON 16
    > > > > SerBaud CON 84 + 16384 ' 9600 baud, 'inverted'
    > > > > ' From BASIC Stamp Prog Man, 2.0c,
    > > > > ' Page 297
    > > > > MAIN:
    > > > > MyData = DataPin ' Read the data state on the pin
    > > > > SEROUT SerPin, SerBaud, [noparse][[/noparse]MyData] ' Send to PC
    > > > > PAUSE 100 ' Wait (in mS) a while for the next reading
    > > > > GOTO MAIN ' And loop.
    > > > >
    > > > > END
    > > > > ' ****** END OF BS2 SIDE ************************
Sign In or Register to comment.