LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview reverse PID control

OK, first post so take it easy if I dont have all the information needed. I am trying to create and adaptive cruise control system using Arduino and LINX. I am using an HC-SR04 sensor to return the distance between the car and a lead object. This part is working fine.

I want a PID control to control the speed of the motor to slow down as it gets closer to the set point.

Example, if the setpoint is 10cm then as the HC-SR04 readings reduce from lets say 20cm to 10cm the PID should be reducing the speed of the motor using PWM.

 

What is actually happening is that the PID outputs full PWM until the snesor reads below the setpoint. So once it goes below 10cm it then starts to react. 

 

I have attached a screenshot of the VI with the graph showing Setpoint, Process Variable and the PID output. 

 

Download All
0 Kudos
Message 1 of 4
(2,652 Views)

What I have done to correct this so far was I have added 10 to the setpoint going into the PID and then I am Subtracting the output from the High Output range and that seems to be controlling the way I want before I tune it. There must be a better way to do this though. All suggestions welcome

0 Kudos
Message 2 of 4
(2,627 Views)

Hi Tony,

 

to reverse the "working direction" of the PID you just need to negate the P gain...

(Your PID gains look rather generic, you probably want to use better values for your control loop.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(2,603 Views)

Apologies for not getting back to you sooner. I will try that and let you know how I get on.

 

Do you think I am going about this the right way?

It is to replicate an adaptive cruise control systme using an ultrasonic sensor to control the distance. From a PID point of view Input is distance and output is speed.

 

I wanted to use an opto interrupter to control the speed but LINX does not seem to support that module so I went with the ultrasonic sensor instead.

0 Kudos
Message 4 of 4
(2,505 Views)