Hot answers tagged

6

You need to implement hysteresis. Set two temperature points around set_temp. One a little higher to be a limit for turning the heater off and a one a little lower then set_temp to turn the heater on. You only need to change your if else condition a little if (current_temp < set_temp - HYST_VALUE) { digitalWrite(ssr_u, HIGH); } else if (current_temp &...


3

It all depends on how the circuit works and how it is controlled. A basic H-bridge looks like this: Normally you have one MOSFET from each side turned on and one turned off - so for example Q1 and Q4 on to make the motor turn one way, or Q2 and Q3 to make it turn the other. Turning on Q2 and Q4 for example would make the motor "brake". However, if it is ...


3

Gidday! First response as a new member. PID control is not an easy subject to grasp for starters but here is a link to a site that does explain it: http://www.csimn.com/CSI_pages/PIDforDummies.html The first thing about your project is that your output is digital (HIGH/LOW) whereas traditionally PID control is analog. AnalogIN to PID to AnalogOUT. So ...


3

I, also, didn't get the idea behind PID from just reading Wikipedia. After some videos/tutorials, I believe the best way to explain it is: What is PID PID is an algorithm. It involves three factors which can be adjusted to tune a signal. It is often used in servo's (and things like thermostates, basic signal controllers) Imagine this The servo will be ...


3

How a PID controller works depends on the particular implementation. There is a algorithm/library for PID on the Arduino: http://playground.arduino.cc/Code/PIDLibrary and an excellent explanation of the all of functions within it at http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/ Over on stackoverflow and electronics, ...


2

Two thing that may be helpful. First make sure you have a common ground. For instance for you transistor you are using separate power from the arduino and 12 volt source. Connecting the two ground of the arduino and the power supply may resolve this for you. The other thing is it is often times helpful to put a capacitor across the DC motor to help with ...


2

I've not used the (unmaintained) code you reference, but if a PID is responding much too fast in a new system, cut the parameters down significantly, first focusing on P and later I. Turn off the D, and the I terms, then slow the P down until it is behaving reasonably. Once Proportional control is working then try bringing I up in proportion to the change ...


2

A PID only has one input and one output. In your case, the input will be the temperature. The use of the arduino would be to process the raw data of the temperature sensor and relay the temperature to the PID. Depending on the make and model of the PID, there could be certain transfer protocols you must adhere to. There are most likely open source libraries ...


2

Each unique variable you want control over should have a single pid loop, and each loop should only ever stretch across one "order" of time. For example, to control the craft's roll rate, you should have one PID loop that takes the target roll rate and outputs the controlled roll torque value, which gets transformed somehow into motor accelerations. The ...


2

Ensure that your period for the PID execution routine is reasonable for your system. I generally like to execute my PID loops at 5 to 20 times the system impulse response. For instance, with a motor, I will apply 100% power from a standstill and measure the time it takes to get up to 90% of final value. I will then multiply that time by 0.1 and start ...


2

Quadcopters usually use 2-PID loops per axis, a rate loop and an angle loop. Your quadcopter needs to be very aggressive about its rate of rotation but relatively relaxed about how quickly it returns its angle to the center so it doesn't overshoot. With a single PID it will either be too slow to correct or overshoot and oscillate with no "usable" range of ...


2

Let's deconstruct this down to a simple example which we can test without the MPU6050: #include <PID_v1.h> double Setpoint, Input, Output; //Specify the links and initial tuning parameters double Kp = 2, Ki = 5, Kd = 1; PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT); void setup() { Setpoint = 100; //turn the PID on myPID....


2

How fast is your system compared to the loop() sampling time? Does (100-map((ax+10900),-1300,1300,0,1024)) change appreciably during the sub-millisecond loop()? With kI=5, an error of only 10 will saturate your 0-255 speed output in 26 iterations of loop(), potentially producing the behavior you see. If you don't have control of your sampling time, the ...


2

Please respect others by presenting code that is readable. By doing that you may also find obvious errors in your code. Let me clean up the loop() and you will see what I mean. void loop() { int a = ax + 10900; if (1) { int val; val = map(ax, -1300, 1300, 0, 1023); Input = val; myPID.Compute(); Serial.println(Output); ...


2

I actually solved this issue and noticed a few things for those interested: the printNumI() function was making the arduino crash as it was badly initiated with an extra argument. Once I solved this and replaced all my printNumF with printNumI I noticed a significant increase in sample rate of about 3-4ms per line changed. In addition, going from float to ...


2

If you can't find some actual info regarding applying PID to a water-based radiator system, then I'd suggest the following principles. First, I assume that the output of the PID algorithm appears as an An Arduino PWM output at some rate. This could be a fast rate, like in the hundreds of Hz (if the load is DC), or fractions of Hz, or even 10 sec or more ...


2

I don't think you would need to use a PID library (or any control loop for that matter) to control a radiator. You could use a simple threshold code, like this: Pseudocode: Check temperature If radiator is off and temperature > (ideal temp - threshold) turn radiator on If radiator is on and temperature > (ideal temp + threshold) turn radiator off


2

You need to know the response time of your system and the repeatability of your measurements to characterize your data (establish confidence). I suggest taking samples and average them before turning the heater back on. Imho, water will not happily stay within 0.5°C. Can you allow for coarse and fine modes? Use a higher PWM for great differences and then ...


2

Short answer: Yes, it is possible to update global variables from interrupt routines, but it comes also with problems. Long answer: First you have to understand, how interrupts work. You are using a timer interrupt and an external (pin) interrupt. The compiled program lies in the flash of the chip. At the start there are some special addresses for the ...


2

A PID controller should be a good match for your application, but it appears that your code doesn't take advantage of the PID_v1 library at all; a PID_v1 object is never declared, and it appears you are attempting to manually compute what the PID library is designed to do for you automatically. I would recommend you 'start slow and simple' by learning how ...


1

This is not an Arduino specific topic, but here is just a pragmatic answer: Use the output of the PID controller directly as your reference velocity, subtract your actual velocity and use it as input for the PID velocity. Units do not care in this case. You have to make sure that the paramters of your PID position are well adjusted, this will set the ...


1

See PID Library - SetOutputLimits() - you can change the limits. For a meaningful result you need to make the output do something reasonable to the speed. Since your detected speed is lower than the desired speed, you have found it outputs a positive value, which is good, as far as it goes. But you have to interpret that in the context of what you are ...


1

I am sorry, but I may not have understood your post, but I think the problem is your code doesn't work and you don't know why. I think the problem is with this line: if(val.m_y,2 >2 ||val.m_y,2<0){ It is because it is not valid code, I suspect its a cut and paste error and should be if(val.m_y > 2.0 || val.m_y < 0.0){ the ,2 you use in the ...


1

For stability and tuning you need to make the adjustment cycle time compatible with the physical system. How fast does this adjustment code get called relative to how fast the physical system oscillates? Without that under control, tuning the gains will be difficult, particularly for krI and krD. For instance, if you are updating every millisecond, and it ...


1

PID loops are a good way to go for something like this, but, you don't need to implement all three parts. I have done industrial control using just the P and I. Start by implementing just the proportional part. For this, you calculate the error between the input signal (Va0) and the feedback signal (Va1). This is just a subtraction Err = Va0 - Va1. You ...


1

Well, (very) simply you could slowly increase/decrease the PWM value driving M2 until the voltage at A1 equals that of A2. If you make the time between adjustments long enough you should not get any (significant) oscillations. However, more likely you want to get to the correct M2 PWM value quickly and for that you need a Proportional, integral, ...


1

How can I convert PID correction values to an PWM brushless command? you have to do that yourself. you have to figure out first how to correct a pid value directionally. for example, should you increase the duty cycle if pid is positive or negative? after that, you will need to map the pid value to a range for your pwm dc. basically, it is application / ...


1

I will give a generic C-answer to it: 1) figure out what parameters / variables involved in a PID control loop; 2) structure those parameters / variables into a struct; 3) pass that struct to a common set of PID algorithm. 4) done. with this approach, the algorithm is only implemented once and the can be used / reused as many times as you want.


1

The keyword you are looking for here is interrupt. What is a pulse but a signal that goes from low to high followed by going from high to low, with some period of time between them? Instead of sitting there waiting for the pulse to arrive then measuring how long it is, which is essentially what pulseIn() does, you need to attach the signal to an interrupt ...


1

Instead of thinking of the PID output as pid_speed, think of it as motor_power, and what the PI controller is doing is translating errors in rpm into a motor power setting. You are probably getting oscillation because of integral windup. If your loop is fast relative to your system, each loop worth of error adds to integrator quickly/quicker than the ...


Only top voted, non community-wiki answers of a minimum length are eligible