How would I control the output of the power in USB ports in Linux? - 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

Related

How to Disable Hardware SPI Chip Enable/Chip Select on Raspberry Pi?

I'm setting up a Raspberry Pi 4b with a number of Adafruit chips, and thus have used their CircuitPython library to control SPI communication. They've conveniently set up a way to use any GPIO pins as chip selects, but as a result I had no idea that there are two hardware chip selects on the Raspi (CE0 and CE1 on GPIO8 and GPIO7 respectively). I have already wired these pins (GPIO7&8) with the intention of using them as GPIO outputs, but I've noticed I GPIO8/CE0 is connected to the SPI clock.
Adafruit actually mentions that the NO_CS flag doesn't work in their documentation, and I can't seem to find anything useful online.
How can I disable the hardware CS pins? I know the SPI_NO_CS flag in SPI_MODE is already a bug in the spi-bcm library, and I found this patch, but I'm not sure if it would work (I think CircuitPython utilizes a hardware CS?), let alone how to apply it.

PCIe cards interfere with each others function

Hello Good People of the Internet!
First time asking...
I have a modern PC running Fedora 24 with a real-time patch (CCRMA audio tools) with an ASUS Essence STX II sterio sound card installed on PCIe. With it we run a playback/capture application. Also, we need to integrate CAN and BLE into the system and have a PCIe-card for each of these functions. The CAN PCIe card is from PEAK and the BLE card is an Intel 8260 M2 card that HP have put on a PCIe card (AFAIK).
With only the audio card installed it works fine (using ALSA as API). When the CAN and BLE is installed the following is observed:
Playback works as before.
One capture channel only returns zero (0) or minus one (-1) in all samples.
The other capture channel returns values in the range -2..2 and when applying our application signal processing low quality, but detectable, expected results are presented.
The ALSA API report no problems in setup and configuration.
CAN and BLE functions as expected.
Without any deeper PCIe experience I suspect that CAN and/or BLE PCIe cards jumble the mapping of the sound card functions.
Can someone:
- Tell me if my hunch is in the ballpark?
- Inform me on where I might go for information on how to rectify the problem?
- ...or, share a solution?
Thanks!

CC2541 (HM10) HID and programming

AIM: use the processor and bluetooth purely on the cc2541 to read from the free pins on the board but outputting in HID format so it could be used as a keyboard.
I understand that there are a few offical TI hardware components that usually are used to program it (I cannot afford the development kit). Would someone please help me either using arduino and a FTDI board program the cc2541 to do this?
While I have no idea how to use the CC2541, if you're limited by a budget you could get a HC-05 for 4 dollars-ish, and if you so happen to have a (old) PC with a parallel port you can reflash it using RN-42 firmware (need to solder 6 wires and plug em into that port with some resistors), which will allow it do become HID devices like joysticks,keyboards and mice.
Just in case someone stumble on this post later on, the following could help a lot I guess ;)
flashing an HC-05 with another firmware using an FTDI adapter
Enjoy ;)
+

spark in arduino,relay and Bluetooth module

My problem is there was a spark when I plug in the voltage source of my 220 V bulb.I have my arduino uno r3,hc-05 Bluetooth Module,Relay Module and 220V bulb.
I cut the wire of my 220V Bulb.
One wire that is near to the bulb was connected to (COM)common connection of our relay.
The other cut was connected to ground.
The Relay Module's VCC was connected to Arduino's 5V.
The Relay's input pin was connected arduino's pin 13 as well as the Normally open(NO) pin of reay.The Relay's ground ws also connected to Arduino's ground.
My Bluetooth module tx was connected to aruino's rx ans Bluetooth module's rx was connected to tx.
I also connected Bluetooth Module,5v to the Arduino's 5v.
and A ground from Bluetooth module to Arduino's Ground.
I made my own version of schematic diagram and this is how it works.It is not that nice but I hoope you will understand.
The small squares serve's as the BreadBoard
https://twitter.com/n_galia/status/419876079403147264/photo/1
Here is a simple relay driver you can use with the Arduino. The component values are not super important, R4 could be larger, R3 can be larger, you can use just about any 5V relay and any NPN transistor. As show it should work with most low/medium sized relay. When active you can check the voltage between Q1's collector and ground. It should be less then a volt. About 4mA is provided by the Ardunio, far below it's output capacity.
PLEASE BE CAREFUL!! you are working with high current and high voltage power. Blowing up an Ardunio is minor compared to the damage you can do to yourself.
The revised schematic might not work either. If your relay is a basic relay a driver will be required. The Ardunio can only sink about 20mA and it's likely your relay will need more to function correctly. The relay coil might look like a short to the Arduino.
If you have a relay with a built in logic level driver or a solid state relay, or even a TRIAC part (not a relay) you might be OK.
In situations like this its advised to use an optical coupler between the Arduino and the relay.
The optical coupler has a transistor that will dive the relay in its output, the transistor is actually a light sensitive transistor (photo-transistor) which is turned on via an LED built into the package. The Arduino would drive this LED (though a limiting resistor) which would activate the transistor to drive the Relay. This way the low voltage electronics are totally protected and isolated from the high voltage stuff.
Ouch!
The Arduino is not compatible of dealing with your 220Vac lines from power and to the light.
Your Arduino may not function correctly anymore.
I have attached a revision to your wiring.

Read digital data directly from a USB port

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.

Resources