element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
Forget Me Not Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Forget Me Not Design Challenge
  • More
  • Cancel
Forget Me Not Design Challenge
Blog [CaTS] ForgetMeNot - Week 7 (2): More testing with RPiSoC
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fvan
  • Date Created: 17 Sep 2014 6:30 PM Date Created
  • Views 1057 views
  • Likes 0 likes
  • Comments 3 comments
  • forget_me_not
  • design_challenge
  • openhab
  • tektronix
  • rpisoc
  • iot_pet_care
  • eclipse
  • internet_of_things
  • enocean
  • cats
  • raspberrypi
  • smarthome
  • challenge
  • iot
  • enocean_pi
Related
Recommended

[CaTS] ForgetMeNot - Week 7 (2): More testing with RPiSoC

fvan
fvan
17 Sep 2014

Previous posts for this project:

  • [CaTS] ForgetMeNot - Index
  • [CaTS] ForgetMeNot - Week 0: Project Description
  • [CaTS] ForgetMeNot - Week 1: EnOceanPi and Sensors
  • [CaTS] ForgetMeNot - Week 2: Elro CoCo and Pi Cam with OpenHAB
  • [CaTS] ForgetMeNot - Week 3: Data persistence and charts with OpenHAB
  • [CaTS] ForgetMeNot - Week 4: Arduino-OpenHAB communication
  • [CaTS] ForgetMeNot - Week 5: Getting familiar with EAGLE
  • [CaTS] ForgetMeNot - Week 6: Getting to know the TBS1052B-EDU oscilloscope
  • [CaTS] ForgetMeNot - Week 7: First tests with RPiSoC
  • [CaTS] ForgetMeNot - 3D Printing: EnOcean sensor bracket
  • [CaTS] ForgetMeNot - 3D Printing: EnOcean rocker switch and magnet holder
  • [CaTS] ForgetMeNot - 3D Printing: Food dispenser prototype
  • [CaTS] ForgetMeNot - 3D Printing: Weighing scale
  • [CaTS] ForgetMeNot - Security: Some basic tips
  • [CaTS] ForgetMeNot - Minion: Dave, the gassy minion

 

  • Introduction
  • Circuit
  • Python script
  • Proto shield
  • Demo

 

Introduction

 

I was able to spend a little more time using the RPiSoC.


Last time, I demonstrated how I planned to control the food and water dispenser using the Python API for the RPiSoC.

Today, I ported the weighing scale, in charge of determining food and water quantity in the bowls, to the RPiSoC as well.

 

Circuit

 

During my initial tests with the weighing scale, I used the HX711 weighing module to demonstrate the functionality of the load cell. Back then, I mentioned I would ultimately move to the INA125P, based on an instructable I found, which would result in easier data collection. The mailman delivered my two INA125P today, so I got started immediately.

 

I drew the circuit in an earlier post, when experimenting with EAGLE. These are the connections:

image

 

In the instructable, a resistor Rg value of 10 ohms is used. I have however had beter results using values between 100 to 150 ohms, in order to cover the range of weight I need to cover (0-1kg).

 

Using the schematic, I breadboarded the whole thing and connected it to the RPiSoC on Port 15 Pin 4.

image

 

Python script

 

The code I used to read the analog value and convert it to weight is a modified version of Embedit Electronics' ADC Voltmeter.

 

from rpisoc import *

RPiSoC('SPI')

My_SAR_ADC = ADC('SAR0')

#ADC value when scale is idle
ScaleOffset = 2202

#Set average to offset for faster initial state
CountsAverage = ScaleOffset

#Analog value change per gram
AdcCountPerGram = 2.89823

try:
    while True:
        My_SAR_ADC.Start()
        My_SAR_ADC.StartConvert()

        while not My_SAR_ADC.IsEndConversion():
            pass

        Counts = My_SAR_ADC.GetResult()
        My_SAR_ADC.StopConvert()
        My_SAR_ADC.Stop()

        Volts = My_SAR_ADC.CountsTo_Volts(Counts)

        #Smoothen the readings
        CountsAverage = (0.9*CountsAverage) + (0.1*Counts)

        Grams = ((CountsAverage-ScaleOffset) / AdcCountPerGram)
        print('ADC OUTPUT:\t %d \nAVG OUTPUT:\t %d\nVOLTAGE:\t %.5f Volts \nWEIGHT:\t %d Grams\n' %(Counts, CountsAverage, Volts, Grams))

        time.sleep(.1)

except KeyboardInterrupt:
    RPiSoC.commChannel.cleanup()

 

I'll have to adapt it even more, in order to feed the data back to openHAB.

 

Proto shield

 

I moved the weighing scale circuit from breadboard to an Arduino proto shield and duplicated it for a second scale.

 

First, I started by soldering some headers, so I could mount the shield on the RPiSoC. I wanted to be sure this would work before soldering the rest of the circuit.

As the RPiSoC we received is still a prototype model, unexpected things could happen (remember the reversed GPIO ?).

imageimage

The proto shield fitted just fine, so I proceeded with soldering the rest of the circuit.

 

This is the result:

image

 

The proto shield needs be extended with connections for the servo motor and digital output to control the solenoid valve.

 

Demo

 

This video was taken with the circuit still assembled on a breadboard, when testing the analog input of the RPiSoC.

 

You will notice a delay in determining the weight of the object. This is because some calculations are made in order to smoothen the fluctuations of the analog reading.

I'll look into a better, faster way of removing the fluctuations and ensuring a stable, correct result.

 

Although, in reality, there will be no such drastic value changes (I hope my cats won't gobble 500gr of food in one go image), so it's probably fine as is.

 

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

 

 

That's it for today. It's looking like I can gradually move all offloaded functionality back to the Pi using the RPiSoC. Great!

  • Sign in to reply
  • hlipka
    hlipka over 10 years ago in reply to fvan

    Oh silly me image I always confude the instrumentation amp with the TIA - and only the latter is in the PSoC... You can build an instrumentation amp in a PSoC, out of its OpAmps, but only one. Sorry about the confusion... (The KickStarter shows the TIA, but its still not in the API though)

    Regarding the ADC: if you need two input channels, you can also use the analog multiplexer. Its able to handle differential inputs.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 10 years ago in reply to hlipka

    Hi Hendrik,

     

    thanks for the feedback!

     

    About the SAR vs DelSig: as I want to hook up two scales to the setup, I thought it would be better to use the same approach/method.

    Using SAR0 for scale 1 and SAR1 for scale 2 will have the advantages of code reuse (same Python API call, just different params).

     

    I've used the external amplifiers for a couple of reasons:

    • compatibility with Arduino & RPiSoC: the shield can be connected to either RPiSoC and Arduino, and all functionality will be maintained
    • I didn't find any reference to amplifiers in either API documentation or User Guide

    Is there more than one ? I'd like to implement both scales in the same way.


    Frederick

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • hlipka
    hlipka over 10 years ago

    The PSoC actually contains an instrumentation amplifier (and a voltage reference). Is there a reason not to use it?

    Also, I would suggest using the DelSig-ADC instead of the SAR ADC, as it should give you better stability in the results. (and IIRC it can do oversampling too)

    If you want to use the PSoC even better: it has a digital filter block (DFB) that can be used to create a low-pass-filter. But I think its not directly supported by the RPiSoC API, you would need to use PSoC Creator to program it.

    • Cancel
    • Vote Up 0 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