Makery Monitoring Microcontroller

From Omaha Maker Projects

Jump to: navigation, search

The Makery Monitoring Microcontroller project comprises three major systems, a serial-attached Arduino microcontroller, a .Net 4.0 Windows service, and a web page.

Contents

Microcontroller

The microcontroller monitors and controls hardware that is located at the Makery. This hardware currently consists of one or more of temperature sensors, light sensors, and hobby servos. It also provides direct access to the digital and analog pins. The controller communicates with a host system via a simple serial protocol.

Serial Protocol

Commands consist of a literal command character, followed by one or more comma separated parameters, and terminated by a carriage return (0x13). A response of 'E' indicates an error processing the command. '0' indicates success. Read commands will return data indicating the requested value, generally an ASCII encoded decimal value.

"Inn,m" : Set digital pin mode, 'nn': pin number 2-13, 'm': mode, 1 output, 0 input
"An" // Read an analog input, 'n': analog pin number 0-5
"Dnn" // Read a digital input, 'nn' : digital pin number 2-14
"an,vvv" // Set an analog output, 'n' : pin number, 'vvv': value to write 0-255
"dnn,v" // Set a digital output, 'nn' : pin number 2-13, 'v' : value 0-1
"Tn" // Read a temp sensor, 'n' : temp sensor id
"sn" // Read a servo position, 'n' : servo id
"Sn,vvv" // Set a servo position, 'n' : servo id, 'vvv' : servo position

Web Service

The web service is a Windows service written in C# on the .Net 4.0 framework, and self-hosts a WCF-based web service to present a control interface for the microcontroller.

When the web service host is up, it is self-documenting via the 'help' interface:

http://localhost:8000/mmm/camera/help

The service can be compiled to run without hardware. In this mode it generates fake data for various outputs.

Interface

Temperature sensor operations:

Get defined sensors:
 GET	http://localhost:8000/mmm/temp/enum  
 Example output:
 [{"Max":125,"Min":10,"Name":"Inside","Value":78.8,"ValueCacheSeconds":5},
 {"Max":125,"Min":10,"Name":"Outside","Value":13.8,"ValueCacheSeconds":5}]

Get sensor value:
 GET	http://localhost:8000/mmm/temp/{SENSOR}
 Example output:
 {"Max":125,"Min":10,"Name":"Inside","Value":78.8,"ValueCacheSeconds":5}

Light sensor operations:

Get defined sensors:
 GET	http://localhost:8000/mmm/light/enum
 Example output:
 [{"Max":99,"Min":0,"Name":"Overhead","Value":99,"ValueCacheSeconds":5}]

Get sensor value:
 GET	http://localhost:8000/mmm/light/{SENSOR}
 Example output:
 {"Max":99,"Min":0,"Name":"Overhead","Value":60,"ValueCacheSeconds":5}

Servo operations:

Get defined servos:
 GET	http://localhost:8000/mmm/servo/enum
 Example output:
 [{"Max":170,"Min":25,"Name":"ServoA","Value":-1,"ValueCacheSeconds":5},      
 {"Max":180,"Min":20,"Name":"ServoB","Value":-1,"ValueCacheSeconds":5}]
Get the position of the specified servo id:
 GET	http://localhost:8000/mmm/servo/get?s={SERVO}
 Example output:
 {"Max":170,"Min":25,"Name":"ServoA","Value":-1,"ValueCacheSeconds":5}
Set the position of the specified servo id:
 GET	http://localhost:8000/mmm/servo/set?s={SERVO}&v={VAL}
 Example output:
 0

Pin operations:

Get defined digital pins:
 GET	http://localhost:8000/mmm/pins/enumd
 Example output:
 [{"Max":true,"Min":false,"Name":"D2","Value":true,"ValueCacheSeconds":1,"PinMode":0,"Pwm":0},
 {"Max":true,"Min":false,"Name":"D3","Value":true,"ValueCacheSeconds":1,"PinMode":0,"Pwm":0},
 .
 .
 .
 {"Max":true,"Min":false,"Name":"D12","Value":true,"ValueCacheSeconds":1,"PinMode":0,"Pwm":0},
 {"Max":true,"Min":false,"Name":"D13","Value":true,"ValueCacheSeconds":1,"PinMode":0,"Pwm":0}]
Get defined analog pins:
 GET	http://localhost:8000/mmm/pins/enuma
 Example output:
 [{"Max":1024,"Min":0,"Name":"A0","Value":812,"ValueCacheSeconds":1},
 {"Max":1024,"Min":0,"Name":"A1","Value":812,"ValueCacheSeconds":1},
 {"Max":1024,"Min":0,"Name":"A2","Value":812,"ValueCacheSeconds":1},
 {"Max":1024,"Min":0,"Name":"A3","Value":812,"ValueCacheSeconds":1},
 {"Max":1024,"Min":0,"Name":"A4","Value":812,"ValueCacheSeconds":1},
 {"Max":1024,"Min":0,"Name":"A5","Value":812,"ValueCacheSeconds":1}]
Get the value on an analog input pin:
 GET	http://localhost:8000/mmm/pins/aget?p={PIN}
 Example output:
 823
 
Set the value on an pwm output:
 GET	http://localhost:8000/mmm/pins/pwmset?p={PIN}&v={VAL}
 Example output:
 0

Get the value on a digital input pin:
 GET	http://localhost:8000/mmm/pins/dget?p={PIN}
 Example output:
 1
 
Set the value on a digital output pin:
 GET	http://localhost:8000/mmm/pins/dset?p={PIN}&v={VAL}
 Example output:
 0
 
Set the mode of a digital pin to input or output
 GET	http://localhost:8000/mmm/pins/pmode?p={PIN}&m={MODE}
 Example output:
 0
  

Camera operations

Change the position of the specified camera to a specified pan, tilt, & zoom
 GET	http://localhost:8000/mmm/camera/{CAMERA}/go/ptz?p={PAN}&t={TILT}&z={ZOOM}
 Example response:
 0
 
Change the position of the specified camera using a defined tag
 GET	http://localhost:8000/mmm/camera/{CAMERA}/go/tag?t={TAG}
 Example response:
 0
Get the current position of the specified camera
 GET	http://localhost:8000/mmm/camera/{CAMERA}/pos
 Example response:
 { "Pan":90, "Tilt":90, "Zoom":0 }

 
Define a tag for the specified camera using the camera's current position
 GET	http://localhost:8000/mmm/camera/{CAMERA}/newtag?t={TAG}
 Example response:
 0
 
Enumerate the tags defined for the specified camera
 GET	http://localhost:8000/mmm/camera/{CAMERA}/tags
 Example response:
 [{
   "Pan":23,
   "Tilt":23,
   "Zoom":0,
   "Tag":"Fridge"
 }]

Enumerate the cameras
 GET	http://localhost:8000/mmm/camera/enum
 Example response:
 [
  {"ImageURL":"http:\/\/www.fusselman.org\/webcam.pl?camera=4",
   "Name":"CamA",
   "Pan": {"Max":170,"Min":25,"Name":"pan","Value":-1,"ValueCacheSeconds":5},
   "Tilt":{"Max":170,"Min":25,"Name":"tilt","Value":-1,"ValueCacheSeconds":5},
   "Zoom":null,
   "tags":[]},
  {"ImageURL":"http:\/\/www.fusselman.org\/webcam.pl?camera=5",
   "Name":"CamB",
   "Pan":{"Max":170,"Min":20,"Name":"pan","Value":-1,"ValueCacheSeconds":5},
   "Tilt":{"Max":175,"Min":22,"Name":"tilt","Value":-1,"ValueCacheSeconds":5},
   "Zoom":null,
   "tags":[]}
 ]

Web Page

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox