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
Experimenting with Extreme Environments
  • Challenges & Projects
  • Design Challenges
  • Experimenting with Extreme Environments
  • More
  • Cancel
Experimenting with Extreme Environments
Blog PicoPorch System Demo
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Experimenting with Extreme Environments to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dougw
  • Date Created: 3 Jun 2024 5:41 AM Date Created
  • Views 529 views
  • Likes 9 likes
  • Comments 4 comments
  • Garden Secrets System
  • dougw
  • Midas MC42005A6W-SPTLYI-V2
  • Hammond 1554VA2GYCL
  • Experimenting with Extreme Environments
  • Pico temperature sensor
  • ComputeCam
Related
Recommended

PicoPorch System Demo

dougw
dougw
3 Jun 2024

Intro

This blog demonstrates the PicoPorch system in operation. All electrical and mechanical subsystems are now built and functioning although one of the stands still needs a few pieces and one of the cameras has not been definitively selected. Despite having many Raspberry Pi's working with many cameras, the CM4 that is part of the challenge kit is not yet working with any camera. There is a backup plan to use a Raspberry Pi 3B with a HQ camera if the CM4 persists in not working with cameras.

This week has seen a lot of 3D design work as well as some wiring and programming.

PicoPorch System Demo

This video shows some of the latest parts and how they work:

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

Firmware

The Raspberry Pi Pico is programmed with the Arduino IDE. I make no claims about the quality of this code but it demonstrates displaying temperature (from the temperature sensor built into the Pico) on the Midas LCD and controlling a DC motor....

/* Porch Control System
 *  Porch1.ino
 *  by Doug Wong 2024
 *   20 character 4 line I2C Display
 *   Uses an LCD library found here: https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
 *   
 *   Uses Raspberry Pi Pico W and the Arduino board manager by Earl Philhower installed with this json message:
 *   https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
 *  
 *  This code allows a Raspberry Pi Pico to display temperature on a Midas LCD and controls a motor controller
 *  The system is called PicoPorch
 */
 // ----------------------------------------------------------------------------

/*-----( Import libraries )-----*/
#include <Wire.h>
//#include <CPU.h>  // Include the library to use the CPU temperature sensor
#include <ST7032_asukiaaa.h>
ST7032_asukiaaa lcd(0x3F);
 
/*-----( Declare Constants )-----*/
const int BLpin = 9;    // the number of the backlight LED pin
const int CSpin = 8;    // the number of the LCD chip select pin
const int MApin = 14;   // motor control pin A
const int MBpin = 15;   // motor control pin B
const int CWpin = 16;   // CW direction input pin
const int CCWpin = 17;  // CCW direction input pin
const int Stime = 20;   // count for motor still time in seconds
const int Mtime = 12000;    // count for motor on time in ms

/*-----( Declare Variables )-----*/
float corT;
int Dstate = 0;   // direction state, 0 =  still, 1 = CW, 2 = CCW
int Tcount = 0;   // counter for motor time

void setup() {
  pinMode(MApin, OUTPUT);
  pinMode(MBpin, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(BLpin, OUTPUT);         // initialize the BL pin as an output
  pinMode(CSpin, OUTPUT);         // initialize the CS pin as an output
  pinMode(CWpin, INPUT_PULLUP);   // CW request pin
  pinMode(CCWpin, INPUT_PULLUP);  // CCW request pin
  digitalWrite(BLpin, HIGH);      //turn on backlight
  digitalWrite(CSpin, LOW);       //Select LCD

//  cpu.begin();  // Initialize the CPU temperature sensor
  
  Serial.begin(9600);

  lcd.begin(20,4);
//  lcd.init();                //initialize lcd
  lcd.setCursor(0, 0);
  lcd.print("     element14      ");
  delay(1500);
  lcd.setCursor(0, 1);
  lcd.print(" Experimenting With "); 
  lcd.setCursor(0, 2);
  lcd.print("Extreme Environments"); 
  lcd.setCursor(0, 3);
  lcd.print(" using Hammond Mfg  "); 
  
  delay(5000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("     PicoPorch     ");
  lcd.setCursor(0, 2);
  lcd.print("Motor State = STILL"); 
  lcd.setCursor(0, 3);
  lcd.print("Pico temp: "); 
}

void loop() {
//  corT = cpu.getTemperature();
//  corT = 21.3;
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on
  corT = analogReadTemp(); // Get internal temperature
  Serial.print("Core temperature: ");
  Serial.println(corT);
  delay(20);
  lcd.setCursor(12, 3);
  lcd.print(corT);
  if (Serial.available()) lcd.print(Serial.read());
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off
  delay(980);
  if (digitalRead (CWpin) == LOW)   // If CW pin is pulled low, turm motor CW
  {
    digitalWrite (MApin, HIGH);
    digitalWrite (MBpin, LOW);
    lcd.setCursor(0, 2);
    lcd.print("Motor State = CW   ");
    delay(Mtime);
    digitalWrite (MApin, LOW);
    digitalWrite (MBpin, LOW);
    lcd.setCursor(0, 2);
    lcd.print("Motor State = STILL");
 
  }
  if (digitalRead (CCWpin) == LOW)   // If CCW pin is pulled low, turm motor CCW
  {
    digitalWrite (MApin, LOW);
    digitalWrite (MBpin, HIGH);
    lcd.setCursor(0, 2);
    lcd.print("Motor State = CCW  ");
    delay(Mtime);
    digitalWrite (MApin, LOW);
    digitalWrite (MBpin, LOW);
    lcd.setCursor(0, 2);
    lcd.print("Motor State = STILL");
  }
  Tcount++;
  if (Tcount > Stime)
    {
     Tcount = 0;
     Dstate++;
     if (Dstate > 3) Dstate = 0;
     if (Dstate == 0)                // motor is still
     {
        digitalWrite (MApin, LOW);
        digitalWrite (MBpin, LOW);
        lcd.setCursor(0, 2);
        lcd.print("Motor State = STILL");
     }
     if (Dstate == 1)                // turm motor CW
     {
        digitalWrite (MApin, HIGH);
        digitalWrite (MBpin, LOW);
        lcd.setCursor(0, 2);
        lcd.print("Motor State = CW   ");
        delay(Mtime);
        digitalWrite (MApin, LOW);
        digitalWrite (MBpin, LOW);
        lcd.setCursor(0, 2);
        lcd.print("Motor State = STILL");
     }
     if (Dstate == 2)                // motor is still
     {
        digitalWrite (MApin, LOW);
        digitalWrite (MBpin, LOW);
        lcd.setCursor(0, 2);
        lcd.print("Motor State = STILL");
     }
     if (Dstate == 3)                // turm motor CCW
     {
        digitalWrite (MApin, LOW);
        digitalWrite (MBpin, HIGH);
        lcd.setCursor(0, 2);
        lcd.print("Motor State = CCW  ");
        delay(Mtime);
        digitalWrite (MApin, LOW);
        digitalWrite (MBpin, LOW);
        lcd.setCursor(0, 2);
        lcd.print("Motor State = STILL");
     }
    }
}

Discussion

It is a big milestone to get the motor system fully under computer control. This includes all the final weatherproof wiring. This week was focused on designing and building the limit switch system which involves tight mechanical tolerances. The system is designed to have no hard stops, so inertial overshoot cannot damage the switches or the motor and its gears.

There is still one stand to design and build, and 2 more cables, but I want to set the system up and start recording some backyard video.

Next up:

  • Build more cables 
  • Wire up the last 2 cameras
  • Design and build the motor controller case mounting stand
  • Test he system in the wild (extreme environment)
  • Make more videos and blogs

Links:

  • Garden Secrets System
  • ComputeCam and PicoPorch - Early Muddling
  • PicoPorch and ComputeCam - The Motor System
  • PicoPorch - LCD PCB & Bezel
  • PicoPorch power wiring
  • PicoPorch Motor Controller Demo
  • PicoPorch System Demo
  • PicoPorch Final Touches
  • Deep Dive On Kit Components
  • Backyard Secrets 1
  • MotionEyeOS Tutorial
  • Garden Secrets Project Summary
  • Experimenting with Extreme Environments Design Challenge
  • Pi 4 Compute Module Datasheet
  • Pi 4 Compute Module I/O Board Datasheet
  • Midas Display Datasheet
  • Enclosure Drawing
  • Enclosure Manufacturer Page
  • Antenna Datasheet
  • Connectors Datasheet
  • Sign in to reply
Parents
  • javagoza
    javagoza over 1 year ago

    Great progress! You could significantly improve the detection of limit switches using interrupts. Here is an example of how to handle interrupts on the Raspberry Pi Pico using the Arduino IDE.

    Raspberry Pi Pico: Detect Motion PIR Sensor (Arduino IDE) | Random Nerd Tutorials

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 1 year ago in reply to javagoza

    Thanks for the tip. That could come in handy in the future.

    The MCU in this design doesn't even detect the limit switches - they are implemented as hardware over-rotation protection. Even if the MCU has a firmware error, goes crazy or crashes, the limit switches will still kill motor power if over-rotation occurs. The motor control hardware operation is covered in a different blog....

     PicoPorch Motor Controller 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • javagoza
    javagoza over 1 year ago in reply to dougw

    I missed that detail. Safety first, you have thought of everything.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • javagoza
    javagoza over 1 year ago in reply to dougw

    I missed that detail. Safety first, you have thought of everything.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
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