element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi IoT
  • Challenges & Projects
  • Design Challenges
  • Pi IoT
  • More
  • Cancel
Pi IoT
Blog [Pi IoT] -  Remote Horse Feeder System #5 : Pi Face Rackin'
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jomoenginer
  • Date Created: 22 Aug 2016 4:24 AM Date Created
  • Views 1369 views
  • Likes 4 likes
  • Comments 3 comments
Related
Recommended

[Pi IoT] -  Remote Horse Feeder System #5 : Pi Face Rackin'

jomoenginer
jomoenginer
22 Aug 2016

Moving away from the OpenHAB interface config for a bit, I started working on the Feeder Control System that will drive the Feeder for my project.  For this, I decided to use the Pi Face Display and Control as well as the Digital 2 connected to the Pi Face Rack.  There were a couple of challenges using the Pi Rack with these devices and I will cover those in this post.  With these devices, my intention was to create a manual means to enter and control the feeder system which will also interact with the OpenHAB interface.

 

Pi Face Pi Rack

 

  The Pi Rack is very handy device to use with the Raspberry Pi which allows expandability of connections to the RasPi.   However, there were a few things that I did run into that made the config a not so simple effort.

 

   The first thing to note, and something I discovered after some searching, is that the Pi Rack is shipped (at least the one I have) with the jumpers to swap between SPI and CS lines in the reverse configuration.  This seems to work fine when using only one device to the Pi Rack, but if you intended to use multiple devices each with a separate SPI addresses, the Rack will not work as is.

I did find this post to be very helpful :  https://www.element14.com/community/thread/27170/l/pirack-problem?displayFullThread=true

 

Here be an image of the Jumper settings that work when using separate SPI addresses for the devices on the Pi Rack:

image

 

Another thing to note form the Image above, when using a ribbon cable with the Pi Rack, Is that with the Power Jumper on the one side of the 26 pin connection, and the SPI/CS jumpers on the other side of the connection, there is not much space to plug in the connector from the ribbon cable so you might have to move the jumpers over a bit.  For the ribbon cables,  I used the IDC 26 pin Dual Row Socket IDS-26-P connectors with 26 wires from a 40 wire ribbon cable since Fry's only had 25 wire ribbon cables but the 26 pin connector; strange.

Also, the reason I used the ribbon cables was that neither the Pi Face Digital 2 nor the Pi Face Display and Control would fit on the Rack.  The Digital 2 has a 40 pin connection so that would not fit and the IR receiver and the Slider switch on the Display and Control got in the way, but in the end this allowed more flexibility with mounting the whole config.

image

Pi Face Digital 2

 

    For my project, I am using the Pi Face Digital 2 to control the motor that will be used in the Feeder system to allow the Feed to be distributed.  At this time, I am just looking at using the 2 relays on the board, but may using one of the outputs as well as a speed control.

In order to address the two Pi Face devices on the Pi Rack, since the Digital 2 has selectable jumpers on board, I set this device to 1 which left the Display and Control to 0.

image

To use the Digital 2 in a python script as I am doing, the Digital 2 libraries need to be imported.

 

import pifacedigitalio as pdio

 

To control the Relays on the Digital 2 (this is also tied to the LEDs on the board as well) I'm using the following commands in my runManual method:

def runManual():
    run_pin = 0
    stop_pin = 1
    pin_on = 1
    pin_off = 0
    clearDisplay()
    setDisplay()
    writeLine(2, 0, "Manual Run")
    print ("manual run")
    pdio.init()
    t.sleep(1)
    pdio.digital_write(run_pin, pin_on, 1)
    t.sleep(10)
    pdio.digital_write(run_pin, pin_off, 1)
    pdio.digital_write(stop_pin, pin_on, 1)
    t.sleep(5)
    pdio.digital_write(stop_pin, pin_off, 1)
    pdio.digital_write(run_pin, pin_off, 1)

 

I'll use the relays as an H-Bridge to control the direction of the DC Motor used in the Feeder system.

 

Pi Face Display and Control

 

  The Pi Face Display and Control will be used to Set Feed Timer, View Timer, Manual Run, and get Feed Status.   I am using Python and the PiFace CAD libs to control the display and grab user input.

When first started, the display will show "Smart Horse Feeder" indicating the system is initializing.

image

 

 

I ended up mapping the port values to the switches and created a Dictionary for use with setting the Timer:

SW0 = 1
SW1 = 2
SW2 = 4
SW3 = 8
SW4 = 16
SW5 = 32
SW6 = 64
SW7 = 128

# Port to Button
button_dict = {SW0 : "Set Day",
               SW1 : "Set Hour",
               SW2 : "Set Min",
               SW3 : "Set AMPM",
               SW4 : "Select Mode",
               SW5 : "Down",
               SW6 : "Left",
               SW7 : "Right"}

 

The display will then prompt the user to select a mode from a selectable list controlled via the switches on the Display and Control device.

The default display is to show the current time with an arrow pointing to switch 4.

image

The timer and the arrow icons where created using a bit map based on the data listed at the following location:

http://www.quinapalus.com/hd44780udg.html

 

The python code looks like this:

timerBM = p.LCDBitmap([
0b00000,
0b00000,
0b01110,
0b10101,
0b10111,
0b10001,
0b01110,
0b00000])

arrow1BM = p.LCDBitmap([
0b00000,
0b00000,
0b00100,
0b00100,
0b00100,
0b11111,
0b01110,
0b00100])

 

When this switch is pressed, it takes the user to the Select Mode option.

 

image

 

From here, the user can select between Set Feed Timer, View Timer, Manual Run and Feed Status.  To keep track of the timer setting, I am using Json to dump and load a Dictionary to a .json file that I intend to use later to show in  OpenHAB via MQTT.

 

def saveTimerData(timer_data):
    with open('timer_data.json', 'w') as outfile:
        json.dump(timer_data, outfile)

def getTimerData():
    if os.path.isfile('timer_data.json'):
        with open('timer_data.json') as data_file:
            data = json.load(data_file)
            return data
    else:
        return None

 

The config with cabling so far looks like this.  I'll still have to get this in  some sort of enclosure before the 29th:

image

 

In the end, the system works as follows.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Next steps are to get all the pieces working together and set in enclosures as well as complete the feeder system.

  • Sign in to reply

Top Comments

  • DAB
    DAB over 9 years ago +2
    Nice update. I like the simple user interface. The only thing I would add is a comment to the display indicating which action the manual mode is running so that anyone monitoring the device can see what…
  • volly
    volly over 9 years ago

    jomoenginer, coming together quite nicely....love it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jomoenginer
    jomoenginer over 9 years ago in reply to DAB

    Nice suggestion.  I was looking at that noticing it was missing something.   Thanks for the tip.

     

    Cheers,

     

    Jon

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    Nice update.

     

    I like the simple user interface.

     

    The only thing I would add is a comment to the display indicating which action the manual mode is running so that anyone monitoring the device can see what it should be doing.

     

    DAB

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube