Skip to content

Commit e7cc0ce

Browse files
author
Dilawar Singh
committed
Works fine with breadboard.
1 parent 9ad6b3f commit e7cc0ce

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

Arduino/Shocker.h

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ void enableReadingShockPad();
1515
void disableReadingShockPad();
1616

1717
int NUM_SAMPLES = 100;
18-
volatile size_t idx = 0;
18+
volatile size_t idx = 0;
19+
bool level = false;
1920

2021
// Do analog sampling only 1 in 10 times, for a freq of of 100 Hz.
2122
int SAMPLING_DIVIDER = 10;
@@ -62,27 +63,35 @@ void enableReadingShockPad()
6263

6364
/* --------------------------------------------------------------------------*/
6465
/**
65-
* @Synopsis Shock monitor is being a called every 100us (0.1ms or 10k). Use
66-
* this to generate a tone on SHOCK_PWM_PIN.
66+
* @Synopsis Shock monitor is being a called every 100us (0.1ms). Use
67+
* this to generate a tone on SHOCK_PWM_PIN of 1k
6768
*/
6869
/* ----------------------------------------------------------------------------*/
6970
void shockMonitor()
7071
{
71-
// Generate 5K tone.
72-
if( HIGH == digitalRead( SHOCK_PWM_PIN ))
73-
digitalWrite(SHOCK_PWM_PIN, LOW);
74-
else
75-
digitalWrite(SHOCK_PWM_PIN, HIGH);
76-
77-
idx++;
78-
79-
// Read very 10 ms.
72+
idx += 1;
8073
if( idx == 10)
74+
{
75+
// Generate 5K tone.
76+
if( HIGH == digitalRead( SHOCK_PWM_PIN ))
77+
{
78+
digitalWrite(SHOCK_PWM_PIN, LOW);
79+
level = false;
80+
}
81+
else
82+
{
83+
digitalWrite(SHOCK_PWM_PIN, HIGH);
84+
level = true;
85+
}
86+
idx = 0;
87+
}
88+
89+
// Read at 9th tick and level is HIGH.
90+
if(level && idx == 5)
8191
{
8292
noInterrupts();
8393
shock_pin_readout = analogRead( SHOCK_PAD_READOUT_PIN );
8494
interrupts(); // enable interrupts again. We are done reading values.
85-
idx = 0;
8695
}
8796
}
8897

Arduino/protocol.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// These variables are generated by cmake + /home/dilawars/Work/GITHUB/BhallaLab/MouseBehaviour/Protocols/protocol_to_config.py
2-
#define PROTO_CODE "Hr3"
3-
#define PROTO_SessionType 16
4-
#define PROTO_Description "light+shock"
1+
// These variables are generated by cmake + /home/dilawars/Work/MouseBehaviour/Protocols/protocol_to_config.py
2+
#define PROTO_CODE "All1"
3+
#define PROTO_SessionType 0
4+
#define PROTO_Description "No stim"
55
#define PROTO_PreStimDuration_LOW 8000
66
#define PROTO_PreStimDuration_HIGH 8000
77
#define PROTO_CSDuration 50
8-
#define PROTO_CSValue "LIGHT"
8+
#define PROTO_CSValue "NONE"
99
#define PROTO_TraceDuration 250
1010
#define PROTO_USDuration 50
11-
#define PROTO_USValue "SHOCK"
11+
#define PROTO_USValue "NONE"
1212
#define PROTO_PostStimDuration 8000
1313
#define PROTO_NextProbeTrial_LOW 6
1414
#define PROTO_NextProbeTrial_HIGH 10
1515
#define PROTO_NumTrialsInABlock 60
16-
#define PROTO_Comments "Hrishi"
16+
#define PROTO_Comments "All"

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ endif()
158158
add_custom_target(run
159159
DEPENDS cam_server upload
160160
COMMAND LD_LIBRARY_PATH=${CAMERA_SERVER_DIR}/external/lib
161-
nice -n -10 ${CMAKE_BINARY_DIR}/cam_server ${RUN_ARGS}
161+
${CMAKE_BINARY_DIR}/cam_server ${RUN_ARGS}
162162
COMMENT "Run arduino client and camera client ${RUN_ARGS}"
163163
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
164164
VERBATIM

0 commit comments

Comments
 (0)