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:
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