Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: USBDevice mbed motor
Fork of mbed_mainboard_source by
Diff: definitions.h
- Revision:
- 0:da5127da2ba0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/definitions.h Thu Oct 13 15:25:01 2016 +0000 @@ -0,0 +1,27 @@ +#ifndef DEFINITIONS_H_ +#define DEFINITIONS_H_ value + +#define NUMBER_OF_MOTORS 3 + +#define MOTOR_PWM(n) MOTOR ## n ## _PWM +#define MOTOR_DIR1(n) MOTOR ## n ## _DIR1 +#define MOTOR_DIR2(n) MOTOR ## n ## _DIR2 +#define MOTOR_FAULT(n) MOTOR ## n ## _FAULT +#define MOTOR_ENCA(n) MOTOR ## n ## _ENCA +#define MOTOR_ENCB(n) MOTOR ## n ## _ENCB + +#define MOTOR_ENC_TICK(i) void motor ## i ## EncTick() { \ + uint8_t enc_dir; \ + motorEncNow[i] = MotorEncA[i]->read() | (MotorEncB[i]->read() << 1); \ + enc_dir = (motorEncLast[i] & 1) ^ ((motorEncNow[i] & 2) >> 1); \ + motorEncLast[i] = motorEncNow[i]; \ + \ + if (enc_dir & 1) motorTicks[i]++; \ + else motorTicks[i]--; \ + } + +#define MOTOR_PID_TICK(i) void motor ## i ## PidTick() { \ + motors[i].pid2(motorTicks[i]); \ + motorTicks[i] = 0; \ + } +#endif