Posted on 4 Comments

SIMcom A7670c LTE Module with UART

This module can be used with Indian 4G bands. This means it can be used with Vodafone, Airtel or Jio networks.

This module comes preconfigured with AT commands.

The module offers UART to issue commands.

Since the communication speed is really high so the 3.3V and 5V UART lines can not be used for communication with the board.

The company offers technical documents on hardware design for the UART.

Here is the circuit I am using for converting the 1.8V to 5V using the BC547 NPN BJT transistor.

I connected the UART on the module to a USB-to-Serial convertor.

I can then use AT commands to control the module functions like call, SMS, data etc.

Here is the basic AT commands

  • For making calls,SMS or data etc from the module you will need a Registered SIM card
  • For making calls from module
    ATDxxxxxxxxxx;
    x’s are your telephone number
    semi colon must be inserted at the end
  • For issuing DTMF tones
    AT+VTS=[number],[duration]
    Example: DTMF tone for digit 8
    AT+VTS=8,500
  • For Receiving Incoming Calls
    ATA
  • For Disconeccting On-going call
    AT+CVHU=0
    ATH
  • For Sending SMS
    AT+CMGF=1
    AT+CMGF=”+[country ISD code][Mobile number]”
    after sending the above commands you can send your message.
    At the end of your message you need to send number 26 (hex 1A) to mark the end of your message.
Posted on Leave a comment

Raspberry Pi Pico

This board is using an RP2040 microcontroller. Which is using a dual-core arm cortex m0+ processor. The speed of the clock signal can be changed on the fly up to 133MHz.

The Pico board is castellated so that you can mount this board directly on your PCB. This board also has options for mounting male/female headers. which is handy for prototyping on a breadboard.

It can be programmed using micropython and ‘C’ programming language.

Raspberry Pi Pico datasheet
Getting started with Raspberry Pi Pico: C/C++ development
Raspberry Pi Pico C/C++ SDK
Raspberry Pi RP2040 datasheet
Hardware design with RP2040

Technical Specifications

21 mm × 51 mm form factor
RP2040 microcontroller chip designed by Raspberry Pi in the UK
Dual-core Arm Cortex-M0+ processor, flexible clock running up to 133 MHz
264KB on-chip SRAM
2MB on-board QSPI Flash
26 multifunction GPIO pins, including 3 analogue inputs
2 × UART, 2 × SPI controllers, 2 × I2C controllers, 16 × PWM channels
1 × USB 1.1 controller and PHY, with host and device support
8 × Programmable I/O (PIO) state machines for custom peripheral support
Supported input power 1.8–5.5V DC
Operating temperature -20°C to +85°C
Castellated module allows soldering direct to carrier boards
Drag-and-drop programming using mass storage over USB
Low-power sleep and dormant modes
Accurate on-chip clock
Temperature sensor
Accelerated integer and floating-point libraries on-chip

Getting Started with MicroPython on Raspberry Pi Pico using Thonny IDE

Posted on 3 Comments

Mini STM32 V3.0

This development board has an STM32F103RB microcontroller. In this development board,

  • 8 Mhz Crystal
  • 32.768 Khz Crystal
  • 2.8 inch TFT-LCD Touch screen.
    The screen is a TFT-LCD Panel driven by the ili9325 driver.
  • PL2303 USB to Serial IC
  • User Programmable USB port
  • battery holder
  • Potentiometer
  • JTAG Port for debug and programming
  • 2 User programmable LED (both Red Colour)
  • 2 User configurable Push button
  • Boot 0 Button
  • Reset Button
  • AMS117 3.3 V LDO

Mini STM32 Schematic Diagram

2.8 inch TFT LCD Schematic

You can develop a program for this board using Keil, IAR or STM32 Cube IDE

You can program the microcontroller by holding the BOOT0 button and then while holding the boot button pressing the RESET button.
Which enable you to program the microcontroller using UART.

You will need STM32 Cube Programmer to upload hex files into the microcontroller

You can also program the Board using the JTAG port.

You can use the below application note for that.

How to use the ST-LINK/V2-1 in STM32L476G-DISCO Board to program the STM32 on an external application board

How To / Guides

Posted on Leave a comment

How to redirect printf() to USART in STM32f103RB using STM32Cube IDE

Printf() function can be redirected to USART and also towards SWO.

Here you will see how to redirect printf() to USART in STM32f103RB

You need to rewrite this code in your main.c file

/*
* Function Name: _write
* Function Description: Redirect the printf() statement towards the UART using the HAL_UART_Transmit
Author: Abhay

*/
int _write(int fd, char* ptr, int len) {
    HAL_UART_Transmit(&huart1, (uint8_t *) ptr, len, HAL_MAX_DELAY);
    return len;
}

If you have created your project using STM32CubeMX or STM32 Cube IDE, then you can rewrite it in between USER CODE BEGIN 0 as shown

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
int _write(int fd, char* ptr, int len) {
    HAL_UART_Transmit(&huart1, (uint8_t *) ptr, len, HAL_MAX_DELAY);
    return len;
}
/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */

  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */
}

After adding the code, connect the uart to your laptop or computer using serial to USB adapter and open serial Terminal application like YAT.
Then you will be able to see printf message over there.

Posted on Leave a comment

How to use the ST-LINK/V2-1 in STM32L476G-DISCO Board to program the STM32 on an external application board

Here is the video showing all the steps.

ST-Link V2-1 on STM32L476G-Disco Board

To use the ST-LINK/V2-1 to program the STM32 on an external application board (out of the STM32L476VGT6 onboard), remove the two jumpers from CN3 as shown in the above figure in red, and connect the board to the CN4 software debug connector according to Table.
Make sure the jumpers JP6.3V3, and JP5.OFF are set.
JP3, must be ON if CN4 pin 5 (NRST) is used in the external application board.

PinCN4 FunctionJTAG PIN NumberJTAG NameNote
1VappVDD from ApplicationDo not Connect Vapp to JTAG.
2SWCLKSWD Clock9TCK
3GNDGround1 to 9GND
4SWDIOSWD data input/output7TMS
5NRSTRESET of target MCU15nSRST
6SWORESERVED

Note: Do not connect Vapp to JTAG on the external board unless you know about the power domain of the external board.
Power the board separately.

You can use STM32CubeProgrammer to read the memory and also write the hex file into the microcontroller.

Here I am using mini stm32 v3.0 as an example.

The mini stm32 v3.0 has an STM32F103RB microcontroller along with a JTAG interface for programming and debugging.

Posted on Leave a comment

How to make ATmega GPIO work as Input or Output

AVR Input Output Port programming means you have to program its GPIO pins.

GPIO – General Purpose Input and Output

The GPIO is a very important peripheral of the microcontroller. Using the GPIO we can use the same exact pin for Input or Output.

To make the PIN input or output we need to set a bit in the data direction register DDR

Now lets take the example of ATmega16. Atmega 16 has 4 ports.
-PORT A
-PORT B
-PORT C
-PORT D

Each PORT has 8 pin
Each pin can be addressed individually
PortA.1 = Pin 1 of Port A
PA.1 = Pin 1 of Port A

To make a PIN input/output
DDRx = 1 // make the pin output
DDRx = 0 // make the pin input

Here x is to be replaced by port number
DDRA = DDR for port A


To Set the value of the pin we use
PORTx = 1 // set all the pins of the port to HIGH
PORTx = 0// Set all the pins of the port to LOW

To Read the value of the pin we use
PINx
usage:
int read_in;
DDRx = 0;
PORTx = 1; // This will enable the internal Pull up
read_in = PINx; // read_in variable will store the value in PINx

If the internal pull-up is not enabled than then value of the pin will always be in a floating state and it will not tell the accurate result.
When the internal pull-up is not enabled then the external pull has to be enabled by the user.

Posted on Leave a comment

Microcontroller + FPGA

The microcontroller performs the task of minimization of peripherals on the PCB by miniaturization and integrating them in one housing.

FPGA on the other hand is used to implement digital logic. Since FPGA can be programmed in a remote location using standard tools. And the growing market of the FPGA has made the tools required to program and debug very affordable.

There are microcontrollers that have FPGA built inside of them. They can implement very small digital logic. But that will result in the minimization of components on the PCB.

They bridge the gap between a dedicated FPGA and a microcontroller. For small applications which only needs a very small custom logic design, they can be used.

Programmable System-On-Chip (PSoC) from Cypress semiconductor and C2000 TMS320F28379D from Texas Instrument are such examples.

The FPGA can be used to implement the Finite State machines Logic.

The microcontroller manufacturer also provides additional peripheral which can be connected in a customized fashion using the crossbar interconnects to make a custom peripheral. And since the logic is not outside there is high security.

FPGA provided on these microcontrollers cannot replace the traditional FPGA.

PSoC from Cypress is highly configurable and along with digital logic, it also has analogue peripheral such as op-amps and comparator which can be used to create custom logic.

Posted on Leave a comment

PAL video signal

PAL Video Signal

Pal video signal consists of 625 individual lines.
In 1 second we have 25 frames. Each frame is made from 625 horizontal lines.

each line is 64 microseconds long.

Out of the 625 horizontal lines, few lines are used for vertical synchronization.

Each Horizontal line consist of
-Horizontal Sync Start
– Black Level
– Color Burst (this can be ignored if you are using Black and white Signal)
– Video Signal
-Horizontal Sync End

Vertical Sync lines consist of a transition section. In older analogue based Television this transition is used by the analogue system to shift the position of the electron gun from the bottom to the top of the screen.

Vertical Syncline is made up of 32-microsecond periods. A total of 10 periods mark the transition of vertical sync.

Posted on Leave a comment

Analog Modulation based Transmitter using ATmega16a

Analog Modulation is the very basic form of modulation that can be produced using very basic components.

The ATmega16a is used to generate a square wave. The frequency can be generated by carefully adjusting the 8-bit PWM Timer.

Using the above method a Carrier Signal is generated.

You can hear the carrier pulses on AM Radio. The reception is full of noise and interference.

The range of such signals is not good. Since the EM wave has very low power.

The circuit is given below.

AM transmitter using ATmega16a

AM Transmitter circuit

/*
 * AM Transmitter.c
 *
 * Created: 11/10/2021 9:59:04 PM
 * Author : abhay
 */ 
#define F_CPU 16000000
#include <avr/io.h>
#include <util/delay.h>


void delay1(){
	_delay_ms(20);
}

int main ()
{
	
	TCCR0 = (1 << WGM01) | (1 << COM00) | (1 << CS00);
		DDRB|=(1<<PB3);  /*set OC0 pin as output*/
	
	while (1)
	{
		OCR0 = 4;	// 1600 KHz
		
		delay1();    //This delay will create pulse of carrier frequency

		OCR0 = 12;	//  615 kHz

		delay1();    //This delay will create pulse of carrier frequency



	}
}

PWM signal is being produced by an 8bit timer of the microcontroller.

The formula used for the value of OCR0

Where

f clk_I/O = 16000000

N = 1

OCRn = (1,2,3 … 255)

Frequency calculated using the formula

The Antenna Used for AM Transmission in this setup is of very small length. Its range and quality get improved if you touch the antenna with your bare hands.

Posted on Leave a comment

Up Counting Timer using STM32L476

I have created this Upcounting timer using the RTC of STM32L476vgt. In this timer, time will keep on incrementing and it will be displayed using the onboard LCD.

How to Read RTC of STM32L476G-DISCO

Here is the code that I have used to make this.

I have used STM32 CUBE IDE for programming and debugging purposes.

  MX_RTC_Init();				// RTC initalization and configuration created using integrated cube mx
  /* USER CODE BEGIN 2 */
  BSP_LCD_GLASS_Init();
  BSP_LCD_GLASS_Clear();
  BSP_LCD_GLASS_DisplayString((uint8_t *)"HALLO");
  HAL_Delay(1000);
  BSP_LCD_GLASS_DisplayString((uint8_t *)"EXASUB");
  HAL_Delay(2000);


  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */

  RTC_TimeTypeDef readTime;	// RTC Time structure
  RTC_DateTypeDef readDate;	// RTC Date structure
  while (1)
  {
    /* USER CODE END WHILE */
    MX_USB_HOST_Process();

    /* USER CODE BEGIN 3 */

    char bufSec[2];
    char bufMin[2];
    char bufHou[2];
    HAL_RTC_GetTime(&hrtc, &readTime, RTC_FORMAT_BIN);	// function to read time from RTC shadow register
    HAL_RTC_GetDate(&hrtc, &readDate, RTC_FORMAT_BIN);	// function to read date from RTC shadow register
   itoa(readTime.Seconds,bufSec,10);
   itoa(readTime.Minutes,bufMin,10);
   itoa(readTime.Hours,bufHou,10);
   if(readTime.Seconds == 0){
	   BSP_LCD_GLASS_Clear();
   }
   if(readTime.Minutes == 0){
	   BSP_LCD_GLASS_Clear();
   }
   /*
    if(readTime.Hours == 0){
   	   BSP_LCD_GLASS_Clear();
      }
   */
   BSP_LCD_GLASS_DisplayChar((uint8_t *)&bufHou[0], POINT_OFF, DOUBLEPOINT_OFF, 0);
   BSP_LCD_GLASS_DisplayChar((uint8_t *)&bufHou[1], POINT_OFF, DOUBLEPOINT_ON, 1);
   BSP_LCD_GLASS_DisplayChar((uint8_t *)&bufMin[0], POINT_OFF, DOUBLEPOINT_OFF, 2);
   BSP_LCD_GLASS_DisplayChar((uint8_t *)&bufMin[1], POINT_OFF, DOUBLEPOINT_ON, 3);
   BSP_LCD_GLASS_DisplayChar((uint8_t *)&bufSec[0], POINT_OFF, DOUBLEPOINT_OFF, 4);
   BSP_LCD_GLASS_DisplayChar((uint8_t *)&bufSec[1], POINT_OFF, DOUBLEPOINT_OFF, 5);

    HAL_Delay(1000);									// HAL Delay of 1000 millisecond
  }
  /* USER CODE END 3 */
}