Shop OBEX P1 Docs P2 Docs Learn Events
Controlling Microcontroller — Parallax Forums

Controlling Microcontroller

Is their anyway possible to control the micro controller from a command window or txt file?

Comments

  • You could use a serial terminal to do very simple commands -- but they would be very simple.

    If you "upgrade" to the Propeller, I have a parser engine that allows me to control various projects from a terminal (live mode) or from a text file. The new Parallax badge uses this parser to allow the user to make changes from a terminal. The BadgeHacker program simplifies the process by typing/sending the commands for you.
  • When you say "command window or txt file" you're really referring to things on a PC and a microcontroller like a Basic Stamp or Propeller is a separate computer. A PC can be connected to a microcontroller either via a wired connection like a serial port (directly or these days via USB) or a wireless connection like Bluetooth or WiFi that, in the end, looks like a serial port. You need a program on the PC to send and receive serial data, either from some kind of command window or a text file or as a result of something in the program. You also need a separate program on the Basic Stamp or Propeller to receive and interpret the serial data and to send replies back to the PC.

    StampPlot Pro is one example of a program that runs on a PC, communicates with a Basic Stamp, and can be controlled from a text file. Data can be transferred back and forth and plotted on the PC among other things. There's a more complex program for the Propeller called ViewPort that can be used as a debugger as well.
  • Could Visual Basic possibly work. I know not many people know the language but I wanted to see if I could possibly send data to be used by the microcontroller from visual basic
  • Yes, Visual Basic can work. I don't have a link to the examples here, but perhaps someone else can post them. You have to open a serial port and transmit some sort of command to the Stamp. Best would be to use 9600 Baud or slower. Usually a command would start with a punctuation character like "!" that's not used anywhere else, then a one or two letter command code that's suggestive of the function to be performed. If the command needs data values, these follow separated by commas, then a carriage return to end the command. On the Stamp end, you'd use a SERIN statement to wait for the "!", then read in the command characters followed by any data values. If some commands don't use data values, you'd be better off using dummy values so you don't have to interpret the command characters until after you've read all the data values.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2015-12-04 10:00
    The Propeller offers the opportunity to work with an interpreted language in the Propeller. I believe there is an interpreted Basic available to the Propeller (and called PropBasic) if that is what you really want. This would use a Terminal application to talk with the Propeller.

    propbasic.blogspot.tw

    With 'Visual Basic' and 'PBasic' you suddenly have to deal with learning two languages at the same time. That can be troublesome.

    Using Visual Basic to talk with 'a few commands' that you create on the BS2 is possible and has been done many times. But sooner or later, you will begin to desire the additional utility and power of a microcontroller that has an interpretted language on-board. It just gets tedious to create more serial commands in PBasic and you may begin to run out of space.

    Go ahead and explore the Visual Basic/PBasic solution if you want, but keep in mind that using a terminal application and PBasic might be clearer. And then you can move to a terminal application as PropBasic to gain more power.

    The BS2 is a compile, load, and run form of Basic. You have to realize that is have 32 bytes of RAM, while the Propeller has 32Kbytes of RAM (a thousand times more).

    The BS2 is better at feeding data to Visual Basic that receiving data from Visual Basic. In that mode, you can gets some nice graphic display of data in near real-time.

    No matter how much you desire, you can only send 32 bytes of 'data' to the BS2 at one go. But the Propeller is capable of accepting much more and processing it more quickly.

    I admit I am biased as I think that Visual Basic would be a distraction and a Terminal program would really demonstrate what you can and cannot do with the BS2 in serial mode.
  • We'll I already know both quite well. I learned both languages in school. But we only have access to the basic stamp. Thanks for the answer mike. I wanted to make sure it was actually possible before I start it.
  • If you desire commands to control the BS2, there is a big advantage to making them a short as possible. You would have to create a table in the BS2 that would cause any given comand to jump to a sub-routine.

    Just two character commands generates 26x26 letter combinations for 676 commands. And that isn't including numbers, upper and lower case, or special characters. But it certain does give your more space for programs and runs fasters through a table.
Sign In or Register to comment.