Setpoint from PAC Display to comm handle


#1

Hello,

I am new to programming strings and RS232. I have recently put a SNAP-SCM-ST2 module into my system to run some stepper motors. I am able to put the example in from OPTO Form 1944, nStatus = TransmitReceiveString(">SetPulseFrequency(50000)", comScmStPort1, sReturn); and was able to create a program to run the motors at set speed. Now I am trying to figure out the easiest way to be able to put in a setpoint from Pac display basic to change the frequency in the TransmitReceiveString (). Thanks, Lloyd


#2

Hope you don’t mind, but I did an edit on your post title to better reflect the question asked.


#3

That’s Good. Yes I have put different variable types in place of the 50000 (interger and floats and strings). But I don’t seem to be able to get the module to work or read with the numbers.


#4

Are you having trouble building the string that you need to send (converting an integer to a string), or is the string you are sending not working with the SCM-ST2 module?

Can you post what you have tried?


#5

Here is one of the ways that I have tried

Drive_LL_speed_01 = 1000 * Transport_Man_PC2_speed_Setpoint;
NumberToString(Drive_LL_speed_01, s_Drivestring01);
Drive_LL_port_status_n = TransmitReceiveString(">SetPulseFrequency(s_Drivestring01)", LL_Drive_controller_ST1, s_driveLLSRet_vr);

The setpoint is coming from Opto display.


#6

What error do you get when you run this?


#7

There are no Lights on the module channel. There are no errors in the program that I am seeing.


#8

If I replace(s_Drivestring01) with a number (1000) in line 3, the modules lights 1 and 2 come on.


#9

You are literally sending the word s_Drivestring01 to the module, you need to concatenate the string variable with your string literals:

“>SetPulseFrequency(” + s_Drivestring01 + “)”


#10

Here is an example that will let you change the pulse frequency on an ST2 module from within the strategy and has been tested and functions.

Drive_LL_speed_01 = 1000 * Transport_Man_PC2_speed_Setpoint;
NumberToString(Drive_LL_speed_01, s_Drivestring01);
sCMD = “>SetPulseFrequency(”+s_Drivestring01+")";
Drive_LL_port_status_n = TransmitReceiveString(sCMD, LL_Drive_controller_ST1, s_DriveLLSRet_vr );

String variables:
Drivestring01
sCMD