Skip to content

Commit 633d008

Browse files
committed
Bug fixes to compressive sensing stuff
mostly communications issues; added comms cache back on front-end.
1 parent 70f1675 commit 633d008

File tree

3 files changed

+42
-557
lines changed

3 files changed

+42
-557
lines changed

.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</dictionary>
2424
<dictionary>
2525
<key>org.eclipse.cdt.make.core.buildArguments</key>
26-
<value>CONFIG=Release</value>
26+
<value>CONFIG=Debug</value>
2727
</dictionary>
2828
<dictionary>
2929
<key>org.eclipse.cdt.make.core.buildCommand</key>

src/fbsMT.xc

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <platform.h>
1616
#include <random.h>
1717

18-
#define BIT_RATE 57600
18+
#define BIT_RATE 19200
1919
#define BIT_TIME XS1_TIMER_HZ / BIT_RATE
2020

2121
// If a positive output turns the beam off (closes the shutter) (SuperSTEM1/Normal)
@@ -92,6 +92,7 @@ void getSettings(chanend set_ch1, chanend go_ch1, chanend interrupt_ch){
9292
int is_sync=0;
9393
timer tmr;
9494
unsigned time;
95+
timeset settings[255]; // tempoorary storage of settings
9596

9697
while(1)
9798
{
@@ -127,7 +128,7 @@ void getSettings(chanend set_ch1, chanend go_ch1, chanend interrupt_ch){
127128
go_ch1 <: STOP;
128129
// tell computer you're ready for data
129130
txByte(255);
130-
nSettings=rxInt(); // get number of settings
131+
nSettings=rxByte(); // get number of settings
131132
// tell number of settings to process threads
132133

133134
// nsettings = 0 means close shutter
@@ -151,27 +152,28 @@ void getSettings(chanend set_ch1, chanend go_ch1, chanend interrupt_ch){
151152
// anything else is a series of on/off sequences
152153
else
153154
{
154-
timeset setting;
155-
156155
is_sync=0;
157156

158-
set_ch1 <: nSettings;
159-
160157
// acquire each sequence of settings
161158
for (int i = 0; i < nSettings; i += 1)
162159
{
163-
setting.setupTime=rxInt();
164-
setting.onTime=rxInt();
165-
setting.max_random_gap=rxInt();
166-
setting.sync=rxByte();
167-
setting.setupUnits=rxByte();
168-
setting.onUnits=rxByte();
169-
170-
if (setting.max_random_gap > 0 || setting.sync > 0)
160+
settings[i].setupTime=rxInt();
161+
settings[i].onTime=rxInt();
162+
settings[i].max_random_gap=rxInt();
163+
settings[i].sync=rxByte();
164+
settings[i].setupUnits=rxByte();
165+
settings[i].onUnits=rxByte();
166+
167+
if (settings[i].max_random_gap > 0 || settings[i].sync > 0)
171168
{
172169
is_sync=1;
173170
}
174-
set_ch1 <: setting;
171+
}
172+
// this sends the settings to the worker thread.
173+
set_ch1 <: nSettings;
174+
for (int i = 0; i < nSettings; i += 1)
175+
{
176+
set_ch1 <: settings[i];
175177
}
176178
}
177179
break;
@@ -181,7 +183,7 @@ void getSettings(chanend set_ch1, chanend go_ch1, chanend interrupt_ch){
181183
}
182184

183185
void output_master(chanend set_ch, chanend go_ch, chanend interrupt_ch, out port out_port) {
184-
unsigned char nSettings=1;
186+
unsigned int nSettings=1;
185187
timeset settings[255];
186188
int DONE=1;
187189
int stop=0;
@@ -258,6 +260,11 @@ void output_master(chanend set_ch, chanend go_ch, chanend interrupt_ch, out port
258260
// For compressive sensing: wait for multiple external clock inputs - these are each blanked pixels.
259261
for (unsigned tick=0; tick < gap; tick += 1)
260262
{
263+
// break out of the for loop to avoid waiting on synchronization
264+
if (break_loop)
265+
{
266+
break;
267+
}
261268
// Wait for sync pulse edge to fall
262269
select
263270
{
@@ -278,30 +285,33 @@ void output_master(chanend set_ch, chanend go_ch, chanend interrupt_ch, out port
278285
}
279286
}
280287

281-
//waits for sync signal to rise
282-
select
288+
if (!break_loop)
283289
{
284-
case ext_sync when pinseq (1) :> void:
285-
{
286-
// wait to receive a sync pulse from ext_sync1
287-
break;
288-
}
289-
// Any interrupt will set break_loop to 1 here.
290-
// That will break the settings loop.
291-
case interrupt_ch :> break_loop:
290+
//waits for sync signal to rise
291+
select
292292
{
293-
// go to beginning of settings loop, which should not
294-
// enter another iteration now that break_loop is 1.
295-
continue;
296-
break;
293+
case ext_sync when pinseq (1) :> void:
294+
{
295+
// wait to receive a sync pulse from ext_sync1
296+
break;
297+
}
298+
// Any interrupt will set break_loop to 1 here.
299+
// That will break the settings loop.
300+
case interrupt_ch :> break_loop:
301+
{
302+
// go to beginning of settings loop, which should not
303+
// enter another iteration now that break_loop is 1.
304+
continue;
305+
break;
306+
}
297307
}
298308
}
299309
}
300310
}
301311

302312
// camera hardware sync signal
303313
// wait until camera signals that it is done acquiring.
304-
if (settings[set_ct].max_random_gap > 0 || settings[set_ct].sync > 0)
314+
if (!break_loop && (settings[set_ct].max_random_gap > 0 || settings[set_ct].sync > 0))
305315
{
306316
select {
307317
//waits for sync signal

0 commit comments

Comments
 (0)