hello
am working on PID to control speed of motor now am confused how to code the program as PID feedback is through proximity sensor and output is pwm
how can i code so both work at same (mean proximity sensor counts rpm and pwm generated through pid produced without no delay ) i used interrupt but my code is not working please help
my code is in attachment
ok what system you used to control motor i mean to say h-bridge or some other technique
actually i want to control speed using and converter and one more thing will you tell me which sensor you used for speed control
I am using the PID program in the link I gave you in Reply #1 and I am using a Pololu DRV8833 motor driver (h-bridge).
I am using a QRE1113 reflective object sensor to detect a blob of white paint on the edge of a black disc on the motor shaft. The disk is a slice from an 8mm plastic knitting needle - painted matt black.
I don't know what you mean by "control speed using and converter" - I suspect there is a typo.
sorry typing mistake i mean to controlling speed of motor using bcuk-boost converter
That still does not make sense. You can, though you shouldn't, provide power to run the motor using a buck-boost converter. But, the source of power has NOTHING to do with how you control the speed of a motor.
PaulS:
That still does not make sense. You can, though you shouldn't, provide power to run the motor using a buck-boost converter. But, the source of power has NOTHING to do with how you control the speed of a motor.
actually am using to control speed using converter which mean control pwm to control voltage as a result speed is control
Robin2:
Why not use a h-bridge? PWM applied directly to the motor is a more effective way to control speed than using a varying voltage.
But whatever control system you use if it is effective it will not matter to the PID algorithm which will only know about the measured speed.
...R
Actually this is my FYP to design cheap and efficient converter to control speed
only problem am confused with pwm frequency mine frequency is about 31khz and the frequency in code you refer is around 1 khz
naeemawan36:
Actually this is my FYP to design cheap and efficient converter to control speed
only problem am confused with pwm frequency mine frequency is about 31khz and the frequency in code you refer is around 1 khz
Does that mean "First Year Project"?
What you have described in the piece I have quoted seems to have nothing at all to do with PID.
In the PID library the Output can be any range you like (the default range is 0 to 255). How do you control the output of the boost/buck converter? If it's an Arduino analog output pin (8-bit PWM) then use the default range.
Input and Setpoint have to be in the same units. Sounds like you want to control motor speed so RPM might be a good choice. You will need to convert the input pulses to RPM so counting pulses over a time interval or measuring time across two or more pulses will give you the data to calculate RPM.
Put the calculated current speed in Input. Put the desired speed in Setpoint. Run the PID. Use the Output value to PWM your converter. Then tune the PID to get good control.
johnwasser:
In the PID library the Output can be any range you like (the default range is 0 to 255). How do you control the output of the boost/buck converter? If it's an Arduino analog output pin (8-bit PWM) then use the default range.
Input and Setpoint have to be in the same units. Sounds like you want to control motor speed so RPM might be a good choice. You will need to convert the input pulses to RPM so counting pulses over a time interval or measuring time across two or more pulses will give you the data to calculate RPM.
Put the calculated current speed in Input. Put the desired speed in Setpoint. Run the PID. Use the Output value to PWM your converter. Then tune the PID to get good control.
thanks alot am confused how to count pulse using interrupt and if you hav come code kindly share it with me