Skip to content

Commit

Permalink
Merge pull request #11 from LennertW/main
Browse files Browse the repository at this point in the history
external_hvp mode and another injection tip example
  • Loading branch information
nezza committed Jan 29, 2022
2 parents 3a86b49 + 78b4e0c commit 13469fb
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 4 deletions.
3 changes: 2 additions & 1 deletion firmware/c/README.md
Expand Up @@ -7,6 +7,7 @@ It currently supports:
- Serial interface for arming/disarming/pulsing
- Automatic disarm after 60 seconds
- Fast-trigger via GPIO0 (uses PIO for very fast and consistent triggering)
- External HVP mode: use an external pulse generator (e.g. ChipWhisperer) to control EM pulse insertion

## Building

Expand All @@ -16,4 +17,4 @@ mkdir build
cd build
cmake ..
make
```
```
22 changes: 19 additions & 3 deletions firmware/c/main.c
Expand Up @@ -11,7 +11,9 @@

static bool armed = false;
static bool timeout_active = true;
static bool hvp_internal = true;
static absolute_time_t timeout_time;
static uint offset = 0xFFFFFFFF;

void arm() {
gpio_put(PIN_LED_CHARGE_ON, true);
Expand All @@ -35,6 +37,9 @@ uint32_t get_status() {
if(timeout_active) {
result |= 0b100;
}
if(hvp_internal) {
result |= 0b1000;
}
return result;
}

Expand All @@ -50,8 +55,10 @@ void fast_trigger() {
// memory. This SDK function will find a location (offset) in the
// instruction memory where there is enough space for our program. We need
// to remember this location!
uint offset = pio_add_program(pio, &trigger_program);

if (offset == 0xFFFFFFFF) { // Only load the program once
offset = pio_add_program(pio, &trigger_program);
}

// Find a free state machine on our chosen PIO (erroring if there are
// none). Configure it to run our program, and start it, using the
// helper function we included in our .pio file.
Expand Down Expand Up @@ -111,7 +118,16 @@ int main() {
pio_sm_set_enabled(pio0, 0, false);
picoemp_configure_pulse_output();
break;

case cmd_internal_hvp:
picoemp_configure_pulse_output();
hvp_internal = true;
multicore_fifo_push_blocking(return_ok);
break;
case cmd_external_hvp:
picoemp_configure_pulse_external();
hvp_internal = false;
multicore_fifo_push_blocking(return_ok);
break;
}
}

Expand Down
8 changes: 8 additions & 0 deletions firmware/c/picoemp.c
Expand Up @@ -83,6 +83,14 @@ void picoemp_configure_pulse_output() {
gpio_put(PIN_OUT_HVPULSE, false);
}

void picoemp_configure_pulse_external() {
// Configure pulse input
gpio_init(PIN_OUT_HVPULSE);
gpio_set_dir(PIN_OUT_HVPULSE, GPIO_IN);
// No pullups & pulldowns
gpio_set_pulls(PIN_OUT_HVPULSE, false, false);
}

void picoemp_init() {
// Initialize LED GPIOs
gpio_init(PIN_LED_HV);
Expand Down
1 change: 1 addition & 0 deletions firmware/c/picoemp.h
Expand Up @@ -17,4 +17,5 @@ void picoemp_enable_pwm();
void picoemp_disable_pwm();
void picoemp_pulse();
void picoemp_configure_pulse_output();
void picoemp_configure_pulse_external();
void picoemp_init();
28 changes: 28 additions & 0 deletions firmware/c/serial.c
Expand Up @@ -39,6 +39,7 @@ void print_status(uint32_t status) {
bool armed = (status >> 0) & 1;
bool charged = (status >> 1) & 1;
bool timeout_active = (status >> 2) & 1;
bool hvp_mode = (status >> 3) & 1;
printf("Status:\n");
if(armed) {
printf("- Armed\n");
Expand All @@ -55,6 +56,11 @@ void print_status(uint32_t status) {
} else {
printf("- Timeout disabled\n");
}
if(hvp_mode) {
printf("- HVP internal\n");
} else {
printf("- HVP external\n");
}
}

bool handle_command(char *command) {
Expand Down Expand Up @@ -130,6 +136,26 @@ bool handle_command(char *command) {
}
return true;
}
if(strcmp(command, "internal_hvp") == 0) {
multicore_fifo_push_blocking(cmd_internal_hvp);
uint32_t result = multicore_fifo_pop_blocking();
if(result == return_ok) {
printf("Internal HVP mode active!\n");
} else {
printf("Setting up internal HVP mode failed.");
}
return true;
}
if(strcmp(command, "external_hvp") == 0) {
multicore_fifo_push_blocking(cmd_external_hvp);
uint32_t result = multicore_fifo_pop_blocking();
if(result == return_ok) {
printf("External HVP mode active!\n");
} else {
printf("Setting up external HVP mode failed.");
}
return true;
}

if(strcmp(command, "reset") == 0) {
watchdog_enable(1, 1);
Expand All @@ -151,6 +177,8 @@ void serial_console() {
printf("- enable_timeout\n");
printf("- disable_timeout\n");
printf("- fast_trigger\n");
printf("- internal_hvp\n");
printf("- external_hvp\n");
printf("- status\n");
printf("- reset\n");
}
Expand Down
2 changes: 2 additions & 0 deletions firmware/c/serial.h
Expand Up @@ -8,6 +8,8 @@
#define cmd_enable_timeout 4
#define cmd_disable_timeout 5
#define cmd_fast_trigger 6
#define cmd_internal_hvp 7
#define cmd_external_hvp 8
#define return_ok 0
#define return_failed 1

Expand Down
7 changes: 7 additions & 0 deletions hardware/injection_tips/README.md
Expand Up @@ -63,6 +63,13 @@ The following is a smaller inductor, Wurth `744710603` (available on Digi-Key):
You need to unwind a wrapping to connect to the SMA. I'd consider trying this coil with less windings
as well (unwrap more windings, but keep the windings as close to the 'active' end as possible).


Alternatively you can also try experimenting with [radial leaded wire wound inductors](https://www.we-online.com/catalog/en/WE-TI#/articles/WE-TI-6065).
Pictured is a modified `744779068` inductor that has the top ferrite cover and a few windings removed.

![](examples/tip_WE_744779068.jpg)


### Shapping Ferrite Core

The following shows the Wurth `744710603` shaped, along with a small ferrite toroid (`35T0119-00P`):
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 13469fb

Please sign in to comment.