cancel
Showing results for 
Search instead for 
Did you mean: 

Few questions about STM32 microcontrollers

KMiko.1
Associate III

Hello, I have a few questions about STM32 microcontrollers:

  1. I want to create a personalized card and use CAN, RS485, I / O, ... to connect several devices
  2. I need an HMI to control the controller (touchgfx? Or Visual studio?)
  3. I want a clear program (main program and call library)
  4. I want to update everything automatically via a C# program (under visual studio) or command lines with the windows console

So ...

  1. Where can I find a card with all my needs?
  2. What is the best thing to do to create a personalized interface? Can I exchange data with windows and C# program ?
  3. Are there any libraries where you just have to call the functions you need? For example I noticed for the HAL CAN library that there was all the configuration in the MAIN program, I would like to only have to call the READ and WRITE functions
  4. Is it possible to update the microcontroller program (and the interface if I am using touchgfx) through C# or the windows console? (I think yes with ST Link)

In the past I only used Programmable Logic Controllers, with all communications built in, so sorry if my questions are "wrong"

  Thanks everyone!

14 REPLIES 14
Javier1
Principal

That sounds like is going to keep you entertained for a loong time.

The solution most of devices similar to yours came up with is:

Taking the entire HMI out of the stm32 chip, use a UART or USB to connect with a PC running your GUI in c#.

Or you meant your device needs to have an embedded screen?

> That sounds like is going to keep you entertained for a loong time.

I second that. Perhaps even an understatement...

Perhaps a Cortex A board, and a Linux-based environment ?

CAN and RS485 are less likely on on eval boards for hobbyist, and more common for industrial usage.

And a nice HMI on smaller MCUs is either complex or resource-consuming, or both.

KMiko.1
Associate III

Hello and thank you both for your answers.

I am in the industrial field, I am looking to replace PLCs (which we currently use) to start on the microcontroller type STM or PIC (microchip).

I already have a foot in the latter (I developed applications and cards with ATMega but it was much easier thanks to the arduino community behind)

The goal is to create a card with a microcontroller capable of communicating with equipment (I/O, RS485, CAN, ...) and to have an HMI under visual studio. And therefore to communicate with this HMI (data exchange) why not in Modbus.

This system makes it possible to have a remote HMI capable of updating itself and of retrieving the microcontroller update file in order to program the latter transparently.

I don't know if STM or microchip is the best to do this (I think it's the same)

Paul1
Lead

1. Make your own card(s).

1a. Start with a demo board (Nucleo...) and maybe a breadboard. The ST demos have headers so easy to jumper to a breadboard circuits like DIP RS-485 driver ICs.

1b. With STM32 ensure select IC with RS-485 DE signal (Not STM32F4, we use STM32L4 and STM32H7 for RS-485 TxEnable signal)

2. We use http://www.stone-hmi.com, this allows us to change touchscreen size with no change to our board, everything by same connector for UART RS-232.

We didn't find reliable larger screens that worked with ST TouchGFX (or Microchip Harmony).

EDT did have some with STM32 MCUs, but the combinations didn't meet our needs.

It comes down to quantity, are you making <1000/year or >10000/year?

For our specialty project we had to avoid SDCard and most graphics interfaces HDMI/DSI/... as they all required licence fees that just didn't amortize well for our quantities.

3. Yes. And if you can't find them just ask on here. Configure IC first with STM32CubeMX. You can even select existing demo boards to initialize MX.

3a. Our STM32 CAN still in progress, but was much easier than Harmony (Actually CAN in Harmony2 sorta worked, but Harmony3 was a mess a year ago)

4. We bootload our boards from a USB stick on our central module, and share the firmware loads over our proprietary system throughout our network. We also have a logfile on the stick which is great when doing diagnostics in the field (customer can just email the logfile to you and often you can resolve without a visit, standard USB stick fits to any PC). You can also firmware update by USB/UART/more with a PC or other computer, there are examples.

*. All our new boards are STM32,

We were using Microchip Harmony but was just years of poor documentation, and the months wait on harmony support answers was a killer. When they did answer it was usually "Is this still an issue" because it took them months to get to our queries. When I saw the Harmony3 posts echoing the ongoing issues/quality/support from Harmony1 and Harmony2 we decided to change. The ST has been so much nicer, not perfect, but support answers are quick, documentation and examples are cleaner, tools are less buggy. Less errata but still need to check IC errata before ordering PCBs. Things take weeks with ST instead of months with Harmony.

Paul

KMiko.1
Associate III

Thank you very much for your answer, from what I understand having a screen directly on the processor, consumes a lot of resources and requires a lot of things (paying)

So from what I see I will start with the following solution: software interface in visual studio, connected by USB to the microprocessor and the processor takes care of managing the equipment.

I looked a little at the complexity of STM and Microchip, the code under STM seems to be very quickly "too" complete I have the impression that everything is in mess ...

In don't find any good tutorial to configure CAN and RS485 with CubeMX and then export code and try to understand it

Paul1
Lead

RS485 is just UART with DE, send and receive is same as any UART/USART example. In MX ensure enable the DE pin and connect it to both the Receive Enable/Transmit enable pins on your RS485 Driver IC (or only Tx Enable if you want Rx always enabled). You can set the polarity of this signal in the UART settings in MX so shouldn't need an inverter.

CAN: I've misplaced where we started for CAN.

I'd start by looking for your chosen STM32xxxx under MOOC in STM32 Education for examples matched to your MCU.

I'd also do a general search of MOOC/STM32 Education for CAN/J1939/NMEA2000 (variants of CAN).

Useful links for getting started in STM32:

- STM32 Tutorials/Examples:

- Misc Examples we've found helpful:

Not as useful:

  • The Examples under this tree are pre-STM32Cube as of 2020Nov: C:\Users\Paul\STM32Cube\Repository

Paul

KMiko.1
Associate III

Thank you very much for your answers, I learned a lot since the day before yesterday, even too much I would say by dint of informing myself, my head is full!

I asked myself a bit to think about the best way to achieve what I want and came to this conclusion:

1- I am not an expert in microcontrollers and it is so complete that I risk getting lost

2- it is necessary to be able to develop the functionalities without changing the processor each time

So I came to this:

- Interface and program under visua studio (contains all the intelligence)

- The program for sending frames with the modbus protocol (best for exchanging data) to the microcontroller

- The micro is responsible for reading the modbus data, and depending on this: activates outputs (relays) sending frames (CAN) it is also partly responsible for reading the CAN data and sending all this via modbus .

Suddenly, I have to realize:

- Activate CAN1 and CAN2

- Add MODBUS

- Use GPIO

And the function that drive all of this

So, I have been looking for two days non stop for examples of programs to give me an idea but nothing ... I wonder if I will not migrate to microchip ...

Paul1
Lead

So you want to have a PC with code written in Visual Studio controlling MODBUS and CAN?

In that case why don't you just do everything on PC, maybe with:

  • adapter - USB to MODBUS/RS485 (Maybe you don't need this at all if only doing CAN?)
  • adapter - USB to CAN

Then you'll only have one piece of code to maintain (code in PC only).

Unless this is a project for a course where you need to develop MCU code?

CAN Protocol Analyzers:

Paul