Provide precise and dependable relay control activated by magnetic fields. It empowers you to optimize applications in security systems and industrial automation with ease.
A
A
Hardware Overview
How does it work?
Hall Switch Click is based on the AH1389, an ultra-sensitive dual output unipolar Hall Effect switch, from Diodes Incorporated. This IC utilizes Hall effect - a phenomenon in which the current flow, or rather - the path of the conductor electrons is affected by the magnetic field. Due to the fact that the path of the electrons is curved, a buildup of positive charges is formed on the opposite side of this path, and the voltage is generated. If a voltmeter is connected to the path perpendicular to the current path and the magnetic field, a voltage will be detected. The AH1389 has the ability to detect both the north and south poles of the magnetic field. The magnetic field from the south pole magnet will pull the output 2 to a LOW (active) state, while the magnetic field from the north pole magnet will pull the output 1 to a LOW
(active) state. The IC features several sections for the signal conditioning. It also provides the hysteresis for the output activation, to avoid erratic triggering. The magnetic field strength which activates outputs is about ±25 G, while the field strength under ±20 G will deactivate outputs, giving a hysteresis of typical 5 G. The positive and negative sign is used with respect to the magnet poles (north pole has a negative sign prefix). The outputs of the AH1389 IC are routed to the operational amplifiers, which work as the inverting comparators. When the output of the AH1389 IC is activated - pulled to a LOW voltage level, the output from the comparator will be set to 5V. This will cause biasing of the BJT, allowing current flow through the relay coil, and thus forming a magnetic field necessary for closing the relay
contacts. A Schottky diode across the relay coil prevents the reverse kickback voltage, which forms due to the inert nature of the coils. Activation of the relay coils is indicated by the red and blue LEDs, respectively. Two outputs of the AH1389 IC are also routed to the mikroBUS pins: north pole output (1) is routed to the CS pin and the south pole output (2) is routed to the INT pin of the mikroBUS™ so that the status of the IC can be monitored by the MCU. Two varistors are used to prevent voltage peaks when the load is connected or disconnected on the relay output contacts. The output contacts are further routed to the screw terminals, which allow up to 10A. However the relays allow up to 5A for 250V AC/30V DC, so the connected load should not exceed these power ratings.
Features overview
Development board
PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive
mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI
GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.
Microcontroller Overview
MCU Card / MCU
![default](https://dbp-cdn.mikroe.com/catalog/mcus/resources/PIC18F57Q43.jpeg)
Architecture
PIC
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
48
RAM (Bytes)
8196
You complete me!
Accessories
Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic
![Hall Switch Click Schematic schematic](https://dbp-cdn.mikroe.com/catalog/click-boards/resources/1ee790a7-e336-6a02-b623-0242ac120009/schematic.webp)
Step by step
Project assembly
Track your results in real time
Application Output
This Click board can be interfaced and monitored in two ways:
Application Output
- Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
UART Terminal
- Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Software Support
Library Description
This library contains API for Hall Switch Click driver.
Key functions:
hallswitch_set_npole
- Function for turn on and turn off N Pole
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file
* \brief Hall Switch Click example
*
* # Description
* The application sets sensor magnetic pole
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes Driver init and turn OFF S-pole and N-pole
*
* ## Application Task
* Turns S and N on and off every 500 ms
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "hallswitch.h"
// ------------------------------------------------------------------ VARIABLES
static hallswitch_t hallswitch;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
hallswitch_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info(&logger, "---- Application Init ----");
// Click initialization.
hallswitch_cfg_setup( &cfg );
HALLSWITCH_MAP_MIKROBUS( cfg, MIKROBUS_1 );
hallswitch_init( &hallswitch, &cfg );
hallswitch_set_npole( &hallswitch, HALLSWITCH_POLE_NO_ACTIVE );
hallswitch_set_spole( &hallswitch, HALLSWITCH_POLE_NO_ACTIVE );
}
void application_task()
{
hallswitch_set_npole( &hallswitch, HALLSWITCH_POLE_ACTIVE );
Delay_ms ( 500 );
hallswitch_set_spole( &hallswitch, HALLSWITCH_POLE_ACTIVE );
Delay_ms ( 500 );
hallswitch_set_npole( &hallswitch, HALLSWITCH_POLE_NO_ACTIVE );
Delay_ms ( 500 );
hallswitch_set_spole( &hallswitch, HALLSWITCH_POLE_NO_ACTIVE );
Delay_ms ( 500 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
/*!
* \file
* \brief Hall Switch Click example
*
* # Description
* The application sets sensor magnetic pole
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes Driver init and turn OFF S-pole and N-pole
*
* ## Application Task
* Turns S and N on and off every 500 ms
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "hallswitch.h"
// ------------------------------------------------------------------ VARIABLES
static hallswitch_t hallswitch;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
hallswitch_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info(&logger, "---- Application Init ----");
// Click initialization.
hallswitch_cfg_setup( &cfg );
HALLSWITCH_MAP_MIKROBUS( cfg, MIKROBUS_1 );
hallswitch_init( &hallswitch, &cfg );
hallswitch_set_npole( &hallswitch, HALLSWITCH_POLE_NO_ACTIVE );
hallswitch_set_spole( &hallswitch, HALLSWITCH_POLE_NO_ACTIVE );
}
void application_task()
{
hallswitch_set_npole( &hallswitch, HALLSWITCH_POLE_ACTIVE );
Delay_ms ( 500 );
hallswitch_set_spole( &hallswitch, HALLSWITCH_POLE_ACTIVE );
Delay_ms ( 500 );
hallswitch_set_npole( &hallswitch, HALLSWITCH_POLE_NO_ACTIVE );
Delay_ms ( 500 );
hallswitch_set_spole( &hallswitch, HALLSWITCH_POLE_NO_ACTIVE );
Delay_ms ( 500 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END