I'm on a project in which I must read the DC (1ms-2ms) of 16 PWM signals with 4 Arduino MEGA 2560, 4 PWM for each one. After have read it, I should send the 16 values to a computer. The initial idea was to use 4 Arduino Ethernet Shield connected to a router and then get on the computer. The other option is to connect the 4 Arduino directly by USB to the computer and perform it with each Serial.print. Which of the two options could give me better results? I have to emphasize that time is important, less than 20ms to receive the 16 PWM values would be optimal.
A greeting and thanks.
20ms is not really an issue here. Assuming you connect the Arduino over USB, using Serial, at 115,000bps, you can send the 4 bytes (Assuming a byte per Duty Cycle reading) to the control computer in .35ms.
Using TCP/IP, and a direct Ethernet connection, it will be orders of magnitude faster than that.
So, I would say, what are you more comfortable with in coding terms? The serial approach will be easy on the Arduino, but you might have to work a bit harder on the control computer. (For instance, will you use C++, and a Serial library like Boost::ASIO ?
Or, are you comfortable with TCP/IP socket programming? And if so, you will have a more robust solution, which will scale better for you.
Related
I'm getting interested in electronics. As a beginner thing, I wanted to try to manually turn on and off my plasma globe through Python code. The globe takes in a 5 volt DC power supply. I can power it through my laptop, which is a nitro 5. So it's sending a constant 5 volts.
I need to communicate with the USB (serial port?). The module Pyserial seems to be the right choice. However, no matter what I try it can't identify the USB serial port. Not even when I plug in a phone. I think it can only identify a COM port, whatever that is. What's the difference? In my device manager, there isn't even a COM port section.
I know it's possible to communicate through that USB port because it can send data to and from my phone, so is this simple thing even possible? Thanks!
Well, the problem is that your plasma ball has most likely not USB interface at all, meaning that from the 4 wires you maybe got inside the cable (rx; tx; GND; 5V) only the 5 volts are used inside the ball to give the HV circuit power.
Other than that, pyserial is a meant to be used for serial communication like devices with RS232 not USB interface.
If i wanted to control the ball from my computer with software i would program an AVR µc to interact via serial communication (probably with an MOS-FET as a switch), from that point on you could use for example your python module to turn it on and of.
I have a project in hand where I need to connect 5 or more arduinos as slaves to Raspberry Pi. Load Cells, Reed Switch, Solenoid lock will be connected to each of the arduino. The arduinos need to send the weight readings when a communication is started by the raspberry pi(master). Only a single arduino will be activated at a time. The arduinos will be placed at a maximum of 6ft distance from the raspberry pi. I need advice regarding how to make this connection. I read that I2C cannot be used for long distances so I am unsure if 6 ft is a long distance for I2C. Next, I am trying to see if a USB would work for my case but the issue is the Pi has only 4 USB slots. So can I use a external USB hub with an external power supply and connected each of the arduinos to the USB hub and provide individual power supply to the arduinos? Will this arrangement work or should I be looking at any other protocol apart from I2C and USB?? Any advice on this will be much appreciated. Thanks a lot for your time.
Arduino (Nano, Uno, Mega etc.) can communicate via SPI, I2C or UART.
Long story short, SPI is not suitable for your application. It is used for fast data transfer over short distances (usually milimeters or centimeters), so mainly for communication between chips mounted on the same PCB or PCBs close together (e.g. display shields).
Using I2C is perfectly fine (let's say up to 10 meters) and in your case it is a way to go. The maximum possible length depends on baud rate, for 10 meters a 9600 baud rate would be OK. The big advantage is that you need only 2 wires to connect all Arduinos, the disadvantage is that only one device can transfer data at the time – in your case, that does not matter.
UART is used for communication with many external modules (GSM, GPS, HMI, ...) and also in combination with USB-TTL chip for communication via USB (virtual COM port). In your case, you can use UART e.g. in combination with external UART-RS485 converter module, but there is no need since you can use I2C.
I am working with Arduino yun, and I would like to know how can I access sensor values from one arduino using another arduino. Which ways of comunication they are between arduinos? Can I access data from another arduino through wireless? Do I need additional hardware to accomplish this, or its possible with just two arduinos and one computer?
It is possible. Arduinos, depending on the model, can usually communicate via SPI, I2C, etc. Both Arduinos can send and receive data via SPI, for example, so you can hook them up to each other.
It also depends on the type of sensor data you have as well as how many open pins you have: if you really wanted to, you could set 8 bits of data to 8 different pins, and simply connect those pins to 8 pins on the receiving Arduino. That's a rather barbaric way to do it considering you have SPI at your disposal, though.
There are a couple of ways, without any external hardware you have :
SPI
I2C
Serial communication/UART
Serial is the easiest to use among these 3.
And for any other kind of communication you will require external hardware, so if you want to go wireless, then you have cheap RF modules, XBee, etc..
That said that's more appropriate question for Arduino SE site ;)
Check this page. https://www.arduino.cc/en/Tutorial/MasterWriter
I used the I2C to trigger sound from on one arduino and play it on the other. There was no noticeable delay. If you want to stream a lot of data then SPI should be used.
I am new to Arduino and just read from the book < Intel Galileo and Intel Galileo Gen 2 API Features and Arduino Projects for Linux Programmers > that:
In 2003, a student named Hernando Barragan created a hardware thesis
describing an IDE and the integration with circuit boards powered by
micro-controllers. With contributions from other researches the concept
evolved allowing developers to write just a few lines of code in order
to reproduce simple connections of hardware components.
Could anyone explain how software could change hardware wiring as the bold part says?
This is not talking about changing physical wires. It means the code can drive a micro-controller to communicate with the hardware. Each pin of a micro-controller can do different things and speak with different hardware but you do have to physically connect the hardware yourself.
For example:-
To communicate with different hardware, such as a gps, we plug the gps wires into pins of the micro-controller and then use code to monitor the pins. The Arduino will monitor the voltage on the pins to determine power on/off (0's and 1's) and allow you to know the result in your own code. It is similar to morse code but much faster. Eight zero's or 1's gives us one byte, one byte is one letter or number. Wait long enough and we have a whole message (in reality it takes a few milliseconds for quite a big message)
Some hardware uses 0's and 1's as described above, some uses analog values to give readings. For example a temperature sensor, when powered, might produce a voltage between 0 and 5 volts. It would have a wire that plugs into one of the Analog pins on the Arduino. The Arduino code can read the voltage of the temperature sensor connected to an analog pin, perform a bunch of calculations and determine what the temperature is.
Some hardware such as motors and other sensors use more complex messaging systems but all connect to pins of the Arduino micro-controller to be read or written to using the methods described in the specification of the hardware. Normally this involves some quite complex code but Arduino/Wiring is a simple set of instructions that in the background uses the complex code.
I have the Arduino UNO board and I want to know if it is possible to use both the USB connection (for exchanging data) and the external jack to power supply it.
I will use the following cable: http://ecx.images-amazon.com/images/I/41OMXaj5cPL.SY355.jpg with a AC-DC 5V adaptor in order to power supply the Arduino. However, I want to use also the USB connection in order to send some data from the computer.
Both will be connected at the same time.
In short, I want the Arduino to be able to run even if the computer is OFF and whenever I open the computer to send data to Arduino from USB connection.
Is this possible? Will the Arduino Uno board support it?
Yes. From the official Arduino website:
Power
The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically.
External DC power will override USB power if the Arduino detects it. [Source]
as other said, it is absolutely possible to have both usb and power jack plugged in.
but be aware that if you shut down your computer and turn it on after, when reading the usb port you'll restart the Arduino and might loose important data.
yeah both of them can be used. If you want to upload the code in arduino then simply use the usb cable otherwise keep it on adapter. it wont harm the device.
What I personally do is, I keep on plugging the adapter and remove the usb once I am done with uploading and then test it as normally the usb cable is quite small and I normally work on robots so I need long wires.
if you want just plugs it in, it's ok but Arduino board will chose one and usb has priority to other power source.
********* Very important :*****
if you are controlling other circuits, that are connected to an external power supply, with your Arduino and connecting it to your PC's usb, Arduino will have potential difference and it will cause current flow that will damage your PC and Arduino board. if you want to do such thing, you have to shield your Arduino board from your other circuits that you want to control and they have external power source. this could happen with optocouplers for digital ports, non signal analog ports with shield relays, and complex analog circuits for analog signals