Brooke's World The life and ramblings of Brooke.

June 8, 2017

SensorBoard v2 final board test section complete

Filed under: Uncategorized — Brooke @ 9:33 pm

I wrote the test sketch for the SN74HC595 and it works.  All sections of the SensorBoard v2 have tested as working.  My next task will be to write some firmware that takes advantage of all 5 sections.  Two temperature sensors, FRAM, photo resistor, and shift register with 8 LEDs.

 

SensorBoard physical design issue

Filed under: Uncategorized — Brooke @ 9:15 pm

Thought I would share a design mistake for the TeensyBreakout w/ SensorBoard v2. It turns out it is a good idea to keep in mind the physical design of your boards when you plan to stack them. I thought I had done pretty well, until I needed to press the reset button! That’s right. It took some creative re-purposing of an ink pen by borrowing its refill to sneak in there and press the button. I am thinking the rev 3 SensorBoard needs to either have a hole that goes through every single “shield” or bring a reset button up to at least the Teensybreakout.

 

June 6, 2017

SensorBoard v2 bringup

Filed under: Uncategorized — Brooke @ 2:05 pm

I tested each of the Arduino sketches with the SensorBoard v2 on a Teensy 3.2 and they all worked. They covered both I2C temp sensors, the SPI FRAM, and the analog-read photoresistor ( values from about 20-1020 ).

The only chip I didn’t have a sketch written for yet was the SN74HC595 shift register. I am working on that sketch next.

June 2, 2017

Completed build of SensorBoard v2 for Contextual Electronics

Filed under: Contextual Electronics — Brooke @ 4:34 pm

I had time last night to work in the SensorBoard v2. I was able to laser cut the stencil, paste, place, reflow and visually inspect. Next stop will be to plug it in and test. During the fab downtime, I have been writing test applications for all the different sections. This should shorten my bring up time.

This board is a replacement due to issues  ran into where the copper was exposed outside of the pads that caused shorts to ground in many places.  It turns out that at some point, KiCAD changed a default setting which caused the issue.  You can read more about it on the CE forums.

May 27, 2017

Testing SN74HC595 shift register with Bus Pirate

Filed under: Uncategorized — Brooke @ 4:54 pm

As part of the CE Header project from the CE Skills course , we have a shift register on the SensorBoard. This chip allows us to light up 8 LEDs ( more with chip chaining ) with 3 pins.  I used a Bus Pirate (Dangerous Prototypes) and probes, from Seeed Studio, to iteratively poke at it until I understood how to talk to it via SPI.

I used a DIP version of the chip in a breadboard and wired it up to the Bus Pirate.  The LEDs are in the breadboard to see it working. Please note, the cable and connectors in the image below are from the Seeed probe cable. Some of the other probe cables have the colors in a different order on the connectors.

I used putty to connect to the Bus Pirate via a mini usb cable.

Command What it does
Initalize the Bus Pirate
M 5 1 1 2 1 2 2
  • Mode SPI
  • Speed 30khz
  • Clock: Idle low *default
  • Output clock edge: Active to idle *default
  • Input sample phase: Middle *default
  • CS: /CS *default, Output Type: Normal (H=3.3V, L=GND)

Make sure the mode number you use is for SPI

W Turn on power, don’t forget this.  If you try to access the FRAM chip before this, you will likely hang the Bus Pirate and have to unplug/plug,setup.

 

Command What it does Output
Turn on output pins
[ 0b00000001 ] Turn on LEDs.  Bit 1 is QA and bit 8 is QH.
QH QG QF QE QD QC QB QA
               
0 0 0 0 0 0 0 1
[ 0b10000000 ] Turn on LEDs
QH QG QF QE QD QC QB QA
               
1 0 0 0 0 0 0 0
[ 0b10101010 ] Turn on LEDs
QH QG QF QE QD QC QB QA
               
1 0 1 0 1 0 1 0
[ 0b00000000 ] Turn all LEDs off
QH QG QF QE QD QC QB QA
               
0 0 0 0 0 0 0 0

 

Looking from the right side

Looking from the left

 

 

Testing MB85RS64V with Bus Pirate

Filed under: Uncategorized — Brooke @ 1:22 pm

As part of the CE Header project from the CE Skills course , I decided to add an IC that used SPI to the SensorBoard. I chose the MB85RS64V chip. This is a Ferroelectric Random Access Memory (FRAM) integrated circuit.  It is similar to FLASH, but with some added benefits. The idea is to be able to write data to it and the data will persist between power off and power on cycles. I used a Bus Pirate (Dangerous Prototypes) and probes, from Seeed Studio, to iteratively poke at it until I understood how to talk to it via SPI.

Once I soldered the MB85RS64V to a small carrier board from Adafruit, I placed it on a breadboard and wired it up to the Bus Pirate. Please note, the cable and connectors in the image below are from the Seeed probe cable. Some of the other probe cables have the colors in a different order on the connectors.

I used putty to connect to the Bus Pirate via a mini usb cable.

Command What it does
Initalize the Bus Pirate
M 5 1 1 2 1 2 2
  • Mode SPI
  • Speed 30khz
  • Clock: Idle low *default
  • Output clock edge: Active to idle *default
  • Input sample phase: Middle *default
  • CS: /CS *default, Output Type: Normal (H=3.3V, L=GND)

Make sure the mode number you use is for SPI

W Turn on power, don’t forget this.  If you try to access the FRAM chip before this, you will likely hang the Bus Pirate and have to unplug/plug,setup.

 

Command What it does Output
Read the ID
[ 0b10011111 r:4 ] Read Chip ID 0x04 0x7F 0x03 0x02

Manufacturer 0x04 Fujitsu
Continuation Code 0x7F ?
Product ID – byte 1
  Proprietary (3 left bits) 0b000 ?
  Density (5 right bits) 0b0011 64kbit
Product ID – byte 2 0x02 2

 

Command What it does Output
Read the status register
[ 0b00000101 r:1 ] Read the register 0x00 (default)

 

Command What it does Output
Read memory
[ 0b00000011 0 0 r:5 ] Read 5 bytes starting at address 0x00 0x00 (msb first) 0x00 0x00 0x00 0x00 0x00

Bytes are initialized to 0 from the manufacturer

[ 0b00000011 0 0 r:8192 ] Read all of the bytes from the chip

 

Write 1 byte to memory
Command What it does Output
[ 0b00000110 ] Write Enable
[ 0b00000010 0x1F 0xFF 0x11 ] Write 5 bytes starting at address 0x1F 0xFF (msb first)  Note: the very last byte is at address 0x1F 0xFF
[ 0b00000100 ] Write Disable
[ 0b00000011 0x1F 0xFF r:1 ] Read the data back from address 0x1F 0xFF 0x11

 

Write 5 bytes to memory
Command What it does Output
[ 0b00000110 ] Write Enable
[ 0b00000010 0x00 0x00 0x01 0x02 0x03 0x04 0x05] Write 5 bytes starting at address 0x00 0x00 (msb first)  Note: the very first byte is at address 0x00 0x00
[ 0b00000100 ] Write Disable
[ 0b00000011 0x00 0x00 r:5 ] Read the data back from address 0x00 0x00 0x01 0x02 0x03 0x04 0x05

 

Go ahead and power off with the w command, unplug the USB from the Bus Pirate, plug it back in.  Go through the set up steps and re-read the data, it should still be there!

It turns out that Adafruit sells this chip ready to go on a breakout board along with an Arduino library!

 

May 9, 2017

MillaMilla_DS7505_Library for Arduino

Filed under: Uncategorized — Brooke @ 7:16 pm

I released my very first Arduino library that can be found right in the Arduino IDE without having to download it and install it manually!  You can still download it and install manually if you like.  It supports the DS7505 temperature sensor.

Many thanks to Adafruit as I started with their MCP9808 library as my template.  I purchase from Adafruit several times a year.  Their products, service, and commitment to education is first class!

To add the library to your project, choose Sketch | Include Library | Manage Libraries … | Search for DS7505

The library supports basic functionality for the DS7505 Temperature Sensor.  Once you install the library, you can open the example sketch and go.

Here’s what the example looks like:

 

If you have a library you would like added to the Arduino IDE, check out the Library Manager FAQ.  It is a very easy to follow reference.  It only took about 2 1/2 days from when I created my issue for it to be found by the IDE.  Thank you to the Library Manager Team!!

May 6, 2017

Testing DS7505 with Bus Pirate

Filed under: Contextual Electronics — Brooke @ 4:53 pm

As part of the CE Header project from the CE Skills course , I needed to learn to work with DS7505.  I used a Bus Pirate (Dangerous Prototypes) and probes, from Seeed Studio, to iteratively poke at it until I understood how to talk to it via I2C.

Once I soldered the DS7505 to a small carrier board from Adafruit, I placed it on a breadboard and wired it up to the Bus Pirate.  Please note, the cable and connectors in the image below are from the Seeed probe cable.  Some of the other probe cables have the colors in a different order on the connectors.

I used putty to connect to the Bus Pirate via a mini usb cable.

Command What it does
Initalize the Bus Pirate
m 4 1 Mode, I2C, Speed 5khz
W Turn power on
P Turn on pull ups

 

Command What it does Output
Find the I2C address
(1) Find the slave address 0x90(0x48 W) 0x91(0x48 R)

 

Command What it does Output
Working with the Config register
[ 0x90 0x01 [ 0x91 r:1 ] Read the register 0x00 (default)
[ 0x90 0x01 0x60 ] Enable 12 bit resolution
[ 0x90 0x01 0x60 [ 0x91 r:1 ] Enable 12 bit resolution and read back current config  0x60

 

Command What it does Output
Working with the temperature register
[ 0x90 0x00 [ 0x91 r:2 ] Read the register ex:  0x19 0xE0
 

How to calculate given: 0x19 0xE0 and 12 bit resolution.

Bit 8 of MSB is the sign. 0=+ and 1=-
MSB is whole number
LSB is fraction

The most significant 4 bits of the LSB are used for 12bit precision.

MSB 0011001
25C +
Total = 25.75C
LSB 1100000
12/16=.75
Given: 0xE6 0x78

Note: negative due to the 8th bit of the MSB being 1

MSB 11100110
(NOT 11100110) +1
00011001 + 1
00011010
-26C +
Total = -25.0625C
LSB 1111000

15/16=.9375

0.9375

 

Click for full size

 

Testing MCP9808 with Bus Pirate

Filed under: Contextual Electronics — Brooke @ 3:55 pm

As part of the CE Header project from the CE Skills course , I picked an additional temp sensor to test with, the MCP9808.  I used a Bus Pirate (Dangerous Prototypes) and probes, from Seeed Studio, to iteratively poke at it until I understood how to talk to it via I2C.

Once I soldered the MCP9808 to a small carrier board from Adafruit, I placed it on a breadboard and wired it up to the Bus Pirate.  Please note, the cable and connectors in the image below are from the Seeed probe cable.  Some of the other probe cables have the colors in a different order on the connectors.

I used putty to connect to the Bus Pirate via a mini usb cable.

Command What it does
Initalize the Bus Pirate
m 4 1 Mode, I2C, Speed 5khz
W Turn power on
P Turn on pull ups

 

Command What it does Output
Find the I2C address
(1) Find the slave address 0x30(0x18 W) 0x31(0x18 R)

 

Command What it does Output
Working with the Config register
[ 0x30 0x01 [ 0x31 r:2 ] Read the register 0x00 (default)
[ 0x30 0x01 0x00 0x08 ] Enable Alert Stat
[ 0x30 0x01 0x00 0x08 [ 0x31 r:2 ] Enable Alert Stat and read back current config  0x00 0x08

 

 

Command What it does Output
Working with the Manufacturer register
[ 0x30 0x06 [ 0x31 r:2 ] Read the register 0x00 0x54  (default)

 

Command What it does Output
Working with the Device register
[ 0x30 0x07 [ 0x31 r:2 ] Read the register 0x04 0x00  (default)

 

Command What it does Output
Working with the Resolution register
[ 0x30 0x08 [ 0x31 r:1] Read the register 0x03  (default)
[ 0x30 0x08 0x00 [ 0x31 r:1] Set register to 0x00 or 1 bit resolution and read back 0x03

 

Command What it does Output
Working with the Ambient temperature register
[ 0x30 0x05 [ 0x31 r:2 ] Read the register ex: 0xC1 0xBC

Celsius = (C1BC & FFF)/16 = 24C or 75F, see P25 of MCP9808 Datasheet

Special result values

0x80 0x00, TA>TCRIT
0x40 0x00, TA>TUPPER
0x20 0x00, TA<TLOWER
0x10 0xBE ( after upper&1F ), TA < 0C, Celsius = d256 – ((( 10 & 0F ) * d16) + (BE/d16))= -245?

 

Click image for full size

 

November 15, 2016

Salt Reactor : Having a minion ask another minion to execute a module with events and reactors

Filed under: Uncategorized — Brooke @ 3:38 pm

 

I needed to solve the task of having a minion execute a job on another minion and this is how I accomplished the task.  This stemmed from having a minion that runs a web applications which just needed to execute an execution module that already existed, but needed to run on a different minion.

My solution depends on Salt events and reactors to orchestrate the request from the web server minion to the worker minion and have the worker minion give a response of the work it completed back to the web server minion.

Salt version: salt 2016.3.4

Machines:

Host Salt Role Use Case
saltmast16 Salt Master Orchestrator
saltmina16 Salt Minion Where execution module will run
saltminb16 Salt Minion Web server that initiates work

 

 

/srv/salt/_modules/rhtest.py

The event.fire_master call sends the com/millamilla/test/event/finish event to the master

saltminb16

Web Server

 Web Server Files/ Code salmast16

Master

 Master Files/ Code saltmina16

Worker

Worker Files/ Code
Send an event from the web server to the master. Send event
com/millamilla/test/event/start
Python: send_event.py 

Receive event
com/millamilla/test/event/start
 /etc/salt/master.d/reactor.conf

 >>>>>>>>>>>>>>>>>>>>   >>>>>>>>>>>>>>>>>>>>>>>>>>>>
 Master handles event and causes execuction module to run on worker minion Handle com/millamilla/test/event/start Event.  Call execution module on worker.  /srv/salt/reactor/rhtesteventstart.sls

 

Execute module Created on master:
/srv/salt/_modules/rhtest.py
and sync’d to minions from master via:
salt ‘*’ saltutil.sync_all

 >>>>>>>>>>>>>>>>>>>  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 After worker minion executes modules send event back to master Receive event
com/millamilla/test/event/finish
/etc/salt/master.d/reactor.conf

<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 Forward event Master received to the web minion. Receive/Handle Event

com/millamilla/test/event/finish

Python: receive_event.py

This needs to run just after sending the message so it can be listening.  You will want to add code that has a timeout in the for…print loop.  Otherwise, it could run forever.

You will also want to add code to look at the data[‘uuid’] to make sure it is the one you sent out.

Typically, you wouldn’t have a separate send/receive program, but you can.  I plant to create a single script that generates the uuid, sends the request, and waits for a message to return within a timeout period.  If the timeout is exceeded an error would be thrown.

Handle Event

com/millamilla/test/event/finish

 /srv/salt/reactor/rhtesteventfinish.sls
 <<<<<<<<<<<<<<<<<<<  <<<<<<<<<<<<<<<<<<<
Older Posts »

Powered by WordPress