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: MODSERIAL USBDevice compensation_tables mbed-dsp mbed
Fork of haptic_hid by
Diff: main.cpp
- Revision:
- 4:9d37f163d64c
- Parent:
- 3:10863117020c
--- a/main.cpp Mon Jun 19 07:40:22 2017 +0000
+++ b/main.cpp Mon Jun 19 08:24:44 2017 +0000
@@ -9,9 +9,16 @@
#include "position_sensor_error.h"
#include "cogging_compensation.h"
#include "main.h"
+
Ticker tickObject;
-#include <iostream>
+//#include <iostream>
+
+
+/*
+* Comment victor: this is defined in main.h
+* MODSERIAL pc(USBTX,USBRX);
+*/
using namespace std;
const int n = 1000;
@@ -98,21 +105,25 @@
void printer(){
int positie = GET_POSITION();
positievec[q] = positie;
- cout << positievec[q] << ",";
+ //cout << positievec[q] << ",";
+ pc.printf("%d,", positievec[q]);
q = q+1;
+ if(q>=n)
+ q=0;
}
int main()
{
// Initialize system
//initialiseer_prbs();
+ pc.baud(115200);
initialize_io();
calibrate_current_sensor();
calibrate_position();
for (int i = 0; i <= n; i++) {
prbstest[i] = rand() % 2;
- cout << prbstest[i] << ",";//"\r\n";
+ pc.printf("%d,", prbstest[i]);
}
while(z<=n){
@@ -120,7 +131,8 @@
//tickObject.attach_us(&printer, 100000);
torque_control();
printer();
- cout << z << ";\r\n";
+ wait_ms(300);
+ pc.printf("%d;\r\n",z);
z = z+1;
wait_us(TORQUE_CONTROLLER_INTERVAL_US);
@@ -129,7 +141,7 @@
//send_report.length = 16;
//recv_report.length = 16;
- cout << "\r\n";
+ //cout << "\r\n";
/*
for(int k=0; k <= n; k++) {
status = prbstest[k];
@@ -147,7 +159,10 @@
blink();
}
}*/
- cout << positievec;
+ for(int i=0 ; i<n ; i++)
+ {
+ pc.printf("%d ",positievec[i]);
+ }
while(1) {
int32_t abspos = ABSPOS();
@@ -296,11 +311,11 @@
// Impedance controller...
if(prbstest[z] == 1){
torque = -0.1;//-ZControl_K*0.00076699f*(ABSPOS()-ZControl_RefPos) - ZControl_B*speed - ZControl_I*acceleration;
- cout << torque << ",";//"\r\n";
+ //cout << torque << ",";//"\r\n";
}
else if(prbstest[z] == 0){
torque = 0.1;
- cout << torque << ",";//"\r\n";
+ //cout << torque << ",";//"\r\n";
}
// Preprocess torque command
