Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

instructables

STONE TFT LCD + STM32 + Servo Head

by greyli1987

This project shows how to use the STONE display, STM32 microcontroller, and a servo head. The goal of the project is to
be able to control the servo head via the STONE display.

The hardware component uses a total of 3 hardware modules.

Step 1: STM32F030 Minimal Version

STONE TFT LCD + STM32 + Servo Head: Page 1


Product Description

Core: ARM 32-bit Cortex™-M3 CPU - 32kHz RTC oscillator with calibration

- Up to 72MHz operating frequency, up to Low power consumption


1.25DMips/MHz at 0 wait cycle of memory up to
1.25DMips/MHz at 0 wait cycle access of memory - Sleep, shutdown, and standby modes
(Dhrystone 2.1)
- VBAT power supply for RTC and backup registers Two
- Single-cycle multiplication and hardware division 12-bit analog-to-digital converters, 1μs conversion time
(up to 16 input channels)
Memory
- Conversion range: 0 to 3.6V
- Flash program memory from 64Kor 128K bytes
- Dual sample and hold function
- Up to 20K bytes of SRAM Clock, reset, and power
management - Temperature sensor

- 2.0 to the 3.6-volt power supply and I/O pins DMA

- Power-on/power-o reset (POR/PDR), programmable - 7-channel DMA controller


voltage monitor (PVD)
- Peripherals supported: Timer, ADC, SPI, I2C, and USART
- 4 to 16 MHz crystal oscillator Up to 80 fast I/O ports

- Embedded factory-tuned 8MHz RC oscillator - 26/37/51/80 I/O ports, all I/O ports can be imaged to 16
external interrupts; almost all ports tolerate 5V signals
- Embedded 40kHz RC oscillator with calibration

- PLL for CPU clock generation

STONE TFT LCD + STM32 + Servo Head: Page 2


Step 2: STONE STVC080WT-01 LCD Display

8-inch Smart TFT-LCD (Thin Film Transistor - Liquid construction machinery and vehicle equipment,
Crystal Display) Industrial Display Module electronic instruments, industrial control systems, power
industry, civil electronic equipment, automation
STONE STVC080WT-01 equipment, transportation equipment, etc.

Product advantages
The smart TFT LCD module with Cortex-M4 32-bit CPU
can be controlled by any MCU through the UART port
with simple hexagonal commands. 1. Touch terminal, thin- lm transistor LCD system.

STONE provides engineers with TOOLBOX software to 2. Any microcontroller can be controlled by a simple
easily and intuitively set up various functions on the GUI instruction set.
such as text, numbers, curves, image switching,
keyboard, progress bar, sliders, dialing, clock and touch 3. Cost-e ective HMI (Human Machine Touch Terminal).
buttons, data storage, USB download, video, and audio.
Operation steps
Engineers can easily adopt the TFT-LCD color user
interface and touch functionality on a variety of 1. Design a set of custom user interfaces.
industrial devices while reducing signi cant
development time and costs. 2. Connect the device to the TFT-LCD module via
RS232/RS485/TTL serial port.
Easy to use:
3. Write a control program in any microcontroller
1. Design a beautiful "graphical user interface" and set containing the instruction set to control the TFT-LCD
up various application functions on the GUI using our module (included in the product).
toolbox software.
Auxiliary Software
2. Connect directly to customer MCUs via RS232, RS485,
or TTL level, plug and play. 3. We provide three software programs to help the
operation of the TFT-LCD module.
3. Write an MCU program to control the TFT LCD module
using 4 simple hex commands. 1. Assistant software: Used to upload pictures, les, and
demo instruction sets.
For example, the image switches command:
2. Touch Control Software: for generating touch control
Send "0xA5 0x5A 0x04 0x80 0x03 0x00 0x01" to display les.
image-01
3. Font software: for generating font les.
0xA50x5A: frame title of each command
Working Principle
0x04: Data length
With the existing command set provided by the product,
0x80: Write registration instructions this TFT-LCD module can generate command
transmission and recognition using the master
0x03: Image switch instruction controller. The master controller receives commands
from the TFT-LCD module to operate the industrial
0x000x01: Image_ID, the serial number of the image device.

STONE TFT LCD + STM32 + Servo Head: Page 3


storage location Note: The engineer can use any microcontroller to
design the master controller.
Application areas: medical beauty equipment,

Step 3: Servo Head

Features: Operating voltage:4.8 v-6v

No-load speed:0.12sec/60degree(4.8V)

Torque:1.2 - -1.4kg/cm(4.8 v)
High-quality SG90 micro servo.
Operating temperature:-30 ~ 60°C
Can meet the needs of many RC robots, RC planes, RC
helicopters, RC boats. Deadband width:7usec

Operating voltage:4.8 v-6v Each servo size:3 * 3 * 1.1cm / 1.2 * 1.2 * 0.4in

Torque:1.2 - -1.4kg/cm(4.8 v). Connector wire length:15cm / 5.9in

No-load speed:0.12 sec/60 degree(4.8v). Weight per servo:9g / 0.3oz

Speci cation: Package size:13 * 9 * 3cm / 5.1 * 3.5 * 1.2in

Material:Plastic Package weight:65g / 2.3oz

Model:SG90

STONE TFT LCD + STM32 + Servo Head: Page 4


Step 4: Serial Port Program

void USART1_Init(void)
{

GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);

/* Connect GPIOs to USART1 RX&TX */

GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1); //Tx

GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1); //Rx

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; //USART1_TX | USART1_RX

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_1;

GPIO_Init(GPIOA, &GPIO_InitStructure);

USART_InitTypeDef USART_InitStructure;

USART_InitStructure.USART_BaudRate = 115200;

USART_InitStructure.USART_WordLength = USART_WordLength_8b;

USART_InitStructure.USART_StopBits = USART_StopBits_1;

USART_InitStructure.USART_Parity = USART_Parity_No;

USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

STONE TFT LCD + STM32 + Servo Head: Page 5


USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

USART_Init(USART1,&USART_InitStructure);

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

USART_Cmd(USART1,ENABLE);

NVIC_InitTypeDef NVIC_InitStructure;

/*****USART1 interrupt Config****/

NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

/************************************************

Function name USART1_IRQHandler

Function USART1 interrupt

Parameter None

Return value None

Author strongerHuang

*************************************************/

uint8_t reData[9],reDndex=0,reflag=0;

void USART1_IRQHandler(void)

if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //Receiving interruptions

USART_ClearITPendingBit(USART1,USART_IT_RXNE);

uint8_t res=USART_ReceiveData(USART1);//(USART1->DR); //Read incoming data

reData[reDndex++] = res;

if(reDndex==9)

reDndex=0;

reflag = 1;

STONE TFT LCD + STM32 + Servo Head: Page 6


void USART2_Init(void)

GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);

/* Connect GPIOs to USART1 RX&TX */

GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1); //Tx

GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_1); //Rx

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; //USART1_TX | USART1_RX

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_1;

GPIO_Init(GPIOA, &GPIO_InitStructure);

USART_InitTypeDef USART_InitStructure;

USART_InitStructure.USART_BaudRate = 115200;

USART_InitStructure.USART_WordLength = USART_WordLength_8b;

USART_InitStructure.USART_StopBits = USART_StopBits_1;

USART_InitStructure.USART_Parity = USART_Parity_No;

USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

USART_Init(USART2,&USART_InitStructure);

USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);

USART_Cmd(USART2,ENABLE);

NVIC_InitTypeDef NVIC_InitStructure;

/*****USART1 interrupt Config****/

NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

/************************************************

Function name USART1_IRQHandler

Function USART1 interrupt

Parameter None

Return value None


STONE TFT LCD + STM32 + Servo Head: Page 7
Return value None

Author strongerHuang

*************************************************/

void USART2_IRQHandler(void)

if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) //Receiving interruptions

USART_ClearITPendingBit(USART2,USART_IT_RXNE);

uint8_t res=USART_ReceiveData(USART2);//(USART1->DR); //Read incoming data

void USART3_Init(void)

GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

/* Connect GPIOs to USART6 RX&TX */

GPIO_PinAFConfig(GPIOB,GPIO_PinSource10,GPIO_AF_4);

GPIO_PinAFConfig(GPIOB,GPIO_PinSource11,GPIO_AF_4);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_1;

GPIO_Init(GPIOB, &GPIO_InitStructure);

USART_InitTypeDef USART_InitStructure;

USART_InitStructure.USART_BaudRate = 115200;

USART_InitStructure.USART_WordLength = USART_WordLength_8b;

USART_InitStructure.USART_StopBits = USART_StopBits_1;

USART_InitStructure.USART_Parity = USART_Parity_No;

USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

USART_Init(USART3,&USART_InitStructure);

USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);

USART_Cmd(USART3,ENABLE);

STONE TFT LCD + STM32 + Servo Head: Page 8


NVIC_InitTypeDef NVIC_InitStructure;

/*****USART1 interrupt Config****/

NVIC_InitStructure.NVIC_IRQChannel = USART3_6_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

USART_ClearITPendingBit(USART3,USART_IT_RXNE);

USART_ITConfig(USART3, USART_IT_ORE, ENABLE); // Open interrupt

void USART6_Init(void)

GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6,ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);

/* Connect GPIOs to USART6 RX&TX */

GPIO_PinAFConfig(GPIOA,GPIO_PinSource4,GPIO_AF_5);

GPIO_PinAFConfig(GPIOA,GPIO_PinSource5,GPIO_AF_5);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_1;

GPIO_Init(GPIOA, &GPIO_InitStructure);

USART_InitTypeDef USART_InitStructure;

USART_InitStructure.USART_BaudRate = 115200;

USART_InitStructure.USART_WordLength = USART_WordLength_8b;

USART_InitStructure.USART_StopBits = USART_StopBits_1;

USART_InitStructure.USART_Parity = USART_Parity_No;

USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

USART_Init(USART6,&USART_InitStructure);

USART_Cmd(USART6,ENABLE);

NVIC_InitTypeDef NVIC_InitStructure;

/*****USART1 interrupt Config****/

NVIC_InitStructure.NVIC_IRQChannel = USART3_6_IRQn;

STONE TFT LCD + STM32 + Servo Head: Page 9


NVIC_InitStructure.NVIC_IRQChannelPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

USART_ClearITPendingBit(USART6,USART_IT_RXNE);

USART_ITConfig(USART6, USART_IT_ORE, ENABLE); // Open interrupt

void USART3_6_IRQHandler(void)

uint8_t res;

if( USART_GetITStatus(USART6,USART_IT_RXNE) != RESET )

USART_ClearITPendingBit(USART6,USART_IT_RXNE);

res=USART_ReceiveData(USART6);//(USART1->DR); //Read incoming data

else if( USART_GetITStatus(USART3,USART_IT_RXNE) != RESET )

USART_ClearITPendingBit(USART3,USART_IT_RXNE);

res=USART_ReceiveData(USART3);//(USART1->DR); //Read incoming data

else if(USART_GetITStatus(USART6, USART_IT_ORE) == SET) //Receiving interruptions

USART_ClearITPendingBit(USART6,USART_IT_ORE);

Step 5: GUI Using Tool Software 4.3 Tool Editing Page

Import the prepared jpg image into the software

STONE TFT LCD + STM32 + Servo Head: Page 10


Step 6: STONE TFT LCD + STM32 + Servo Head Effect Picture

We just need to connect the STM32 board, the servo head, the display and the power supply. Drag the progress bar at
the top of the STONE display to control the activity of the servo head.

STONE TFT LCD + STM32 + Servo Head: Page 11

You might also like