Skip to main content
electronicsbasickid
Associate III
April 15, 2021
Solved

Can we use Visual Basic For Applications (VBA) to code a STM32 ?

  • April 15, 2021
  • 11 replies
  • 2703 views

Hi,

I have a project in which I have to connect my PC to a measurement device thanks to VBA. I would like to use a mcu in order to control a component related to the device. This component is a decoder using the mcu outputs as input signals. These signals changing with time.

I have to control the signals with the code controlling the measurement device. Indeed, they will be changing according to a variable used in this code. Therefore, I would like to know if it is possible to program a MCU such as a STM32L100RCT6 with VBA? And if not, is there any alternative that can help me control this kind of mcu via VBA?

Thank you in advance for your help,

Jay.

This topic has been closed for replies.
Best answer by Peter BENSCH

There are different steps:

  • The data transfer to the MCU, which can be done via UART communication. To do this, you need an UART interface on the PC, for which you can use a USB-UART converter (this is already integrated on the NUCLEO cards for a virtual COM port called VCP).
  • Access from VBA to this COM port: there are several suggestions on the Internet, e. in an article on Stackoverflow
  • Define the API, which data should be sent to the MCU and which data you expect in VBA - only those who know the project know how it is or should be defined
  • Create the program on the MCU to receive the commands/data and set the peripheral devices accordingly

Good luck!

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

/Peter

11 replies

Peter BENSCH
ST Technical Moderator
April 15, 2021

Programming via VBA would require a cross-interpreter, which currently does not exist.

You could define an API between VBA (PC) and MCU and send control data via e.g. a serial interface to the MCU, which provides the parameters for the MCU program.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
electronicsbasickid
Associate III
April 15, 2021

Hi,

thank you for your help. Any ideas on how I could make this API?

Andrew Neil
Super User
April 15, 2021

Depends what you want to do with it!

Look around at similar systems - see how they do it ...

Some examples:

AT Commands: https://en.wikipedia.org/wiki/Hayes_command_set

MIDI: https://en.wikipedia.org/wiki/MIDI

OSC; https://en.wikipedia.org/wiki/Open_Sound_Control

Firmata: http://firmata.org/wiki/Main_Page

etc, etc, ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Peter BENSCH
Peter BENSCHBest answer
ST Technical Moderator
April 15, 2021

There are different steps:

  • The data transfer to the MCU, which can be done via UART communication. To do this, you need an UART interface on the PC, for which you can use a USB-UART converter (this is already integrated on the NUCLEO cards for a virtual COM port called VCP).
  • Access from VBA to this COM port: there are several suggestions on the Internet, e. in an article on Stackoverflow
  • Define the API, which data should be sent to the MCU and which data you expect in VBA - only those who know the project know how it is or should be defined
  • Create the program on the MCU to receive the commands/data and set the peripheral devices accordingly

Good luck!

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
electronicsbasickid
Associate III
April 16, 2021

I was thinking about a STM32L100RCT6. Is it possible to use two different codes on the same serial port (usb) ?

Peter BENSCH
ST Technical Moderator
April 16, 2021

What do you mean with two different codes?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.