Forum

Please or Register to create posts and topics.

STONE HMI +STM32 +COFFEE MAKER

Page 1 of 2Next

project Introduction

Recently received a project is to be a coffee machine, household requirements with a touch screen operation, the function is good, is above the screen selection may not be very good, fortunately, this project I can decide what MCU to use myself also can be used to decide what the screen, so I chose the STM32 of this kind of simple and easy MCU to use, display screen I chose STONE's touch screen display, the screen is simple and easy to use, My STM32 MCU only through UART communication is ok with it.

STONE serial LCD display screen which can communicate through the serial port of MCU. At the same time, the logic design of the UI interface of this display screen can be designed directly by using the STONE Designer provided by STONE's official website, which is very convenient. So I'm going to use it for this coffee machine project.

Coffee machine display screen function introduction

This project has the following functions:

•    Displays the current time and date

•    There are four buttons on the display for americano, latte, cappuccino, and espresso.)

•    Displays the current amount of remaining coffee beans, milk, and coffee sugar

•    A text display box displays the current state

GUI design

STM32F103RCT6

STM32F103RCT6 MCU has powerful functions. Here are the basic parameters of the MCU:

•    Series: STM32F10X

•    Kernel: ARM - COTEX32

•    Speed: 72 MHZ

•    Communication interface: CAN, I2C, IrDA, LIN, SPI, UART/USART, USB

•    Peripheral equipment: DMA, motor control PWM, PDR, POR, PVD, PWM, temperature sensor, WDT

•    Program storage capacity: 256KB

•    Program memory type: FLASH

•    RAM capacity: 48K

•    Voltage - power supply (Vcc/Vdd) : 2 V ~ 3.6 V

•    Oscillator: internal

•    Operating temperature: -40°C ~ 85°C

•    Package/housing: 64-lqfp

void uart_init(u32 bound){

GPIO_InitTypeDef GPIO_InitStructure;

USART_InitTypeDef USART_InitStructure;

NVIC_InitTypeDef NVIC_InitStructure;

 

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA, ENABLE); //Clock

  

//USART1_TX   GPIOA.9

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //PA.9

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

  GPIO_Init(GPIOA, &GPIO_InitStructure);//GPIOA.9

   

  //USART1_RX   GPIOA.10

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;//PA10

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

  GPIO_Init(GPIOA, &GPIO_InitStructure);//GPIOA.10  

 

  //Usart1 NVIC

NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3 ;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

 

   //USART

USART_InitStructure.USART_BaudRate

 

u8 USART_RX_END=0;

void USART1_IRQHandler(void)                 //Uart1 handler

{

u8 Res;

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

{

if(USART_RX_END==0)

{

Res =USART_ReceiveData(USART1);

USART_RX_BUF[USART_RX_STA]=Res ;

USART_RX_STA++;

if(USART_RX_STA>8)

{

USART_RX_END=1;

}

}

}

}

GPIO

In the user interface of this project, there are a total of four buttons, which are actually the making of four kinds of coffee. In the coffee machine, controlling the number of coffee beans, milk consumption, and water flow of different coffees is actually realized by controlling sensors and relays, while I simply control the GPIO pin first.

void PAD_INIT(void)

{

 

 GPIO_InitTypeDef  GPIO_InitStructure;

 

 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOE, ENABLE);  //ENABLE CLOCK

 

 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3;  //-->PB config

 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;  // PP OUT

 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;  //GPIO SPEED 50MHz

 GPIO_Init(GPIOB, &GPIO_InitStructure);  

 GPIO_SetBits(GPIOB,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3);  //config out hight

Timer

When initializing the timer, specify the frequency division coefficient PSC, here is our system clock (72MHz) for frequency division

Then specify the reload value arr, which means that when our timer reaches this arr, the timer will reload other values.

For example, when we set the timer to count up, the value of the timer count is equal to arr and will be cleared by 0 and recalculated

The timer count is reloaded and once is an Update

Calculate the Update time formula Tout = ((arr+1)*(PSC +1))/Tclk

Formula derivation: Tclk is the clock source of the timer, here is 72Mhz

We divide the allocated clock frequency, specify the frequency division value as PSC, then divide our Tclk into PSC +1, the final frequency of our timer is Tclk/(PSC +1) MHz

So what we mean by the frequency here is that we have 1s of Tclk over PSC +1 M Numbers (1M=10 ^ 6), and the time for each number is PSC +1 /Tclk, and it's easy to understand that the inverse of the frequency is the period, and the period for each number here is PSC +1 /Tclk seconds and then we go from 0 to arr is (arr+1)*(PSC +1)/Tclk

For example, let's set arr=7199 and PSC =9999

We divided 72MHz into 9999+1 is equal to 7200Hz

This is 9,000 counts per second, and each count is 1/7,200 of a second

So we're recording 9,000 Numbers here to go to the timer update (7199+1)*(1/7200)=1s, so 1s goes to an update.

 

void TIM3_Int_Init(u16 arr,u16 psc)

{

  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;

NVIC_InitTypeDef NVIC_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //clock

TIM_TimeBaseStructure.TIM_Period = arr;

TIM_TimeBaseStructure.TIM_Prescaler =psc;

TIM_TimeBaseStructure.TIM_ClockDivision = 0; //TDTS = Tck_tim

TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  

TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE );

NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;  

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;  

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;  

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

I needed a timer interrupt to time how much coffee and milk I had left, so I wrote the code for the timer driver and wrote a timer interrupt function

//handler

void TIM3_IRQHandler(void)   //TIM3

{

if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)

{

WatchDog

To prevent the system from crashing while the program was running, I added the watchdog. In fact, all projects that use the MCU generally use a watchdog.

STM32 has two built-in watchdogs, providing greater security, time accuracy, and flexibility. Two watchdog devices (independent watchdog and window watchdog) can be used to detect and resolve faults caused by software errors. When the counter reaches a given timeout value, an interrupt (window watchdog only) or system reset is triggered.

Independent watchdog (IWDG) :

Driven by a dedicated low-speed clock (LSI), it works even if the master clock fails.

It is suitable for use in situations where the watchdog is required to work completely independently outside the main program and requires low time accuracy. Window watchdog (WWDG) :

Driven by the clock from APB1 clock after frequency division. Detect abnormally late or premature application operation through a configurable time window. Suitable for programs that require watchdogs to function in precise timing Windows.

int main(void)

 {

delay_init();       //delay init

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //NVIC INIT

uart_init(115200);  //UART INIT

  PAD_INIT();      //Light Init

IWDG_Init(4,625);        

while(1)

{

if(USART_RX_END)

{    

switch (USART_RX_BUF[5])

{

case Espresso:

CoffeeSelect(Espresso,USART_RX_BUF[8]);

break;

case Americano:

CoffeeSelect(Americano,USART_RX_BUF[8]);

The Main logic in the Main function is as follows:

u8 timer_cnt=0;

void TIM3_IRQHandler(void)   //TIM3

{

if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)

{

TIM_ClearITPendingBit(TIM3, TIM_IT_Update  );

timer_cnt++;

if(timer_cnt>=200)

{

milk_send[6]=milk();

Finally, add the code in the timer interrupt:

In the timer interrupt, my goal is to check how much coffee and milk is left, and then send the detected value to the display screen through a serial port.

Measuring how much milk and coffee beans are leftover is usually done by sensors. Simple methods include pressure sensors, which measure the current weight of the milk and coffee beans to determine how much is left over.

Demo

It is the introductory section that describes the literary works that the author talked about in the project. It also includes recognition of all those who helped complete the project. by essay writer uk

Hi, I appreciate your business, but why complicate things? A lot of classics espresso or latte machines(review) haven't sensor panels and have existed for decades without any negative comment. And, as far as I know, touch screens are break easily and non-stable. What do you think about it?

Quote from FrankMcG on September 2, 2021, 11:13 am

Hi, I appreciate your business, but why complicate things? A lot of classics espresso or latte machines(review) haven't sensor panels and have existed for decades without any negative comment. And, as far as I know, touch screens are break easily and non-stable. What do you think about it?

Thank you for your reply sir, I am not a business person, I am an electronics hobbyist and I have no intention to use the designed project as a business. I simply want to share the project.

FrankMcG has reacted to this post.
FrankMcG

Shaw Merchant Group, LLC. Our goal is to gather accurate, updated information and assist you in your research. We recommended that you check ... Credit Card Processing Sales Jobs

Thank you for such a well written article. It’s full of insightful information and entertaining descriptions. Your point of view is the best among many. 꽁머니 3만

Discover Huawei mobile repair in UAE. Huawei being the greatest smartphone manufacturers in terms of product innovation and quality. The care also deserves the same standards .This is where you can rely on the expertise of Axiom care team when it comes to Huawei phone repair service. All type of phones complaints are taken care by the repair experts who are available at your request, right from broken display to software support available. In the event of your Huawei phone breakdown, please visit our care center or book online for a pick up request. Authorized Huawei repairs at affordable price at Axiom care. Huawei mobile repair

wonderful! These are fantastic! This is a very remarkable part of the text. In addition, you can join interesting entertainment news at drift hunters.

Voice Over Services | Voice Dubbing Production - GothamLab Find the right voice over services for your project, in any language, Gothamlab offering quality voice over transalation and voice dubbing services since 2004. New York's leading voiceover agency. Hire professional voice over male & female artists.  dubbing services

Voice Over Services | Voice Dubbing Production - GothamLab Find the right voice over services for your project, in any language, Gothamlab offering quality voice over transalation and voice dubbing services since 2004. New York's leading voiceover agency. Hire professional voice over male & female artists. dubbing services

Page 1 of 2Next