Results 1 to 6 of 6

Thread: com port via VB Script - help needed

  1. com port via VB Script - help needed

    Hi all;

    I have some basic programming skills but am new to vb scripting.

    I'm looking to be able to create a simple vb script I can call to control a physical motor.

    I was hoping to create a high/low state on 2 pins (one for left on for right rotation) through either a serial DB9 port (preferred) or parallel port.

    Can anyone offer an example script I can call to turn a pin on and then another to turn it off? (high/low)

    Thanks !!!

  2. Re: com port via VB Script - help needed

    I do have some samples in VB if this will help, I have samples of using the Parallel Port as well as the pin out and how to use the Mscomm or serial. Which would you prefer.

  3. Re: com port via VB Script - help needed

    Thanks. I "believe" that a parallel port is "easier"? However is not typically available on newer laptops so an adapter would be required. If this is possible on a serial (DB9) port, I'd really be interested in that. So... either or both? lol I'm open to suggestions. I do want to avoid a micro controller though. thx!

  4. #4

    Re: com port via VB Script - help needed

    The PC serial hardware cannot do this. PC parallel port hardware can sometimes do this, but support is so old and ancient (and USB versions so undocumented and hard to find) that you really don't want to do it that way.

    The easiest way is to get some USB-connected microcontroller, and tell that what to do. You can use an Arduino Leonardo, or a Teensy 3.1, or an OpenCM 9.04, or one of a number of other controllers available. You then write a very small piece of software to run on that controller to toggle pins as appropriate, and talk to that controller from the PC using a serial port (check the SerialPort class/component.)

    Assuming your Arduino runs a sketch like this:

    Code:
    void setup() {
      Serial.begin(9600);
    }
    
    char cmd = 0;
    
    void loop() {
      if (Serial.available()) {
        char ch = Serial.read();
        if (cmd == 0) {
          if (ch == '+' || ch == '-') {
            cmd = ch;
          }
        } else {
          if (ch >= 2 && ch <= 13) { // digital pins 2 .. 13 allowed
            pinMode(ch, OUTPUT);
            digitalWrite(ch, (cmd == '+') ? HIGH : LOW);
          }
          cmd = 0;
        }
      }
    }
    Then, you can tell the controller to turn pin 8 high by doing:

    Code:
    Namespace x
    	Public Class y
    		Private serialPort1 As System.IO.Ports.SerialPort
    		Public Sub New()
                            InitializeComponent();
    			serialPort1.Write(New Byte() {CByte("+"C), 8}, 0, 2)
    		End Sub
    	End Class
    End Namespace

  5. #5
    Join Date
    Jan 2015
    Location
    Near Hannover, Germany
    Posts
    9
    Rep Power
    17

    Re: com port via VB Script - help needed

    Just dropping in: Are you sure about your hardware-setup? Quote: igh/low state on 2 pins (one for left on for right rotation)
    does not seem to work to me? Does your hardwaresetup involve something like a H-Bridge (an L293d IC or something)?

    (Just my 2cts)

  6. Re: com port via VB Script - help needed

    I have used two different servo controller boards and have found that the Veyron 24 Channel works the best and is much more forgiving.
    You can check it out here. https://www.dfrobot.com/index.php?ro...scription=true The other one I have used is by Pololu and they make it in a 6, 12, 18 and 24 channel. https://www.pololu.com/search?query=Maestro&x=5&y=9 There are samples of using VB with the Pololu board and as for the Veyron board I can help out there.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Arbotix and i2C port
    By zman81 in forum Software and Programming
    Replies: 1
    Last Post: 11-12-2012, 01:05 PM
  2. how to read from serial port
    By KAYSHEHU in forum Project Showcase
    Replies: 2
    Last Post: 08-09-2012, 05:03 AM
  3. Access Denied to Port??!!
    By cloud_skyblue in forum Arbotix, Microcontrollers, Arduino
    Replies: 1
    Last Post: 08-23-2010, 09:14 AM
  4. Serial Port in VBScript
    By Judge in forum Software and Programming
    Replies: 11
    Last Post: 01-04-2010, 08:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •