How to get Multiturn function out of CUI AMT22 Absolute MultiTurn Encoder? - c++

I'm currently using the CUI Devices AMT22 Multiturn Absolute encoder with an arduino uno and have been trying to use the example code on the site to try and get the encoder to count the number of full 360 degree rotations.
This is the link of the example code I've been combing through I'm not quite sure where to start as I am fairly new to understanding encoders.
text

Related

Pi 3 USB USB Microphone; accessing programmtically in C/C++

I am doing a speech processing project with a Raspberry Pi 3 (running Raspbian) using a USB Microphone. I can see the Microphone show up as a selectable audio device for the Pi and it produces/captures sound perfectly.
I cannot figure out how to use this in my code; I have done a ton of research regarding this and have found some tutorials but nothing that making sense. I come from more of a hardware background and have done something like this with controllers where I hook up an actual Mic and process the Analog Signal into Digital on IO Pins; I am so frustrated with this that I am about to pump data over from an Arduino using a Mic and A2D conversion.
-------------------------------------------------------My questions----------------------------------------------------
1) I want to know how to access a USB data stream or USB device in C or C++. My Linux abilities are not the best. Do I open a Serial Connection or open a filestream in "/dev/USB/...."? Can you provide a code example?
2) Regardless of the fidelity of the USB Mic Input, I want to know how to access its Input in C/C++. I have been looking at ALSA but cannot really understand a lot of its complexity. Is there something that gives me access to a raw input signal on the USB Port that I can process ( where I extrapolate out frequency, amplitude, etc.)?
I have already gone through a lot of the similar posts on here. I am really stuck on this one. I 'm really looking to understand what is going on from the OS perspective; I'll use a library given but I want to understand how it works.
Thanks!
So an update:
So I did all of my code in C with some .sh scripts. I went ahead and figured out how to use the Alsa asoundlib (asound.h specifically). As of now, I am able to generate and record sound via USB Mic/Headset with my Pi 3. Doing so is rather arduous but here is a useful link (1).
For my project, I also found a CMU tutorial/repos for their PocketSphinx Audio Recognition Device at link (2) and video link (3). This project utilizes the Alsa asoundlib as well and was a great help for me. It takes a while to download and you need to crawl through its .sh scripts to figure out its gcc linking. But I am able to now give audio cues which are interpreted by my Pi 3 and pushed to speaker output and GPIO pins.
LINKS(1)http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html
(2)https://wolfpaulus.com/embedded/raspberrypi2-sr/
(3)https://www.youtube.com/watch?v=5kp5qpwVh_8

Transmitting and Receiving with 2 USRP N210

I am very new to SDRs and with little background on DSP. I installed the uhd drivers and dependencies and can run/build the c++ examples. If I run tx_samples_from_file or tx_waveform at the TX end and run rx_samples_to_file at the RX end, I get random characters in the .dat file. Please what is the function of rx_samples_to_file? I thought rx_samples_to_file is supposed to get complex IQ sampled data equivalent of the received samples.
Eventually, what I would like to achieve with the USRPs is to generate random integers, map and modulate with say QAM or QPSK and transmit with the USRP TX and receive with USRP RX using a simple RF1 (back-to-back) connection.
Please help
Generally speaking, You can find a lot of information about Ettus Research
hardware and software in UHD Manual, Ettus Knowledge Base and USRP mailing list.
I think that You can find solution to Your problem by consulting
application note Examples Provided with the USRP Hardware Driver (link is given below).
https://www.ettus.com/content/files/kb/application_note_uhd_examples.pdf
Ivan

Playing programmatically-generated sounds on Windows with C++

I am having the hardest time trying to find information on how to programmatically, dynamically generate audio output on Windows with C++. For example, inputting values to control pitch and tone, amplitude, etc. I would imagine that this has to be low level and closer to hardware. I am trying to make a text-to-speech program on my own. Any information is appreciated. Thanks.
I think that as you seem to be new at this you should take a look at Juce library.
It should helps you to create a basic app to make audio, and then you can connect to the audio card directly
Look into the examples of the lib.
http://www.rawmaterialsoftware.com/juce.php
You will see that in order to get sound you have to connect to the audio system WASAPI or direct X on Win.
I really think you should use this library in order to focus on making the audio and not bothering how to connect to the audio device.
If ever you still want to do it yourself look at the wasapi api.
best
To generate a sine wave:
y(t) = A sin (2 Π f t + Φ)
Where:
A = Amplitude
Π = pi (3.14159...)
f = frequency (Hz)
t = period (in seconds)
Φ = phase (in radians)
Source: http://en.wikipedia.org/wiki/Sine_wave

creating realtime 2D maps of indoor environment

I am using ultrasonic sensors to get the data about the indoor environment i.e the distance of the from each wall . I want draw a realtime map of the surronding environment using that can u please guide that which software or which library is best suited for this purpose
Try OpenCV. It has everything you need for image processing. Could be an overkill tho, but I wouldn't mind it.
http://opencv.org/
If you want realtime map, I'd use Labview->embedded MATLAB code / C++. Labview has excellent hardware/peripheral support and operations, and you can embed custom code in the signal flow representation.
If you are using something like arduino or raspberry or any other such electronics kit to capture the ultrasound data, you can send the data to the serial port and then use Matlab to read from that serial port and use it to plot a live map. A good step by step example of how this can be done is available at Matlab Arduino org website

how to use c++ to do data acquisition from frame grabber

We have an "MC1362 Camera" and an "Inspecta-5" frame grabber in our lab. There is program in LABVIEW11 which gets the data from a frame grabber, however as the Labview is slow my supervisor has told me to write a program in c++ to get the data from the frame grabber. I have no idea how to write a c++ program to connect to a frame grabber and do the data acquisition. I know how to write software in c++, but have never tried programming to connect to hardware and read data from it. Is there any specific library or framework which can help me, or any tutorial?
Please, if anybody knows, help me in this matter.
Update:just to add, we are doing medical image analysis, and a laser illuminate a subject, so camera will take pictures and pass it to the computer. I need to grab the pictures and analysis them.
You basically have a couple of options,
1 see if there is an SDK for the grabber card, if there is this is usually easier then option 2 but is of course restricted to work with that grabber or familly of grabber cards, we do it this way with the eurysys grabber cards.
2 assuming you are running on a windows platform, implement a DirectShow filtergraph and write your own ouput filter to get the data, the SDK for DirectShow is quiet good and has many examples. This approach is far more flexible and you should be able to use a number of grabber but its also alot more complex, we do it this way for USB / some other inbuilt grabbers.
Our software is done in Delphi 7 but its just importing DLLs, for C++ should be no problem and most SDK's are written round C++ anyway.
I know its not much but its a place to start.
Update
Just done a quick Google search and there is an SDK for that Grabber and on first looks its seams fairly straight forward.