An example code for using the motorshield for 2.74
Dependencies: QEI_pmw MotorShield
Diff: main.cpp
- Revision:
- 2:358bdcaaf496
- Parent:
- 1:7811196d1a57
- Child:
- 3:1eee0d9f1223
--- a/main.cpp Thu Aug 27 14:55:33 2020 +0000 +++ b/main.cpp Sat Sep 12 14:34:20 2020 +0000 @@ -36,11 +36,11 @@ else motorShield.motorAWrite(0.5, 1); //run motor A at 50% duty cycle and in the reverse direction for 5 seconds - position = encoderA.getPulses(); //read position in ticks of the encoder - velocity = encoderA.getVelocity(); //read position in ticks per second of the encoder - current = motorShield.readCurrentA(); //read current for motor A in raw 16 bit ADC counts + position = 0; //MODIFY THIS + velocity = 0; //MODIFY THIS + current = motorShield.readCurrentA()*(30.0/65536.0)-15; //read current for motor A in amps. Note: this is a slightly different current sensor so its a different conversion than last lab. - pc.printf("Current reading: %i, Velocity: %i, Angle: %i \n\r", current, velocity, position); + pc.printf("Current reading: %i Amps, Velocity: %i, Angle: %i \n\r", current, velocity, position); wait(.01); //run control loop at 100Hz }