Read digital data directly from a USB port - io

I use Arduino for comunication between sensors and my C# application using a serial port. Is there any possibility to access digital components directly such as Force Sensitive Resistor - Square, from a USB port?
Do I have to write a driver for that?
I drew a semi-schematic diagram to exemplify:

There isn't a way to directly read an analog sensor over USB since it's a digital bus. You need some sort of processing to convert the analog signal to digital and communicate over the bus properly.

In order to sample information from any sensor, you will need an intermediary. The Arduino uses an FTDI chip to convert UART (Serial) to USB. When you read data over this connection, you are reading it over the Serial over USB interface. My recommendation is to stick with using the Arduino or other micro controller.
If you are really bent on reading it Directly over USB (instead of through the Serial over USB converter) you would have to implement some sort of protocol in a device that supports USB such as the Stellaris Launchpad or an Atmega32U4 AKA Arduino Lenardo. You would also have to write a driver to describe how to communicate with this USB device. Unless you were able to implement it as an already known device such as a keyboard or serial port (Yep, we went full circle there).
In short, there's no already made chip that converts Analog (or Digital) values from a sensor into something any OS would natively understand. Since USB is a protocol much like IP, you're not going to be able to use discreet devices. You're going to have to use a micro-controller with a USB stack.
Again, my advice would be to pass the sensor values over USB through the existing Serial (over USB) port. This is pretty straight forward and easily reproducible without an entire Arduino.

From the looks of the force-sensitive resistor, this is an analog component; the resistance and capacitance changes with the force applied to the sensor. If you check out the FSR installation guide document there are suggested electrical interfaces starting on page 16.
I would recommend the first circuit, connect Vout to an analog input on the Arduino. From there you will need to convert from ADC counts to voltages and then use a lookup table function in the Arduino to convert from voltage to force according to Figure 9. At this point you have a variable containing the force applied to the sensor. From here you can transmit the value over the USB serial bus just like any other value. Your C# application then needs to read the serial data, and parse out the value.

Related

need to send ASCII codes over Bluetooth

Just looking for a "pre-made" device that could get ASCII codes (at the same time power up the device where the codes come from) and send the ASCII string over Bluetooth,
Technically, I want a device where I can connect standard Keyboard with a USB plug, and send the the keystrokes via bluetooth,
Just wondering if there is a device already setup to do this, no time to develop,
thanks
Assuming you want to convert a USB keyboard to Bluetooth, there's a handful of options out there, like the BT-500 from handheldci.com: http://handheldsci.com/kb/
And some similar FOSS arduino version: https://github.com/juancgarcia/HID-Relay
If this is not what you're trying to do, you'll need to specify it a bit better. "send characters over bluetooth" is sadly not that simple, the bluetooth device has to identify as some type of device. That could be a keyboard (HID), however it could also be something like a serial port over bluetooth which something like a HM-05 implements.

Get MIDI note from USB interface on Arduino Yun

I am using an Arduino Yun and a MIDI to USB interface and my goal is to read the incoming MIDI note on the installed Linux operating system.
The goal is to have the computer on the Yun read the note and send it to the Arduino which then transmits a square wave over the pins at the note played on the piano.
But I can't figure out how to read from the USB interface; the Linux system is command line only and I can't figure out a good way to read the incoming note.
There is nothing special about USB; the USB MIDI driver makes the interface show up as a normal MIDI port, which can be accessed like any other MIDI port.
If you want to write a shell script, the easiest way is probably to parse the output of aseqdump.
See Translating MIDI input into computer keystrokes on Linux? for an example.
If you want to write a C program, you have to use the ALSA sequencer API; consider using the aseqdump source code as a template.
If you just want to send the raw MIDI bytes over the serial line, you can simply read them from /dev/snd/midiC?D?.

bluetooth module HM-15 and Arduino scanning for iBeacons

I bought a HM-15 BLE bluetooth module and successefully connected to Arduino. I am able to sent At commands and I would like to use it for scanning for iBeacons and get their major and minor.
Using AT+DISC? I can see the beacon address but I cannot connect to it and now I am stuck on how to retrieve major and minor
Can you help me? Here is the datasheet of the module:
http://www.elecrow.com/download/bluetooth40_en.pdf
Thanks
Bluetooth beacons do not require a connection and you read the identifiers directly from the advertisement.
Read section 19, Start a discovery scan, and learn how to read and decode the bytes in the discovered peripherals. The exact byte layout varies for different beacon types. For AltBeacon, an open source beacon variant, you can see the byte layout here: https://github.com/AltBeacon/spec
To decode a proprietary beacon format, you will need to learn how that beacon layout differs from the example linked above.
Old question, but just for the record, you can use AT-DISI?
This will scan for beacons, including iBeacons and also AltBeacons. The response from HM-10 will include RSSI for each.
PS: I'm assuming HM-15 and HM-10 operate the same way. Probably not exactly a fully reasonable assumption.

How would I control the output of the power in USB ports in Linux?

I built a robot from a thin client pc (can run Windows CE or Linux) and two servo motors. I put USB ends on the servo motors, so when they are plugged in to the thin client they continuously run. In Linux, how could I set the amount of current or voltage going from the USB ports to the servo motors? Would I be able to run a shell script to set the power of a certain USB port to slow down a motor or stop one? If this cannot be done through software, what is the easiest way to do this through hardware without having to buy too much?
The USB voltage is fixed at a nominal 5 volts and cannot be controlled.
The behavior of USB devices regarding their current draw is well defined in the USB specifications. USB devices are supposed to draw up to 1 unit load (100mA) unless they have negotiated a higher load from the USB host. It's quite likely that the servo motors that you have are going to need to draw higher currents than that, and wouldn't be able to request it without being a USB device and negotiating with the host.
It's also likely, depending on the servo motor that you are trying to control, that you'll need to either provide a PWM signal or an analogue voltage to control motor position. USB hosts are not intended to provide either of these.
Your best options to drive your motor from your PC are:
Get a dedicated USB controller for your servo motor (if one exists)
Make your own, based on a small microprocessor (eg. using an arduino)
Choose a different port on the PC. If available, PC parallel ports can be controlled to provide control for motor drivers.
The answers here seem to say it is a hardware issue, but I think this is a software issue. ASUS has Ai Charge which more then doubles the volts to charging Apple products from a standard 2.0 usb port.
USB 1.0, 2.0 and 3.0 Specs (All at 5 volts) 4 Wires (2 Data and 2
dedicated power)
Voltage Breakdown: USB 1.0 and USB 2.0 = 0.5A or 500 mA = 2.5 watt
USB 3.0 = 0.9A or 900mA = 4.5 watt Wall wart = 1.5A or 1500 mA = 7.5
watt Ai Charge = 1.2A or 1200mA = 6 watt
Ai Charge works on ASUS and non-ASUS motherboards and is a program you can install in Windows.
Personally I HATE Apple so I want to figure out a way to do this 1.2A usb 2.0 output trick for my netbook while running Linux.
I don't believe it is possible to directly manipulate the USB voltages. They are designed to provide a +5V output at all times unless power is diminised with other hubs.
You might be better served posting this question on http://electronics.stackexchange.com
you need to use PWM to control motors speed, to do that you need a micro controller, PIC18F series supports USB communication, there are plenty of code samples available internet how to use USB in PIC18F series, also you need a transistor array or H-Bridge to control mortors from PIC.
The simplest way to communicate is, program a USB serial in PIC18F micro controller, and when you plug that 18F to your computer, it will detect USB serial port, so you can send the commands to serial port to control speeds.
I dont think its possible, and even if it was, consider this: The USB port is not suposed to power motors because you can burn the USB port. USB is limited to 500mA (or there abouts) and any power device like a motor can potentially require more than that.
Another thing is that servos should be driven with constant voltage, and the speed is controlled by timing impulses on the control wire.
http://en.wikipedia.org/wiki/Pulse-width_modulation
You should use a driver (hardware) to power the motor with an external power source.
This is transistor's purpose, or try with a potentiometer

LabVIEW string output

How do I send a string output from a DAQ Board (NI- USB 6259) using LabVIEW? I want to send commands such as "CELL 0" or "READ" to a potentiostat device using LabVIEW.
Thanks
The 6259 doesn't do string output. It's a data acquisition board that's intended for reading/sourcing analog voltages or sending/receiving individual digital signals. It's not a communications device.
If you're really trying to send strings to this device, you probably need something more like an RS-232 or GPIB connection.
As eaolson said a DAQ is not intended to control devices. However it is an interesting project to enter the guts of the communication protocol. Doing it with a DAQ would require to:
Identify the protocol (GPIB or RS-232)
Make your cable from the DAQ output connector
For each command, generate the waveform in LabVIEW, by using the letters' ASCII code, stop bits, etc. This is the funniest part (INMHO, but I understand it's not everybody!)
Send it (using DAQ analog write VIs, you should find many examples for this)
The oscilloscope will be your best friend

Resources