Skip to content

Commit

Permalink
Merge branch 'release/v1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
laurb9 committed Aug 22, 2016
2 parents 0bd5b1e + 5f287c8 commit 8b32f61
Show file tree
Hide file tree
Showing 19 changed files with 395 additions and 213 deletions.
70 changes: 49 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,83 @@ Current state: fully functional prototype board, field-tested, frequently upgrad
- Grid size and position
- Precision movement control
- Multiple delay options: pre-shutter and post-shutter, short or long shutter pulse (for bracketing).
- Bluetooth joystick control via phone

### Hardware
- 32-bit ARM controller board
- OLED 128x64 display
- Joystick menu navigation and optional IR remote
- Joystick menu navigation, optional IR remote
- Can operate with battery voltage from 10V down to 6V
- Lower power usage and later voltage cutoff than original Gigapan

## Wiring map

<img src="images/connection-diagram.png" width="870" alt="Breadboard setup with Teensy LC">

### Teensy LC / 3.x
- A0 - Battery Voltage via divider: Vin---[47K]---A0---[10K]---GND
- A1
- A2 - Joystick Vx
- A3 - Joystick Vy
- A1 - Joystick SW
- A2 - Joystick Vy
- A3 - Joystick Vx
- A4 - SDA - Display and MPU-6050 board
- A5 - SCL - Display and MPU-6050 board
- A6
- A7
- D0/RX - camera focus (active LOW)
- D1/TX - camera shutter (active LOW)
- D2(int) - Joystick SW
- D2 - MPU-6050 INT
- D3(int) - IR Remote In (AX-1838HS)
- D4
- D5 - StepperV DIR
- D4 - BLE RST
- D5 - DIR (both)
- D6 - StepperV STEP
- D7 - MPU-6050 INT
- D8 - StepperH DIR
- D7 - BLE INT
- D8 - BLE CS
- D9 - StepperH STEP
- D10- M0
- D11- M1
- D12
- D13(led) - ~SLEEP (to both steppers) - LED indicates motors are on
- D10 - ~ENABLE (both)
- D11 - SPI MOSI[BLE]
- D12 - SPI MISO[BLE]
- D13[LED] - SPI SCK[BLE]

### Feather M0 / Bluefruit

- A0
- A1 - Joystick SW
- A2 - Joystick Vy
- A3 - Joystick Vx
- A4 - Battery Voltage via divider: Vin---[47K]---A0---[10K]---GND
- A5
- SCK[BLE]
- MOSI[BLE]
- MISO[BLE]
- RX/0 - camera focus (active LOW)
- TX/1 - camera shutter (active LOW)

- 4[BLE] CS (internally connected)
- 7[BLE] IRQ (internally connected)
- 8[BLE] RST (internally connected)

- SDA/20 - Display and MPU-6050 board
- SCL/21 - Display and MPU-6050 board
- 5 - DIR (both)
- 6 - StepperV STEP
- 9[A7] - StepperH STEP
- 10 - ~ENABLE (both)
- 11
- 12 - MPU-6050 INT
- 13[LED]

### Other

- All ~EN tied to GND
- All ~SLEEP tied to Vcc
- All VMOT tied to Vin
- All M1 tied to Vcc (1:32 mode)
- All M0 left unconnected (1:32 mode)
- 3.3V step-down adapter from Vin to Vcc

## Notes

- *Atmega328-based boards are not supported*, see issue #57
- IR remote not supported on Adafruit Feather M0, see issue #59
- Settings memory not supported on Feather M0 (no EEPROM)
- Settings memory on Feather M0 only works with Bluefruit (M0 has no EEPROM itself)
- Future rewiring plan
- M0, M1 can be hardwired (M0=Vcc, M1 unconnected for 1:32 mode)
- DIR should be shared (it is only sampled on STEP)
- Tie all ~EN together to ground
- Tie all ~SLEEP together to D13 (LED indicates motors are on)
- if we ever want to use ESP-12, need to reduce pins. ESP-12 only has 11:
(0,2,4,5,12,13,14,15,16,RXD,TXD,ADC)
- Adafruit Feather M0 BLE uses 4, 7, 8 as Bluefruit RESET, IRQ and CS.
Expand Down Expand Up @@ -111,6 +136,7 @@ lower current even, if we reduce the speed.
- (untested but same Cortex M0 as above) <a href="https://www.adafruit.com/products/2843">Arduino Zero</a>
- 2 x <a href="https://www.pololu.com/product/2134">DRV8834 Low-Voltage Stepper Motor Driver</a> from Pololu
- <a href="http://www.amazon.com/Yellow-Serial-128X64-Display-Arduino/dp/B00O2LLT30">128x64 OLED display, SSD1306 I2C</a> from anywhere
- Adafruit <a href="https://learn.adafruit.com/introducing-the-adafruit-bluefruit-spi-breakout">Bluefruit SPI Breakout</a> (if not onboard) - provides Bluetooth LE 4.1 joystick control - optional
- 2-axis + switch analog joystick
- 1834HS IR receiver with some remote - optional but recommended
- Remote codes are hardcoded in remote.cpp if you have a different remote
Expand All @@ -127,6 +153,7 @@ lower current even, if we reduce the speed.
### Libraries
- Adafruit_SSD1306
- Adafruit_GFX
- Adafruit Bluefruit nRF51
- IRremote
- Wire
- <a href="https://github.com/laurb9/StepperDriver/releases">StepperDriver</a>
Expand All @@ -145,3 +172,4 @@ The only thing required of the platform is the two horiz/vert stepper motors.
- Notes:
- the DRV8834 current limit must be set according to motor spec
- reduction gear settings are hardcoded in pano.h

55 changes: 0 additions & 55 deletions WIRING.md

This file was deleted.

111 changes: 111 additions & 0 deletions ble_remote.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Bluetooth LE Remote
*
* Copyright (C)2016 Laurentiu Badea
*
* This file may be redistributed under the terms of the MIT license.
* A copy of this license has been included with this distribution in the file LICENSE.
*/

#include "ble_remote.h"

#define PACKET_BUTTON_LEN (5)
#define READ_BUFSIZE (20)

#define BUTTON_ID(code) (code & 0x0f)
#define IS_PRESSED(code) (code >> 4)

BLERemote::BLERemote(Adafruit_BluefruitLE_SPI& ble)
:ble(ble)
{}

void BLERemote::init(void){
if (ble.isConnected()){
if (!active){
ble.setMode(BLUEFRUIT_MODE_DATA);
active = true;
Serial.println("Connected");
}
} else {
active = false;
}
}

unsigned BLERemote::read(void){
unsigned event = EVENT_NONE;

uint8_t buttonCode = readButtonCode();

if (IS_PRESSED(buttonCode)){
switch (BUTTON_ID(buttonCode)){
case 1:
event |= EVENT_OK;
break;
case 3:
event |= EVENT_CANCEL;
break;
case 5:
event |= EVENT_UP;
break;
case 6:
event |= EVENT_DOWN;
break;
case 7:
event |= EVENT_LEFT;
break;
case 8:
event |= EVENT_RIGHT;
break;
}

next_repeat_time = millis() + REPEAT_DELAY;
last_event = event;

} else if (BUTTON_ID(buttonCode)){ // button depressed
last_event = EVENT_NONE;

} else if (last_event){ // button currently remaining pressed
if (millis() > next_repeat_time && !isEventOk(last_event) && !isEventCancel(last_event)){
event = last_event;
next_repeat_time = millis() + REPEAT_INTERVAL;
}
}
return event;
}

/*
* Read the controller messages.
* Returns a byte which contains button number in low nibble, and pressed state in the high.
*/
uint8_t BLERemote::readButtonCode(void){
static uint8_t packetbuffer[READ_BUFSIZE];

init();
if (!active){
return 0;
}

int i = 0;
while (ble.available() && i < PACKET_BUTTON_LEN){
char c = ble.read();
if (i == 0 and c != '!'){
continue;
}
packetbuffer[i++] = c;
}

if (!i || packetbuffer[1] != 'B'){
return 0;
}

// Verify checksum
uint8_t checksum = 1;
for (; i > 0;){
checksum += packetbuffer[--i];
}
if (checksum){ // checksum mismatch
return 0;
}

return (packetbuffer[2] - '0') + (packetbuffer[3] - '0' << 4);
}
29 changes: 29 additions & 0 deletions ble_remote.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Bluetooth LE Remote
*
* Copyright (C)2016 Laurentiu Badea
*
* This file may be redistributed under the terms of the MIT license.
* A copy of this license has been included with this distribution in the file LICENSE.
*/
#ifndef BLE_REMOTE_H_
#define BLE_REMOTE_H_

#include <Adafruit_BluefruitLE_SPI.h>
#include "hid.h"

class BLERemote : public HID {
private:
Adafruit_BluefruitLE_SPI& ble;
uint8_t readButtonCode(void);
unsigned last_event = EVENT_NONE;
unsigned next_repeat_time;

public:
bool active = false;
BLERemote(Adafruit_BluefruitLE_SPI& ble);
void init(void);
unsigned read(void) override;
};

#endif /* BLE_REMOTE_H_ */
36 changes: 36 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Pano Controller Master Configuration File
*/

#if defined(__AVR__)
#error "AVR is not supported"

#elif !defined(ARDUINO_SAMD_FEATHER_M0)
#include "config_teensy.h"

#else
#include "config_feather_m0.h"
#endif

// Address of I2C OLED display. If screen looks scaled edit Adafruit_SSD1306.h
// and pick SSD1306_128_64 or SSD1306_128_32 that matches display type.
#define DISPLAY_I2C_ADDRESS 0x3C
#define OLED_RESET 12
#define TEXT_SIZE 1
#define DISPLAY_ROWS SSD1306_LCDHEIGHT/8/TEXT_SIZE
#define DISPLAY_COLS SSD1306_LCDWIDTH/6/TEXT_SIZE

// Battery monitoring settings
#define VCC 3300
#define LOW_BATTERY 7000
// R1/R2 is the voltage divisor in Ω (GND-R1-A0-R2-Vin)
// measure resistors and enter actual values for a more accurate voltage
#define BATT_R1 9980
#define BATT_R2 46500
#define BATT_RANGE (VCC * (BATT_R1 + BATT_R2) / BATT_R1)

// MPU (accel/gyro)
#define MPU_I2C_ADDRESS 0x68

// Stepper motors steps per revolution
#define MOTOR_STEPS 200
Loading

0 comments on commit 8b32f61

Please sign in to comment.