Shop OBEX P1 Docs P2 Docs Learn Events
using macros in the DEBUG window? — Parallax Forums

using macros in the DEBUG window?

terahertzterahertz Posts: 55
edited 2006-10-16 02:36 in BASIC Stamp
I've searched around a bit and I can't find any useful information on how to use macros, maybe someone can help? I'm not even sure I need macros for what I'm trying to do, but I'd still like to know how to use them.

I'm controlling a motor's speed using DEBUGIN from a keyboard. Currently·I have 1-4 = reverse speeds, 5=stop, and 6-9 = forward speeds, everything works well this way.

What I want it to do is for instance I would press·the 1 key·and the motor starts, the longer I hold down the 1 key, the faster the motor goes, when I let the 1 key go the motor ramps back down to stopped. I know there are many ways to control motor speed using pots and such but I need to do it via a keyboard.

The reason I think I need macros is because I've been trying some sample code and it works but I need to press ENTER over and over again while in the DEBUG window. Can macros in effect press the ENTER key over and over again for me at like 500mS intervals? Do I even need macros to do this?

·

Comments

  • Paul Sr.Paul Sr. Posts: 435
    edited 2006-10-15 14:54
    terahertz said...
    I've searched around a bit and I can't find any useful information on how to use macros, maybe someone can help? I'm not even sure I need macros for what I'm trying to do, but I'd still like to know how to use them.


    I'm controlling a motor's speed using DEBUGIN from a keyboard. Currently I have 1-4 = reverse speeds, 5=stop, and 6-9 = forward speeds, everything works well this way.



    What I want it to do is for instance I would press the 1 key and the motor starts, the longer I hold down the 1 key, the faster the motor goes, when I let the 1 key go the motor ramps back down to stopped. I know there are many ways to control motor speed using pots and such but I need to do it via a keyboard.



    The reason I think I need macros is because I've been trying some sample code and it works but I need to press ENTER over and over again while in the DEBUG window. Can macros in effect press the ENTER key over and over again for me at like 500mS intervals? Do I even need macros to do this?

    I believe if you have to keep pressing ENTER, then there must be code that is waiting for it. If you simply use something like "DEBUGIN char" in a loop, ANY key pressed will resume the program.

    As far as the decrementing when the key is released, you might want to look at using a "SERIN 16, baud, timeout, no_data, char" type statement instead of DEBUGIN - check it out in PBasic Help.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-10-15 18:36
    The issue here with macros is that the Basic Stamp IDE isn't scriptable. In other words, macros are program scripts that run within a particular environment. Since the Basic Stamp IDE isn't scriptable, it has no way to run a macro.

    If, however, by pressing the enter key manually you almost able to do what you need, you should be able to create a program that allows you to do what you want. You would need to use something like Visual Basic, or a similar programming language/environment. Basically the program would need to create the serial connection, read the keyboard, and send the info over the connection.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-10-15 18:45
    Kevin -

    Just a small correction. The PBASIC IDE DOES support a somewhat limited macro language, but it's not at execution time, it's at compile time. See any of the excellent compile time macros written by Jon Williams, by way of example. If you need a link, just ask.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • terahertzterahertz Posts: 55
    edited 2006-10-15 19:17
    Thanks for the responses, I'm going to try this afternoon what Paul Sr. recommended. I'd rather keep the programming as simple as possible using PBASIC, if I need to I'll download the free version of VB from MS.· I'm a hardware guy, I enjoy hardware, I only learn software when I HAVE to. mad.gif

    Hmmm, wait a minute maybe I won't need to·download VB, I have this software suite I got somewhere devil.gif . It has these CD's: Visual C++.net disks 1 and 2, VisualStudio.net prerequisites,·MSDN library disks1 2 and 3, and windows 2000 SP4. Anything I can use there, or would I be better of with the free begginers version? the only reason I have this software is from something I needed C++ for.

    Bruce would you mind shooting me that link? I assumed macros must have some functionality with the BS2 since I can access the utility from a debug window. If it's just for compilation scripts I don't think I will have any use for it but who knows,·I don't like to have buttons where I don't know what they do.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-10-15 22:34
    Thanks, Bruce.

    It sounds like the compile time macros are similar to C or ASM macros, as opposed to Word or Excel macros.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-10-16 02:36
    That is exactly so.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
Sign In or Register to comment.