I've been looking around for a PIC-style development board and the Arduino Mega 2560 sounds ideal for my application. I am new to microcontrollers but I have a background in electronics and I have done 6502 and ARM assembler, as well as various flavours of BASIC. My project will involve accurately measuring audio frequencies (around 1000 to 2300Hz) by timing each half-cycle, suitably amplified and clipped to a square wave. I need to measure to an accuracy of roughly 1 microsecond. I will collect approximately 1000 bytes of data every 450mS and I will then need to transfer this data quickly to a PC running a VB.NET app which I will also write. The only problem is, I will only have a spare couple of mS before the Arduino code needs to start sampling the audio again. Can I arrange some kind of serial buffer that will transfer the data to the PC without interrupting my precise half-cycle measurments? Do I need a second microcontroller to handle the serial transfer? Any ideas on this fast data transfer would be appreciated.
I think I would save time and $$$ and go with the $50 data logger below.
It's not that kind of project. My VB.NET software will be processing the data in real time and producing a display. The radio hams on this forum may have an idea of what I'm planning. It's called SSTV, and no, I don't want to do it with Windows sound card programming ...
Paul57:
I've been looking around for aPICAVR-style development board
Spelling corrected.
My project will involve accurately measuring audio frequencies (around 1000 to 2300Hz) by timing each half-cycle, suitably amplified and clipped to a square wave. I need to measure to an accuracy of roughly 1 microsecond.
The "Input Capture" available on timer 1 is just what you need. The hardware captures the current timer value and generates an interrupt.
I will collect approximately 1000 bytes of data every 450mS
= 2300 bytes per second. Serial port set to 115200 baud = 115200 / 10 = 11520 bytes per second = enough throughput to move the data.
Can I arrange some kind of serial buffer that will transfer the data to the PC without interrupting my precise half-cycle measurments?
The latest Arduino core has interrupt driven transmit which will help.
You should also consider using a Teensy.
Do I need a second microcontroller to handle the serial transfer?
Doesn't look like it.
I will collect approximately 1000 bytes of data every 450mS
So that is 2250bytes/sec = 20Kbits
Recently I experimented with boosting Arduino Serial see - IDE - serial monitor higher baud rates - Suggestions for the Arduino Project - Arduino Forum -
Highest baudrate without fauilure was 500K, At this speed it would be easy to send those 20Kbits.
Rob
Thanks for the replies. It wasn't so much whether the Arduino could send that amount of data in the available time, it was whether it could be done without disturbing my nearly-continuous sample measuring. There will only be around 3mS of "spare" time available every 450mS, not enough time to transfer the 1KB of data collected. Does a serial transfer need much processing "power" or can it be done with some kind of buffer/interrupt routine?
EDIT: Sorry, just re-read Coding Badly's reply and saw reference to "interrupt driver transmit" which probably answers that last question. All comments appreciated though ...
3msec is too little time for 1000 bytes over Serial line, that is 10.000 bits in 3 msec ~~ 3MB/s;
or put it otherwise @16Mhz its about 5 instructions per bit. You might check the SPI interface.
Why can't the 1000 bytes not be send during the 450mS e.g. 2 bytes every millisec?
what is the meaning of those 1000 bytes?
Can you post code so we can think with you about finding alternative solutions?
furthermore have you seen:
It might be possible to send the data "little and often" although I would prefer to collect 1000 bytes at a time and then transfer it.
Sorry, no code yet. This project is still at the early planning stage.