How To Connect A Linear Actuator To The Arduino (Part 2)

It’s been awhile since I last talked about Actuonix’s linear actuator, but I recently heard from some university students asking for commented source code. Unfortunately, the only comments I had regarding the source code were along the line of “Comments? We don’t need no steenking comments”.

Then I dug into the code and realized I DID need comments.

Oops.

Oh well…

So if you’re trying to get that actuator (or any actuator going) here’s some tips from when I was programming it for the Arduino:

  • Make sure you have enough current for the device. I can’t emphasize this enough. Motors use a LOT of current when they start up, and they’ll take it from the Arduino if necessary, effectively powering it down. The worst part is that it won’t be obvious or regular; instead, it will seem that the actuator is just acting up randomly, sometimes working and sometimes not. I’d recommend separate power supplies for the actuator and the Arduino, or if you have to share, a capacitor to isolate the ripples as the device starts up.
  • Ensure your actuator works like my code expects. The one I used works like a servo – give it a specific signal and it will try to go to a specific position. Like a servo, it relies on an on/off signal with the”on” part giving the position. To keep the position, the pulses have to be sent regularly; say 50 times a second or so, although I find most servos just stick to their last position if you interrupt the pulse train. With a typical servo, an “on” pulse for 1.5ms will be the 90 degree position, or center, or in the case of the actuator, about half way out.
  • Figure out the conversion. Translating degrees to inches is annoying. In the case of this device, it’s easier (and more accurate) to send the pulses in microseconds, which make more sense than degrees. I found a pulse ranging from 1,000 to 2,000usec (1.0 to 2.0 millisecond) moved the device from low to high. So you can use those values as a percent entry – 0% is 1,000usec and 100% is 2,000usec (the original function SetStrokePerc() did this, with a percent value from 1 to 99, to avoid edges problems with 0 and 100.) But what if you wanted to do it by measuring; say, 15mm high on a 50mm actuator? Then you’d want a percentage of 15/50=30%, or you could use the function SetStrokeMM(15,50) which just does the math for you.
  • Figure out the input. The servo functions will run and run and run, sending its signal – but unless you change the values, the actuator will never move. So you need to read data in, decide how to convert it, and then send it to the servo via myServo.writeMicroseconds() (or use the helper functions in the code.) One warning though – try not to change the values too quickly. The actuator is a physical device, and it simply won’t move from end to end in 1/10th of a second.
  • Understand the hardware. To use the servo code, you need to include it in your Arduino program, and connect it to a specific pin (the servo signal pin, NOT the power/ground pins) via a pin you specify in setup() with myServo.attach(pin#). I like to break the problem into two parts: hardware versus software. Start by using one of the demo servo programs in the Arduino to ensure your servo is working, then add your own code (or even modify the demo code in tiny pieces, saving your work frequently.) Alternately, you could use an ordinary servo, if you have one lying around, along with the demo program to eliminate any problems: If you get the demo working with a known working servo, then you know the Arduino is working. Swap in the actuator, and when you know it’s working, swap in the code. And so on.

These tips helped me get it up and running, and hopefully they’ll help you if you are using the actuator. Divide and conquer is always a smart practice when working with hardware, along with incremental additions; once you get one section working, just add bits at a time. Eventually, you’re on your way!

A (Long) Month Of eBook Marketing…

So it’s been a busy month for me marketing Gwen’s books (actually 5 weeks, but I treated myself to a nasty flu/cold for one of those weeks.)

I decided to focus on getting reviews, jazzing up her book website, and also a Facebook page for Gwen’s books.

The results?

Total cost – under $500, but that’s because I traded labor for money, and did it all on my own – manually contacting potential reviewers, customizing the website, coordinating sales and reviews, and of course, doing all the design and copy writing. Oh, and digging into Facebook big time (for example, reading both the 1st and 3rd edition of Ultimate Guide to Facebook Marketing.) I’m guesstimating that’s solid results for about 1/10th the cost of hiring others…

High points:

  • Getting 1 penny likes to the Facebook page when advertising. They didn’t last long, but it was fun to get likes at that rate. Contrasted sharply with some 25 cent ones (and higher) that I stopped ASAP (low cost Facebook marketing means constantly monitoring your account!)
  • Digging into the Facebook ad system to specify exactly the types of fans we wanted, so the likes meant we were getting real cozy mystery fans and not generic ‘likes.’
  • Finally getting the look of the site nailed down, including all the artwork (like logos) needed for the Facebook page (we even bought some PLM magnetic calendars for 2018 as well as promotional mugs, something we’ve talked about for years.)
  • Getting about 1,300 to download Gwen’s first book for free with a call to action over five days, leading to the bulk of the reviews, some good sales of book #2, and a really solid fan base.

The effort was so much fun I’m actually considering a “soup to nuts” one stop shop for ebook authors – from cover design, manuscript editing and formatting to Facebook promotion and review solicitation, and so forth. Just a minor issue of finding the time…

Next month?

Back to my long-awaited (by me) audio app, due REAL SOON NOW. And for Gwen’s book? Time to focus on the email side of things, and build up Gwen’s email list in time for the release of book 3 – Codename: “Pear Tree.”

Gwen Pankhurst’s “The Plant Lady Twigs To Villainy” FREE ‘Till October 27th

As part of my nascent book promotion efforts, Gwen’s first book in her series is temporarily free for Kindle, from today through Oct 27, 2017.

The goal is reviews – lots and lots of reviews – since reviews let others know if the book is right for them.

So download it, read it, enjoy it…

…and PLEASE leave a review!

The Amazon.com link is here, and if you prefer Amazon.ca, the link is here (for everyone else, just go to your amazon, and search on”Gwen Pankhurst” to see the books.)

Enjoy!

Ready For A Second Heaping Helping Of “The Plant Lady” In Action?

For you Plant Lady Mystery fans, the suspense is over – Gwen has finished her second novel, “The Plant Lady Cracks A Nut!”

To quote the book blurb:

Local mall “Plant Lady” Eden Tywyn is desperate to escape her past. But her past keeps showing up and threatening to destroy her future. Strange accidents, odd behavior from people she thought she knew, and the feeling of being watched make her think that her time in the quaint town of Packard Falls may soon be over. But until then, something strange is definitely going on, something that threatens her friends and the future peace of Packard Falls. Is it enemies from her life before, or something even more sinister? Eden must find out the truth – but will she find it in time?

You can get in paperback or immediately on Kindle via the links below – get it now, devour it in an afternoon, and then leave a stellar review so others can enjoy the series!

A DIY Stand For Your (Solved?) Rubik’s Cube

Although I haven’t talked about my Rubik’s Cube solution for awhile now, I recently dug out my cube and tried to solve it by memory – and succeeded. Slow, but successful, so I’m quite pleased.

Of course, what better way to showcase your solved Rubik’s Cube than with a fancy stand? Although eBay sells nice plastic stands that tilt the cube for best effect (see the listings below), I recently read how to make my own out of cardboard.

Here’s how:

  1. Draw a perfect square on a piece of paper, then another one centered inside it (see diagram.)
  2. Cut out the dark gray area (and optionally the light gray area too.)
  3. Crease the lines and bring the tab to the other side, causing the paper to form a pyramid.
  4. Glue the tab to the side, and add a cube to display.

Some thoughts about the design:

  • The center light gray can be cut out or kept – if kept, bend it so it folds into the stand, forming a pyramid-shaped “cup” for the cube to rest in. This adds a bit of strength to the stand.
  • Since the ‘dip’ cannot be deeper than the stand, you’ll understand why the center square cannot be larger than the edges (mathematically, the width of the inner square must be less than 1/2 the width of the larger square.)
  • Secure the tab well with glue or staples – as the Rubik’s cube rests, it is in effect a wedge trying to split the stand apart. A very light wedge, true, but it puts pressure on the stand, so secure it well.
  • Another variation is instead of a table, the dark gray area is kept, and then glued/stapled directly behind one of the other sides as a large “tab.” This gives more surface for the glue, and more stickability.
  • Try a few out with paper to get the feel for it (and pick a size) and then make one in cardboard.

Enjoy!

How To Add A Title To Images In The NextGEN Gallery Plugin

So as I’m modding Gwen’s site, I had a problem: In the lightbox for each page, the art was displayed when you clicked on it, but with only a description, not a title.

A few years back, I had made a mod to the NextGEN gallery plugin to manage it, but with WordPress plugin updates, it had been wiped out; as well, the plugin seems to have been rewritten, making the issue moot.

The key to fix it is to make sure the tag in the galleries includes a title along with the description – the file I modded was found in

/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_basic_gallery/templates/thumbnails/index.php

And the actual change I did was found in here:

<div class="ngg-gallery-thumbnail">
  <a href="<?php echo esc_attr($storage->get_image_url($image, 'full', TRUE))?>"
    title="<?php echo esc_attr($image->description)?>"
    data-src="<?php echo esc_attr($storage->get_image_url($image)); ?>"
    data-thumbnail="<?php echo esc_attr($storage->get_image_url($image, 'thumb')); ?>"
    data-image-id="<?php echo esc_attr($image->{$image->id_field}); ?>"
    data-title="<?php echo esc_attr($image->alttext); ?>"
    data-description="<?php echo esc_attr(stripslashes($image->description)); ?>"
    data-image-slug="<?php echo esc_attr($image->image_slug); ?>"
    <?php echo $effect_code ?>>
      <img
        title="<?php echo esc_attr($image->alttext)?>"
        alt="<?php echo esc_attr($image->alttext)?>"
        src="<?php echo esc_attr($storage->get_image_url($image, $thumbnail_size_name, TRUE))?>"
        width="<?php echo esc_attr($thumb_size['width'])?>"
        height="<?php echo esc_attr($thumb_size['height'])?>"
        style="max-width:100%;"
    />
  </a>
</div>

I changed line #03 to add the title:

title="<?php echo esc_attr($image->alttext),": ",esc_attr($image->description)?>"

Voila – a title below each lightbox image – as the screen shot below shows.

I even tried with with <strong> (or <b> if your theme handles it properly) to bold the title:

title="<?php echo "<strong>",esc_attr($image->alttext),":</strong> ",esc_attr($image->description)?>"

But in the end, adding html within a <img> tag parameter didn’t feel right, so I went back.

Some caveats with this method:

  • It works because the title= parameter in the <img> tag is used by the FancyBox lightbox code to caption the images. If you use one of the other lightboxes in NextGEN, this may not work.
  • Likewise, it’s for the Basic Gallery display – if you want it to work for another type of gallery and this doesn’t work, then plan to spelunk your way through the code looking for the appropriate place to patch.
  • And of course, patches will disappear with the new update. So make the change, check it out, and then backup the file (maybe even the whole plugin.) And plan to fix it every update.

Enjoy!

You Should Be Paranoid – Your Printer IS Talking About You Behind Your Back…

Steganography is a fascinating/unnerving subject – hiding private messages in plain sight. It smacks of something from the Cold War and Microdots, or making invisible ink from lemon juice. But it’s very real – and an example of how it was used recently to find a leak is this article on ars technica. In this case, the NSA leaker included a scanned document, and the printer printed its serial number in very small light yellow dots on the page. The eye missed it but the NSA could use it to track the printer and even time of day it was printed, leading to an arrest.

So if you send printed letters, you might as well sign them – your printer is going to anyways…