Geeks With Blogs

The Life and Times of a Dev Yes, we're really that weird

I’m working on a hardware project that involves software controlling motors, grippers and the like.  I can’t go into details on the project, but it’s quite a bit of fun.

I’ve learned a really important design principle for hardware interaction.  I’m sure some of you that have more hardware experience than I do will simply say, “duh”, but I had to learn the hard way.

In version one, I made good objects for all of the components and then tied them together into a single device.  They had base classes and such, good OO techniques.

It ended up being a pain in the kiester!  Who would have thought!

A far better pattern to follow is the Actor pattern.  Basically, you have a central state manager (ActorManager) that is responsible for giving each Actor (i.e. software addressable component) a chance to do its thing.

Each actor has access to a central state repository, and is responsible for writing it’s state to that repository as well.  If it cares about another component, it looks in state for the information it needs, otherwise it does its thing and moves on.

As an example, suppose you have three axis on a gantry (X, Y, Z), and these axis have to move in such a way that they don’t collide in their container.

With a top down approach, like the first revision, the device has to talk to x, y, and z and do a bunch of work to determine if they’re in a state where they can move, if they’re going to do something bad, etc.

With the actor pattern, if X needs to know if Z is in a good position, it looks in state for Z’s position.  If z isn’t in a good position, it does nothing, or if it’s in a good position, it moves.  Simple.  Y on the other hand, doesn’t care where Z or X are, so it can just move and does so.  Z is the same.  Simple.

Objects are still involved, they’re just much more loosely coupled.

Posted on Thursday, November 20, 2014 12:44 PM Hardware , Actor | Back to top

Comments on this post: Working with Hardware

# re: Working with Hardware
Requesting Gravatar...
iOS 11 could do well with a serious Siri upgrade. A sports update integration, as is rumored, will also be a welcome addition. iOS 11 Download
Left by Justin Levy on Apr 22, 2017 4:36 AM

# iOS 11 Beta 2
Requesting Gravatar...
Here is how you can download iOS 11 beta 2 for iPhone and iPad devices. WE have published the direct download links.
Left by Charles on Jun 17, 2017 7:41 PM

# Game
Requesting Gravatar...
this is the only platform where I really enjoy to work.... download and play this game Geometry Dash Game and enjoy every shadow moment and sharpen your mind
Left by Pyare on Jul 10, 2017 4:48 AM

# WhatsApp Java
Requesting Gravatar...
I feel quite interested in this field, also love to enjoy my WhatsApp Java in my phone.,.. No Smartphone need..... quite cool
Left by Ahara on Jul 11, 2017 1:46 AM

# vShare
Requesting Gravatar...
Apple launched iOS 9.3.5 to further hinder the use of PPHelper but Pangu released another update for its users to jailbreak iOS 9.3.5 as well.
Left by vShare iOS on Jul 24, 2017 12:20 AM

# re: Working with Hardware
Requesting Gravatar...
Twitter++ is an app that gives you a whole new level of user experience for the same Twitter App and allowed you to download twitter videos from this app.
Left by Bruce on Jul 31, 2017 6:18 AM

# re: Working with Hardware
Requesting Gravatar...
Pangu released another update for its users to jailbreak iOS 9.3.5 as well. Download Lagu Gfriend RainBow
Left by biglagu on Sep 17, 2017 2:50 AM

# re: Working with Hardware
Requesting Gravatar...
articles that really inspire and simplify my works.thanks
jhonlin group
Left by jhonlin group on Sep 17, 2017 12:24 PM

# INstagram Captions
Requesting Gravatar...
Very interesting article about the hardware.
Instagram Captions
Left by Good Insta on Oct 02, 2017 2:00 AM

# re: Working with Hardware
Requesting Gravatar...
Thanks you brother Mustikalagu
Left by Mustikalagu on Oct 23, 2017 4:28 PM

# re: Working with Hardware
Requesting Gravatar...
thanks sir

visit my site Stafaband
Left by on Feb 15, 2018 5:55 AM

Your comment:
 (will show your gravatar)

Copyright © Robert May | Powered by: