How should items that function at different baud rates work together? - camera

I've got an Arduino Uno which I'd like to setup to with a TTL Serial JPEG Camera for image capture and send that data using a GPRS shield.
Currently I've got the two pieces of hardware working independently. The camera is taking and storing photos. The GPRS shield is sending SMS, and connecting to web urls.
Now that I've confirmed both work in isolation, how do I combine the code? The baud rate for the GPRS is set at 19200 and the camera at 9600. I've tried to set the baud of the GPRS shield down to 9600 and while it 'runs' I don't get any response from the text message I tried to send. Also the camera documentation says not to change the baud rate. Any guidance is appreciated

Connect these two devices to two separate serial lines. Since you're on an Uno, which has only one hardware Serial line (pins 0 and 1), you can use SoftwareSerial to use another pair of pins as a second serial line.
Then you can simply specify different baud rates when setting each serial line up.

Related

STM32f103 HAL USB - UART bridge

I have a third party device that is UART programmable.
I need to create a USB - UART bridge with a functional password (programming only after entering the correct password)
generated the code using the latest version of STM32CubeMX for Atollic TrueSTUDIO for STM32 9.3.0 ...
I transfer data between USB and UART through a buffer (one for usb-uart, and another one for uart-usb)
when I try to transfer several characters everything is OK, but when I try to transfer a large data packet, problems start due to the fact that the USB speed is much higher than the UART ...
there are two questions:
1.How do I tell USB that I need to stop transferring data and wait until the UART (buffer) is busy
2.How on the side of the microcontroller to get the baud rate set on the PC (set when the terminal is connected to the virtual COM port)
USB provides flow control. That's what you need to implement. A general introduction can be found here:
https://medium.com/#manuel.bl/usb-for-microcontrollers-part-4-handling-large-amounts-of-data-f577565c4c7d
Basically, the setup for the USB-to-UART direction should be:
Indicate that the code is ready to receive a USB packet
Receive a USB packet
Indicate that you are no longer ready to receive a USB packet
Transmit the data via UART
Start over
Step 0: Initial setup
Call USBD_CDC_SetRxBuffer to set the buffer for receiving the USB data. Unless you use several buffers to achieve higher throughput, a single call at the start of the program is sufficient.
Step 1: Ready to receive data
Call USBD_CDC_ReceivePacket. Other than what the name implies, this function indicates that the app is ready to receive data. It immediately returns before the data has actually been received.
Step 2: Receive a USB packet
You don't need to do anything here. It will happen automatically. Once it's complete, CDC_Itf_Receive will be called.
Step 3: Indicate that you are no longer ready to receive a USB packet
Nothing to do here. This happens automatically whenever a packet has been received (and double buffering is not enabled).
Step 4: Transmit the data via UART
I guess you know how to do this. It's up to you whether you want to do it in a blocking fashion or using DMA.
Since a callback is involved, you cannot put this code into the main loop. It might be possible to put all code into CDC_Itf_Receive if blocking UART is used. It would appear in the order 2, 3, 4, 1. Additionally, initialization is needed (0 and 1).
In the UART-to-USB direction, you would need to implement flow control on the UART. The USB flow control is managed by the host. Even though USB is much faster than UART, flow control is relevant as the application on the host can process data as slow as it likes to.
Regarding question 2: I'm not sure I understand it... The microcontroller cannot set the baud rate on the host. Either the host can specify a baud rate (transmitted over USB and applied to UART), or if the UART has a fixed baud rate, you can ignore baud rate (any baud rate set on the host side will work as it does not apply to USB).

Playing real-time sound from serial port (COM)

I'm using arduino's ADC to capture data from external microphone and send it through the serial port. My question is: How to capture and play this data with NAudio?
Well, if you know how to receive audio from a serial port, you'd put it into a BufferedWaveProvider as you received it. The BufferedWaveProvider can be played with WaveOutEvent

How to get audio from GSM modem - Not to a speaker but as a RTP stream

I have a GSM modem with a serial port and soldered points for MIC and Speaker. Through the serial port I can send AT signalling commands, send SMS and make/receive calls. I had to solder a speaker and a MIC to the modem card. My problem is that I want to read the audio stream as a RTP stream, possibly through some intermediate hardware/software. My goal is to ultimately get the audio as a RTP stream on some port with some RTP profile. I understand that I need to run a UDP server to serve the audio over a UDP IP-address/port tuple, but how do I get the audio to the UDP server in the first place? Codec conversion is also something that I am familiar with and am aware that I may need it.
This is a simplified diagram of what I intend to do:
GSM-modem-audio ---*1*---> audio-over UDP(ip-address:port)---->
>---*2*--> Kurento RTPendpoint---*3*--->Kurento-WebRTC endpoint
I don't know how to handle part * 1 * piece of the puzzle.
Easy way: get Rassbery-PI, get usb sound card, connect analog output of modem to sound card.
Have be no problem convert digital ALSA sound card signal to rtp stream.
More complex way - create special hardware which will do same.. oh wait! That will be like sangoma board.
Anyway it is not wise idea create something like that yourself except for educational purpose, becuase it will be costly or low quality.

XBee S1 read values from API mode

I have two XBees S1-one attached to a temperature sensor. This Xbee reads analog values, converts them into digital values thanks to the ADC and transmits them.
The other XBee - the receiver, is connected to a computer via a USB Explorer.
This XBee works in API mode. The XBee connected to a computer receives the data send by the transmitter. I monitor the received values with the X-CTU software, version 6.2.0. Up until this point, everything works fine.
However, the problem that I encounter is that the data received on the computer is coded: there are bits corresponding to the address of the receiver, bits corresponding to the address of the sender, the data itself, acknowledgment bits,etc. My question is how can I extract only the data bits without all th other information send by the transmitter?
I tried to read the values with a USB to TTL cable, connecting this cable to the Tx, Rx,GND and 5V(there is a 5V input in the USB Explorer despite that the XBee works at 3.3V) of the receiver XBee and using the screen command in Linux. However, in this way I receive ASCII characters and I want to receive the binary code.
I want to put those values in a database in order to be able to treat them later.
Thank you for your assistance.
With a library like this one, you can use function to get the data from your Xbee in python ;) (if you use linux)
You just have to initialise the port (should be on /dev/tty...) and than catch the data with a loop which check if new data is coming.
If you need more help I can send you part of my code (doesn't have it near me, it's on my raspy)
I hope I've help you ;)
Thana

Getting Epson receipt printer to print from Arduino

I'm trying to build a microprinter using an Arduino and an Epson TM-T88II receipt/POS printer. The printer uses the Epson Esc/POS system, but I can't get it to do anything at all from the Arduino. I'm doing things like:
#include <SoftwareSerial.h>
#define out_pin 3
#define in_pin 2
SoftwareSerial printer = SoftwareSerial(in_pin, out_pin);
void setup()
{
pinMode(in_pin, INPUT);
pinMode(out_pin, OUTPUT);
printer.begin(9600);
delay(1000);
printer.print(0x1B, BYTE);
printer.print('#'); // ESC(HEX 1B) # is supposed to initialize the printer
printer.print("hello world");
printer.print(0xA, BYTE); // print buffer and line feed
}
I just can't get the printer to respond at all. The printer powers up and prints its self test just fine. It's a serial (RS-232) printer, and I'm connecting it to the Arduino through a MAX233 chip. I've checked and rechecked my connections through the chip, which I think are right based on a friend who has a similar setup working. I read somewhere that the TM-T88 printers need null-modem serial cables, so I bought an adapter, and that didn't seem to make any difference.
I'm new to electronics, so I'm completely stumped. I just want to get it to print something, so I can get to the fun part - the programming :). Any thoughts on things to test/try? I can give more detail on wiring or anything else, just didn't want this to get TOO long.
Are you using an RS-232 transceiver? The Arduino outputs 0 and 5 V for serial, while the printer uses -12 and 12 V for serial. You should use a MAX232 or similar device to get the correct physical interface. (You might be able to cheat if you invert the serial port on the Arduino, but that might not work, and it's more trouble when just getting started.)
Once that's taken care of, the RTS and DTR may be your problem. You should be able to change the DIP-switch settings on the printer and turn off flow control altogether, or switch it to software flow control.
Also, you may need to send both line feed and carriage return.
However, once all that's done it should print just fine, even without any reset commands. Send a bunch of ASCII characters and line feed/carriage returns, and it'll spit it all out.
You can ignore the RX line (on the Arduino side, TX on the printer side) for now - just send it data until you figure out the wiring, level conversion, flow control, etc.
You could check whether you can communicate with a PC, both from the Arduino and to the printer.
I would use an oscilloscope to see if the serial signals come out of the Arduino and the MAX as they should, but then you probably don't have one.
Are you sure the communication settings are correct? You set the baud rate to 9600, but what about data bits, parity, stop bits? What about the control lines?
I'd hook another PC instead of the printer to the other end of the serial cable and run telnet or PuTTY on that system to make sure you are communicating out and actually talking through the serial port. If so, you could use the same solution to send data to the printer to confirm all settings such as number of data bits, parity, etc.
I've done a similar project and had the same issue. You need a null modem / crossover cable to go from max232 to the printer as both devices are in slave configuration