Simon Ford
/
LabVIEW_PID
Simple PID example for LabVIEW
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "QEI.h" 00003 #include "Motor.h" 00004 00005 Serial pc(USBTX, USBRX); 00006 QEI Encoder(p29 ,p30, NC, 48); 00007 Motor Wheel(p23, p21, p22); 00008 00009 int main() { 00010 float MotorOutput = 0; 00011 Encoder.reset(); 00012 while (1) { 00013 pc.scanf("%f", &MotorOutput); 00014 float NoPulses = Encoder.getPulses(); 00015 00016 float Percentage = (NoPulses / 48) * 100; 00017 pc.printf("%f\n", Percentage); 00018 00019 Wheel.speed((MotorOutput - 50) * 2 / 100); 00020 00021 wait(0.005); 00022 } 00023 }
Generated on Tue Jul 12 2022 11:13:38 by 1.7.2