MjG0001
Posts: 1
Joined: Tue Jul 19, 2016 1:47 am

How To Build A Simple Device Tester

Tue Jul 19, 2016 1:53 am

Completely new, lost, and overwhelmed. I want to build a tester that turns a device on and off over and over, and counts how many times it works and how many times it fails. All I need is one output, and one input to do this. What is the correct approach? A GUI and the ability to print test results would be nice. I would prefer to program it in C++. Please advise - thank you.

User avatar
davidcoton
Posts: 5084
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: How To Build A Simple Device Tester

Tue Jul 19, 2016 8:57 am

MjG0001 wrote:Completely new, lost, and overwhelmed.
New to Pi, or new to programming?
At what point did you get lost? You have a fair definition of what you want, enough to get started
What part has overwhelmed you? The usual answer is to divide the problem and solve it bit by bit. So:

Get into a programming environment (C++ or Python -- I'll come back to that).
Write a "Hello, World" program, get that working.
Find a GPIO library, import it and get an LED flashing.
Arrange to read the GPIO that tells you whether the device worked.
Complete the integration of the test hardware, with a convenient way of connecting the "Device Under Test".
Put that lot together to do a one-off Pass/Fail test.
Put that in a loop, control the delays and number of attempts, count the results and display them.
Rewrite it all , making it better in the light of what you have learnt.
Assess your ideas for improvements, implement those that are worthwhile.
Job done, though possibly never finished (see last step above :lol: )

Why C++? A respectable language, great if you already know it.
But Python is probably better supported on the Pi, and has a more interactive environment. It's interpreted rather than compiled, which makes for a quicker build/test/fix cycle.
If you don't know either, Python is a less steep learning curve. There are good learning resources online, for example Code Academy. There is an extensive GUI library (TKinter).
Signature retired

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: How To Build A Simple Device Tester

Tue Jul 19, 2016 9:15 am

If you are actually comfortable with C++ , install QtCreator
on your PC and get started with Qt (a GUI toolkit) , which also
works on the Pi. You might be able to avoid cross-compiling
if you transfer and compile the project files to/on your Pi after
finishing an alpha version solely on the PC.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: How To Build A Simple Device Tester

Tue Jul 19, 2016 10:22 am

I'd 2nd what davidcoton has already said:

Most (if not all programming tasks) are best broken into small pieces and built up incrementally, start off with something small and build up from there. The exact starting point will potentially depend on what experience you already have, if you're starting with little experience a basic console app is likely the best option, you can always add a gui later (or potentially decide you want to re-write it with a gui as a 2nd version).

For languages:
C++, it's a very powerful option, but has a steeper learning curve and lots of pitfalls. Whilst this is one of my preferred languages it's not something I'd suggest for a beginner. There are also lots of bad examples out there so it's very easy to get into bad habits.

Python, very popular and lots of support on the Pi, Whilst it's not a language I particularly like it's probably the best option for someone starting out.

Ruby, maybe less popular than Python and some of the Pi support is harder to find and understand, but it's a very capable language.

My personal choice for something like this would probably be Ruby, but that's partly due to personal preference of Ruby over Python. As a project like this grew larger I might look to move it into C++.

mikerr
Posts: 2827
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: How To Build A Simple Device Tester

Tue Jul 19, 2016 10:29 am

Easiest GUI is probably with python and tkinter:

https://www.youtube.com/watch?v=Bvq0LdBn0dY [code at 2:30)

Then move on to QTCreator
Android app - Raspi Card Imager - download and image SD cards - No PC required !

Return to “General discussion”