-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Andrew,
On 09/04/13 22:57, AndrewMc wrote:
> Hiya
>
> (BTW wasn't MakerFaire awesome?)
YES!
> I am trying to use D0 / Serial1 to receive TTL serial data and
> relay it to my PC. I have verified using a digital CRO that the
> data is 57600 baud 8n1, but all I get is garbage.
>
> If I loopback D1 to D0 it works, but I dont think that really
> replicates 'reality'
>
> Does anyone know if there is an upper limit to the RX speed on the
> TTL serial with Arduino? Does it deal well with small variations
> in clocking speeds?
Is Serial1 a soft-serial device or are you using somethiug like a mega
with multiple UARTs?
soft-serial devices don't have a hardware buffer. If you're not
reading when the data arrives you miss it.
Even the 'real' serial port uses an ISR to feed an internal buffer.
I hacked the wiring library once to increase the size of the buffer
and to add a callback; you could use something like that to send the data.
Also, 57600 and 115200 are reasonably quick, especially as the arduino
lacks any kind of HW handshaking.
Don't make your cables too long:
http://www.lammertbies.nl/comm/info/RS-232_specs.html#phys
We used to run data between 2 PCs over a 10m cable or so and had to
drop the baud rate below 57600.
Thomas
> thanks, --Andrew
>
> int led_green = 9; int baud_device = 57600; int baud_pc = 115200;
>
> void setup() { Serial.begin(baud_pc); Serial.setTimeout(100);
> Serial1.begin(baud_device); Serial1.setTimeout(100);
> pinMode(led_red, OUTPUT); pinMode(led_green, OUTPUT);
> pinMode(led_blue, OUTPUT); digitalWrite(led_blue, LOW);
> digitalWrite(led_green, LOW); digitalWrite(led_red, LOW); }
>
> const int blen = 32; char buffer[blen+1]; int b = 0; boolean
> enable_loopback_test = false;
>
> void do_echo_loop() { if (enable_loopback_test) { if
> (Serial.available() > 0) { char c = Serial.read();
> digitalWrite(led_blue, HIGH); Serial1.print(c);
> digitalWrite(led_blue, LOW); return; } }
>
> int n = 0; n = Serial1.readBytesUntil( '\n', buffer, blen); if (n
> > 0) { digitalWrite(led_green, HIGH); buffer[n] = 0;
> Serial.print(n); Serial.print(": "); for (int i=0; i < n; i++) {
> Serial.print(buffer[i], HEX); Serial.print(" "); }
> Serial.println(buffer); } else { digitalWrite(led_green, LOW); } }
>
> void loop() { do_echo_loop(); }
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -
http://www.enigmail.net/
iQIcBAEBAgAGBQJRZG4RAAoJEHqA0UHc+pSDORwP/ipkFAxh5bP9nXe6RUl7Fnpn
kuHiEF59mGuzycijx4hWDUjiVMYwDC4Y9TSbi+jMmIhF7CYv5z6en77BSmWG223c
mJ81TIJpINEv2BbQMFAxPSqHUOXNXfL/3D5eUE5YA+wrkAijUyYF4BRNaqnUG14E
HXTkUsbIuG673jh4e/5oeYQy27yKmpa6kaexX5p2B8qcPN/7a4POKGaY5JUfG+TO
X3Jkh2tlQbhlko35lHovd9cjmbLhJRDVkuEJT32sRSUaLoQgM1JfjltWOIKI/Tvr
hS0Vf8ZJAbct9QfDWiyF2FgYwbIeEL1QdzTnqZXN1460rdY9HnOWV4laD2FprS/G
BkR7c8aM1+gJQDdkL1DnwdxOGjp+ca7gsimV4n0m9cOM5mpkGbVwUPC+Z+sFh6Xs
k949t3VBAQVURsqM1yGzN4C5On3aVMxjaFeeQJuPdwIl1jG9OwzWx4Vxn6N4tKz1
BAGGI4QPMKjGP/jmSxljYafKrRhEpk8+XS5Jc9Xl2sDkOq8CbA1KczvvIcLnqtvb
b2oB8+9OOhtK+LVupFZgK9NZK63p1UlTR7OFz9v0FL2U2rnmH7/qREj3z/CoRa0R
JNC67AKZXR+D1wAMZb9qrTdJCOpO81a43dIYFHDoGkVUdZQIVleYnpB81xyRZT3z
6TPEHwKxRLqFMZaLAC9W
=7pVk
-----END PGP SIGNATURE-----