Closed jerabaul29 closed 3 years ago
Will be really curious of what that gives; wonder if it is the problem. I would be quite pissed off against Blue Robotics if their library is what kept me awake tonight ^^ ...
Sorry for delay (hard to find lunch on public holiday!)
This works on barebone Due...
Really? Now I am confused! Can you show the output? This means that the sonar works on bare bone Due... I don't understand why it does not work in my code then. Can you post the output?
Sorry, I did not know it was a free day in Australia today...
Will be really curious about how this looks - must be the answer somehow...
When you print the terminal output, can you add a print of the value of ping.profile_data_length() ? :)
Ok, can you run this and show the output you get for that:
// Sonar ping
#include "ping1d.h"
static Ping1D ping { Serial2 };
int Sonar; //if Sonar is present
void setup() {
Serial.begin(115200);
//set Sonar
Serial2.begin(9600);
if (ping.initialize() == true) {
Sonar = 1;
} else {
Sonar = 0;
}
}
void loop() {
Serial.print(F("start loop; ms: "));
Serial.println(millis());
if (ping.request(Ping1DNamespace::Profile)) {
Serial.print("got profile; ms: ");
Serial.println(millis());
Serial.println("profile points: ");
for (int i = 0; i < ping.profile_data_length(); i++) {
Serial.print(" > ");
Serial.println(ping.profile_data()[i]);
Serial.println(millis());
}
} else {
Serial.println("attempt to get profile failed");
}
Serial.print(F("end loop; ms: "));
Serial.println(millis());
}
Ok, rectification: can you run this instead:
// Sonar ping
#include "ping1d.h"
static Ping1D ping { Serial2 };
int Sonar; //if Sonar is present
void setup() {
Serial.begin(115200);
//set Sonar
Serial2.begin(9600);
if (ping.initialize() == true) {
Sonar = 1;
} else {
Sonar = 0;
}
}
void loop() {
Serial.print(F("start loop; ms: "));
Serial.println(millis());
if (ping.request(Ping1DNamespace::Profile)) {
Serial.print("got profile; ms: ");
Serial.println(millis());
Serial.print(F("nbr profile points: "));
Serial.println(ping.profile_data_length());
Serial.println("profile points: ");
for (int i = 0; i < ping.profile_data_length(); i++) {
Serial.print(" > ");
Serial.println(ping.profile_data()[i]);
Serial.println(millis());
}
} else {
Serial.println("attempt to get profile failed");
}
Serial.print(F("end loop; ms: "));
Serial.println(millis());
}
Good morning! FOllowing output:
start loop; ms: 8632
got profile; ms: 9034
nbr profile points: 200
profile points:
> 253
9034
> 253
9034
> 253
9034
> 253
9034
> 253
9034
> 253
9035
> 253
9036
> 253
9037
> 253
9039
> 253
9040
> 253
9041
> 253
9042
> 253
9043
> 253
9045
> 253
9046
> 253
9047
> 253
9048
> 253
9049
> 253
9051
> 253
9052
> 253
9053
> 253
9054
> 253
9055
> 253
9057
> 253
9058
> 253
9059
> 253
9060
> 253
9061
> 253
9063
> 253
9064
> 253
9065
> 253
9066
> 253
9067
> 253
9069
> 176
9070
> 139
9071
> 127
9072
> 87
9073
> 48
9074
> 15
9075
> 9
9076
> 12
9078
> 9
9079
> 7
9080
> 2
9081
> 0
9082
> 0
9083
> 0
9084
> 2
9085
> 0
9086
> 0
9087
> 0
9088
> 0
9089
> 0
9090
> 0
9091
> 0
9092
> 2
9093
> 2
9094
> 4
9095
> 2
9096
> 4
9097
> 0
9098
> 1
9099
> 3
9100
> 1
9101
> 3
9102
> 2
9103
> 2
9104
> 0
9105
> 0
9106
> 0
9107
> 0
9108
> 0
9109
> 0
9111
> 0
9112
> 0
9113
> 0
9114
> 0
9115
> 0
9116
> 0
9117
> 0
9118
> 0
9119
> 3
9120
> 14
9121
> 6
9122
> 13
9123
> 0
9124
> 0
9125
> 0
9126
> 0
9127
> 8
9128
> 15
9129
> 34
9130
> 21
9132
> 0
9133
> 0
9134
> 0
9135
> 0
9136
> 0
9137
> 2
9138
> 0
9139
> 9
9140
> 6
9141
> 18
9142
> 6
9143
> 0
9144
> 10
9145
> 5
9146
> 3
9147
> 11
9148
> 15
9149
> 4
9150
> 4
9151
> 0
9152
> 0
9153
> 8
9154
> 7
9156
> 0
9157
> 4
9158
> 0
9159
> 0
9160
> 0
9161
> 0
9162
> 0
9163
> 0
9164
> 13
9165
> 15
9166
> 10
9167
> 0
9168
> 2
9169
> 14
9170
> 26
9171
> 255
9173
> 108
9174
> 95
9175
> 138
9176
> 120
9177
> 126
9178
> 179
9180
> 224
9181
> 253
9182
> 202
9183
> 96
9184
> 59
9186
> 19
9187
> 0
9188
> 0
9189
> 0
9190
> 0
9191
> 20
9192
> 20
9193
> 33
9194
> 38
9195
> 32
9196
> 4
9197
> 0
9198
> 14
9199
> 22
9201
> 26
9202
> 23
9203
> 43
9204
> 27
9205
> 4
9206
> 2
9207
> 0
9208
> 0
9209
> 0
9210
> 9
9211
> 6
9212
> 13
9213
> 15
9214
> 12
9216
> 13
9217
> 0
9218
> 5
9219
> 6
9220
> 3
9221
> 9
9222
> 8
9223
> 8
9224
> 0
9225
> 0
9226
> 6
9227
> 0
9228
> 0
9229
> 0
9230
> 0
9231
> 0
9232
> 2
9233
> 4
9234
> 0
9235
> 0
9236
> 0
9237
> 0
9238
> 0
9239
> 0
9240
> 4
9241
> 13
9243
> 15
9244
> 37
9245
end loop; ms: 9246
start loop; ms: 9248
Thanks! Does it continue after that or does it hang?
it continues:)
Ok, perfect, thanks! So that seems to work :) .
@jvoermans I wonder if the external sonar library is the culprit...
Can you try something like this and tell me how it looks, i.e. a new sketch for testing just the sonar:
It is the middle of the night here (cannot sleep because of this stuff not working), and I do not have the sonar, so well possible you need to tweak a bit to fix possible syntax errors, let me know.