I created a tool that runs on the command line or “DOS box” that lets you use a U401 or U421 (output) in a batch file or other type of PC script. This is output only. You can set or reset the lines on the U401 or U421 using this executable file.
The program is called usbmout and can be downloaded (it is in a zip file with the USBm.dll included too) for free.
That little graphic is about as boring as it gets, isn’t it?
But it is a quick example of controlling a U401 or U421 via command-line.
The syntax for the command is reasonably straight forward.
usbmout 0 set 2
The program name is “usbmout”. The first argument is the U401 or U421 device that you want to address. 0 is the first USBmicro device found on your PC, 1 is the next device, etc. (It is a zero-indexed list).
The word “set” is the command that you want to give to the U401/U421. It is a command that sets an output bit (one of the 16 lines) of the U401/U421 device. If you think that another command to reset that bit would be “reset”, you would be right. 2 is the bit that you wish to set or reset. Again, this is zero-indexed so the 16 output lines are numbered 0 – 15.
usbmout 0 set 1
This looks at the first U401/U421 that it can find (because of the 0) and sets bit 1 (on).
usbmout 3 set 9
This looks at the fourth U401/U421 that it can find (because of the 3) and sets bit 9 (on). You you can control any number of U401/U421 devices that you have connected to your PC. The first device is 0, the second is 1, etc.
usbmout 0 reset 1
This looks at the first U401/U421 that it can find (because of the 0) and resets bit 1 (off).
The set and reset commands give you the ability to turn single U401/U421 lines off and on. Two more commands let you write a full 8 bits to the port at once. The commands are “porta” and “portb” and the value that follows them is the value (decimal) copied to that port.
usbmout 0 porta 9
This looks at the first U401/U421 that it can find (because of the 0) and sets bit 0 and 3 of port A (on) and turns off the other bits.
With the usbmout.exe program (and the DLL in the same directory) you can control a U401 or U421 that in turn controls LEDs or relays or what-have-you. You can turn things on and off from the command line. If you have batch files, scripts, program macro languages, programs like AutoHotKey, or any program that will call command line programs, you can control a U401/U421 and CONTROL THE WORLD.
Or at least control your little part of it. 🙂
Leave a Reply