LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use the output value from SIMPLE PID to write something to the serial port?

I am working on my Senior Design Project that requires the use of incoming compressed air, propotional valves, continuous servo motors, and a serial servo motor microcontroller.  I have figured out how to send byte sequences to the microcontroller through LabVIEW using the VISA serial write function.  The motors are attached to the valves to control the flow rate.  I have created my own simple feedback system using a bunch of case structures but I realized that I am basically trying to recreate the wheel (I basically was writing my own PID VI).   I have an older version of LabVIEW (7.0 Express) and theres no way to upgrade or buy the PID toolkit, so I am stuck using the Simple PID VI.  Also, the only way the motor works is sending an array of bytes to tell it to turn on/off, direction, and speed.  Is there any way I can use the Simple PID VI in conjunction with the VISA SERIAL write function, or is there any other way I can communicate with the serial port using this pid vi?  Any information would be appreciated.
0 Kudos
Message 1 of 12
(4,669 Views)
By serial port, I mean the RS-232 com port (not sure if there is a difference between RS-232 and DB-9).
0 Kudos
Message 2 of 12
(4,665 Views)
Look in the example finder for examples using serial communications.
0 Kudos
Message 3 of 12
(4,651 Views)

> (not sure if there is a difference between RS-232 and DB-9).

 

RS-232 is a serial communications protocol.

 

DB-9 is a physical connector type that is commonly used for RS-232 interfacing. The connector is shaped like the letter "D" and has 9 pins.

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 12
(4,639 Views)
I know how to communicate to the serial port, but I do not know how to use the output value from the SIMPLE PID vi to communicate and send a signal out.
0 Kudos
Message 5 of 12
(4,625 Views)

Hi gpatel,

 

you know how to communicate to serial port, but you don't know how to send a value from SimplePID to serial port???

 

You know how to communicate, but then you don't know how to communicate???

 

You should explain this in more detail...

 

Edit:

From you first post you know what values your motor driver is expecting. You know which values the PID.vi is providing. Now all you need is a formula to reshape the values from PID to the motor. It's up to you to make such a formula. Unless you provide any details we cannot give more precise answers...

Message Edited by GerdW on 02-28-2010 08:35 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 12
(4,623 Views)
I guess my main concern is that I dont really understand what the output really means.  I see that it is a value ranging from your min to your max value that you indicate.  But what do those mean.  Say the set point is 15 L/min and your max and min values are 1 and 0 respectively.  Is the output equal to 1 when the process variable equals 15 L/min, or is the output equal to 0.  If thats the case then I guess I can make two cases to tell the motor to open and close the valve.  But I know I will run into problems when the output value is in between that range.  Any sort of help about understanding how to use the output value of the SIMPLE PID vi would be help.  I realized I was very unclear before.  I do not need to know anything about communicating through the serial port.  I just need help understanding the concepts so I can set up a few case structures for the motors.
0 Kudos
Message 7 of 12
(4,555 Views)

Only you know what commands your motor is expecting.

 

What kind of command do you give it for full open?  Full closed?  50%?  All you need to do is take the number that comes out of the PID and translate that into a string value that your motor is expecting in its command.   Look in the string palette for string/number conversion functions.

 

Also, I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
0 Kudos
Message 8 of 12
(4,546 Views)
The problem is that it is a continuous servo so there is no specific command for it to fully open or close or half way.  Also the continuous servo (Parallax) is communicating to LabVIEW with a Pololu controller, which is mainly used for non-continuous servos.  So there are different commands for setting the position and speed.  There controller takes in an array of 5-byte or 6-byte commands, the first two which are always the same number >> byte 1=128..byte2=1.. byte 3 = command number (varies from 0-5 depending on if you want to set the position, speed, etc).. byte 4= servo number (the controller can hold up to 8 servos).. bytes 5 and 6 are data for the commands (speed position) and some commands use 2 bytes while others use 1.  If we were using a non-continuous servo, then I understand wat you are saying by translating the PID output into some kind of rotational value so te motor would only turn the valve a certain amount so the set point flow rate would be achieved.  But how would I do that with a continuous servo because you cannot tell it to go to a certain position?  Sorry if i was vague earlier.  Any help would be very appreciated.  Thank you for replying quickly to my earlier posts.
0 Kudos
Message 9 of 12
(4,509 Views)

Hi gpatel,

 

Is this similar to the to the cont. servo you are using? You will need to use the PID output (aka "controller effort") to send commands to speed up or slow down the motor.  If it needs to move just a bit and is currently still, you will speed it up and then quickly slow it down to 0. That way the it will only move very little.  Your accuracy will be dependent on how often you acquire feedback (an encoder, I assume) send commands.  Since you are doing control in which the exact amount in needs to move may not be know precisely, you may want to take a look at fuzzy logic.  However, that may be more than you are looking for.  I hope this helps.

 

Kristen H.

0 Kudos
Message 10 of 12
(4,471 Views)