cancel
Showing results for 
Search instead for 
Did you mean: 

Can I do that with Nucleo-L432 or Nucleo F411re boards?

MÇeli.2
Associate II

Hello. I have a simple project, but I have a hard time doing my project in STM. The difficulty of the project is that all processes have to work at certain sampling times. As you can see in the picture, I have a robot that is controlled by 2 channel biological signal (EOG). Robot movements are measured with two potentiometers. So what do I want?

0693W00000QLvDXQA1.jpg 

1- I want to transfer 2 channels of EOG data controlling the robot and 2 pot data that allows us to measure the movement of the robot to the SD card or PC via serial port (1KHZ sampling, the transfer does not have to be real time).

2- According to the EOG data read, there is a linear function that provides the movement of the robot's joint (m*x+n). The PWM value (min. 10 KHz PWM) produced with this function will be transferred to the robot actuator via the driver.

In the first attempt, while recording the data to the SD card with DMA at 1KHz sampling time, I could not generate PWM signals from that data. Therefore, I performed the recording process with another MCU and the PWM generation with another MCU.

I know how to read ADC with DMA.

I know how to write data to SD card or send data from serial port.

I know how to create PWM.

However, I could not implement an application where I could combine them all. I wonder if I should try RTOS? Because during PWM production, data misses occur during data transfer from the buffer.

Waiting for your suggestions. Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
S.Ma
Principal

I wouldn't use sdcard, use uart interface, the built in stlink has usb serial port feature. Otherwise use hc05 bluetooth dongle to be wireless for convenience.

Then, the key is without rtos to implement a uart data queue for transmission as background operation. Use the simple 8 bit mcu mode, byte by byte interrupt to transmit out. Fifo is a queue and makes transmission not freezing time until done.

View solution in original post

5 REPLIES 5
KnarfB
Principal III

How do you generate the PWM? If you use a timer channel, adjusting the duty cycle is a mere write to a register.

hth

KnarfB

Servo control is a computation and a register write to change the pulse width.

Writing to SD Cards should be done in large, aligned blocks, writing small drips of data will be disaster. I would do this as a foreground task, in slack time, and use DMA for the data to/from the card.

Sampling, use a TIM to trigger the ADC(s), with data buffered via DMA

An RTOS would, in my opinion, be overkill for something that could be managed via interrupts as data is available. Data can be queued to the SD card, perhaps with reasonably sized ping-pong buffers, flushed as they are filled.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief III

I know how to read ADC with DMA.

I know how to write data to SD card or send data from serial port.

I know how to create PWM.

Maybe no how big is ADC DMA buffer?

Real hw control system need first job do ADC and PWM primary, and data store on demand.

Your PWM require hw based management, maybe too DMA...

RTOS no. SDCARD no for start system.

Yes I adjust the duty cycle with __HAL_TIM_SET_COMPARE function.

S.Ma
Principal

I wouldn't use sdcard, use uart interface, the built in stlink has usb serial port feature. Otherwise use hc05 bluetooth dongle to be wireless for convenience.

Then, the key is without rtos to implement a uart data queue for transmission as background operation. Use the simple 8 bit mcu mode, byte by byte interrupt to transmit out. Fifo is a queue and makes transmission not freezing time until done.