Add MOSFET support to Wiegand app.
This commit is contained in:
parent
a7c155e88d
commit
f1c4a190e6
@ -2,9 +2,32 @@
|
||||
|
||||
This application supports W4, W8, W24, W26, W32, W34, W37 and W40 formats.
|
||||
|
||||
This application can be used to test Wiegand readers and keypads. It can
|
||||
save the data to a file, and can load and replay the data. Timings are
|
||||
measured and displayed; which can be used to help debug Wiegand readers.
|
||||
This application can be used to test Wiegand readers and keypads. It can save the data to a file, and can load and replay the data. Timings are measured and displayed; which can be used to help debug Wiegand readers.
|
||||
|
||||
|
||||
## Wiring
|
||||
The D0 and D1 wires of the Wiegand must be about 1K or higher for the Flipper to be able to effectively pull them down to ground. If the line has a lower resistance, like 100 ohms, then you need to add MOSFETs to help pull the lines low. The following [YouTube video](https://youtu.be/OVyd3ffnZ0M) is a demonstration of how to correctly wire the device.
|
||||
|
||||
In all configurations:
|
||||
- Pin A7 goes to your Wiegand D1 (white) wire.
|
||||
- Pin A4 goes to your Wiegand D0 (green) wire.
|
||||
- Pin GND goes to your Wiegand GND (black) wire.
|
||||
This is sufficient for reading signals with both this application and the Debug Accessor application.
|
||||
|
||||
If the pull-up resistors on your card reader are less than 1K, you also need the following:
|
||||
- Two additional MOSFETs are required. I used IRF540 (but perhaps IRL540 would be better?)
|
||||
- Two additional Pull-down resitors are required. I used 5K, but 4.7K would be fine as well.
|
||||
- I'm still learning, but perhaps a MOSFET driver / optocoupler would provide even more protection to the Flipper GPIO pins? Use this circuit at your own risk. :)
|
||||
|
||||
Here is how you wire up the MOSFET and the pull-down resistors:
|
||||
- The source pin of each MOSFET connects to ground.
|
||||
- The gate pin connects to one side of a resistor. The other side of the resistor goes to ground.
|
||||
- For the MOSFET used for D1:
|
||||
- The gate pin of the MOSFET for D1 goes to pin A6 on the Flipper. (It should also already be connected to the pull-down resistor)
|
||||
- The drain pin of the MOSFET for D1 goes to pin A7 on the Flipper.
|
||||
- For the MOSFET used for D0:
|
||||
- The gate pin of the MOSFET for D0 goes to pin B3 on the Flipper. (It should also already be connected to the pull-down resistor)
|
||||
- The drain pin of the MOSFET for D0 goes to pin A4 on the Flipper.
|
||||
|
||||
## W4: 4-bit Wiegand
|
||||
|
||||
|
@ -14,6 +14,7 @@ void wiegand_instructions_scene_on_enter(void* context) {
|
||||
"Connect D0 (Green) to pin A4\n"
|
||||
"Connect D1 (White) to pin A7\n"
|
||||
"Connect GND (Black) to GND\n"
|
||||
"\nOption 1 (no mosfet):\n"
|
||||
"Add a 10K inline resistor on D0\n"
|
||||
"between keypad and door.\n"
|
||||
"Connect Flipper on door\n"
|
||||
@ -22,6 +23,21 @@ void wiegand_instructions_scene_on_enter(void* context) {
|
||||
"door. Connect Flipper on\n"
|
||||
"door side. Do not inturrupt\n"
|
||||
"the D0/D1 connections while\n"
|
||||
"adding the resistors.");
|
||||
"adding the resistors."
|
||||
"\n\nOption 2 (mosfet):\n"
|
||||
"Connect pin A6 to gate of\n"
|
||||
"mosfet for D1. Connect 5K\n"
|
||||
"resistor from gate to GND.\n"
|
||||
"Connect pin A7 to drain of\n"
|
||||
"mosfet for D1. Connect source\n"
|
||||
"of mosfet for D1 to GND.\n"
|
||||
"Connect pin B3 to gate of\n"
|
||||
"mosfet for D0. Connect 5K\n"
|
||||
"resistor from gate to GND.\n"
|
||||
"Connect pin A4 to drain of\n"
|
||||
"mosfet for D0. Connect\n"
|
||||
"source of mosfet for D0 to\n"
|
||||
"GND.\n"
|
||||
);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WiegandWidgetView);
|
||||
}
|
||||
|
@ -24,8 +24,12 @@ void wiegand_play() {
|
||||
|
||||
furi_hal_gpio_write(pinD0, true);
|
||||
furi_hal_gpio_init(pinD0, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
|
||||
furi_hal_gpio_write(pinD0mosfet, false);
|
||||
furi_hal_gpio_init(pinD0mosfet, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
furi_hal_gpio_write(pinD1, true);
|
||||
furi_hal_gpio_init(pinD1, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh);
|
||||
furi_hal_gpio_write(pinD1mosfet, false);
|
||||
furi_hal_gpio_init(pinD1mosfet, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
|
||||
single_vibro();
|
||||
furi_delay_ms(500);
|
||||
@ -33,18 +37,24 @@ void wiegand_play() {
|
||||
int j = 0;
|
||||
for(int i = 0; i < bit_count; i++) {
|
||||
if(data[i]) {
|
||||
furi_hal_gpio_write(pinD1, false);
|
||||
furi_hal_gpio_write(pinD1mosfet, true); // Activate the mosfet to ground wire
|
||||
furi_hal_gpio_write(pinD1, false); // Ground the open-drain wire
|
||||
furi_delay_us(delays[j++]);
|
||||
furi_hal_gpio_write(pinD1, true);
|
||||
furi_hal_gpio_write(pinD1, true); // Float the wire
|
||||
furi_hal_gpio_write(pinD1mosfet, false); // Deactivate the mosfet
|
||||
furi_delay_us(delays[j++]);
|
||||
} else {
|
||||
furi_hal_gpio_write(pinD0, false);
|
||||
furi_hal_gpio_write(pinD0mosfet, true); // Activate the mosfet to ground wire
|
||||
furi_hal_gpio_write(pinD0, false); // Ground the open-drain wire
|
||||
furi_delay_us(delays[j++]);
|
||||
furi_hal_gpio_write(pinD0, true);
|
||||
furi_hal_gpio_write(pinD0, true); // Float the wire
|
||||
furi_hal_gpio_write(pinD0mosfet, false); // Deactivate the mosfet
|
||||
furi_delay_us(delays[j++]);
|
||||
}
|
||||
}
|
||||
|
||||
furi_hal_gpio_init_simple(pinD0, GpioModeAnalog);
|
||||
furi_hal_gpio_init_simple(pinD1, GpioModeAnalog);
|
||||
furi_hal_gpio_init_simple(pinD0mosfet, GpioModeAnalog);
|
||||
furi_hal_gpio_init_simple(pinD1mosfet, GpioModeAnalog);
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
#include "wiegand.h"
|
||||
|
||||
const GpioPin* const pinD0 = &gpio_ext_pa4;
|
||||
const GpioPin* const pinD0mosfet = &gpio_ext_pb3;
|
||||
const GpioPin* const pinD1 = &gpio_ext_pa7;
|
||||
const GpioPin* const pinD1mosfet = &gpio_ext_pa6;
|
||||
volatile int bit_count = 0;
|
||||
volatile bool data[MAX_BITS];
|
||||
volatile uint32_t data_fall[MAX_BITS];
|
||||
|
@ -14,7 +14,9 @@
|
||||
#include <storage/storage.h>
|
||||
|
||||
extern const GpioPin* const pinD0;
|
||||
extern const GpioPin* const pinD0mosfet;
|
||||
extern const GpioPin* const pinD1;
|
||||
extern const GpioPin* const pinD1mosfet;
|
||||
extern volatile int bit_count;
|
||||
#define MAX_BITS 42
|
||||
extern volatile bool data[];
|
||||
|
Loading…
Reference in New Issue
Block a user