Hi, I have to sample a signal and then send it to pc, I've set the sample rate to 300Khz, the speed of the serial port to 500KByte/s and a single sample is an 8 bit number but my pc receives only 50Ksample/s(50Kbyte/s), can I reach a speed of 100/200Ksample or 50Ks is the maximum speed that I can use?How much time takes a Serial.print() instruction?
This is the arduino sketch:
byte mask=B01000000;//mask for start of conversion & state of conversion boolean first=true; char t=' '; void setup() { Serial.begin(4000000);//500kByte/s, super speed! ADMUX=B01100000;//I'm using input A0,result is left adjusted DIDR0=0x01;//shut off digital input for A0 ADCSRA=B11000010;//I'm using 4 as division factor ADCSRB=0x00;//free running, default setting } void loop() { if(first)//do it only the first time { startofconversion(); first=false; } t=waitandget(); Serial.print(t);//send data startofconversion();//start a new conversion } void startofconversion() { ADCSRA=ADCSRA|mask;//let's start a conversion! } byte waitandget() { while((ADCSRA&mask)==mask)//wait { } return ADCH; }