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.
Revision 1:d24fd64d1fcb, committed 2019-06-30
- Comitter:
- benkatz
- Date:
- Sun Jun 30 02:04:46 2019 +0000
- Parent:
- 0:d6186b8990c5
- Commit message:
- updating
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri May 26 19:47:57 2017 +0000 +++ b/main.cpp Sun Jun 30 02:04:46 2019 +0000 @@ -6,7 +6,7 @@ Serial pc(PA_2, PA_3); -CAN can(PB_8, PB_9); // CAN Rx pin name, CAN Tx pin name +CAN can(PB_8, PB_9, 1000000); // CAN Rx pin name, CAN Tx pin name CANMessage rxMsg; CANMessage txMsg1; CANMessage txMsg2; @@ -20,17 +20,16 @@ float theta1, theta2, dtheta1, dtheta2; /// Value Limits /// - #define P_MIN -12.5f +#define P_MIN -12.5f #define P_MAX 12.5f - #define V_MIN -30.0f - #define V_MAX 30.0f + #define V_MIN -45.0f + #define V_MAX 45.0f #define KP_MIN 0.0f #define KP_MAX 500.0f #define KD_MIN 0.0f #define KD_MAX 5.0f #define T_MIN -18.0f #define T_MAX 18.0f - #define I_MAX 40.0f /// CAN Command Packet Structure /// /// 16 bit position command, between -4*pi and 4*pi @@ -105,6 +104,7 @@ dtheta2 = v; } + //printf("%d %.3f %.3f %.3f\n\r", id, p, v, i); } void onMsgReceived() { @@ -115,9 +115,11 @@ void sendCMD(){ /// bilateral teleoperation demo /// - pack_cmd(&txMsg1, theta2, dtheta2, 10, .1, 0); - pack_cmd(&txMsg2, theta1, dtheta1, 10, .1, 0); - can.write(txMsg2); + pack_cmd(&txMsg1, 0, 0, 0, 0, -0.1f); + //pack_cmd(&txMsg2, theta1, dtheta1, 10, .1, 0); + //pack_cmd(&txMsg2, 0, 0, 0, 0, 1.0); + //pack_cmd(&txMsg1, 0, 0, 0, 0, 1.0); + //can.write(txMsg2); wait(.0003); // Give motor 1 time to respond. can.write(txMsg1); } @@ -198,7 +200,6 @@ int main() { pc.baud(921600); pc.attach(&serial_isr); - can.frequency(1000000); // set bit rate to 1Mbps can.attach(&onMsgReceived); // attach 'CAN receive-complete' interrupt handler can.filter(CAN_ID<<21, 0xFFE00004, CANStandard, 0); //set up can filter printf("Master\n\r");