I am try to build a wireless sensor(right now I am using an adxl335 accelerometer with an analog output) but this project should be general for any sensor that outputs analog. The issue is that I have to first convert the analog to digital to transmit it over RF(I have a 12d,12e RF series which is a four channel Rf transmitter with reciever). But the issue is if I need to convert the analog to digital then I need a microcontroller for the CS as well as clock lines. This just adds enormously to the cost of the project as well as the number of hours I would spend assembling them together and a microcontroller for each sensor does not seem sensible at all. I am wondering what is the general route taken to make an accelerometer or any other sensor that outputs anolog wireless.
Electronic – How to make any sensor a wireless one
sensorwireless
Related Solutions
I understand that you wanted to choose a development environment that you were familiar with such that you can hit the ground running, but I think the hardware/software trade off may have boxed you in by sticking with Arduino and not picking a part that had all the hardware peripherals that you needed and writing everything in interrupt-driven C instead.
I agree with @Matt Jenkins' suggestion and would like to expand on it.
I would've chosen a uC with 2 UARTs. One connected to the Xbee and one connected to the camera. The uC accepts a command from the server to initiate a camera read and a routine can be written to transfer data from the camera UART channel to the XBee UART channel on a byte per byte basis - so no buffer (or at most only a very small one) needed. I would've tried to eliminate the other uC all together by picking a part that also accommodated all your PWM needs as well (8 PWM channels?) and if you wanted to stick with 2 different uC's taking care of their respective axis then perhaps a different communications interface would've been better as all your other UARTs would be taken.
Someone else also suggested moving to an embedded linux platform to run everything (including openCV) and I think that would've been something to explore as well. I've been there before though, a 4 month school project and you just need to get it done ASAP, can't be stalled from paralysis by analysis - I hope it turned out OK for you though!
EDIT #1 In reply to comments @JGord:
I did a project that implemented UART forwarding with an ATmega164p. It has 2 UARTs. Here is an image from a logic analyzer capture (Saleae USB logic analyzer) of that project showing the UART forwarding:
The top line is the source data (in this case it would be your camera) and the bottom line is the UART channel being forwarded to (XBee in your case). The routine written to do this handled the UART receive interrupt. Now, would you believe that while this UART forwarding is going on you could happily configure your PWM channels and handle your I2C routines as well? Let me explain how.
Each UART peripheral (for my AVR anyways) is made up of a couple shift registers, a data register, and a control/status register. This hardware will do things on its own (assuming that you've already initialized the baud rate and such) without any of your intervention if either:
- A byte comes in or
- A byte is placed in its data register and flagged for output
Of importance here is the shift register and the data register. Let's suppose a byte is coming in on UART0 and we want to forward that traffic to the output of UART1. When a new byte has been shifted in to the input shift register of UART0, it gets transferred to the UART0 data register and a UART0 receive interrupt is fired off. If you've written an ISR for it, you can take the byte in the UART0 data register and move it over to the UART1 data register and then set the control register for UART1 to start transferring. What that does is it tells the UART1 peripheral to take whatever you just put into its data register, put that into its output shift register, and start shifting it out. From here, you can return out from your ISR and go back to whatever task your uC was doing before it was interrupted. Now UART0, after just having its shift register cleared, and having its data register cleared can start shifting in new data if it hasn't already done so during the ISR, and UART1 is shifting out the byte you just put into it - all of that happens on its own without your intervention while your uC is off doing some other task. The entire ISR takes microseconds to execute since we're only moving 1 byte around some memory, and this leaves plenty of time to go off and do other things until the next byte on UART0 comes in (which takes 100's of microseconds).
This is the beauty of having hardware peripherals - you just write into some memory mapped registers and it will take care of the rest from there and will signal for your attention through interrupts like the one I just explained above. This process will happen every time a new byte comes in on UART0.
Notice how there is only a delay of 1 byte in the logic capture as we're only ever "buffering" 1 byte if you want to think of it that way. I'm not sure how you've come up with your O(2N)
estimation - I'm going to assume that you've housed the Arduino serial library functions in a blocking loop waiting for data. If we factor in the overhead of having to process a "read camera" command on the uC, the interrupt driven method is more like O(N+c)
where c
encompasses the single byte delay and the "read camera" instruction. This would be extremely small given that you're sending a large amount of data (image data right?).
All of this detail about the UART peripheral (and every peripheral on the uC) is explained thoroughly in the datasheet and it's all accessible in C. I don't know if the Arduino environment gives you that low of access such that you can start accessing registers - and that's the thing - if it doesn't you're limited by their implementation. You are in control of everything if you've written it in C (even more so if done in assembly) and you can really push the microcontroller to its real potential.
Bluetooth is a term that covers a protocol stack and the hardware specification required to implement radio based links between two or more devices in a standardised way. The aim is to allow consumers to be able to purchase "Bluetooth" capable devices from any vendor and that those products should function with each other without issue. Thus your Nokia mobile phone should function with a Motorola head-set or the hands-free car kit in your BMW without any issues or problems.
Allowing "anything" to connect to "anything" via the Bluetooth protocol does not always make practical sense, neither is it always worthwhile. For example, does it make sense that a Bluetooth enabled printer can connect to a Bluetooth headset? Additionally, the type of data you wish to transfer over the Bluetooth link is important to know. For example, if I wish to print something out via Bluetooth, I am more concerned that my letter is printed without error rather than how long it takes (within reason). For audio, I am more concerned that I have a stream of continuous audio without breaks, pops or crackles but if a millisecond or two of audio is lost occasionally or the signal is not 100% accurately reproduced upon arrival, I probably won't hear this. (Hence, if you are an audiophile, Bluetooth is not a choice you would consider!)
Thus, depending on what type of data and functionality is desired, the Bluetooth SIG (they write the specification) have defined different "profiles" to cover them. For a plain vanilla data connection to provide a wireless alternative to a COM/RS-232 type connected, you have the "Serial Port Profile" or SPP. For high-quality audio transfer you have the "Advanced Audio Distribution Profile" or H2DP. For low-quality telephony audio for head-sets you have the "Head Set Profile" or HSP. (see http://en.wikipedia.org/wiki/Bluetooth_profile)
So, to the Arduino BT module. Looking at the brief overview it seems to be targeted at serial data transfer and I am probably not far wrong in saying that it uses primarily the SPP profile. Thus the data rate on offer will vary wildly depending on factors such as distance, interference etc. Not an issue perhaps for wireless data, but no good for wireless audio where a 'as good as electronically possible' minimum data rate needs to be guaranteed.
Thus you need to look for a Bluetooth module that supports the A2DP profile, of which there are many (randomly found product is here http://kcwirefree.com/audio.html)
A system build up for an audio link via Bluetooth could look as follows:
Audio In/Out <-> Audio CODEC (hardware) <-> Microcontroller <-> BT Module <-> Antenna
or
Audio In/Out <-> Audio CODEC (hardware) <-> BT Module <-> Antenna
^ ^
| |
Microcontroller
Note that there are some BT modules that have all the necessary support and only require the external Audio CODEC and no microcontroller at all.
The audio CODEC is a hardware chip that converts analogue audio signals into a digital bit stream, as well as doing the reverse, which has a interface functioning similar to SPI except the clock runs continuously. Such an interface is often call I2S. They also have a real SPI interface that is used to configure the CODEC (sample rate, amplification of signals etc.) An example from Wolfson is here: http://www.wolfsonmicro.com/products/codecs/WM8731/
The microcontroller performance depends on how much of the Bluetooth protocol is implemented in the Bluetooth module. The Bluetooth protocol stack splits fairly neatly in two; below HCI and above HCI, where HCI stands for Host Controller Interface. Bluetooth implementations for PCs (as an example) use Bluetooth modules/chipsets where only HCI and below is implemented, and then rely on the the PC operating system to run the HCI and above portion of the software stack. The upper half of the stack requires a decent performance processor (own experience says 16-bit and 16MHz or better considering you probably want to run your own application too!) Many Bluetooth modules have the whole stack and much more running on them and then offer some sort of proprietary protocol over a serial interface (USART, I2C or SPI) allowing you to interact with the Bluetooth module. This protocol allows you to choose the profiles you want to use, set up a PIN code, create and destroy connections etc. In this case a simple 8-bit microcontroller with a few kBytes flash and a few hundred bytes of RAM should suffice for implementing an audio link.
Bluetooth is not a simple protocol to implement. Even the big consumer electronics manufacturers have challenges to get it right (although they have more at stake if it doesn't work perfectly all the time!)
It may seem like a cop-out/taking the easy path but I would seriously recommend using a module solution that is designed to support audio over Bluetooth such as the link already mentioned (http://kcwirefree.com/audio.html) Your chances of success are much higher and you will be able to concentrate of some other cool features you may want to implement rather than struggling to make the Bluetooth link work.
Please note: I am in no way related to any of the companies I mentioned here - they are simply the most relevant links that appeared highest on Google when I looked.
Hope this fills some knowledge holes. Feel free to add any corrections you see necessary!
Best regards, Stuart
Best Answer
It is very common to take an analog signal, pass it through and ADC, into a microcontoller, and out a digital radio. There are many wireless microcontrollers with integrated radios and ADCs for just this task. One example is the mc13224v that's on an Econotag.
The other option would be to transmit the analog signal directly with AM or FM.