DIY hardware interface for simple data collection and robot control?

For issues with communication ports, protocols, etc.
h4tt3n
Posts: 685
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: DIY hardware interface for simple data collection and robot control?

Postby h4tt3n » Jan 25, 2018 17:47

MrSwiss wrote:
h4tt3n wrote:Do you know of an economic, software controllable piece of hardware that will allow us to flip a series of pins on/off or do measurements on them?
Yes, have a look at Arduino, or any of the many Clones: "Open Source HW", as well as
plenty possible add on Modules (for many specific tasks, such as Network, Robotics etc.).
Controlled by itself, autonomous mode (external control via VCP, serial communication).

Price here, for a Uno/Clone: 15 - 25 US$/piece (completely assembled/soldered board).
There are even special sets available, for educational purposes.


Thanks, noted! :-)
h4tt3n
Posts: 685
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: DIY hardware interface for simple data collection and robot control?

Postby h4tt3n » Jan 25, 2018 17:57

badidea wrote:Apart from the hardware, do you have practical (automation) ideas that the students would interest?


Yes. Most of it is pretty straight-forward. For the input part, I want to measure if a certain switch is on or off. I'd also like to measure frequency / rotations per second when comparing different pendulums / wind turbines / steam engines / DIY electromotors etc. I would also like to measure voltage as a means of comparing temperature / light / sound / generator output. For the output part, I would simply like to be able to turn stuff on and off, like a LED, relay, or thyristor.

With these basic building blocks, some scrap metal and bit of duct tape we can make almost everything.
Gunslinger
Posts: 35
Joined: Mar 08, 2016 19:10

Re: DIY hardware interface for simple data collection and robot control?

Postby Gunslinger » Jan 27, 2018 18:53

A lot of arduino starter kit are easy to find.
https://nl.aliexpress.com/store/1738188 ... autifyAB=5
h4tt3n
Posts: 685
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: DIY hardware interface for simple data collection and robot control?

Postby h4tt3n » Feb 13, 2018 11:11

Hello again,

I've been looking into things and have decided on the Arduino. I have ordered an Arduino Uno and Mega and some extra shields for sensor input and motor control. The programming ide is very straight forward to use for anyone with basic programming skills, and when the mailman arrives I'll already have several test programs ready to install.
As a side note, growing up with the Commodore and Amiga computers, the lack of direct hardware access in modern pc's have become increasingly frustrating, and simply beeing able to read and write directly to a pin without having to install any libraries, drivers or bypass abstraction layers or safety measures really feels like beeing "home" again :-)

I'll keep you updated, Cheers Mike
grindstone
Posts: 654
Joined: May 05, 2015 5:35
Location: Germany

Re: DIY hardware interface for simple data collection and robot control?

Postby grindstone » Feb 19, 2018 12:11

I found an interesting site:
http://vusb.wikidot.com/start
MrSwiss
Posts: 3272
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: DIY hardware interface for simple data collection and robot control?

Postby MrSwiss » Dec 13, 2018 14:14

h4tt3n wrote:I'll keep you updated, Cheers Mike

Well, how far is your current progress? Just curious ...
h4tt3n
Posts: 685
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: DIY hardware interface for simple data collection and robot control?

Postby h4tt3n » Dec 15, 2018 8:39

MrSwiss wrote:
h4tt3n wrote:I'll keep you updated, Cheers Mike

Well, how far is your current progress? Just curious ...


I ended up trying Arduino and wasn't disappointed. It's basically like an old Commodore 64 in a matchbox :-) For a very few quid, and spending a very little time, you've got LED's blinking and stepper motors humming about. Throw in a few rubber bands, some duct tape, scrap wood, and LEGO bricks, and you're away inventing stuff.

Cheers, Mike
TJF
Posts: 3481
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: DIY hardware interface for simple data collection and robot control?

Postby TJF » Dec 26, 2018 10:27

Hi h4tt3n!

Arduino is a good choise, since newcommers can get a system running in a short time. They don't have to study lots of configuration stuff.

But it's limited when it comes to big memory or fast CPU requirements, ie. video or network tasks. And you cannot follow your initial plan
h4tt3n wrote:... I am planning on using FB as an integral part of my education.

Unfortunatelly nobody pointed you to the Beaglebone hardware yet. That are modern check card computers in a cost range starting at Arduino level, but running a modern CPU under LINUX. Several hardware flovours are availabe, ie.

  • Pocket Beagle (headless, cheap and small)
  • Green (headless with original headers)
  • Green wireless (WLAN, headless with original headers)
  • Black (hdmi output)
  • Blue (prepared for roboting tasks)
Due to special co-processors (PRU = Programable Realtime Unit, two are available) they do not only have the same realtime capabilities as an Arduino, they are much better even when running under a non-realtime OS.

Unlike other LINUX systems the hardware configuration is as easy as on the Arduino. No setup in any system files. Instead everything gets controlled in single source from your code, when you use a special library called libpruio.

And finally this library is a FreeBASIC project. You can also use FreeBASIC for you project code, and therefor follow your original planning. (Further languages: currently C and Python.)

Do not hasitate to ask if you need further information.

Regards
h4tt3n
Posts: 685
Joined: Oct 22, 2005 21:12
Location: Denmark

Re: DIY hardware interface for simple data collection and robot control?

Postby h4tt3n » Dec 26, 2018 12:00

Hi TJF,

That looks really cool! :) So far I'm going to stick with Arduino because I don't really need a lot of cpu power or memory, but I really, really need it to be simple, and I need the very easy I/O functionality that allows you to add sensors, led's, motors and so on.

Cheers, and happy holidays,
Mike
TJF
Posts: 3481
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: DIY hardware interface for simple data collection and robot control?

Postby TJF » Dec 26, 2018 12:41

It does not only look cool :-)

Sure, it takes a lot off effort starting a new educational job. Everything has to be prepared well, in order not to fail in the classroom. You don't need much CPU power and memory. But your students may need in future. And when you have your head free, starting to think about their needs, I hope you'll remember my proposal.

All the best for your job!
fridlund
Posts: 21
Joined: Jun 03, 2007 15:24
Location: Southern California

Re: DIY hardware interface for simple data collection and robot control?

Postby fridlund » Oct 15, 2019 0:39

Hi Ms. Swiss,
Re: the below, can you share any FB code you've written to use your LabJack U12? This looks like a simple DAQ that could work for my own lab applicaion as well. I just need the code to achieve A/D conversion of 4 channels, possibly some Digital I/O to 2 or 3 outputs. I see your application is commercial. Mine is not, but for my private university lab, and I'd be happy to sign any necessary NDA's
Many thanks,
Alan

I prefer a LabJack U12, any day (which I use for my commercial environmental Monitoring-SW).[list]
MrSwiss
Posts: 3272
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: DIY hardware interface for simple data collection and robot control?

Postby MrSwiss » Oct 16, 2019 14:15

fridlund wrote:Hi Ms. Swiss, <-- MrSwiss please (I'm not Miss Switzerland ;-) )
Re: the below, can you share any FB code you've written to use your LabJack U12?

Sorry, but no (commercial), it's also far too complex for simple use.

For simple Lab-Applications I'd use a "graphical coding environment" which most likely contains
the necessary "building-block" to access the HW. This is far simpler, than coding that sort of
thing yourself. (You'll have to link to a in C written DLL, e.t.c.)

In the LabJackU12's driver kit, there is one of them included ... (trial version, IIRC).
There are of course others like LabView(TM), to which you might already have access to, if
you're working at a University (no additional cost).
MrSwiss
Posts: 3272
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: DIY hardware interface for simple data collection and robot control?

Postby MrSwiss » Oct 16, 2019 17:22

It is also from the FBC 32 bit, only days ...
Therefore, I've tested it (q & d -- hack) if it still works, in principle.

Just as a demo, how to load the DLL and access one single Function within.
(I'd never use it that way. I'd split it into a static Lib, which the .exe loads.)

LabJack_U12-first.bas:

Code: Select all

' LabJack_U12-first.bas -- (c) 2019-10-16, MrSwiss
'
' just a quick & dirty hack to show minimal use
'

Dim As Any Ptr  LJ_lib                  ' the DLL's base address

#Ifdef __FB_64BIT__
LJ_lib = DylibLoad("C:\Windows\System32\ljackuw.dll")   ' FBC 64
#Else
LJ_lib = DylibLoad("C:\Windows\SysWOW64\ljackuw.dll")   ' FBC 32
#EndIf

If LJ_lib = 0 Then
    Print "ERROR: 'ljackuw.dll' load failed!"
    Beep : Sleep : End 1
End If

Dim LJ_AISample As Function( _          ' Declaration of Function
    ByVal idnum       As Long   Ptr, _  ' @I32
    ByVal demo        As Long,       _  ' I32
    ByVal stateIO     As Long   Ptr, _
    ByVal updateIO    As Long,       _
    ByVal ledOn       As Long,       _
    ByVal numChannels As Long,       _
    ByVal channels    As Long   Ptr, _
    ByVal gains       As Long   Ptr, _
    ByVal disableCal  As Long,       _
    ByVal overVoltage As Long   Ptr, _
    ByVal voltages    As Single Ptr  _  ' float (binary32)
    ) As Long
LJ_AISample = DylibSymbol(LJ_lib, "AISample")   ' Function Ptr

If LJ_AISample = 0 Then
    Print "ERROR: 'LJ_AISample' load failed!"
    Beep : Sleep : End 2
End If

' the whole data to be sent/aquired must be pre-allocated (dimmed)
Dim As Long     LJ_idnum = -1, _        ' use @LJ_id in call (pointer)
                LJ_demo = 0, _          ' straight use (not a pointer) real (not demo)
                LJ_stateIO(0 To 3), _   ' digital pin's: 0 .. 3 (lo = 0, hi > 0)
                LJ_updateIO = 0, _      ' default: don't update digital IO's (output)
                LJ_ledOn = 1, _         ' default: ON
                LJ_numChannels = 4, _   ' get 4 analog channels (max.)
                LJ_channels(0 To 7) = { 0, 1, 2, 3, 4, 5, 6, 7 }, _ ' SE channels (2 call's needed!)
                LJ_gains(0 To 3), _     ' not used on SE channels only differential channels
                LJ_disableCal = 0, _    ' typically: OFF
                LJ_overVoltage(0 To 7), _   ' per call only 4 needed
                LJ_idx = 0              ' helper for channels selection (0 or 4)
Dim As Single   LJ_voltages(0 To 7)     ' either @LJ_voltages(0) or @LJ_voltages(4)


If LJ_AISample(@LJ_idnum, LJ_demo, @LJ_stateIO(0), LJ_updateIO, LJ_ledOn, _
               LJ_numChannels, @LJ_channels(LJ_idx), @LJ_gains(0), LJ_disableCal, _
               @LJ_overVoltage(LJ_idx), @LJ_voltages(LJ_idx)) > 0 Then
    Print "ERROR: 'LJ_AISample' call failed!"
    Beep : Sleep : End 3
Else
    Print "AI0: "; LJ_voltages(0)
    Print "AI1: "; LJ_voltages(1)
    Print "AI2: "; LJ_voltages(2)
    Print "AI3: "; LJ_voltages(3)
    Print
    Print "D-I/O 0: "; LJ_channels(0)
    Print "D-I/O 1: "; LJ_channels(1)
    Print "D-I/O 2: "; LJ_channels(2)
    Print "D-I/O 3: "; LJ_channels(3)
End If

Sleep
' clean up: release loaded DLL
DylibFree(LJ_lib)
NOTE: it assumes a 64 bit Windows, may fail on 32 bits!
fridlund
Posts: 21
Joined: Jun 03, 2007 15:24
Location: Southern California

Re: DIY hardware interface for simple data collection and robot control?

Postby fridlund » Oct 16, 2019 18:13

Dear MrSwiss,
Thank you so much for the help. I'll give your sample code a go.
All the best,
Alan

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 39 guests