wireless Arduino debug

15 views
Skip to first unread message

Ralph Hipps

unread,
Feb 22, 2021, 5:59:56 PM2/22/21
to HomeBrew Robotics Club
are you an Arduino user? (like me...)

do you use the serial monitor for debug & status info? (like me...)

do you hate it when the USB cable gets wrapped around your robot, or it trips over it, or tugs on it, or having to run along behind your bot outdoors carrying your laptop (and hoping you don't trip and fall...) (defnly like me...)

Well, your days of misery and suffering are over!   =)

I've been looking into this for some time, and I think I may have found a great solution!

Think of it as the Arduino version of a ROS bag file. You collect up & locally store a bunch of data, readings, measurements, status info, or whatever you like, and then review it all after your test run at your leisure.

The basic idea I thought of was to use micro SD cards (or µSD). 

It turns out there are readily available adapter or breakout boards for these, but most depend on the MCU SPI port for their interface. This is way better than I2C but has some notable limitations. Writing a single INT can take 20-30 ms, which can be an issue at the wrong time, and can certainly add up fast if you're debugging a lot of sensors, etc.

Burst writes (up to 512 bytes) are a lot better, but can take 80 - 190 ms in my testing, see attached spreadsheet. This is more efficient, and the writes could perhaps be done when there are 'breaks in the action' so to speak, but that might not be the most convenient thing depending on what you're trying to do. You would have to monitor your buffer level and stop when it's full, write it to the SD, then resume, etc. 

Or just keep going and 'fly blind' and pray you don't hit anything while writing out the buffer.    =)

The best solution I've found is called OpenLog, and it basically uses another 'Arduino' ST MCU to receive your serial port writes and manages buffering and writing the data to the µSD card for you. The buffer is only 2 kB, so is has some limitations as well, but it turns out the performance greatly depends on the speed of the card rather than the MCU you're using.

I've found that you can stream error free continuously at 57,600 baud with a class 10 card (10 MB/s), and 115,200 baud error free with a class 30 or v30 card (30 MB/s).

Since I normally like to run my serial monitor at the latter rate, that is perfect for what I need. 

Plus this only takes one IO pin (serial TX) vs. four for SPI, and the adapter is about the size of a postage stamp. Level shifting is optional, only needed for reads but should really work fine without it (plus I don't do reads anyway).

I plan on putting an OpenLog on all my bots from now on.    =)

Code and test results on GitHub. Let me know if you have any Qs.


Ralph




Ralph Hipps

unread,
Feb 26, 2021, 10:39:11 PM2/26/21
to HomeBrew Robotics Club
Based on some feedback and Qs at the last club meeting I wanted to share some additional findings, with more to come.

Chris Mayer asked if the µSD card could be used like a hard drive attached to an Arduino. I've confirmed both the OpenLog and 'dumb' SPI SD adapters have read & write capability, so the answer is yes. The OpenLog uses it's own non-SPI protocol (easy examples provided), but otherwise ok.

Ralph Campbell pointed out that some Teensy's have on board SD sockets, so I looked into that, and I found that the 3.5, 3.6, and 4.1 have them. What's especially interesting is that the Teensy uses SDIO rather than SPI, which has the capability to be much, much faster!

Up to 800 Mbps of data transfer for SDIO cards using 4 parallel data lines in SDR mode.

SDIO uses 4 data pins and a clock speed potentially as high as 208 MHz depending on the CPU.

The SF Redboard I used for my testing has an SCLK speed of 8 MHz, and one data pin (MOSI), so you get the idea.

I haven't benchmarked my Teensy 3.6 yet, but I am planning on it. I have found anecdotal evidence on the interweb of 3x faster performance with SDIO. I suspect it could be higher depending on the SD card.

I also suspect the CPU will no longer be the bottleneck as it is with SPI, instead it will be the card, but I need to test this hypothesis.

Couple that with the Teensy 4.1's 600 MHz ARM M7 processor and that's a rockin' little brain for your next project, unless you need ROS.
Screenshot-from-2018-03-16-215841.png
Screenshot-from-2018-03-16-215401-300x174.png

Marco Walther

unread,
Feb 27, 2021, 2:09:04 AM2/27/21
to hbrob...@googlegroups.com
My little mower is using an Adafruit Grand Central M4 Express
(https://www.adafruit.com/product/4064) which also has a MicroSD (SPI),
I also added an extension https://smile.amazon.com/dp/B07WWVBK8V to
bring the MicroSD to the outside;-)

-- Marco
> <https://github.com/DarkLordRobotics/sd_card_testing>
>
> Ralph
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "HomeBrew Robotics Club" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hbrobotics+...@googlegroups.com
> <mailto:hbrobotics+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hbrobotics/d24b58b7-8fe7-4ae5-ac62-1c66189bfd6fn%40googlegroups.com
> <https://groups.google.com/d/msgid/hbrobotics/d24b58b7-8fe7-4ae5-ac62-1c66189bfd6fn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Ralph Hipps

unread,
Feb 27, 2021, 9:38:08 AM2/27/21
to HomeBrew Robotics Club
I like the extension, could come in really handy depending on where your CPU is, etc.

Ralph

>+<
 |    /\
 |___/  \
 [_@_]   `<
 O O O   
      DL Robotics!
------------------------------------------------------------------------
In the twenty-first century, the robot will take the place
which slave labor occupied in ancient civilization.
 -- Nikola Tesla
------------------------------------------------------------------------



You received this message because you are subscribed to a topic in the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hbrobotics/eAAGi6shCPs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hbrobotics+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/e1e37425-e8e4-be0a-81df-36922b47a48a%40gmail.com.
Reply all
Reply to author
Forward
0 new messages