cancel
Showing results for 
Search instead for 
Did you mean: 

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

electronicsbasickid
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

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.

View solution in original post

11 REPLIES 11
Peter BENSCH
ST Employee

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 II

Hi,

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

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, ...

Peter BENSCH
ST Employee

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.

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

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.

One program (VBA) and another one for the MCU.

Yes, of course. The NUCLEO and DISCOVERY boards working exactly this way and are able to debug/program the board via USB, while having a serial communication (VCP) between the MCU and the PC at the same time.

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.

Alright. Thank you for your help !