STM32 ADC Set Frequency Sampling - stm32f4

I'm a beginner in STM32 MCU's and I need to record an ECG signal with 1000 Hz sampling rate.
As an autonomous student, I have been reading a lot of online tutorials, but I can't understand what are the best practices to do this...I mean, should I continue learning the basics of STM32 with HALs library? And how people change the sampling rate of a signal? What are the right steps (the best practices)?
I'm a little confused about all the information that I have been learning on the internet.

Should I continue learning the basics of STM32 with HALs library?
Yes, otherwise you would get into details of the ADC registers that are not that relevant to you.
What are the right steps (the best practices)?
No sure about right steps but here some useful ones:
Use STM32CubeMX
Get a basic program working , blink led or reading a button...etc
Implement a simple ADC program by Enabling your ADC module trough STM32CUbeMX , read a constant voltage and store it in a variable that you can read using debug mode.
Implement a simple Timer program
Combine them both timer providing your sample rate and ADC sampling your EKG channels
Once you start doing progress more specific questions would pop up, then you can continue asking on this site :)
Recommend readings Mastering STM32 by Carmine Noviello and STM32 user manual

Use timer event to trigger the ADC conversion. It is 100% precise.

Related

What is the more common way to build up a robot control structure?

I’m a college student and I’m trying to build an underwater robot with my team.
We plan to use stm32 and RPi. We will put our controller on stm32 and high-level algorithm (like path planning, object detection…) on Rpi. The reason we design it this way is that the controller needs to be calculated fast and high-level algorithms need more overhead.
But later I found out there is tons of package on ROS that support IMU and other attitude sensors. Therefore, I assume many people might build their controller on a board that can run ROS such as RPi.
As far as I know, RPi is slower than stm32 and has less port to connect to sensor and motor which makes me think that Rpi is not a desired place to run a controller.
So I’m wondering if I design it all wrong?
Robot application could vary so much, the suitable structure shall be very much according to use case, so it is difficult to have a standard answer, I just share my thoughts for your reference.
In general, I think Linux SBC(e.g. RPi) + MCU Controller(e.g. stm32/esp32) is a good solution for many use cases. I personally use RPi + ESP32 for a few robot designs, the reason is,
Linux is not a good realtime OS, MCU is good at handling time critical tasks, like motor control, IMU filtering;
Some protection mechnism need to be reliable even when central "brain" hang or whole system running into low voltage;
MCU is cheaper, smaller and flexible to distribute to any parts inside robot, it also helps our modularized design thinking;
Many new MCU is actually powerful enough to handle sophisticated tasks and could offload a lot from the central CPU;

Is it possible to use a joystick with vhdl?

I’m pretty new to coding with vhdl and i just finished making a simple game using a pretty rough vga driver that i made. The last thing now that i need to do is hook up a joystick to be able to control the object in the game( this game is a mini project so i have to present it and using the onboard switches wouldn’t cut it). The problem is that the joystick gives an analog input and i don’t know how to include that in my vhdl program or if its even possible. I’m using a de-10 lite board. I’m sorry if my question is messy and i hope I made it clear for you. Thx in advance.
DE10-Lite is built with MAX 10 fpga which has two on-chip ADCs, and the board has analog buffers to scale 5v analog inputs down to acceptable voltage of 2.5v.
You'll need to instantiate "Modular ADC core" and PLL to clock it.
Depending on your project needs you can instantiate just the ADC control core (it has simple streaming interface), or "standard sequencer with avalon-mm sample storage".
Check with the board's manuals to find which pins are connected to banks with ADC.
Apparently, there's an example project for ADC included with "CD-ROM" that you can download from Terasic site.

digital to analog conversion

I have a SRF04 distance module and I don't want to use it with it's digital output. So I have to convert it to analog. To do that I bought a small AT-tiny micro controller.
Can help me how can I convert digital to analog. I'm using codevision-AVR program.
thanks a lot.
FDMX.
The SRF04 unit sends back a pulse to the ATTiny. You have to measure the time of the pulse using interrupts or polling. The time of the pulse will be 58 us times the distance in cm.
Once you have that number, you can use the ATTiny to convert the number to a voltage using PWM.
There are lots of code examples of both these things on the Internet. Search for AVR interrupts, and for PWM. Stack Overflow is not meant to be a place to repeat the examples for everyone who posts a question. If you get some code almost working, you can come back here to post your code and ask why is doesn't work.

Run VHDL code that displays on monitor

I am new to VHDL and FPGA. I have a Cyclone 2, DE 1 board. I am trying to program in VHDL such that it produces an animation of something (Say an algorithm). I have worked on the board and played with switches. Now, the biggest challenge for me is to get the display. For simple programs, I load the .sof file and directly manipulate the switches. Now, I downloaded a VHDL code that draws a rectangle to understand VGA and compiled it. When I load the .sof files, it loads but I do not see anything on the screen. My question is, Should VGA involved files be loaded/run in any different manner? I see that lots of material is available for xilinx but not for cyclone 2. Can anyone help me as to how the VGA works with respect to coding, compiling and running? I know the theory, need some basic practical knowledge.
All you need is to write a VGA driver. I learned it on this site. The example is pretty suitable for one who isn't familiar with VGA. You can download example code as well. Pay attention to the timing specifications for various VGA modes at the bottom of that page.
Also this teaches how to write a Pong game. Have fun with it:).

Advice for interfacing strain gauges to PC

I'm using an arduino to excitate and amplify strain gauges on a rod - the resulting voltage will be picked up by the analog inputs available on the arduino. I need to plot the 'torque' taken by that rod with respect to time on a graph, and the easiest way I see to do this is using the Processing language, as the basic arduino environment does not provide for graphical display.
Any tips on where to start? I only have prior experience with MATLAB, and a bit with Java.
EDIT: I should add a specific question - how do I assign a variable in Processing to the physical values read on the arduino (varying voltage through analog)?
Thanks.
Since you have experience with MATLAB, consider using the ArduinoIO API provided by The MathWorks. Basically lets you interface your Arduino to MATLAB - all the pin I/O features are available. So let MATLAB do the work plotting, etc, for you and just use your Arduino to collect your data.
I can personally vouch for how useful this API is. It's powering my master's thesis (building Arduino-powered vehicles and doing control on them).

Resources