digital to analog conversion - avr

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.

Related

STM32 ADC Set Frequency Sampling

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.

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.

Arduino Uno: Running multiple servos

I have a Arduino Uno, and I am pretty new to the Arduino stuff. I am new to circuits also. I am thinking about working on a simple spider robot and making it more complex as I learn about the Arduino. Anyways, yesterday I tried seeing if I could run 10 server motors (small ones) with the Arduino. I linked all the positive wires in parrel and connected it to the 5v on the board. I observed that not all the servers moved like the code says. I looked it up and found out I can't do that or else I might fry it. I did not fry it thank goodness. I then found out that I have to have a separate power supply and connect the servers red wires(positive wire) to the power supplies red wire and connect the ground wires to ground on the Arduino. I found this picture showing this.
https://www.google.com/search?q=arduino+uno+connecting+multiple+servos&biw=1920&bih=974&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjU5r6ovv7RAhVp5oMKHV_cDqAQ_AUIBigB#imgrc=DmQfCRVK9SXwAM:
I also saw that in another forum someone said something about using a capacitor. So I have some questions still. My first question is do I have to have a capacitor or can I just do what the picture in the link I gave does? It shows the power supply being a 6v NiMH 2800 mAh battery. I looked online I could not find that exact same battery with a charger, but I found this on ebay.
http://www.ebay.com/itm/121963271143
So I thought if I connect 5 of the batteries in series that way the amps is left alone for 2800 mAh and 6v, the exact spec of the battery in the picture. So my second question is will this work? I have this pack from Radio Shack near my house that I got.
https://www.radioshack.com/products/radioshack-8-aa-battery-holder#
There is a problem with this one though and that is it holds 8 and not 5. So my third question is will it still work with only 5 batteries in it? The forth question is how do I connect the wires to this item since it has no wires coming off of it? My fifth question is are these battery packs connected in series since they add the volts? Thank you for reading this and taking your time to clear up my confusion. I will restate the questions down below.
Do I have to have a capacitor or can I just do what the picture in the first link I gave does?
Will this work?
Connecting 5 of the batteries in series that way the amps is left alone for 2800 mAh and 6v, the exact spec of the battery in the picture.
Will it still work with only 5 batteries in the 8 battery holder?
How do I connect the wires to this battery holder since it has no wires coming off of it?
Are these battery packs connected in series since they add the volts?
Again, thank you for reading this long forum question and thank you for your time.

What are tsetup and thold in VHDL?

I am learning VHDL. When I tried to make a testbanch I run into these words. What do they mean? I could find any simple explanaition on google.
Thanks in advance.
tSetup and tHold aren't VHDL keywords to my knowledge but the minimum setup and hold time for the device being simulated to operate correctly.
tSetup - The amount of time the data/control needs to be valid before the clock edge.
tHold - The amount of time the data/control needs to be valid after the clock edge.
A simple graphic explaining this:
http://en.wikipedia.org/wiki/Flip-flop_%28electronics%29#Setup.2C_hold.2C_recovery.2C_removal_times
As TOTA says, setup and hold times are digital logic design terms, not VHDL terms.
The vast majority of the time, you do not need to concern yourself with them in testbenches as you are almost always testing internal blocks within your chip and the tools will manage all the timing for you.
When you are working at the device pin level, you can set you models up to check the setup and hold times for violations. When simulating RTL, there are no delays (usually) modelled, so your timing should be fine. You can later simulate a back-annotated netlist which has all the real chip delays included and check that you are still going to meet all the timing requirements of your external devices.

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