Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Oscilloscope using a Feather M0 and 3.5 inch tft display
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Oscilloscope using a Feather M0 and 3.5 inch tft display

by BryonMiller on Mon Jul 17, 2017 9:52 am

hi,

I have built an oscilloscope using a Feather M0 and 3.5 inch tft display (pid:2050). You can see it in operation at https://www.youtube.com/watch?v=s2gPyz4bXjo. I realize I could get a Chinese kit cheaper than even the cost of the display but what fun would that have been.

BACKGROUND:
I'm pretty happy with the way it is right now but I want to take the scope to the next level. The current problem I'm trying to address has to do with showing individual points across the screen. When looking at a relatively slow-moving signal it is satisfactory to put a pixel at each location representing the time value and the voltage value. But if the signal has a high slew rate (relative to the sweep speed) the voltage at "this" point in time can be quite a bit different that the voltage at the previous point in time. This makes for pixels that are quite a distance apart and thus a display that is difficult to see. I believe the solution is to draw a line between the points rather than just lighting up individual points.

THE PROBLEM:
Trouble is drawing lines seems really slow. I'm using SPI since I don't have the pins to use the 8-bit interface. I'm using SW SPI since my early speed testing showed SW to be quicker. But when I went back to look over my speed testing I rediscovered when I draw individual points SW SPI is indeed faster. But if I draw a line, HW SPI is faster (as long as the line is straight). A straight line is one that has either x1==x2 or y1==y2. I understand that the HX8357 library takes advantage of features of the controller chip that allow drawing n consecutive points faster than n individual points. What I don't understand is why there would be a difference in speed advantage of SW SPI vs HW SPI for lines vs points.

TEST PROGRAM:
Here is the result of my test program
Code: Select all | TOGGLE FULL SIZE
Vertical - 320 points
HW SPI line time (us) 1859
SW SPI line time (us) 5786

HW SPI point time (us) 58472
SW SPI point time (us) 44285

MY QUESTIONS:
Do these results make sense to anyone? Or am I fooling my self by my testing methodology? My program has two tft objects declared as shown

Code: Select all | TOGGLE FULL SIZE
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_HX8357 tftHW = Adafruit_HX8357(TFT_CS, TFT_DC, TFT_RST);

// SoftSPI - note that on some processors this might be *faster* than hardware SPI!
Adafruit_HX8357 tftSW = Adafruit_HX8357(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST, MISO)

I test by using "tftHW" to draw a line, then using "tftSW" to draw a same sized line, then on to points.

I'm thinking I'll just use the HW SPI object since it is much faster for lines and not that much slower for points, but since this doesn't make sense to me I'd thought I'd see if anyone else understood the whys and agreed with my conclusion.

Thanks

BryonMiller
 
Posts: 214
Joined: Fri Mar 04, 2016 10:34 am

Re: Oscilloscope using a Feather M0 and 3.5 inch tft display

by adafruit_support_bill on Mon Jul 17, 2017 10:13 am

Nice work! Thanks for posting.

adafruit_support_bill
 
Posts: 82451
Joined: Sat Feb 07, 2009 10:11 am

Re: Oscilloscope using a Feather M0 and 3.5 inch tft display

by adafruit_support_rick on Mon Jul 17, 2017 11:48 am

Actually, the library doesn't take advantage of any controller features. It's just the way that SPI is used in the library. For single points, SW SPI doesn't have the overhead of SPI.beginTransaction and SPI.endTransaction calls on each point. HW SPI has to call those functions for each point.

HW SPI is faster on vertical and horizontal lines (if you call drawFastVLine or drawFastHLine) because it only calls beginTransaction and endTransaction at the start and end of the line, not for each point,
FillScreen and fillRect also amortize the begin and end transaction calls in the same way. The other graphics primitives do not do this, and draw each point individually.

So, vertical and horizontal lines, fillScreen, and fillRect will be faster with HW SPI. Other graphics primitives will be faster with SW SPI.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Oscilloscope using a Feather M0 and 3.5 inch tft display

by adafruit2 on Mon Jul 17, 2017 2:06 pm

neat! can you post up the source code on github or as a zip? i think others would be really into it!

adafruit2
Site Admin
 
Posts: 20358
Joined: Fri Mar 11, 2005 7:36 pm

Re: Oscilloscope using a Feather M0 and 3.5 inch tft display

by BryonMiller on Mon Jul 17, 2017 2:28 pm

adafruit2 wrote:can you post up the source code on github or as a zip?

OK, I think I have github figured out well enough to post source and wiring. I'll put a link here when I have,

BryonMiller
 
Posts: 214
Joined: Fri Mar 04, 2016 10:34 am

Re: Oscilloscope using a Feather M0 and 3.5 inch tft display

by BryonMiller on Mon Jul 17, 2017 3:41 pm

adafruit_support_rick wrote:So, vertical and horizontal lines, fillScreen, and fillRect will be faster with HW SPI. Other graphics primitives will be faster with SW SPI.


Rick, Thanks for your explanation. I must have read the inner workings of the library wrong. (Not hard to imagine me doing this). Hopefully if I can see where my problem in understanding lies I'll be able to ask more questions later. Meanwhile, I've incorporated HW SPI into my design since vertical line drawing is what I really wanted to speed up.

BryonMiller
 
Posts: 214
Joined: Fri Mar 04, 2016 10:34 am

Re: Oscilloscope using a Feather M0 and 3.5 inch tft display

by BryonMiller on Mon Jul 17, 2017 10:51 pm

adafruit2 wrote:can you post up the source code on github or as a zip?

I put source code and wiring information here. What I did not post was any description of the analog circuitry used to make two different analog signal ranges available to the M0. I can work on this if anyone is interested.

BryonMiller
 
Posts: 214
Joined: Fri Mar 04, 2016 10:34 am

Please be positive and constructive with your questions and comments.