08-17-2012 01:21 AM
So now I decided to move to a little hardware
I have been controlling the speed and direction of a DC motor by passing a combination of ASCII values and HEX values.For eg:- P20 will give me some speed P50 will give me another.M1/0 will rotate the motor in both the directions.S will give me counts which has been converted to the respective RPM.
So I have no issues here. But now I have to implement a PID controller with it.
That means Set Point will be decided by user(That is me) and Process Variable(PV) will I think be the feedback from the output of RPM.And, I think output of PID will be given as HEX to VISA.I don't know.Am I correct over here?
How to implement the motor control with the PID block?
Can anyone guide me in the right direction?
08-17-2012 02:04 AM
Hi Sunny,
the output of the PID is a number used to set an actuator. In your case you have to send that number to your motor control board, which expects strings (not any kind of HEX)! As you already gave examples of the expected strings you would use a FormatIntoString function to form the proper commands.
VISA also only uses strings as in-/output, you have to create them anyway!
08-17-2012 04:34 AM
But with a format into string function don't you think that the appropriate command will not be given to controller.
I mean if ASCII P and HEX 20 gives me some speed then with the function I think it will not give me the expected result. If I give ASCII P and HEX 00 to stop a motor
it will definitely not perform the desired function with the format into string function.
08-17-2012 04:48 AM - edited 08-17-2012 04:49 AM
Hi Sunny,
it depends on what you mean by "HEX". There are numerous threads in this forum that deal with the definition of a "HEX" value! "P20" is all ASCII, with two digits representing a hexadecimal formatted number...
Given your description before I would use a format string link "P%02x" to form a command like "P20" or "P50"...
08-17-2012 07:02 AM
I am still not able to figure how to give the output of PID.vi which gives a number to the VISA write function which expects a string.
Now my set point I have just given it as a complete HEX value and for the PV I have given the feedback of the number of counts. The area where I am stuck up is PID output and VISA input.
08-17-2012 07:05 AM - edited 08-17-2012 07:06 AM
Hi Sunny,
as told before: you have to define your "complete HEX value"! What do you understand by that term? Are there any uncomplete values???
Please give descriptive examples of a decimal number and the resulting (needed) string...
08-17-2012 07:46 AM
I am so sorry if I misundersttod you.
The HEX values are already defined in the microcontroller by me. I am able to pass those values as it is through the VISA.
But when I use a PID block in my VI and give its output to the VISA that is where I am having problem.
08-17-2012 07:50 AM
Hi Sunny,
it seems you don't want to understand what I wrote...
As noted several times before: you have a definition of "HEX values". Would you be so kind to share that definition with us?
When you know the commands needed for your device you could probably give some meaningful examples, as asked before!
08-17-2012 09:06 AM
Ok.So these are my HEX values which I give to the controller.
50H 00H is the zero speed command upto 50H FFH is for maximum speed of the motor.
4D30 for anticlockwise and 4D31 for clockwise.
and finally 53H which gives me the required rpm of the motor.
08-17-2012 09:10 AM - edited 08-17-2012 09:10 AM
Hi Sunny,
you still have to define your meaning of "HEX value"!
Do you send bytes containing 50h 00h (in ASCII you would read "P ") or do you send 4 ASCII chars "5000" (which would be 4 bytes containing 35h30h30h30h).
I asked for that definition several times before...