Open Source Electronics for Laboratory Physics Chapter 4: OSPL
Download
Report
Transcript Open Source Electronics for Laboratory Physics Chapter 4: OSPL
Saint Cloud State University, MN, USA
[email protected]
AAPT workshop W03 July 26, 2014
CH4: OSPL
Device cost
Device features
How to use the LCD
How to use the rotary encoder
Simple user interface
Set up the Bluetooth module
How to use the micro-SD card
The standard firmware
The next hardware revision
How to get more devices
OSPL features
3 DIN-5 plugs with 40N insertion/extraction force
Two analog or digital inputs per plug, one with on-
board 10Kohm pull-up resistors, making wiring
resistive and open-drain sensors very easy
Micro-SD card slot with dedicated 3.3V power supply
and level shifter that supports SDHC cards up to 32GB
LCD and rotary encoder for easy user interface
Bluetooth socket for wireless control or data transfer
Pin A6 senses battery voltage with a 22Kohm/10Kohm
voltage divider
Schematic V 2.1.6
1. 10Kohm pull-up
resistors
2. Din-5 plug
3. LCD back light
jumper
4. Bluetooth TX
jumper
5
3
1
6
4
2
5. To sense battery
voltage, read
channel A6. and
multiply by
(10+22)/10=3.2.
6. To use the buzzer,
call tone() with
pin 8.
Schematic (cont.)
1
1. 10Kohm resistors between A1, A3, A5 and 5V to sense
Vernier sensor AUTO-ID resistors, thermistor, photo
resistors, photo transistors, and open-drain sensors
without having to include a resistor in your wiring.
2. Din-5 plug wiring shows on the diagram
3. Removing this jumper disables back light saves battery.
4. Removing this jumper enables the USB serial port to talk
with OSPL, inserting it enables Bluetooth module to take
to OSPL.
2
3
4
OSPL Cost:
$60 if you wish to purchase parts for one unit
$40 parts if you purchase parts for 25 units
Standalone and needs no PC or mobile device
Sensors can be constructed from parts for a few dollars
Future models (V 2.2 and up) will be fully assembled.
For part costs, please refer to the Bill of Materials
(BOM) spreadsheet in the design folder.
LCD
1
2
3
5
4
6
7
1. Include library
2. LCD size and pins
used to drive it.
3. Create lcd object
4. Initialize lcd
5. Clear lcd
6. Set cursor before
every print.
7. There is only print
and no println.
Printing on lcd takes
tens of milliseconds so
don’t print to it when
sensing photo gates.
Rotary encoder
1
2
3
4
5
6
Messages and lists
Display a long scrollable message on the LCD, use
rotary encoder to read it and dismiss with shaft click
simple_text_area(message_to_display);
simple_text_area("Developed by:\nDr.Liu 11/25/12\nhttp://liudr.
wordpress.com\nThis is an example.\nPress Confirm to continue");
Display a select list with title on the LCD, use rotary
encoder to highlight an item and shaft click to select
int choice=simple_select_list(list_with_title);
response=simple_select_list("Day of
week:\nSUN\nMON\nTUE\nWED\nTHU\nFRI\nSAT\n");
Simple user interface setup
1. Include the libraries
2. Define the relevant parameters for the hardware, such as pins etc.
3. Define what button output represents what function, such as ‘B’ button means
enter ‘U’ button means up.
4. Instantiate objects for different keypad types, including serial port keypad
5. Include all keypad types in an array
6. Initialize the library for use
7. Set up some simple parameters
8. Call library functions to interact with the user.
9. You can also call wait_on_escape(time_ms) to get button pushes from all input
devices.
10. You may substitute or simulate button presses with serial port monitor.
Initial setup (don’t change)
Your code
1
2
3
4
5
5
1.
2.
3.
4.
5.
6.
Define some messages and lists
Begin the lcd
Initialize the phi_prompt library
Display a scrollable simple text area
Prepare and display a simple select list
Respond to user’s choice
Bluetooth
1
2
4
5
3
The optional Bluetooth module acts as a wireless serial port,
sending data to a smart phone or tablet.
1. It only needs to be set up once. You need to know ahead of
time what baud rate it is using (or guess a few times).
2. You need to set a name to identify your unit.
3. You may change to a new baud rate if needed.
4. Use “AT” to start command mode, wait a bit, then send in
new name xxxx with “AT+NAMExxxx”, then wait.
5. This time send in new baud rate x with “AT+BAUDx”.
Baud rates:1=1200, 2=2400,… 8=115200. See array values.
Micro-SD card
1. Wait for user input before start logging.
2. Initialize the SD card. Pin 10 is the Chip-select
pin on the OSPL and some SD shields.
3. Use logfile to open LOGGER00.CSV to write to,
create it if it doesn’t exist, append if it does.
4. Wait for user input again before stop logging.
5. The open file must be closed to prevent data
loss. One shouldn’t just turn off OSPL when it
is logging to SD card.
1
2
3
4
5
SD logging is made extremely easy with the SdFat
library written by William Greiman. You can print to a
file just like you can to the serial port. The only
difference is that it has a lot more functions than a
serial port, such as creating/renaming/deleting files
and folders, testing the existence of files and adding
date/time call-back functions so the file has
meaningful date/time instead of 2000/1/1 12:00am.
Standard firmware
A list of Vernier sensors and 10DOF sensor board
sensors are included
One may pause (resume) live display by turning the
rotary encoder left (right)
One may start (stop) sending data to serial port by
turning the rotary encoder to the right (left)
Current version has not included SD card functions
Also battery voltage sensing is not included yet
Revision V 2.2
Fully assembled units will be available
A different chip will be used (ATMEGA32U4)
No more Arduino Nano daughter board
No more jumper to switch between USB serial and
Bluetooth. Both will be active with Serial and Serial1.
Four DIN-5 plugs, with first 3 having analog/digital
I/O pins and the last one with digital I/O and I2C pins.
Real time clock and battery will be included to log date
and time for data acquisition and file creation time
Rotary encoder will be connected to digital pins