1.

Solve : Novice: How do I control a stepper motor with a rs232 port interface?

Answer»
I have a step motor with rs232 communication.
I know c++ , but programmed only in CLASS years ago, I have no experience with visual basic.
The sw I have is Vstudio 6 with Vbasic and Vc++ student edition from quite a while ago, I don't know if downloading the new express edtions are any better for a novice to work with. For now, I woudl just like to see the freaken motor move lol! Looking for the most vanilla procedure in C++ and/or Visual Basic. I hear VB is easier to use? Any help appreciated.


I want to
Configure Ports
Move motor

Seria Port Settings:
I. configure serial port
•Baud Rate: 38400
•Parity: None
•Data Bits: 8
•Stop Bits: 1
•Flow Control: none


'Here is the command to move motor 500 counts: but how do I pass this command to motor?
II. Send index to motor:
"@0N1_500” & Chr$(13)

I'll get this later but first, I want to see the motor move.
III. loop

‘where 0=address,N=Index Command 500=IndexTravel chr$(13)=carriage rtn

For count = 0 to 4449
‘Set Direct = cw
"@0+” & Chr$(13)

‘Move Motor * Index Number - move motor up position
"@0G1” & Chr$(13)

‘Set Direct = ccw‘
"@0+” & Chr$(13)

‘Move Motor * Index Number – move motor down position
"@0G1” & Chr$(13)

Count = count+1
write (count, pc date & TIME) stamp to text file
Next Count


Brief overview of cammands and a very brief VB code, but I just get errors if I try to perform anything, I don't really know anything much about the structure of VB:

N - Index Number
Format: N#_[value] - where # is the motion profile number 1 or 2
Sample: N1_10000 Index number of profile 1 equals 10000
Description: This command sets the number of pulses to index for the motion profile. This value must
be set before motion begins. These values are saved in the EEProm for stand-alone use.
Range: 0 - 8,388,607


Unit Selection
In order to select a unit the @ command followed by 0 (address of the unit) must be sent.
NOTE: There should be no spaces between the @ and the 0.
How to select the unit:
@0 (Unit is selected)
How to get a response from the unit:
@0$ (Carriage Return)
After the $ command, the pulse generator will return a SMSI30 + the current version number.
Note: In direct talk mode each command is followed by a carriage return.
The unit communicates in half duplex mode, therefore proper setup of hyper terminal is necessary to view characters,
if characters are to be echoed back to the screen.
Instructions
All instructions require that no spaces be sent between the command and the parameter followed by a carriage
return. The commands are also case sensitive and are all sent as capitals.
Command Summary:
A - Acceleration/Deceleration
B - BASE Speed
G - Go (Index)
H - Hard Limit
M - Max Speed
N - Index Number
R - Microstep Resolution
S - Soft Limit
T - Complete Time
V - Verify
+ - Clockwise Direction
- - Counterclockwise Direction
$ - Version Number Register
! - Error Codes Register
% - Verify Controller Address
~ - Set Controller Address




Visual Basic Direct Mode Programming Example
This Example is for Axis=0, and Profile=1
DimConst DefaultTimeout As Single = 0.5
frmMain.MSComm1.Output = "@0A1_100000. & Chr$(13) .Set Acceleration
Pause DefaultTimeout
frmMain.MSComm1.Output = "@0B1_1000. & Chr$(13) .Set Base Speed
Pause DefaultTimeout
frmMain.MSComm1.Output = "@0M1_4000. & Chr$(13) .Set Maximum Speed
Pause DefaultTimeout
frmMain.MSComm1.Output = "@0N1_500. & Chr$(13) .Set Index Number
Pause DefaultTimeout
frmMain.MSComm1.Output = "@0T1_100. & Chr$(13) .Set Complete Time
Pause DefaultTimeout
frmMain.MSComm1.Output = "@0R8. & Chr$(13) .Set Microstep Resolution
Pause DefaultTimeout
frmMain.MSComm1.Output = "@0+. & Chr$(13) .Set Direction CW
Pause DefaultTimeout
frmMain.MSComm1.Output = "@0G1. & Chr$(13) .Start the Index
Pause DefaultTimeout
Wadzilla,
you are making things far to difficult, and you want instant results.
I tried to work with this RS232 communications, but that stuff is enough to drive anyone nuts.
Here are some basics to get things going, but maybe this is not what you want:
-Use VB for programming and Excel for layouts, Binary values etc.
-Download InpOut_32 dll and write a few VB Procs.
-Dissect an old CD drive, it has mostlikely a 3 phase and a 4 phase Bi-Directional stepper motor. The 3 phase is more interesting and more difficult to get the correct Sequences.
-Use LPT1 port and Printer cable and use pin D0 to D7 and pin #25, using InpOut_32 to which you need to pass 4 (step) Binary values for a 4 Phase or 9 (step) Binary values for a 3 phase.
-Search the Internet, after a few 100 pages you will have collected dozens of of sample diagrams, and electronics to buy.
-Be prepared to blow your power supply if you don't send the proper binary values to the LPT1 port, or incorrectly hook-up things.
-For fun you can add an old Analog Joystick to control your treasure (an other dll download is required).

Now, isn't this a giveaway?

The motor is fullt integrated already has a rs-484 interface built in (I have a rs232 to RS485 converter) and it has to run for 600,000 rotations = 800 up/down cycles in a 120 degree environment to pass a reliability test. The Motor also has a language set of 16 commands. I was pretty much told that it has to work with this interface directly to a laptop.. Here is it's user guide:

http://www.anaheimautomation.com/manuals/L010273%20-%2023MDSI%20Series%20Users%20Guide.pdf


Wish I could do it as a leisure hobby but part of a larger project


Discussion

No Comment Found